/*
 * MCP and the Road Not Taken — Website Layout
 * 
 * Single-page long-form essay layout with sticky sidebar TOC.
 * Imports tokens.css and components.css.
 * 
 * Layout structure:
 *   ┌──────────────────────────────────────────────────┐
 *   │ [Progress bar — 2px, fixed top]                  │
 *   ├──────────┬───────────────────────────────────────┤
 *   │          │                                       │
 *   │  TOC     │  Hero (full width)                   │
 *   │  256px   │                                       │
 *   │  sticky  ├───────────────────────────────────────┤
 *   │          │                                       │
 *   │          │  Article content (42rem)              │
 *   │          │  centered in available space          │
 *   │          │                                       │
 *   │          │  Wide elements (tables, code)          │
 *   │          │  break out to 56rem                   │
 *   │          │                                       │
 *   │          │  Section dividers between §§           │
 *   │          │                                       │
 *   │          │  Nav footer (prev/index/next)          │
 *   │          │                                       │
 *   └──────────┴───────────────────────────────────────┘
 * 
 * Mobile (<900px): TOC becomes a hamburger drawer.
 *   ┌──────────────────────────────────────────────────┐
 *   │ [Menu] MCP & the Road Not Taken     [Progress]  │
 *   │                                                  │
 *   │  Article content (full width, 1.5rem margins)    │
 *   │                                                  │
 *   └──────────────────────────────────────────────────┘
 */


/* ── Body & Page ── */

html {
  scroll-behavior: smooth;
  font-size: 18px;   /* Base. All rem values scale from this. */
}

body {
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ── Progress Bar ── */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: var(--progress-height);
  background: var(--color-accent);
  z-index: 200;
  width: 0%;
  transition: width 100ms linear;
}


/* ── TOC Sidebar ── */

.toc {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  padding: var(--space-8) var(--space-5);
  background: var(--color-white);
  border-right: 1px solid var(--color-rule);
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.toc__header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-rule);
}

.toc__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
  text-decoration: none;
  line-height: var(--leading-tight);
}

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

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.toc__item {
  margin-bottom: var(--space-1);
}

.toc__link {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--border-radius-sm);
  color: var(--color-ink-light);
  text-decoration: none;
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.toc__link:hover {
  background: var(--color-accent-soft);
  color: var(--color-ink);
}

.toc__link--active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: var(--weight-medium);
}

.toc__num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-section-num);
  letter-spacing: var(--tracking-normal);
  min-width: 2.5em;
  flex-shrink: 0;
}

.toc__link--active .toc__num {
  color: var(--color-accent);
}

.toc__footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-rule);
  display: flex;
  gap: var(--space-4);
}

.toc__link--secondary {
  font-size: var(--text-xs);
  color: var(--color-ghost);
}

.toc__link--secondary:hover {
  color: var(--color-accent);
}


/* ── Main Content Area ── */

.essay {
  margin-left: var(--sidebar-width);
  padding: 0 var(--space-7);
  min-height: 100vh;
}


/* ── Hero ── */

.hero {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-10) 0 var(--space-9);
  text-align: center;
}

.hero__title {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
  line-height: 1.1;
}

.hero__subtitle {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-style: italic;
  color: var(--color-ink-light);
  margin-bottom: var(--space-6);
}

.hero__meta {
  font-size: var(--text-sm);
  color: var(--color-ink-light);
  line-height: var(--leading-relaxed);
}


/* ── Section ── */

.section {
  max-width: var(--content-width);
  margin: 0 auto;
  padding-top: var(--section-pad-top);
  padding-bottom: var(--section-pad-bot);
}

.section + .section {
  border-top: 1px solid var(--color-rule);
}

.section__number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-ultra);
  text-transform: uppercase;
  color: var(--color-section-num);
  display: block;
  margin-bottom: var(--space-2);
}


/* ── Wide Elements ── */
/* Tables and code blocks break out of the content column */

.section__wide {
  max-width: var(--content-wide);
  margin-left: calc(-1 * (var(--content-wide) - var(--content-width)) / 2);
  margin-right: calc(-1 * (var(--content-wide) - var(--content-width)) / 2);
}

/* Simpler approach: table and pre expand if content needs it */
.section table,
.section pre {
  max-width: var(--content-wide);
}


/* ── Footer Navigation ── */

.nav-footer {
  max-width: var(--content-width);
  margin: var(--space-8) auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5) 0;
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-sm);
  color: var(--color-ink-light);
}

.nav-footer__prev,
.nav-footer__next {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-footer__next {
  text-align: right;
}

.nav-footer__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-ghost);
}

.nav-footer__link {
  color: var(--color-accent);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.nav-footer__link:hover {
  text-decoration: underline;
}

.nav-footer__index {
  font-size: var(--text-sm);
  color: var(--color-ink-light);
  text-decoration: none;
}

.nav-footer__index:hover {
  color: var(--color-accent);
}


/* ── Essay Footer ── */

.essay-footer {
  margin-left: var(--sidebar-width);
  padding: var(--space-8) var(--space-7);
  text-align: center;
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-sm);
  color: var(--color-ink-light);
}

.essay-footer__text {
  margin-bottom: var(--space-3);
}

.essay-footer__text a {
  color: var(--color-accent);
  text-decoration: none;
}

.essay-footer__text a:hover {
  text-decoration: underline;
}

.essay-footer__copyright {
  color: var(--color-ghost);
}


/* ── TOC Toggle (Mobile) ── */

.toc-toggle {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 300;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--border-radius-md);
  background: var(--color-white);
  border: 1px solid var(--color-rule);
  cursor: pointer;
  font-size: var(--text-lg);
  color: var(--color-ink);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.toc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}


/* ── Responsive ── */

@media (max-width: 1200px) {
  :root {
    --sidebar-width: 14rem;
    --content-width: 38rem;
    --content-wide: 52rem;
  }
}

@media (max-width: 900px) {
  /* Mobile: TOC becomes a drawer */
  .toc {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    width: 80vw;
    max-width: 280px;
  }

  .toc--open {
    transform: translateX(0);
  }

  .toc-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .toc-overlay--visible {
    display: block;
  }

  .essay {
    margin-left: 0;
    padding: 0 var(--space-5);
  }

  .progress-bar {
    /* On mobile, progress bar sits below the toggle button */
    top: 0;
  }

  .section {
    padding-top: var(--space-7);
    padding-bottom: var(--space-5);
  }

  .hero {
    padding: var(--space-8) 0 var(--space-7);
  }

  .hero__title {
    font-size: var(--text-2xl);
  }

  .hero__subtitle {
    font-size: var(--text-lg);
  }

  .essay-footer {
    margin-left: 0;
    padding: var(--space-6) var(--space-5);
  }

  html {
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  .nav-footer {
    flex-direction: column;
    gap: var(--space-3);
    text-align: center;
  }

  .nav-footer__next {
    text-align: center;
  }

  .hero__title {
    font-size: var(--text-xl);
  }
}


/* ── Print ── */

@media print {
  .toc,
  .toc-toggle,
  .toc-overlay,
  .progress-bar {
    display: none !important;
  }

  .essay {
    margin-left: 0;
    padding: 0;
  }

  .section {
    page-break-before: auto;
  }

  body {
    font-size: 12pt;
  }

  a {
    color: inherit;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: var(--color-ink-light);
  }
}