/* kit.css — the shared design system for the whole library.
   One drafting-board world: deep graphite ground, a faint blueprint grid, precise
   hairline structure, the ∞ guide as the brand mark, real book covers as the colour.
   Linked by the shelf, every book page, and the lesson shell. Tokens are the single
   source of truth; a book sets --accent to tint its own surfaces. */
:root {
  --bg: #0b0e12; --raise: #121823; --raise-2: #182029; --well: #090b0f;
  --fg: #e9edf1; --mut: #8b97a3; --faint: #58626c;
  --line: rgba(150,170,190,.14); --line-2: rgba(150,170,190,.26);
  --grid: rgba(150,180,205,.05);
  --ink: #7cc3df;                 /* system interactive accent (drafting blue) */
  --accent: var(--ink);           /* each book overrides this with its own hue */
  --sans: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, "Consolas", monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --wrap: 1120px; --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100svh; background: var(--bg); color: var(--fg);
  font: 400 17px/1.6 var(--sans); letter-spacing: -.003em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
/* the board, in two fixed layers: a generative shader field (fx.js) and, above it,
   the engineering grid. Content sits above both. Without WebGL the body colour stands in. */
.fx { position: fixed; inset: 0; z-index: -2; width: 100%; height: 100%; display: block; pointer-events: none; }
.ground { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 100% 44px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 44px 100%;
  -webkit-mask-image: radial-gradient(130% 100% at 50% 0, #000 55%, transparent); mask-image: radial-gradient(130% 100% at 50% 0, #000 55%, transparent); }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* brand lockup — ∞ guide + wordmark, identical on every page */
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--fg); }
.brand svg { width: 30px; height: 21px; overflow: visible; color: var(--accent); }
.brand .mbody { transform-box: view-box; transform-origin: 60px 42px; }
.brand b { font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.brand .pupil { transform-box: fill-box; transform-origin: center; }
/* layout + chrome shared by every page */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(18px, 4vw, 40px); }
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 13px clamp(18px, 4vw, 40px); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); }
.bar .sp { margin-left: auto; }
.bar .where { min-width: 0; color: var(--mut); font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .where b { color: var(--fg); font-weight: 600; }

/* buttons — crisp, no → suffix, meaning carried by fill vs outline */
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; border-radius: 999px;
  font: 600 15.5px var(--sans); border: 1px solid transparent; cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s, border-color .25s, color .25s; }
.btn.primary { background: var(--fg); color: #0a0d11; }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--fg) 50%, transparent); }
.btn.ghost { border-color: var(--line-2); color: var(--fg); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.btn[hidden] { display: none; }

/* small structural bits */
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--mut); }
.chip.status { color: var(--fg); }
.chip.status i { width: 7px; height: 7px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.chip.status.soon { color: var(--mut); } .chip.status.soon i { background: var(--faint); box-shadow: none; }
.metarow { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 20px; color: var(--mut); font-size: 14.5px; }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }
.foot { color: var(--faint); font-size: 13.5px; padding: 40px 0 56px; }

/* one restrained load reveal; nothing animates on scroll */
@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.reveal { animation: enter .8s var(--ease) both; }
/* every page in the library opts into the same cross-document transition */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: .4s; animation-timing-function: var(--ease); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .reveal { opacity: 1; }
}
/* a book cover — the one vivid object; real image, or a designed fallback. Shared by the
   shelf grid and each book's hero so a cover looks identical wherever it appears. */
.cover { position: relative; display: block; aspect-ratio: 1 / 1.3; border-radius: 2px 5px 5px 2px; overflow: hidden;
  background: var(--well); box-shadow: 0 1px 2px rgba(0,0,0,.5), 0 18px 34px -14px rgba(0,0,0,.72), inset 0 0 0 1px rgba(255,255,255,.06);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .spine { position: absolute; inset: 0 auto 0 0; width: 9px; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.42), rgba(0,0,0,.04) 60%, rgba(255,255,255,.12)); }
a.cover:hover, a.cover:focus-visible { transform: translateY(-7px);
  box-shadow: 0 7px 10px rgba(0,0,0,.4), 0 36px 62px -18px rgba(0,0,0,.84), inset 0 0 0 1px rgba(255,255,255,.1); }
.cover .art { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 20px 18px;
  background: linear-gradient(158deg, var(--raise-2), #0a0c0f 74%); color: #fff; }
.cover .art .g { position: absolute; right: 10px; bottom: 4px; font: 400 128px/1 Palatino, Georgia, serif; color: var(--accent); opacity: .13; }
.cover .art .o { font-size: 11.5px; color: var(--accent); }
.cover .art h3 { position: relative; margin: 12px 0 0; font-weight: 680; font-size: 23px; line-height: 1.04; letter-spacing: -.02em; }
.cover .art .a { position: relative; margin-top: auto; font-size: 12px; color: rgba(255,255,255,.72); }

/* the shelf grid — grows cleanly as books are added */
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: clamp(28px, 4vw, 46px) clamp(20px, 3vw, 34px); }
.item { display: flex; flex-direction: column; }
.item .cover { margin-bottom: 15px; }
.item .t { font-weight: 600; font-size: 16.5px; letter-spacing: -.01em; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .s { margin-top: 3px; color: var(--mut); font-size: 13.5px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* statuses sit on one line across the whole shelf, whatever the titles do above them */
.item .metarow { margin-top: auto; padding-top: 12px; font-size: 13px; gap: 8px 14px; }
/* a book page's hero: its cover + title + where-to-start */
.hero { display: grid; grid-template-columns: 224px 1fr; gap: clamp(28px, 5vw, 60px); align-items: center;
  padding: clamp(40px, 7vw, 78px) 0 clamp(28px, 5vw, 46px); }
.hero .cover { width: 224px; }
.hero .ttl { margin: 0; font-weight: 700; font-size: clamp(32px, 5vw, 54px); line-height: 1.02; letter-spacing: -.03em; }
.hero .by { margin: 14px 0 0; color: var(--mut); font-size: 15.5px; }
.hero .lede { margin: 18px 0 0; max-width: 52ch; color: var(--fg); opacity: .9; font-size: 17px; line-height: 1.6; }
.hero .acts { margin: 26px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }

/* parts + chapters — same card language as the shelf */
.part { padding: clamp(30px, 5vw, 50px) 0 0; }
.part .head { display: flex; align-items: baseline; gap: 14px; margin: 0 0 20px; }
.part .ix { color: var(--accent); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.part h2 { margin: 0; font-weight: 640; font-size: clamp(20px, 2.6vw, 26px); letter-spacing: -.02em; }
.chaps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.chap { position: relative; display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center; min-height: 82px;
  padding: 15px 18px; border-radius: var(--r); background: var(--raise); border: 1px solid var(--line);
  transition: transform .3s var(--ease), border-color .3s, background .3s; }
a.chap:hover { transform: translateY(-3px); border-color: var(--line-2); background: var(--raise-2); }
.chap .n { font: 600 30px/1 var(--sans); color: var(--accent); font-variant-numeric: tabular-nums; opacity: .92; }
.chap .ct { min-width: 0; }
.chap .ct b { display: block; font-weight: 550; font-size: 16px; line-height: 1.25; letter-spacing: -.01em; }
.chap .ct small { color: var(--mut); font-size: 13px; }
.chap.soon { opacity: .45; } a.chap.soon { pointer-events: none; }
.chap.done .ct small::before { content: "✓ "; color: var(--accent); font-weight: 700; }

@media (max-width: 680px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 40px; }
  .hero .cover { width: 164px; }
  .books { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
