/* ============================================================
   The Writing Shelf — design system: BLUE PENCIL
   ------------------------------------------------------------
   The site is a marked-up manuscript: the books are the
   typescript, the verdicts are the editor's pencil. Blue marks
   mean keep (stet, links, active); the proofreader's red
   appears ONLY on cut/skip marks. Light is typing paper; dark
   is the desk after hours — same room, lamp on.
   Full record: specs/design.md. House rules:
   - tokens on :root, dark variant re-declares them under .dark
   - reading surface never pure white, ink never pure black
   - one strong accent; further accents carry meaning
   ============================================================ */

:root {
  /* surfaces & ink */
  --c-bg: #F3EFE4;          /* typing paper, aged one shade */
  --c-surface: #FBF8EF;     /* index-card face (cards, verdict boxes, rail) */
  --c-ink: #26221C;         /* ribbon black, warm */
  --c-muted: #5C554A;
  --c-rule: #D8D1BE;
  /* accent */
  --c-accent: #2A5DA0;      /* THE accent: the editor's blue pencil — stet, links, active */
  --c-accent-soft: #1F4C8A;
  --c-redline: #9C3B31;     /* proofreader's red — cut/skip marks ONLY, never decorative */
  /* cluster spines — shelf identity, not decoration */
  --c-myth: #8A6A2F;        /* bronze — story structure & myth */
  --c-life: #4F7264;        /* verdigris — the writing life & publishing */
  --c-craft: #5C5F66;       /* graphite — craft & technique */
  --c-dark: #6E3037;        /* oxblood — dark & speculative fiction */
  --c-offpage: #6B5A86;     /* violet — advice off the page */
  /* type */
  --font-display: "Libre Caslon Text", Georgia, serif;
  --font-body: "Spectral", Georgia, serif;
  --font-mono: "Courier Prime", "Courier New", monospace;
  --font-ui: var(--font-mono); /* Blue Pencil chrome is Courier — the typescript face */
  /* layout */
  --measure: 34rem;
  --rail: 15rem;
  --page: 64rem;
}

html.dark {
  /* the desk after hours: same room, lamp on */
  --c-bg: #1B1813;
  --c-surface: #242019;
  --c-ink: #E9E2D2;
  --c-muted: #A69D8B;
  --c-rule: #3A352A;
  --c-accent: #82ABDE;
  --c-accent-soft: #9FC0E8;
  --c-redline: #CE7460;
  --c-myth: #B4914E;
  --c-life: #7A9C8C;
  --c-craft: #8F939B;
  --c-dark: #A05560;
  --c-offpage: #9B87BC;
}

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

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  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-accent-soft); }

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: 600; }

.masthead__links { display: flex; align-items: center; gap: 1.1rem; }

.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; }
}

/* ---------- 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; }

/* ---------- Blue Pencil components ---------- */

/* typescript grain — tiled on the body itself (a fixed overlay layer seams in
   full-page captures and costs a compositing layer) */
body {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="240" height="240"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="2"/></filter><rect width="240" height="240" filter="url(%23n)" opacity="0.05"/></svg>');
}

/* masthead in the typescript face */
.brand__title { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.brand__tick { color: var(--c-accent); }
.navlink { font-size: 0.85rem; }

.kicker {
  font-family: var(--font-mono); font-size: 0.85rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--c-muted); margin: 0 0 1.1rem;
}

/* ---------- home: hero with the editor's markup ---------- */

.shelf-hero { max-width: var(--page); margin: 0 auto; padding: 3.5rem 1.25rem 2rem; }
.shelf-hero h1 {
  font-family: var(--font-display); font-weight: 700; margin: 0;
  font-size: clamp(2.1rem, 6vw, 3.4rem); line-height: 1.12; text-wrap: balance;
  max-width: 22ch;
}
.shelf-hero .struck { position: relative; white-space: nowrap; }
.shelf-hero .struck::after {
  content: ""; position: absolute; left: -2%; right: -2%; top: 54%; height: 3px;
  background: var(--c-accent); transform: rotate(-1.2deg); border-radius: 2px; opacity: 0.85;
}
.shelf-hero .inserted { color: var(--c-accent); font-style: italic; }
.underline-svg { display: block; margin-top: 0.6rem; width: min(16rem, 60%); height: 12px; color: var(--c-accent); }
.shelf-hero .lede { max-width: var(--measure); margin: 1.4rem 0 0; font-size: 1.15rem; color: var(--c-muted); }
.shelf-hero .lede strong { color: var(--c-ink); font-weight: 600; }
.hero-plate { max-width: var(--page); margin: 0 auto 1rem; padding: 0 1.25rem; }
.hero-plate img { width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; border: 1px solid var(--c-rule); border-radius: 3px; display: block; }

/* ---------- cluster filter chips ---------- */

.filters { max-width: var(--page); margin: 0 auto; padding: 0 1.25rem 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.04em;
  border: 1px solid var(--c-rule); border-radius: 999px; padding: 0.28rem 0.85rem;
  background: none; color: var(--c-muted); cursor: pointer; display: inline-flex; align-items: center; gap: 0.45rem;
}
.chip__dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--dot, var(--c-muted)); }
.chip[aria-pressed="true"], .chip:hover { border-color: var(--c-accent); color: var(--c-ink); }

/* ---------- the shelf: index-card grid ---------- */

.shelf {
  max-width: var(--page); margin: 0 auto; padding: 0 1.25rem 3rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem;
  list-style: none;
}
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-rule); border-radius: 3px;
  border-left: 4px solid var(--spine, var(--c-rule));
  padding: 1.1rem 1.2rem 1rem; display: flex; flex-direction: column; gap: 0.4rem;
  box-shadow: 0 1px 2px rgba(38, 34, 28, 0.07);
}
.card__meta { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-muted); display: flex; justify-content: space-between; gap: 0.5rem; }
.card h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; line-height: 1.25; margin: 0; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover { color: var(--c-accent); }
.card__author { font-style: italic; color: var(--c-muted); font-size: 0.95rem; margin: 0; }
.card__oneline { font-size: 0.95rem; margin: 0.2rem 0 0; }

/* JS-driven cluster filter — degrades to all-visible with JS off */
.shelf[data-filter="myth"] .card:not([data-cluster="myth"]),
.shelf[data-filter="life"] .card:not([data-cluster="life"]),
.shelf[data-filter="craft"] .card:not([data-cluster="craft"]),
.shelf[data-filter="dark"] .card:not([data-cluster="dark"]),
.shelf[data-filter="offpage"] .card:not([data-cluster="offpage"]) { display: none; }

/* cluster spine hooks */
.card[data-cluster="myth"], .plate[data-cluster="myth"] { --spine: var(--c-myth); }
.card[data-cluster="life"], .plate[data-cluster="life"] { --spine: var(--c-life); }
.card[data-cluster="craft"], .plate[data-cluster="craft"] { --spine: var(--c-craft); }
.card[data-cluster="dark"], .plate[data-cluster="dark"] { --spine: var(--c-dark); }
.card[data-cluster="offpage"], .plate[data-cluster="offpage"] { --spine: var(--c-offpage); }

/* ---------- home: essays strip ---------- */

.essay-strip { max-width: var(--page); margin: 0 auto; padding: 0 1.25rem 4rem; }
.essay-strip h2 { font-family: var(--font-display); font-size: 1.45rem; margin: 0 0 0.8rem; }
.essay-strip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.essay-strip .dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--spine, var(--c-muted)); margin-right: 0.5rem; }

/* ---------- article pages (book + essay) ---------- */

.page { max-width: calc(var(--measure) + var(--rail) + 6rem); margin: 0 auto; padding: 3rem 1.25rem 4rem; }
.page > * { max-width: var(--measure); }
.crumbs { font-family: var(--font-mono); font-size: 0.8rem; color: var(--c-muted); margin: 0 0 1.6rem; }
.crumbs a { color: inherit; }
.page h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 4.5vw, 2.6rem); line-height: 1.15; text-wrap: balance; margin: 0 0 0.4rem; }
.byline { font-style: italic; color: var(--c-muted); margin: 0 0 2rem; }
.page p { margin: 0 0 1.1rem; }
.page h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; margin: 2.2rem 0 0.9rem; }

/* the style sheet rail: book metadata beside the measure on wide screens */
.stylesheet {
  background: var(--c-surface); border: 1px solid var(--c-rule); border-radius: 3px;
  padding: 1rem 1.1rem; font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.9;
  margin: 0.5rem 0 1.5rem;
}
.stylesheet dt { color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.7rem; float: left; clear: left; width: 5.2rem; }
.stylesheet dd { margin-left: 5.6rem; }
@media (min-width: 68rem) {
  .stylesheet { float: right; width: var(--rail); margin: 0.35rem 0 1.5rem 2rem; }
}

/* ---------- THE SIGNATURE: the editor's verdict ---------- */

.verdict {
  clear: both;
  background: var(--c-surface);
  border: 1px solid var(--c-rule); border-radius: 3px;
  margin: 2.5rem 0 0; padding: 1.3rem 1.4rem 1.2rem;
  position: relative;
}
.verdict::before {
  content: "EDITOR’S VERDICT";
  position: absolute; top: -0.75rem; left: 1rem;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.18em;
  background: var(--c-surface); border: 1px solid var(--c-rule); border-radius: 2px;
  color: var(--c-accent); padding: 0.15rem 0.6rem;
  transform: rotate(-0.6deg);
}
.verdict__row { display: grid; grid-template-columns: 4.4rem 1fr; gap: 0.9rem; padding: 0.55rem 0; align-items: baseline; }
.verdict__row + .verdict__row { border-top: 1px dashed var(--c-rule); }
.verdict__mark { font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.08em; }
.verdict__row--stet .verdict__mark { color: var(--c-accent); }
.verdict__row--cut .verdict__mark { color: var(--c-redline); }
.verdict__row--cf .verdict__mark { color: var(--c-muted); }
.verdict__row p { margin: 0; font-size: 0.98rem; }

/* ---------- essay apparatus ---------- */

.plate { margin: 0 0 1.6rem; }
.plate img { width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; border: 1px solid var(--c-rule); border-top: 4px solid var(--spine, var(--c-rule)); border-radius: 3px; display: block; }
.plate__frame {
  aspect-ratio: 2 / 1; border: 1px solid var(--c-rule); border-radius: 3px;
  border-top: 4px solid var(--spine, var(--c-rule));
  background:
    radial-gradient(ellipse at 30% 35%, color-mix(in srgb, var(--spine, var(--c-muted)) 16%, transparent), transparent 65%),
    var(--c-surface);
  display: grid; place-items: center;
  color: var(--c-muted); font-family: var(--font-mono); font-size: 0.8rem; text-align: center; padding: 1rem;
}
.plate figcaption { font-family: var(--font-mono); font-size: 0.78rem; color: var(--c-muted); margin-top: 0.5rem; }

.divergence {
  border-left: 4px solid var(--c-accent); background: color-mix(in srgb, var(--c-accent) 6%, transparent);
  border-radius: 0 3px 3px 0; padding: 0.9rem 1.1rem; margin: 1.4rem 0;
}
.divergence__label { font-family: var(--font-mono); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--c-accent); display: block; margin-bottom: 0.3rem; }
.divergence p { margin: 0 0 0.6rem; font-size: 0.98rem; }
.divergence p:last-child { margin-bottom: 0; }

/* ---------- start page: goal paths ---------- */

.paths { list-style: none; margin: 1.5rem 0; padding: 0; display: grid; gap: 1rem; }
.paths > li {
  background: var(--c-surface); border: 1px solid var(--c-rule); border-radius: 3px;
  border-left: 4px solid var(--c-accent); padding: 1rem 1.2rem;
}
.paths .goal { font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 0.35rem; }
.paths p { margin: 0; font-size: 0.98rem; }

/* ---------- 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; }
}
