/* ── Reset / Base ──────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
}

/* ── CSS Variables ─────────────────────────────────── */

:root {
  /* Background */
  --bg-primary: #faf8f5;
  --bg-secondary: #f2ede6;
  --bg-nav: rgba(250, 248, 245, 0.95);

  /* Text */
  --text-primary: #2c2420;
  --text-secondary: #6b5e54;
  --text-muted: #9c8e82;

  /* Accent */
  --accent: #8b6f47;
  --accent-hover: #6d5535;
  --accent-light: rgba(139, 111, 71, 0.1);

  /* Borders & surfaces */
  --border: #e5ddd3;
  --border-light: #ede7df;

  /* Callout */
  --callout-bg: #f0ebe3;
  --callout-border: #d4c9b8;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Layout */
  --content-width: 680px;
  --nav-height: 60px;
  --radius: 8px;
  --radius-sm: 4px;
}

/* ── Typography ────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: 'Lora', Georgia, 'Times New Roman', serif;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 {
  font-size: 2.25rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

h2 {
  font-size: 1.625rem;
  font-weight: 600;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-lg);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

p {
  margin-bottom: 1.25em;
}

strong {
  font-weight: 600;
}

/* ── Layout ────────────────────────────────────────── */

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: calc(var(--nav-height) + var(--space-2xl)) var(--space-lg) var(--space-2xl);
}

.article-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-2xl);
  font-style: italic;
  font-family: 'Lora', Georgia, serif;
}

/* ── Header / Navigation ──────────────────────────── */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.site-title:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-group + .nav-group {
  margin-left: var(--space-sm);
  padding-left: var(--space-sm);
  border-left: 1px solid var(--border);
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color 0.2s, background-color 0.2s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--accent-light);
}

.nav-link.active {
  color: var(--accent);
  background-color: var(--accent-light);
}

/* Hamburger */

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
  margin-right: calc(-1 * var(--space-sm));
}

.hamburger {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  position: relative;
  transition: background 0.2s;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  left: 0;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  transition: transform 0.3s;
}

.hamburger::before {
  top: -7px;
}

.hamburger::after {
  top: 7px;
}

.nav-toggle[aria-expanded="true"] .hamburger {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .hamburger::before {
  top: 0;
  transform: rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .hamburger::after {
  top: 0;
  transform: rotate(-45deg);
}

/* ── Article Content ───────────────────────────────── */

.article ul,
.article ol {
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}

.article li {
  margin-bottom: 0.5em;
}

.article li::marker {
  color: var(--accent);
}

blockquote {
  border-left: 3px solid var(--accent);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-xl) 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.7;
}

blockquote p:last-child {
  margin-bottom: 0;
}

hr {
  border: none;
  text-align: center;
  margin: var(--space-2xl) 0;
}

hr::after {
  content: '···';
  color: var(--text-muted);
  font-size: 1.25rem;
  letter-spacing: 0.5em;
}

/* ── Callout Boxes ─────────────────────────────────── */

.callout {
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
}

.callout-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.callout p:last-child {
  margin-bottom: 0;
}

/* ── Table of Contents ─────────────────────────────── */

.toc {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.toc-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  margin-bottom: var(--space-sm);
}

.toc a {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.toc a:hover {
  color: var(--accent);
}

/* ── Section Divider ───────────────────────────────── */

.section-divider {
  border: none;
  text-align: center;
  margin: var(--space-2xl) 0;
}

/* ── Reading Guide (Home page) ─────────────────────── */

.reading-guide {
  margin-top: var(--space-xl);
}

.reading-guide-list {
  list-style: none;
  padding: 0;
}

.reading-guide-list li {
  margin-bottom: var(--space-md);
  padding-left: 0;
}

.reading-guide-list a {
  font-weight: 500;
}

.reading-guide-list .guide-desc {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.15em;
}

/* ── Footer ────────────────────────────────────────── */

.site-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-2xl);
}

.footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-top: 1px solid var(--border);
  padding-top: var(--space-lg);
}

.footer-link {
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.footer-link:hover {
  color: var(--accent);
}

.footer-link .footer-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.15em;
}

.footer-link.next {
  text-align: right;
}

/* ── Responsive: Tablet ────────────────────────────── */

@media (max-width: 1024px) {
  .nav-link {
    font-size: 0.8rem;
    padding: var(--space-xs) 6px;
  }

  .nav-group + .nav-group {
    margin-left: 6px;
    padding-left: 6px;
  }
}

/* ── Responsive: Mobile ────────────────────────────── */

@media (max-width: 640px) {
  body {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.375rem;
  }

  h3 {
    font-size: 1.125rem;
  }

  .content {
    padding: calc(var(--nav-height) + var(--space-xl)) var(--space-md) var(--space-xl);
  }

  /* Mobile nav */
  .site-header {
    overflow: visible;
  }

  .nav-toggle {
    display: block;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100vh - var(--nav-height));
    background: var(--bg-primary);
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-lg);
    gap: var(--space-sm);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    overflow-y: auto;
  }

  .site-nav.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-group {
    flex-direction: column;
    gap: 0;
  }

  .nav-group + .nav-group {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-light);
  }

  .nav-link {
    font-size: 1rem;
    padding: var(--space-sm) var(--space-md);
  }

  /* Footer */
  .footer-nav {
    flex-direction: column;
    gap: var(--space-md);
  }

  .footer-link.next {
    text-align: left;
  }

  .article-subtitle {
    font-size: 1.05rem;
  }
}
