/* ============================================================
   Token system
   ============================================================ */
:root {
  --paper:        #FBF8F2;
  --ink:          #241F1A;
  --ink-soft:     #4A4239;
  --muted:        #9C9285;
  --line:         #E6DFD1;
  --copper:       #B4622A;
  --copper-soft:  #E8C9AE;
  --green:        #2F4538;

  --font-display: "Source Serif 4", Georgia, serif;
  --font-body:    "Inter", -apple-system, system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Page layout
   ============================================================ */
.page {
  display: grid;
  
  gap: 64px;
  max-width: 980px;
  margin: 0 auto;
  padding: 72px 24px 120px;
}

@media (max-width: 900px) {
  .page {
    grid-template-columns: 1fr;
    gap: 0;
    max-width: 640px;
    padding: 32px 20px 80px;
  }
}

/* ============================================================
   Sidebar / TOC
   ============================================================ */
.toc-wrap {
  align-self: start;
  position: sticky;
  top: 40px;
}

@media (max-width: 900px) {
  .toc-wrap {
    position: static;
    margin-bottom: 28px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
  }
}

/* Mobile dropdown trigger — hidden on desktop */
.toc-dropdown {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: transparent;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

@media (max-width: 900px) {
  .toc-dropdown { display: flex; }
}

.toc-chevron {
  color: var(--muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.toc-dropdown[aria-expanded="true"] .toc-chevron {
  transform: rotate(180deg);
}

/* toc-body: visible by default on desktop, collapsible on mobile */
.toc-body {
  display: block;
}

@media (max-width: 900px) {
  .toc-body {
    display: none;
    padding: 4px 16px 18px;
    border-top: 1px solid var(--line);
  }
  .toc-body.is-open {
    display: block;
  }
}

.toc-label {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 900px) {
  .toc-label { margin-top: 14px; }
}

/* Signature element: the "extraction rail" — fills as you read,
   a nod to an espresso pour, sitting flush against the link list. */
.toc-rail {
  position: absolute;
  left: 0;
  top: 34px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

@media (max-width: 900px) {
  .toc-rail { display: none; }
}

.toc-rail-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0%;
  background: var(--copper);
  transition: height 0.25s ease;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@media (max-width: 900px) {
  .toc-list { padding-left: 0; }
}

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -21px;
  padding-left: 19px;
  transition: color 0.15s ease;
}

@media (max-width: 900px) {
  .toc-link { margin-left: 0; padding-left: 10px; }
}

.toc-link:hover {
  color: var(--ink);
}

.toc-link.is-active {
  color: var(--ink);
  font-weight: 600;
}

.toc-link .toc-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--copper-soft);
  flex-shrink: 0;
}

.toc-link.is-active .toc-num {
  color: var(--copper);
}

/* ============================================================
   Article
   ============================================================ */
.article { min-width: 0; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--copper);
  margin: 0 0 14px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.12;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

.dek {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 52ch;
  margin: 0 0 48px;
}

.article section {
  padding-top: 40px;
  margin-top: 40px;
  border-top: 1px solid var(--line);
}

.article section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 24px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 16px;
}

h2 .toc-num {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 12px;
  color: var(--copper);
}

.article p {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 15.5px;
}

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

.footnote {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

