/* ============================================================
   GRID & GRAIN — the design system of Shadow and Schema
   ------------------------------------------------------------
   The grid is the schema: the cadastral survey, the standard,
   the score — the state's (and the platform's) way of seeing.
   The grain is what the grid cannot hold: paper grain, metis,
   and the literal grain fields legibility was invented to tax.
   Every page sits on a faint survey grid; the texture, the
   vermilion markers and the persona voices are the territory
   pushing back.
   House rules: tokens on :root, dark re-declares under .dark;
   reading surface never pure white, ink never pure black;
   accents carry meaning, never decoration.
   ============================================================ */

:root {
  /* ground — the survey office by day */
  --paper:   #F3EFE6;  /* warm survey paper, never white */
  --paper-2: #ECE6D7;  /* parcel fill (cards, asides) */
  --ink:     #201C13;  /* iron-gall ink, never black */
  --ink-soft:#5C5445;  /* secondary text, captions */
  --line:    #D6CDB9;  /* hairlines, parcel borders */
  --grid:    rgba(43, 80, 168, 0.055); /* the cadastral grid wash */

  /* semantic accents */
  --schema:  #2B50A8;  /* the map: links, structure, UI — surveyor's ink blue */
  --contra:  #C2492F;  /* the territory pushing back: steelman, critique, alarms */
  --prov:    #8A6A2F;  /* provenance & citation bronze: reading blocks, source lines */
  /* small-text ink variants — same meanings, darkened to hold AA (≥4.5:1) at
     mono-label sizes on both paper tones; graphic/large uses keep the base hue */
  --contra-ink: #B03E26;
  --prov-ink:   #755A22;

  /* persona accents — byline chips and essay rules only, never body text */
  --p-observer:    #3D5A80;  /* Analytical Observer — slate survey blue */
  --p-architect:   #3F7264;  /* Systems Architect — verdigris */
  --p-philosopher: #524A8F;  /* Analytical Philosopher — indigo */
  --p-strategist:  #8A6A2F;  /* Pragmatic Strategist — bronze */
  --p-critic:      #8E3B2E;  /* Cultural Critic — oxblood */
  --p-essayist:    #7B4B68;  /* Reflective Essayist — plum */
  --p-ai:          #55707F;  /* AI Perspective — graphite blue */

  --radius: 3px;

  /* template aliases — structural CSS below consumes these */
  --c-bg: var(--paper);
  --c-surface: var(--paper-2);
  --c-ink: var(--ink);
  --c-muted: var(--ink-soft);
  --c-rule: var(--line);
  --c-accent: var(--schema);
  --c-accent-soft: var(--contra);
  /* type */
  --font-display: "Gloock", Georgia, serif;
  --font-body: "Spectral", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-ui: "Hanken Grotesk", system-ui, sans-serif;
  /* layout */
  --measure: 39rem;
  --page: 72rem;
}

html.dark {
  /* ground — the drafting table at night: re-lit, not inverted */
  --paper:   #14151A;
  --paper-2: #1B1D25;
  --ink:     #E9E2D2;
  --ink-soft:#A69D89;
  --line:    #2C2F3B;
  --grid:    rgba(127, 161, 232, 0.07);

  --schema:  #7FA1E8;
  --contra:  #E0745A;
  --prov:    #C2A15C;
  --contra-ink: #E0745A; /* dark theme already passes AA at small sizes */
  --prov-ink:   #C2A15C;

  --p-observer:    #8FB0D8;
  --p-architect:   #7FAF9E;
  --p-philosopher: #9C93D8;
  --p-strategist:  #C2A15C;
  --p-critic:      #CE7A64;
  --p-essayist:    #C08BAC;
  --p-ai:          #93B0BF;
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  /* Seat the footer at the bottom on short pages — without this, a 404 at
     800px tall ends with the colophon mid-viewport and bare paper below. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--c-bg);
  /* layer 1: paper grain (feTurbulence, opacity baked in) · layers 2+3: the
     28px cadastral survey grid — the schema under every page */
  background-image:
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240"><filter id="g"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2"/><feColorMatrix values="0 0 0 0 0.4 0 0 0 0 0.36 0 0 0 0 0.28 0 0 0 0.045 0"/></filter><rect width="240" height="240" filter="url(%23g)"/></svg>'),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 240px 240px, 28px 28px, 28px 28px;
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.72;
}

body > main { flex: 1 0 auto; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400; /* Gloock ships a single weight — hierarchy comes from size */
  line-height: 1.2;
  text-wrap: balance;
}

a { color: var(--c-accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--c-ink); text-decoration-thickness: 2px; }

code, pre, .data { font-family: var(--font-mono); font-size: 0.9em; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--c-accent); color: var(--c-bg); padding: 0.5rem 1rem;
}
.skip-link:focus { left: 0; z-index: 10; }

/* ---------- masthead ---------- */

.masthead { border-bottom: 1px solid var(--c-rule); }

.masthead__inner {
  max-width: var(--page); margin: 0 auto; padding: 0.9rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}

.brand { text-decoration: none; color: var(--c-ink); }
.brand__title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 400; }
.brand__title .amp { color: var(--contra); }

.masthead__right { display: flex; align-items: center; gap: 1.4rem; }
.masthead__links { display: flex; align-items: center; gap: 1.1rem; }
.masthead__actions { display: flex; align-items: center; gap: 0.6rem; }

.navlink {
  font-family: var(--font-ui); font-size: 0.95rem;
  color: var(--c-ink); text-decoration: none;
}
.navlink:hover { color: var(--c-accent); }

.masthead__burger { display: none; }

.theme-toggle {
  background: none; border: 1px solid var(--c-rule); border-radius: 999px;
  width: 2.1rem; height: 2.1rem; padding: 0.35rem; cursor: pointer; color: var(--c-ink);
}
.theme-toggle svg { width: 100%; height: 100%; }
.theme-toggle__moon { display: none; }
html.dark .theme-toggle__sun { display: none; }
html.dark .theme-toggle__moon { display: block; }

@media (max-width: 40rem) {
  .masthead__burger {
    display: flex; flex-direction: column; gap: 4px;
    background: none; border: none; padding: 0.4rem; cursor: pointer;
  }
  .masthead__burger span { width: 20px; height: 2px; background: var(--c-ink); }
  .masthead__links {
    display: none; position: absolute; right: 1rem; top: 3.4rem;
    flex-direction: column; align-items: flex-end; gap: 0.8rem;
    background: var(--c-surface); border: 1px solid var(--c-rule);
    border-radius: 6px; padding: 1rem 1.25rem; z-index: 20;
  }
  .masthead__links.is-open { display: flex; }
  /* the toggle and burger stay side by side and always visible */
  .masthead__right { gap: 0.6rem; }
}

/* ---------- content ---------- */

.hero { max-width: var(--measure); margin: 3.5rem auto 1rem; padding: 0 1.25rem; }
.hero__title { font-size: clamp(2rem, 6vw, 3.2rem); margin: 0 0 0.5rem; }
.hero__dek { color: var(--c-muted); font-size: 1.15rem; margin: 0; }

.prose { max-width: var(--measure); margin: 2rem auto 4rem; padding: 0 1.25rem; }
.prose h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); }
.prose img { max-width: 100%; height: auto; }
.prose blockquote {
  margin: 1.5rem 0; padding: 0.25rem 0 0.25rem 1.1rem;
  border-left: 3px solid var(--c-accent); color: var(--c-muted); font-style: italic;
}
.prose table { border-collapse: collapse; width: 100%; }
.prose th, .prose td { border-bottom: 1px solid var(--c-rule); padding: 0.4rem 0.6rem; text-align: left; }
.prose th { font-family: var(--font-ui); font-size: 0.85rem; }

/* ---------- colophon ---------- */

.colophon { border-top: 1px solid var(--c-rule); margin-top: 2rem; }
.colophon__inner {
  max-width: var(--page); margin: 0 auto; padding: 2rem 1.25rem 2.5rem;
  font-family: var(--font-ui); font-size: 0.9rem; color: var(--c-muted);
}
.colophon__title { font-family: var(--font-display); color: var(--c-ink); margin: 0 0 0.5rem; }
.colophon__links { display: flex; flex-wrap: wrap; gap: 1rem; }
.colophon__links a { color: var(--c-muted); }
.colophon__foot { margin-top: 1.25rem; }

/* ---------- Grid & Grain apparatus ---------- */

/* home masthead */
.mast { max-width: var(--page); margin: 0 auto; padding: 3.6rem 1.25rem 2.6rem; }
.kicker {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--schema); margin: 0 0 1.1rem;
}
.mast h1 {
  margin: 0; font-size: clamp(2.6rem, 7.5vw, 5rem); line-height: 1.04;
}
.mast h1 .shadow-w { text-shadow: .045em .05em 0 color-mix(in srgb, var(--contra) 34%, transparent); }
.mast h1 .amp { color: var(--contra); font-size: .8em; }
.mast h1 .schema-w {
  padding: 0 .06em;
  background-image:
    linear-gradient(color-mix(in srgb, var(--schema) 22%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--schema) 22%, transparent) 1px, transparent 1px);
  background-size: 100% 33.3%, 14.28% 100%;
  box-decoration-break: clone;
}
.mast .thesis {
  max-width: 46rem; margin: 1.4rem 0 0; font-size: 1.2rem; font-style: italic;
  color: var(--ink-soft); text-wrap: pretty;
}

/* parcel grid */
.parcels {
  max-width: var(--page); margin: 0 auto; padding: 0 1.25rem 3rem;
  display: grid; gap: 1.4rem; grid-template-columns: repeat(3, 1fr);
}
.parcel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper-2); overflow: hidden;
  display: flex; flex-direction: column;
}
.parcel.feature { grid-column: span 2; grid-row: span 2; }
.parcel img {
  aspect-ratio: 2 / 1; object-fit: cover; height: auto; width: 100%;
  border-bottom: 1px solid var(--line);
}
.parcel.feature img { aspect-ratio: 4 / 3; }
.parcel.feature .deck { font-size: 1.05rem; }
.parcel .parcel__body { padding: 1.1rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.parcel .cat {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--schema); margin: 0;
}
.parcel .cat .series-tag { color: var(--prov-ink); white-space: nowrap; }
.parcel h3 { font-size: 1.35rem; line-height: 1.18; margin: 0; }
.parcel.feature h3 { font-size: 2.1rem; }
.parcel h3 a { color: inherit; text-decoration: none; }
.parcel h3 a:hover { color: var(--schema); }
.parcel .deck { font-size: .95rem; color: var(--ink-soft); margin: 0; }
.parcel .parcel__foot { margin-top: auto; display: flex; align-items: center; gap: .7rem; padding-top: .5rem; }
.date { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-soft); }

/* byline chip — persona swatch + name; persona color never colors body text */
.byline {
  display: inline-flex; align-items: center; gap: .45em;
  font-family: var(--font-ui); font-size: .82rem; font-weight: 600;
  color: var(--ink-soft); text-decoration: none;
}
.byline .swatch {
  width: .62em; height: .62em; background: var(--pc, var(--ink-soft));
  display: inline-block; transform: rotate(45deg); flex: none;
}
a.byline:hover { color: var(--pc, var(--schema)); }

/* series strip (home) */
.series-strip { max-width: var(--page); margin: 0 auto 4rem; padding: 0 1.25rem; }
.series-strip .series-strip__inner {
  border: 1px solid var(--line); border-radius: var(--radius);
  background:
    linear-gradient(color-mix(in srgb, var(--schema) 4%, transparent), color-mix(in srgb, var(--schema) 4%, transparent)),
    var(--paper-2);
  padding: 1.5rem 1.75rem; display: grid; grid-template-columns: 16rem 1fr; gap: 1.5rem;
}
.series-strip h2 { font-size: 1.6rem; margin: 0; }
.series-strip .lede { font-size: .92rem; color: var(--ink-soft); margin: .4rem 0 0; }
.series-parts { display: grid; gap: .6rem; align-content: center; margin: 0; }
.series-parts .part {
  display: grid; grid-template-columns: 5.2rem 1fr; gap: 1rem; align-items: baseline;
  padding: .45rem .1rem; border-bottom: 1px dashed var(--line);
}
.series-parts .part:last-child { border-bottom: 0; }
.part .no { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; color: var(--prov-ink); }
.part .t a { color: inherit; }
.part.soon .t { color: var(--ink-soft); font-style: italic; }
.part.soon .no { color: var(--contra-ink); }

/* essay page */
.essay { max-width: var(--measure); margin: 0 auto; padding: 3.2rem 1.25rem 2rem; }
.essay-head .series-marker {
  font-family: var(--font-mono); font-size: .75rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--prov-ink); margin: 0 0 1rem;
}
.essay-head .series-marker a { color: inherit; }
.essay-head h1 {
  margin: 0 0 1rem; font-size: clamp(2rem, 5.4vw, 3.1rem); line-height: 1.1;
}
.essay-head .meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
  padding: .8rem 0 0; border-top: 1px solid var(--line); margin-bottom: 2rem;
}
.essay .prose-body > p:first-of-type::first-letter {
  font-family: var(--font-display); font-size: 3.4em; float: left;
  line-height: .82; padding: .06em .12em 0 0; color: var(--contra);
}
.essay h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.12; margin: 1.2rem 0 1rem; }
.essay h2 { font-size: 1.75rem; margin: 2.4rem 0 1rem; }
.essay h3 { font-size: 1.3rem; margin: 2.2rem 0 .9rem; }
.essay strong { font-weight: 600; }
.essay ol, .essay ul { padding-left: 1.3rem; }
.essay li { margin-bottom: .5rem; }

/* plate figures (also the migrated image.html include) */
figure.plate { margin: 2.2rem 0; }
figure.plate img { border: 1px solid var(--line); border-radius: var(--radius); width: 100%; height: auto; }
figure.plate figcaption {
  font-family: var(--font-mono); font-size: .74rem; color: var(--ink-soft);
  padding-top: .55rem; display: flex; gap: .6rem;
}
figure.plate figcaption::before { content: "FIG."; color: var(--schema); letter-spacing: .1em; }

/* the steelman: the essay confronting its own strongest counterargument */
.steelman {
  margin: 2.4rem 0; padding: 1.3rem 1.5rem 1.4rem;
  border-left: 3px solid var(--contra); border-radius: 0 var(--radius) var(--radius) 0;
  background:
    linear-gradient(color-mix(in srgb, var(--contra) 7%, transparent), color-mix(in srgb, var(--contra) 7%, transparent)),
    var(--paper-2);
}
.steelman .steelman__label {
  font-family: var(--font-mono); font-size: .74rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--contra-ink); margin: 0 0 .6rem;
}
.steelman p { margin: 0 0 .9rem; font-size: .98rem; }
.steelman p:last-child { margin-bottom: 0; }

/* reading block: what the essay thinks with */
.reading {
  margin: 2.6rem 0 0; padding: 1.2rem 1.5rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2);
}
.reading .reading__label {
  font-family: var(--font-mono); font-size: .74rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--prov-ink); margin: 0 0 .6rem;
}
.reading ul { margin: 0; padding: 0; list-style: none; }
.reading li { padding: .3rem 0; border-bottom: 1px dashed var(--line); font-size: .95rem; margin: 0; }
.reading li:last-child { border-bottom: 0; }
.reading .au { font-family: var(--font-ui); font-size: .82rem; color: var(--ink-soft); }

/* provenance line — every essay states where it came from */
.provenance { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem 3rem; }
.provenance .provenance__inner {
  border-top: 1px solid var(--line); padding-top: .9rem;
  font-family: var(--font-mono); font-size: .76rem; line-height: 1.7; color: var(--prov-ink);
}

/* authors roster */
.roster { max-width: var(--page); margin: 0 auto; padding: 3.2rem 1.25rem; }
.roster > h1 { font-size: clamp(2rem, 5.4vw, 2.8rem); margin: 0 0 .4rem; }
.roster .roster__note { color: var(--ink-soft); font-size: .98rem; font-style: italic; margin: 0 0 1.8rem; max-width: 46rem; }
.roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1.1rem; }
.author-card {
  border: 1px solid var(--line); border-left: 3px solid var(--pc, var(--line));
  border-radius: var(--radius); background: var(--paper-2); padding: 1rem 1.2rem;
}
.author-card .author-card__name { font-family: var(--font-ui); font-weight: 700; font-size: 1.02rem; color: var(--pc, var(--ink)); margin: 0 0 .3rem; }
.author-card .author-card__role { font-size: .9rem; color: var(--ink-soft); margin: 0 0 .5rem; }
.author-card .author-card__works { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-soft); margin: 0; }
.author-card .author-card__works a { color: inherit; }

/* colophon disclosure */
.colophon__disclosure { color: var(--ink); max-width: 60rem; }
.colophon__disclosure strong { color: var(--contra-ink); font-weight: 600; }

/* responsive parcels */
@media (max-width: 900px) {
  .parcels { grid-template-columns: 1fr 1fr; }
  .parcel.feature { grid-column: span 2; grid-row: auto; }
  .series-strip .series-strip__inner { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .parcels { grid-template-columns: 1fr; }
  .parcel.feature { grid-column: auto; }
}

/* ---------- motion & print floor (non-negotiable) ---------- */

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

@media print {
  .masthead, .colophon, .theme-toggle, .skip-link { display: none; }
  body { background: #fff; color: #000; }
}
