@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/instrument-serif-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Instrument Sans Variable";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/instrument-sans-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --background: #0f1815;
  --surface: #17231e;
  --line: #4d6255;
  --ink: #f1eddf;
  --muted: #c2cbbf;
  --patina: #9bb2a3;
  --focus: #ffdf9a;
  --brass: #d8ba7b;
  --paper: #f0ead8;
  --paper-ink: #1b2b22;
  --paper-muted: #4b5b4f;
  --paper-line: #d2cbb8;
  --paper-panel: #e4deca;
  --paper-cell: #f0ead8;
  --paper-cell-line: #b4bca9;
  --paper-link: #244b37;
  font-family: "Instrument Sans Variable", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--background);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-padding-top: 24px; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--background); }
a { color: inherit; text-underline-offset: 0.22em; }
a:hover { color: #f3d594; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { color: var(--paper-ink); background: var(--brass); }

.skip-link { z-index: 20; position: absolute; top: 8px; left: 8px; min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; transform: translateY(calc(-100% - 14px)); color: #17221b; background: var(--brass); font-weight: 700; text-decoration: none; }
.skip-link:focus-visible { transform: translateY(0); outline: 3px solid #fff; outline-offset: 3px; }
.guide-shell { width: min(100% - 64px, 1280px); margin: 0 auto; }
.site-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.brand { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-mark { width: 29px; height: 29px; position: relative; display: grid; place-items: center; border: 1px solid var(--brass); border-radius: 50%; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: var(--brass); }
.brand-mark::before { width: 1px; height: 35px; }
.brand-mark::after { width: 35px; height: 1px; }
.brand-mark span { z-index: 1; width: 10px; height: 10px; border: 1px solid var(--brass); border-radius: 50%; background: var(--background); }
.brand-name { font: 400 1.35rem/1 "Instrument Serif", Georgia, serif; letter-spacing: -0.015em; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.site-nav a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 11px; color: var(--muted); font-size: 0.875rem; text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"], .site-nav a.selected-section { color: var(--ink); background: var(--surface); }
.site-nav .nav-action { padding-inline: 15px; border: 1px solid #e8cc8c; border-radius: 999px; color: #17221b; background: var(--brass); font-weight: 650; }
.site-nav .nav-action:hover { color: #17221b; background: #ecd49c; }

main { padding: 30px 0 0; }

/* Page head on the dark shell */
.guide-breadcrumb { display: flex; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 0.875rem; }
.guide-breadcrumb a { color: var(--muted); }
.guide-breadcrumb a:hover { color: var(--ink); }
.guide-breadcrumb [aria-current="page"] { color: var(--ink); }
.guide-title { max-width: 18ch; margin: 20px 0 26px; font: 400 clamp(2.625rem, 5.3vw, 4.75rem)/1.12 "Instrument Serif", Georgia, serif; letter-spacing: -0.01em; }
.dek { max-width: 66ch; margin: 0; color: var(--muted); font-size: 1.125rem; line-height: 1.65; }
.guide-meta { margin: 18px 0 0; color: var(--patina); font-size: 0.875rem; }

/* Hero: whole-frame browser-native original, visible at every width */
.guide-hero { margin: 38px 0 46px; }
.guide-hero img { display: block; width: 100%; height: auto; }
.hero-caption { margin-top: 10px; color: var(--muted); font-size: 0.94rem; line-height: 1.55; }

/* Article layout: contents rail + paper sheet. The aside itself is sticky and
   self-aligned so it keeps travelling with the article column. */
.guide-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 40px; }
.guide-toc { position: sticky; top: 24px; align-self: start; padding-top: 44px; }
.guide-toc nav { display: grid; gap: 15px; font-size: 0.9375rem; line-height: 1.4; }
.guide-toc a { color: var(--muted); text-decoration-color: #5b6f61; }
.guide-toc a:hover { color: var(--ink); }
.guide-toc a:focus-visible { outline-offset: 4px; }

.guide-paper { min-width: 0; padding: 56px; background: var(--paper); color: var(--paper-ink); font-size: 1.125rem; line-height: 1.7; }
.guide-paper :focus-visible { outline-color: var(--paper-ink); }
.guide-paper p, .guide-paper ul, .guide-paper ol { max-width: 70ch; }
.guide-paper p, .guide-paper ul, .guide-paper ol, .guide-paper table { margin: 0 0 1.15em; }
.guide-paper h2, .guide-paper h3 { margin: 0 0 0.5em; color: var(--paper-ink); font-family: "Instrument Serif", Georgia, serif; font-weight: 400; letter-spacing: -0.005em; }
.guide-paper h2 { margin-top: 2.1em; font-size: 2.25rem; line-height: 1.12; }
.guide-paper h3 { margin-top: 1.5em; font-size: 1.625rem; line-height: 1.18; }
.guide-paper h2:first-child, .guide-paper h3:first-child { margin-top: 0; }
.guide-paper ul, .guide-paper ol { padding-left: 1.4em; }
.guide-paper li { margin-bottom: 0.35em; }
.guide-paper li::marker { color: var(--paper-muted); }
.guide-paper a { color: var(--paper-link); font-weight: 550; text-decoration-thickness: 1px; }
.guide-paper a:hover { color: #79602c; }
.guide-paper table { width: 100%; border-collapse: collapse; font-size: 1rem; line-height: 1.5; }
.guide-paper th, .guide-paper td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1px solid var(--paper-line); }
.guide-paper th { font-weight: 650; color: var(--paper-ink); }

/* Teaching figures: authored HTML/SVG with visible scope and evidence links */
.guide-figure { margin: 2em 0 2.2em; }
.figure-panel { padding: 22px 24px; border: 1px solid var(--paper-cell-line); background: var(--paper-panel); }
.figure-heading { margin: 0 0 16px; color: var(--paper-ink); font: 400 1.55rem/1.2 "Instrument Serif", Georgia, serif; }
.figure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.figure-cell { min-width: 0; padding: 14px 16px; border: 1px solid var(--paper-cell-line); background: var(--paper-cell); font-size: 0.95rem; line-height: 1.55; }
.figure-cell b { display: block; margin-bottom: 7px; color: #263d30; font-size: 1.05rem; }
.figure-cell p { margin: 0; }
.figure-diagram { display: block; width: 100%; height: auto; margin-bottom: 14px; }
.figure-compact { display: none; }
.guide-paper .figure-evidence { margin: 16px 0 0; color: var(--paper-muted); font-size: 0.94rem; line-height: 1.55; }
.figure-evidence a { font-weight: 500; }
.figure-caption { margin-top: 10px; color: var(--paper-muted); font-size: 0.94rem; line-height: 1.55; }
.figure-caption .when-compact { display: none; }

/* After-article paths */
.related-links { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin: 46px 0 8px; }
.related-links a { display: block; padding: 18px 0; border-top: 1px solid var(--line); color: var(--ink); font-weight: 550; }
.related-links a:hover { color: #f3d594; }

/* Hub */
.start-panel { margin: 40px 0; padding: 38px 40px; background: var(--paper); color: var(--paper-ink); }
.start-panel h2 { margin: 0 0 10px; font: 400 2.25rem/1.12 "Instrument Serif", Georgia, serif; letter-spacing: -0.005em; }
.start-panel p { max-width: 62ch; margin: 0; color: var(--paper-muted); font-size: 1.06rem; line-height: 1.6; }
.start-panel a { display: inline-flex; align-items: center; min-height: 44px; margin-top: 14px; color: var(--paper-link); font-weight: 650; }
.start-panel a:hover { color: #79602c; }
.start-panel :focus-visible { outline-color: var(--paper-ink); }
/* Hub catalog: illustrated ledger rows; images alternate sides on wide screens
   and lead each row on narrow ones. Whole frames only — never cropped. */
.catalog article { display: grid; grid-template-columns: 60px minmax(180px, .8fr) minmax(0, 1.2fr); gap: 12px 30px; padding: 30px 0; border-top: 1px solid var(--line); }
.catalog .n { grid-column: 1; grid-row: 1; color: var(--brass); font: 400 3rem/1 "Instrument Serif", Georgia, serif; }
.catalog-original { display: block; width: 100%; height: auto; grid-column: 2; grid-row: 1 / span 2; }
.catalog h2 { grid-column: 3; margin: 0; font: 400 2rem/1.15 "Instrument Serif", Georgia, serif; letter-spacing: -0.005em; }
.catalog p { grid-column: 3; margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.6; }
.catalog article:nth-child(even) .catalog-original { grid-column: 3; }
.catalog article:nth-child(even) h2, .catalog article:nth-child(even) p { grid-column: 2; }
.catalog h2 a { color: var(--ink); text-decoration-thickness: 1px; }
.catalog h2 a:hover { color: #f3d594; }
.guide-evidence { padding-top: 26px; }
.guide-evidence h2 { margin: 0 0 14px; font: 400 2.25rem/1.12 "Instrument Serif", Georgia, serif; letter-spacing: -0.005em; }

/* Shared footer, matching the legal pages */
.site-note { margin: 18px 0 26px; color: var(--muted); font-size: 0.875rem; }
.site-footer { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px 28px; padding: 22px 0 28px; border-top: 1px solid var(--line); color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 17px; }
.site-footer nav a { min-height: 36px; display: inline-flex; align-items: center; color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 0.25em; }
.site-footer p { margin: 0; font-size: 0.875rem; }
.site-footer .footer-credit { grid-column: 2; text-align: right; }
.site-footer a[href^="mailto"] { color: #f1d18a; }

/* Single-column range: the rail would otherwise squeeze the paper sheet and
   figure diagrams below readable label size (~14 CSS px on the 760-unit SVGs). */
@media (max-width: 1119px) {
  .guide-shell { width: min(100% - 32px, 1280px); }
  .guide-hero { margin: 30px 0 38px; }
  .guide-layout { display: block; }
  .guide-toc { position: static; padding: 0 0 22px; }
  .guide-toc nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
  .guide-toc a { min-height: 32px; display: inline-flex; align-items: center; }
  .guide-paper { padding: 44px 40px; }
}

@media (max-width: 760px) {
  .guide-shell { width: min(100% - 32px, 650px); }
  .site-header { align-items: flex-start; flex-direction: column; gap: 4px; padding: 8px 0 11px; }
  .site-nav { display: grid; grid-template-columns: repeat(2, max-content); gap: 0 5px; }
  .site-nav a { min-height: 40px; padding-inline: 9px; }
  main { padding-top: 22px; }
  .guide-title { font-size: clamp(2.625rem, 10vw, 3.2rem); }
  .dek { font-size: 1.0625rem; }
  .guide-hero { margin: 26px 0 34px; }
  .guide-paper { padding: 24px 20px; font-size: 1.0625rem; }
  .guide-paper h2 { margin-top: 1.9em; font-size: 1.85rem; }
  .guide-paper h3 { font-size: 1.4rem; }
  .guide-paper th, .guide-paper td { padding: 9px 10px; font-size: 0.9rem; }
  .figure-panel { padding: 18px 16px; }
  .figure-heading { font-size: 1.35rem; }
  .figure-diagram { display: none; }
  .figure-compact { display: grid; gap: 8px; margin: 0 0 14px; padding: 0 0 0 1.3em; }
  .figure-caption .when-diagram { display: none; }
  .figure-caption .when-compact { display: inline; }
  .related-links { grid-template-columns: 1fr; gap: 0; margin-top: 36px; }
  .related-links a { padding: 16px 0; }
  .start-panel { margin: 30px 0; padding: 26px 22px; }
  .start-panel h2, .catalog h2, .guide-evidence h2 { font-size: 1.85rem; }
  .catalog article { grid-template-columns: 36px minmax(0, 1fr); gap: 14px; padding: 24px 0; }
  .catalog .n { font-size: 2.25rem; }
  .catalog-original, .catalog article:nth-child(even) .catalog-original { grid-column: 2; grid-row: auto; }
  .catalog h2, .catalog p, .catalog article:nth-child(even) h2, .catalog article:nth-child(even) p { grid-column: 2; }
  .site-footer { grid-template-columns: 1fr; gap: 10px; }
  .site-footer .footer-credit { grid-column: auto; text-align: left; }
}

@media (max-width: 380px) {
  .guide-shell { width: min(100% - 24px, 650px); }
  .guide-paper { padding-inline: 16px; }
  .guide-title { font-size: 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

@media print {
  :root { background: #fff; }
  body { background: #fff; }
  .site-nav { display: none; }
  .site-header, .brand { color: #1b2b22; }
  .brand-mark { border-color: #4b5b4f; }
  .brand-mark::before, .brand-mark::after { background: #4b5b4f; }
  .brand-mark span { border-color: #4b5b4f; background: #fff; }
  .guide-title, .dek, .guide-meta, .guide-breadcrumb, .guide-breadcrumb a, .guide-breadcrumb [aria-current="page"], .guide-toc a, .catalog .n, .catalog h2, .catalog h2 a, .catalog p, .guide-evidence h2, .related-links a, .site-note, .site-footer, .site-footer nav a, .site-footer a[href^="mailto"] { color: #1b2b22; }
  .hero-caption, .figure-caption, .figure-evidence { color: #4b5b4f; }
  .start-panel { border-color: #999; background: #fff; }
  .guide-paper { background: #fff; }
  .figure-panel, .figure-cell { background: #fff; }
  .guide-figure, .guide-hero, .start-panel, .catalog article { break-inside: avoid; }
  /* Print the destination of external source links inside the paper sheet so
     citations stay verifiable on paper. Internal/mailto links stay clean. */
  .guide-paper a[href^="https://"]::after { content: " (" attr(href) ")"; overflow-wrap: anywhere; word-break: break-word; font-size: 0.8em; }
}
