/* ==========================================================================
   p31.css: the reading system.
   Everything brand-specific comes from tokens.css (custom properties only).
   Swap tokens.css for tokens-b.css or tokens-c.css to change direction.
   No external requests, no build step.
   ========================================================================== */

/* ---- Base ------------------------------------------------------------- */

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

:root {
  --gutter: 1rem;
  --wide: calc(var(--measure) + 6rem);
  --flow: 1.05em;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (min-width: 40em) { :root { --gutter: 1.5rem; } }
@media (min-width: 64em) { :root { --gutter: 2rem; } }

html {
  background: var(--paper);
  color: var(--ink);
  scroll-padding-top: 1.5rem;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--body-size-phone);
  font-weight: var(--body-weight);
  line-height: var(--leading);
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}
@media (min-width: 48em) { body { font-size: var(--body-size); } }

::selection { background: var(--selection); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

img, svg, video, canvas { max-width: 100%; height: auto; }
svg { overflow: visible; }

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  text-decoration: none;
}
.skip:focus { top: 0.75rem; }

/* ---- Marks ------------------------------------------------------------ */

.mark { display: none; width: 1.75rem; height: 1.75rem; color: var(--mark-ink); flex: none; }
.mark-a { display: var(--show-mark-a); }
.mark-b { display: var(--show-mark-b); --mark-accent: var(--accent); }
.mark-c { display: var(--show-mark-c); }
.mark-b path { fill: var(--mark-accent); }
.mark-c circle { fill: var(--mark-accent); stroke: var(--paper); stroke-width: 2; }

/* ---- Site bar ---------------------------------------------------------- */

.site-bar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 76rem;
  width: 100%;
  margin: 0 auto;
  padding: 0.9rem var(--gutter);
  padding-top: max(0.9rem, env(safe-area-inset-top));
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
}
.site-bar::after {
  content: "";
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 0;
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  min-height: 44px;
}
.brand .mark { width: 1.6rem; height: 1.6rem; }
.brand:hover .brand-name { color: var(--accent-text); }
.site-nav { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.site-nav ul { display: flex; gap: clamp(0.9rem, 1.6vw, 1.6rem); list-style: none; margin: 0; padding: 0; white-space: nowrap; }
.site-nav li { margin: 0; padding: 0; }
.site-nav a {
  display: inline-block;
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.6rem 0;
  text-underline-offset: 0.45em;
}
.site-nav a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--link-underline); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
}
.site-nav .preview-pill {
  font-family: var(--font-ui);
  color: var(--paper);
  background: var(--ink);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-decoration: none;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
/* Phones and small tablets: the nav becomes a second row that scrolls
   sideways inside itself, so the page never does. */
@media (max-width: 60em) {
  .site-bar { flex-wrap: wrap; row-gap: 0; padding-bottom: 0.2rem; }
  .site-nav {
    order: 2;
    flex: 1 0 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
    margin-top: -0.35rem;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav ul { gap: 1.15rem; padding-right: 2rem; }
  .site-nav a { padding: 0.55rem 0 0.65rem; }
}

/* Reading progress */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 50;
  pointer-events: none;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ---- Document --------------------------------------------------------- */

main.doc {
  flex: 1 0 auto;
  width: 100%;
  padding: 0 var(--gutter) 5rem;
  outline: none;
}

.doc-head, .doc-body > * {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}
.doc-head { padding-top: clamp(2.5rem, 7vw, 5.5rem); }

/* Title: from frontmatter (h1.title) or the document's own first heading. */
.doc-head .title,
.doc-body > h1:first-child {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: clamp(2.35rem, 1.55rem + 3.6vw, 4.4rem);
  line-height: var(--display-leading);
  letter-spacing: var(--display-tracking);
  text-transform: var(--display-transform);
  text-wrap: balance;
  margin-top: 0;
  margin-bottom: 1.25rem;
}
.doc-body > h1:first-child { margin-top: clamp(2.5rem, 7vw, 5.5rem); }
.doc-head .title { margin-bottom: 1.1rem; }

.doc-head .subtitle {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 1rem + 0.9vw, 1.55rem);
  line-height: 1.3;
  color: var(--ink-2);
  margin: 0 0 1.5rem;
  text-wrap: balance;
}

/* Datelines: frontmatter date, or an all-italic line right under the title. */
.dateline,
.doc-body > h1:first-child + p:has(> em:only-child) {
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  line-height: 1.6;
  color: var(--ink-3);
  margin-top: 0;
  margin-bottom: 1.5rem;
}
.doc-body > .dateline { margin-bottom: 1.5rem; }
.dateline em, .doc-body > h1:first-child + p > em:only-child { font-style: normal; }
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--ink-3);
  margin-top: -0.75rem !important;
  margin-bottom: 1.5rem !important;
}
.doc-meta span::before { content: "\2022"; color: var(--accent); margin-right: 0.5rem; }
.doc-meta span:first-child::before { content: none; }

/* Flow */
.doc-body p, .doc-body ul, .doc-body ol, .doc-body dl,
.doc-body blockquote, .doc-body pre, .doc-body figure, .doc-body table {
  margin-top: 0;
  margin-bottom: var(--flow);
}
.doc-body p { text-wrap: pretty; hanging-punctuation: first; }
@media (max-width: 40em) {
  .doc-body p, .doc-body li {
    hyphens: auto;
    -webkit-hyphens: auto;
    hyphenate-limit-chars: 9 4 4;
    -webkit-hyphenate-limit-before: 4;
    -webkit-hyphenate-limit-after: 4;
  }
  .is-home .doc-body p { hyphens: manual; -webkit-hyphens: manual; }
}

strong, b { font-weight: var(--strong-weight); }
em, i { font-style: italic; }

/* Headings */
.doc-body h1, .doc-body h2, .doc-body h3, .doc-body h4, .doc-body h5, .doc-body h6 {
  font-family: var(--font-display);
  color: var(--ink);
  text-wrap: balance;
  scroll-margin-top: 1.5rem;
}
.doc-body h1:not(:first-child),
.doc-body h2 {
  font-weight: var(--h2-weight);
  font-size: clamp(1.6rem, 1.3rem + 1.25vw, 2.2rem);
  line-height: 1.12;
  letter-spacing: calc(var(--display-tracking) * 0.6);
  margin: 4.25rem auto 1.1rem;
  border-top: var(--h2-rule);
  padding-top: var(--h2-pad);
}
.doc-body h3 {
  font-weight: var(--h3-weight);
  font-size: clamp(1.2rem, 1.1rem + 0.45vw, 1.42rem);
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 2.6rem auto 0.55rem;
}
.doc-body h4, .doc-body h5, .doc-body h6 {
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  font-weight: 500;
  color: var(--ink-2);
  margin: 2rem auto 0.5rem;
}
.doc-body hr + h2, .doc-body hr + h1 { margin-top: 0; }

/* h3 enhancements added by site.js: "2026:" and "1." become labels */
.h-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  font-weight: 500;
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--accent-text);
  margin-bottom: 0.35rem;
}
.h-label.is-year { font-size: 0.875rem; letter-spacing: 0.04em; }
.h-note { color: var(--ink-3); font-style: normal; font-family: var(--font-ui); font-size: 0.6em; letter-spacing: var(--ui-tracking); text-transform: var(--ui-transform); vertical-align: 0.25em; margin-left: 0.4em; white-space: nowrap; }
.h-note::before { content: ""; display: inline-block; width: 0.5em; height: 0.5em; border-radius: 50%; background: var(--accent); margin-right: 0.4em; vertical-align: 0.05em; }

/* Section break */
.doc-body hr {
  border: 0;
  height: var(--hr-h);
  width: var(--hr-w);
  max-width: var(--measure);
  background: var(--hr-bg);
  margin: 3.5rem auto;
}
.doc-body > h1:first-child + p + hr { margin-top: 2rem; }

/* Links */
a { color: var(--link); }
.doc-body a {
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.15s, color 0.15s;
}
.doc-body a:hover {
  color: var(--accent-text);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

/* Lists */
.doc-body ul, .doc-body ol { padding-left: 1.4em; }
.doc-body li { margin: 0 0 0.45em; padding-left: 0.2em; }
.doc-body li > p { margin-bottom: 0.6em; }
.doc-body li > ul, .doc-body li > ol { margin: 0.45em 0 0.6em; }
.doc-body ul { list-style: none; padding-left: 1.4em; }
.doc-body ul > li { position: relative; }
.doc-body ul > li::before {
  content: "";
  position: absolute;
  left: -1.05em;
  top: calc(var(--leading) * 0.5em - 0.17em);
  width: 0.34em;
  height: 0.34em;
  border-radius: 50%;
  background: var(--accent);
}
.doc-body ol > li::marker {
  font-family: var(--font-ui);
  font-size: 0.8em;
  font-weight: 500;
  color: var(--accent-text);
}
.doc-body ol { padding-left: 1.9em; }

/* Plain blockquotes */
.doc-body blockquote {
  margin-left: auto;
  margin-right: auto;
  padding: 0.1rem 0 0.1rem 1.25rem;
  border-left: 2px solid var(--rule-strong);
  color: var(--ink-2);
}
.doc-body blockquote > :last-child { margin-bottom: 0; }

/* Without JavaScript, a blockquote that opens with a bold lead-in still reads
   as a callout: the lead-in becomes its label. */
.doc-body blockquote > p:first-child > strong:first-child {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  font-weight: 500;
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--accent-text);
  margin-bottom: 0.3rem;
}

/* ---- Branch points ---------------------------------------------------- */
/* site.js turns "> **Branch point: X.** question" into this structure:
   aside.branch-point > .bp-head(.bp-glyph, .bp-kicker, .bp-count) + .bp-name + .bp-q */

.doc-body > .branch-point {
  position: relative;
  max-width: var(--wide);
  margin: 2.5rem auto 2.75rem;
  padding: 1.35rem 1.25rem 1.45rem;
  background: var(--bp-bg);
  color: var(--bp-ink);
  border-top: 3px solid var(--bp-border);
  border-radius: var(--bp-radius);
}
@media (min-width: 48em) {
  .doc-body > .branch-point {
    padding: 1.75rem 3rem 1.9rem;
  }
}
.bp-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.55rem !important;
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  font-weight: 500;
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--bp-kicker);
  line-height: 1.2;
}
.bp-glyph { width: 1.6rem; height: 1rem; flex: none; color: var(--bp-kicker); }
.bp-count { margin-left: auto; opacity: 0.85; font-variant-numeric: tabular-nums; }
.bp-name {
  font-family: var(--font-display);
  font-weight: var(--h2-weight);
  font-size: clamp(1.5rem, 1.2rem + 1vw, 1.95rem);
  line-height: 1.1;
  letter-spacing: calc(var(--display-tracking) * 0.6);
  margin: 0 0 0.6rem !important;
}
.bp-q {
  font-size: 1.04em;
  line-height: 1.52;
  margin: 0 !important;
  text-wrap: pretty;
}
.bp-q strong { font-weight: var(--strong-weight); }
.branch-point a.bp-anchor { color: inherit; text-decoration: none; }
.branch-point:target { box-shadow: 0 0 0 2px var(--focus); }

/* ---- Tables ----------------------------------------------------------- */

.doc-body > .table-wrap,
.doc-body > table {
  max-width: var(--wide);
}
.table-wrap {
  margin: 2rem auto 2.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
html.no-js .doc-body > table { display: block; overflow-x: auto; }
.doc-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0;
}
.doc-body col { width: auto !important; }
.doc-body caption {
  caption-side: top;
  text-align: left;
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--ink-3);
  padding-bottom: 0.6rem;
}
.doc-body th, .doc-body td {
  text-align: left;
  vertical-align: top;
  padding: 0.75rem 1rem 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.doc-body th:last-child, .doc-body td:last-child { padding-right: 0; }
.doc-body thead th {
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  font-weight: 500;
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--ink-3);
  border-bottom: var(--rule-width) solid var(--rule-strong);
  padding-top: 0;
  vertical-align: bottom;
}
.doc-body tbody td:first-child { color: var(--ink); }
.doc-body tbody tr:last-child td { border-bottom: var(--rule-width) solid var(--rule-strong); }
.doc-body td a.bp-ref { text-decoration-color: var(--accent); }

/* Phones: wide tables scroll inside their box rather than crushing words. */
@media (max-width: 36em) {
  .table-wrap:not(.table-stack) table { min-width: 34rem; }
}
/* Phones: tables with up to four columns become stacked records. */
@media (max-width: 36em) {
  .table-stack table, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack tr { padding: 0.9rem 0; border-bottom: 1px solid var(--rule); }
  .table-stack tbody tr:last-child { border-bottom: var(--rule-width) solid var(--rule-strong); }
  .table-stack td { border: 0; padding: 0.15rem 0; }
  .table-stack td:first-child { font-family: var(--font-display); font-size: 1.15em; padding-bottom: 0.35rem; }
  .table-stack td[data-label]:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-ui);
    font-size: 0.7rem;
    letter-spacing: var(--ui-tracking);
    text-transform: var(--ui-transform);
    color: var(--ink-3);
    margin-top: 0.35rem;
  }
  .table-stack tbody tr:last-child td { border: 0; }
}

/* ---- Code, figures, footnotes ---------------------------------------- */

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--paper-2);
  padding: 0.08em 0.3em;
  border-radius: 3px;
}
pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
  line-height: 1.55;
  background: var(--paper-2);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border-radius: var(--radius);
}
pre code { background: none; padding: 0; font-size: 1em; }
figure { margin-left: auto; margin-right: auto; }
figcaption { font-family: var(--font-ui); font-size: var(--ui-size); color: var(--ink-3); margin-top: 0.6rem; }

.doc-body .footnote-ref, .doc-body a[role="doc-noteref"] {
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.7em;
  color: var(--accent-text);
  padding: 0 0.1em;
}
.doc-body sup { line-height: 0; }
.doc-body .footnotes {
  font-size: 0.86em;
  color: var(--ink-2);
  margin-top: 4rem;
}
.doc-body .footnotes hr { width: 4rem; height: 1px; background: var(--rule-strong); margin: 0 0 1.25rem; }

/* ---- Table of contents (built by site.js, or pandoc --toc) ------------ */

.toc-inline {
  margin: 0 auto 2.5rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.toc-inline > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--ink-2);
  min-height: 44px;
}
.toc-inline > summary::-webkit-details-marker { display: none; }
.toc-inline > summary::after {
  content: "+";
  font-size: 1.1rem;
  line-height: 1;
  color: var(--accent-text);
  transition: transform 0.2s;
}
.toc-inline[open] > summary::after { transform: rotate(45deg); }
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0 0 1rem;
  counter-reset: toc;
}
.toc-list li {
  counter-increment: toc;
  margin: 0;
  padding: 0;
}
.toc-list li::before { content: none !important; }
.toc-list a {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.25rem;
  padding: 0.38rem 0;
  color: var(--ink-2);
  text-decoration: none !important;
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.3;
}
.toc-list a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--ink-3);
  padding-top: 0.2rem;
}
.toc-list a:hover { color: var(--accent-text); }
.toc-list a.is-current { color: var(--ink); }
.toc-list a.is-current::before { color: var(--accent-text); }

.toc-rail { display: none; }
@media (min-width: 82em) {
  .toc-rail {
    display: block;
    position: fixed;
    top: 6rem;
    left: max(var(--gutter), calc(50% - var(--measure) / 2 - 19rem));
    width: 14.5rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
  }
  .toc-rail.is-visible { opacity: 1; transform: none; pointer-events: auto; }
  .toc-rail .toc-title {
    font-family: var(--font-ui);
    font-size: var(--ui-size);
    letter-spacing: var(--ui-tracking);
    text-transform: var(--ui-transform);
    color: var(--ink-3);
    margin: 0 0 0.6rem;
  }
  .toc-rail .toc-list a { font-size: 0.875rem; padding: 0.3rem 0; }
  .has-rail .toc-inline { display: none; }
}

/* pandoc --toc output, if the build ever passes it */
nav#TOC { max-width: var(--measure); margin: 0 auto 2.5rem; font-size: 0.95em; }
nav#TOC ul { list-style: none; padding-left: 0; }
nav#TOC ul ul { padding-left: 1.2rem; }
nav#TOC a { color: var(--ink-2); text-decoration: none; }

/* ---- Footer ----------------------------------------------------------- */

.site-foot {
  flex: none;
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 var(--gutter) max(2rem, env(safe-area-inset-bottom));
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--ink-3);
}
.foot-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  align-items: start;
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
}
.foot-inner .marks { grid-row: span 3; }
.foot-inner .mark { width: 2.5rem; height: 2.5rem; }
.foot-inner p { margin: 0; line-height: 1.6; }
.foot-status { color: var(--ink-2); }
.foot-status strong { font-weight: 500; color: var(--ink); }
.foot-meta .commit { font-family: var(--font-mono); text-transform: none; letter-spacing: 0; }
.foot-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.foot-nav a { color: var(--ink-2); text-decoration: none; padding: 0.4rem 0; display: inline-block; }
.foot-nav a:hover { color: var(--accent-text); }
.foot-nav .foot-signout { color: var(--ink-3); }
@media (min-width: 48em) {
  .foot-inner { grid-template-columns: auto 1fr auto; }
  .foot-inner .marks { grid-row: span 2; }
  .foot-nav { grid-column: 3; grid-row: 1 / span 2; justify-self: end; }
}

/* ---- Home page --------------------------------------------------------- */
/* html.is-home comes from frontmatter `home: true` (or intro.js detection).
   A compact hero: the field and the title side by side, the lead beside them
   on laptops, so the first row of cards is visible without scrolling. */

.hero-field { display: none; }
.is-home main.doc {
  max-width: 76rem;
  margin: 0 auto;
  padding-top: clamp(1.25rem, 3.2vw, 2.75rem);
}
.is-home .doc-head,
.is-home .doc-body > * { max-width: none; }
.is-home .doc-head {
  padding-top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: clamp(1rem, 2.4vw, 2rem);
  align-items: center;
}
.is-home .hero-field {
  display: block;
  grid-row: 1 / span 2;
  width: clamp(4.75rem, 3rem + 7vw, 11rem);
  aspect-ratio: 1;
  color: var(--ink);
}
.is-home .hero-field svg { width: 100%; height: 100%; display: block; }
.is-home .doc-head .title {
  grid-column: 2;
  align-self: end;
  font-size: clamp(2.6rem, 1.7rem + 3.6vw, 4.6rem);
  line-height: 0.95;
  margin: 0 0 0.55rem;
}
.is-home .doc-head .subtitle {
  grid-column: 2;
  align-self: start;
  font-size: clamp(1.05rem, 0.95rem + 0.45vw, 1.3rem);
  line-height: 1.32;
  max-width: 30ch;
  margin: 0;
}
@media (max-width: 40em) {
  .is-home .hero-field { grid-row: 1; }
  .is-home .doc-head .title { align-self: center; margin: 0; }
  .is-home .doc-head .subtitle { grid-column: 1 / -1; margin-top: 0.9rem; max-width: none; }
}

.is-home .doc-body > .lead {
  margin: 1.5rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.08rem, 1rem + 0.35vw, 1.25rem);
  line-height: 1.45;
  text-wrap: pretty;
}
.is-home .lead p { margin: 0 0 0.6em; }
.is-home .lead p + p { color: var(--ink-2); margin-bottom: 0; }

@media (min-width: 62em) {
  .is-home main.doc {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    column-gap: clamp(2.5rem, 5vw, 5rem);
    align-items: center;
  }
  .is-home .doc-head { grid-column: 1; grid-row: 1; }
  .is-home .doc-body { display: contents; }
  .is-home .doc-body > * { grid-column: 1 / -1; }
  .is-home .doc-body > .lead {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    padding-left: clamp(1.25rem, 2.5vw, 2rem);
    border-left: 1px solid var(--rule);
  }
}

.is-home .doc-body > h2 {
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  font-weight: 500;
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--ink-3);
  border-top: 1px solid var(--rule);
  padding-top: 0.9rem;
  margin: clamp(1.75rem, 3.5vw, 2.5rem) 0 1rem;
  align-self: start;
}

/* ---- Cards (fenced divs: ::: cards / ::: card) ------------------------ */

.cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  margin: 0 0 1rem;
}
@media (min-width: 36em) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 60em) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; } }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper-2);
  border-radius: var(--radius);
  padding: 1.05rem 1.2rem 1.25rem;
  color: var(--ink-2);
  font-size: 0.94em;
  line-height: 1.45;
  transition: background-color 0.18s;
}
.card:hover { background: var(--paper-3); }
.card:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.card a:focus-visible { outline: none; }
.card > p { margin: 0 0 0.5rem; }
.card > p:last-child { margin-bottom: 0; }
.card-kicker {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--accent-text);
}
.doc-body .card h3 {
  font-family: var(--font-display);
  font-weight: var(--h2-weight);
  font-size: clamp(1.25rem, 1.1rem + 0.45vw, 1.5rem);
  line-height: 1.15;
  letter-spacing: calc(var(--display-tracking) * 0.5);
  margin: 0 0 0.4rem;
}
.doc-body .card h3 a { color: var(--ink); text-decoration: none; }
.doc-body .card h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card:hover h3 a { color: var(--accent-text); }
.card p a:not(.card-thumb) { position: relative; z-index: 2; }

/* The film card: poster thumbnail with a play mark, flush to the card edge */
.card-film { padding-top: 0; overflow: hidden; }
.card-film > p:first-child { margin: 0 -1.2rem 0.9rem; }
.doc-body .card-thumb {
  position: relative;
  z-index: 2;
  display: block;
  aspect-ratio: 16 / 9;
  background: #12110f;
  overflow: hidden;
}
.card-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.card-thumb::after {
  content: "";
  position: absolute;
  left: 0.9rem;
  bottom: 0.9rem;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z' fill='white'/%3E%3C/svg%3E") 56% 50% / 1.35rem no-repeat,
    var(--accent);
  box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s;
}
@media (prefers-reduced-motion: no-preference) {
  .card-film:hover .card-thumb img { transform: scale(1.03); }
  .card-film:hover .card-thumb::after { transform: scale(1.08); }
}

/* Secondary row: lighter, two across */
@media (min-width: 36em) { .cards-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cards-secondary .card {
  background: transparent;
  border-top: 1px solid var(--rule-strong);
  border-radius: 0;
  padding: 0.9rem 0 0.5rem;
}
.cards-secondary .card:hover { background: transparent; }

.more-links {
  margin-top: 2rem !important;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--ink-3);
}
.more-links p { margin: 0; }
.more-links a { color: var(--ink-2); }
.more-links em { font-style: normal; }

/* ---- Film lightbox (site.js) ----------------------------------------- */

html.film-open { overflow: hidden; }
dialog.film-dialog {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f4f0e8;
  overflow: hidden;
}
dialog.film-dialog[open] { display: grid; place-items: center; }
dialog.film-dialog::backdrop { background: rgba(10, 9, 8, 0.95); }
.film-frame {
  position: relative;
  width: min(92vw, calc((100vh - 7rem) * 16 / 9), 80rem);
  padding-top: 3rem;
}
.film-frame video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  background: #000;
  border-radius: var(--radius);
}
.film-close {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 0.25rem 0 0.75rem;
  border: 0;
  background: transparent;
  color: #f4f0e8;
  font: 500 0.75rem/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.film-close span { font-size: 1.5rem; line-height: 1; font-family: var(--font-body); }
.film-close:hover { color: #fff; }
.film-caption {
  margin: 0.75rem 0 0;
  font: 0.75rem/1.4 var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(244, 240, 232, 0.6);
}
@media (max-width: 40em), (max-height: 30em) {
  .film-frame { width: 100vw; padding-top: 3.25rem; }
  .film-frame video { border-radius: 0; }
  .film-close { right: 0.75rem; }
  .film-caption { padding: 0 1rem; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.film-dialog .film-frame { transition: opacity 0.22s ease, transform 0.22s ease; }
  dialog.film-dialog::backdrop { transition: opacity 0.22s ease; }
  dialog.film-dialog:not(.is-open) .film-frame { opacity: 0; transform: translateY(12px) scale(0.985); }
  dialog.film-dialog:not(.is-open)::backdrop { opacity: 0; }
}

/* ---- Contents page ---------------------------------------------------- */

.is-contents .doc-body > h2,
.is-contents .doc-body > h1:not(:first-child) {
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  font-weight: 500;
  letter-spacing: var(--ui-tracking);
  text-transform: var(--ui-transform);
  color: var(--accent-text);
  border-top: 0;
  padding-top: 0;
  margin: 3rem auto 0.25rem;
}
.is-contents .doc-body > ul {
  padding-left: 0;
  border-top: 1px solid var(--rule-strong);
}
.is-contents .doc-body > ul > li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin: 0;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}
.is-contents .doc-body > ul > li::before { content: none; }
.is-contents .doc-body > ul > li > a {
  flex: 1;
  font-family: var(--font-display);
  font-weight: var(--h2-weight);
  font-size: clamp(1.15rem, 1.05rem + 0.45vw, 1.4rem);
  line-height: 1.25;
  text-decoration: none;
  color: var(--ink);
}
.is-contents .doc-body > ul > li > a:hover { color: var(--accent-text); }
.is-contents .doc-body .meta,
.doc-body .meta {
  font-family: var(--font-ui);
  font-size: var(--ui-size);
  letter-spacing: 0.02em;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---- Home hero field (drawn by intro.js; turns very slowly) ----------- */
.hero-field .field-accent { fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .hero-field .field-spin {
    transform-box: fill-box;
    transform-origin: center;
    animation: p31-field-turn 420s linear infinite;
  }
}
@keyframes p31-field-turn { to { transform: rotate(360deg); } }

/* ---- Print ------------------------------------------------------------ */

@media print {
  :root { --paper: #fff; --ink: #000; --ink-2: #222; --ink-3: #555; --rule: #bbb; --rule-strong: #666; }
  html, body { background: #fff; }
  body { font-size: 10.5pt; }
  .site-bar, .progress, .toc-rail, .toc-inline, .skip, .foot-nav, .p31-intro { display: none !important; }
  .doc-body a { text-decoration: none; }
  .doc-body > .branch-point { break-inside: avoid; background: none; border: 1px solid #999; border-top: 3px solid #000; color: #000; }
  .doc-body h2, .doc-body h3 { break-after: avoid; }
  main.doc { padding-bottom: 1rem; }
}
