/* ============================================================
   The Consulting Shelf — design system: "SECOND OPINION"
   ------------------------------------------------------------
   The site is a trusted colleague's second opinion on what to
   read: an advisory memo world. Bond paper (the engagement
   letter, deliberately not cream), blue-black fountain ink,
   ONE accent — the signing-pen blue an advisor commits with —
   and verdicts delivered as stamps. The editor's red appears
   only where something is cut (Skip-it-if, cautions, 404).
   Dark mode is the same desk after the client call — lamp-lit,
   not inverted. See specs/design.md.
   House rules that survive any redesign:
   - 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 */
  --paper:   #F6F4EE; /* bond paper — the engagement letter, deliberately not cream */
  --paper-2: #EDEAE0; /* manila — folder wells, rails, card grounds */
  --ink:     #21262E; /* blue-black fountain ink — never pure black */
  --ink-soft:#59616E; /* pencil — secondary text, captions */
  --line:    #D9D5C9; /* hairline rules */
  /* accents — each carries meaning */
  --pen:     #2A4CB3; /* THE accent: signing-ink blue — links, Essential stamp, Read-it-if */
  --pen-wash: rgba(42, 76, 179, .08);
  --red:     #A63B33; /* editor's red — Skip-it-if, cautions, 404. never decoration */
  --red-wash: rgba(166, 59, 51, .07);
  --craft:     #7A5C3D; /* shelf accent: the consulting craft — workshop sepia */
  --influence: #59487C; /* shelf accent: negotiation & influence — persuasion violet */
  --plate-ground: #EDEAE0; /* plates are intrinsically lit; caption tokens sit outside the swap */
  /* template aliases (structural styles below consume 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(--pen);
  --c-accent-soft: #223E93;
  /* type — Besley (modern Clarendon) display, Spectral reading, mono data, grotesk chrome */
  --font-display: "Besley", Georgia, serif;
  --font-body: "Spectral", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-ui: "Hanken Grotesk", system-ui, sans-serif;
  /* layout: the dossier — reading column + mono fact rail */
  --measure: 38rem;
  --rail: 15rem;
  --page: 72rem;
}

html.dark {
  --paper:   #14171D; /* the desk after the client call — lamp, not inversion */
  --paper-2: #1B1F28;
  --ink:     #E4E1D8;
  --ink-soft:#9AA2B0;
  --line:    #2C313C;
  --pen:     #8DA4EE; /* the pen under lamplight */
  --pen-wash: rgba(141, 164, 238, .10);
  --red:     #D0847B;
  --red-wash: rgba(208, 132, 123, .09);
  --craft:     #B99A6B;
  --influence: #A48FD0;
  --c-accent-soft: #A9BCF3;
}

/* ---------- 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;
  /* bond-paper grain, tiled (never position:fixed — it seam-bands in stitched shots) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)' opacity='0.045'/%3E%3C/svg%3E");
}

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

/* ============================================================
   "Second Opinion" components — the advisory-memo apparatus
   ============================================================ */

/* ---- shared atoms ---- */

.kicker {
  font-family: var(--font-mono); font-weight: 500; font-size: 0.72rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft);
}
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { color: var(--pen); }

.brand__title { font-family: var(--font-ui); font-weight: 700; letter-spacing: -0.01em; }
.brand { display: flex; align-items: center; gap: 0.55rem; }
.brand__mark { width: 1.3rem; height: 1.3rem; flex: none; }

/* Verdict stamps — the signature device. Meaning through weight, not extra hues:
   essential = filled pen, recommended = pen outline, situational = dashed pencil. */
.stamp {
  display: inline-block;
  font-family: var(--font-mono); font-weight: 600; font-size: 0.7rem; line-height: 1;
  letter-spacing: 0.14em; text-transform: uppercase;
  border: 1.5px solid currentColor; border-radius: 3px;
  padding: 0.42em 0.65em;
  transform: rotate(-2.5deg);
}
.stamp--essential   { color: var(--paper); background: var(--pen); border-color: var(--pen); }
.stamp--recommended { color: var(--pen); }
.stamp--situational { color: var(--ink-soft); border-style: dashed; }

/* Generated plates — intrinsically lit, identical in both themes */
.plate { margin: 0; background: var(--plate-ground); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.plate img { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; }
.plate--book img { aspect-ratio: 16 / 9; }
.plate-caption { font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.5; color: #59616E; padding: 0.6rem 0.8rem; border-top: 1px solid var(--line); }

/* ---- home: hero + shelves ---- */

.shelf-home { max-width: var(--page); margin: 0 auto; padding: 0 1.25rem; }

.hero2 { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 3.5rem; align-items: center; padding: 4rem 0 3rem; }
.hero2 h1 { font-size: clamp(2.4rem, 5.2vw, 3.7rem); font-weight: 800; letter-spacing: -0.015em; margin: 0.7rem 0 1.1rem; }
.hero2 .lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 34rem; margin: 0; }
.hero2 .signoff { margin: 1.4rem 0 0; font-style: italic; font-size: 0.92rem; color: var(--ink-soft); border-left: 2px solid var(--pen); padding-left: 0.9rem; }

.shelf { padding: 2.2rem 0 1rem; }
.shelf--craft { --shelf: var(--craft); }
.shelf--influence { --shelf: var(--influence); }
.shelf-head { display: flex; align-items: baseline; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.shelf-head .kicker { color: var(--shelf); }
.shelf-head h2 { font-size: 1.7rem; font-weight: 700; margin: 0; }
.shelf-head .count { margin-left: auto; font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1.4rem; margin: 1.6rem 0 1rem; list-style: none; padding: 0; }
.card {
  background: color-mix(in srgb, var(--paper-2) 55%, var(--paper));
  border: 1px solid var(--line); border-radius: 5px;
  padding: 1.1rem 1.2rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.55rem; position: relative;
}
.card:hover { border-color: var(--shelf, var(--ink-soft)); }
.card .kicker { color: var(--shelf); }
.card h3 { font-size: 1.22rem; font-weight: 700; margin: 0; line-height: 1.2; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
.card h3 a:hover { color: var(--pen); }
.card .author { font-family: var(--font-ui); font-weight: 500; font-size: 0.82rem; color: var(--ink-soft); margin: 0; }
.card .hook { font-size: 0.95rem; font-style: italic; color: var(--ink-soft); flex: 1; margin: 0; }
.card .stamp { align-self: flex-start; margin-top: 0.3rem; }
.card .thumb { margin: -1.1rem -1.2rem 0.4rem; border-bottom: 1px solid var(--line); background: var(--plate-ground); }
.card .thumb img { display: block; width: 100%; height: auto; aspect-ratio: 8 / 3; object-fit: cover; }

/* ---- book page: the dossier ---- */

.book { display: grid; grid-template-columns: var(--rail) minmax(0, var(--measure)); gap: 3.2rem; justify-content: center; padding: 3rem 1.25rem 2rem; }
.book-rail { font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.6; color: var(--ink-soft); }
.book-rail .stamp { margin-bottom: 1.2rem; }
.book-rail dl { margin: 0; border-top: 1px solid var(--line); }
.book-rail .row { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.book-rail dt { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; }
.book-rail dd { margin: 0; color: var(--ink); }
.book-rail dd a { font-family: var(--font-ui); }

.book-main .kicker { display: block; }
.book-main h1 { font-size: clamp(2rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: -0.012em; margin: 0.6rem 0 0.3rem; }
.book-main .byline { font-family: var(--font-ui); font-weight: 500; font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 1.6rem; }
.book-main .plate { margin: 0 0 1.8rem; }
.book-main h2 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; margin: 2.2rem 0 0.8rem; }
.book-main > p, .book-body > p { margin: 0 0 1rem; }
.book-body .plate + p::first-letter,
.book-body > p:first-child::first-letter {
  font-family: var(--font-display); font-weight: 800; font-size: 3.1em;
  float: left; line-height: 0.82; padding-right: 0.09em; color: var(--pen);
}

.ideas { list-style: none; padding: 0; margin: 0 0 1rem; }
.ideas li { padding: 0.75rem 0 0.75rem 1.1rem; border-left: 2px solid var(--line); margin-bottom: 0.5rem; }
.shelf--craft .ideas li:hover, .book--craft .ideas li:hover { border-left-color: var(--craft); }
.book--influence .ideas li:hover { border-left-color: var(--influence); }
.ideas b { font-family: var(--font-ui); font-weight: 700; font-size: 0.95rem; }
.ideas span { display: block; font-size: 0.93rem; color: var(--ink-soft); }

.verdict-blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin: 1.6rem 0; }
.readif, .skipif { border-radius: 4px; padding: 1rem 1.2rem; font-size: 0.95rem; }
.readif { background: var(--pen-wash); border-left: 3px solid var(--pen); }
.skipif { background: var(--red-wash); border-left: 3px solid var(--red); }
.readif h2, .skipif h2 {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600; line-height: 1;
  letter-spacing: 0.16em; text-transform: uppercase; margin: 0 0 0.6rem;
}
.readif h2 { color: var(--pen); }
.skipif h2 { color: var(--red); }
.readif ul, .skipif ul { margin: 0; padding-left: 1.1rem; }
.readif li, .skipif li { margin-bottom: 0.35rem; }

/* ---- start here: reading paths ---- */

.paths { max-width: 46rem; margin: 0 auto; padding: 3rem 1.25rem; }
.paths > .kicker { display: block; }
.paths h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 800; margin: 0.6rem 0 0.8rem; }
.paths .lede { color: var(--ink-soft); font-size: 1.1rem; max-width: 36rem; margin: 0; }
.path { margin-top: 2.6rem; border-top: 1px solid var(--line); padding-top: 1.4rem; }
.path h2 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.path .for { font-family: var(--font-ui); font-weight: 500; font-size: 0.88rem; color: var(--ink-soft); margin: 0.3rem 0 1.2rem; }
.path ol { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.path ol li { counter-increment: step; display: grid; grid-template-columns: 2.6rem 1fr; gap: 0.9rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.path ol li::before { content: counter(step); font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; color: var(--pen); line-height: 1.1; }
.path ol b { font-family: var(--font-display); font-weight: 700; font-size: 1.06rem; }
.path ol b a { color: inherit; }
.path ol span { display: block; font-size: 0.93rem; color: var(--ink-soft); }

/* ---- 404: the editor's red pen ---- */

.notfound { max-width: var(--measure); margin: 4rem auto; padding: 0 1.25rem; }
.notfound .stamp { color: var(--red); margin-bottom: 1rem; }
.notfound h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; margin: 0.4rem 0 0.8rem; }
.notfound p { color: var(--ink-soft); }

/* Dark cards sit nearly flush with the page ground — lift the surface */
html.dark .card { background: var(--paper-2); }

/* The verdict belongs at the top of the page; on wide screens the rail's stamp
   does that job, on narrow ones the rail stacks last — so a byline stamp takes
   over below the dossier breakpoint. */
.byline__stamp { display: none; }

/* ---- responsive ---- */

@media (max-width: 60rem) {
  .hero2 { grid-template-columns: 1fr; gap: 2rem; padding-top: 2.5rem; }
  .book { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .book-rail { order: 2; }
  .book-rail > .stamp { display: none; }
  .byline__stamp { display: inline-block; margin-left: 0.5rem; }
  .verdict-blocks { grid-template-columns: 1fr; }
}

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