@font-face { font-family: "Young Serif"; src: url(web/fonts/young-serif.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url(web/fonts/atkinson-hyperlegible-next.woff2) format("woff2");
  font-weight: 200 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(web/fonts/jetbrains-mono.woff2) format("woff2");
  font-weight: 100 800; font-display: swap; }
@property --x { syntax: "<percentage>"; inherits: true; initial-value: 50%; }

:root { --bg:#24211E;--float:#2E2925;--fg:#D7C484;--hi:#EDDEA9;--sel:#473D3A;--accent:#D18C58;--red:#D07264;--yellow:#CAA056;--green:#7F9D4B;--cyan:#41A2A1;--blue:#798FC5;--magenta:#B37AAE;--ink-red:#D07264;--ink-yellow:#CAA056;--ink-green:#7F9D4B;--ink-cyan:#41A2A1;--ink-blue:#798FC5;--ink-magenta:#B37AAE;--b-red:#FE9C8C;--b-yellow:#F5C572;--b-green:#A6C96C;--b-cyan:#63CFCD;--b-blue:#A0B9F7;--b-magenta:#E3A1DC;--shot-dark:#24211E;--shot-light:#F0EBE1; color-scheme: dark; }
:root[data-theme=light] { --bg:#F0EBE1;--float:#E6E0D6;--fg:#252F1E;--hi:#533701;--sel:#D4CAB8;--accent:#A15501;--red:#A23B2A;--yellow:#A16D03;--green:#4C6E03;--cyan:#027071;--blue:#415EA3;--magenta:#894381;--ink-red:#801100;--ink-yellow:#785104;--ink-green:#344D01;--ink-cyan:#024E4F;--ink-blue:#213E86;--ink-magenta:#6B1E63;--b-red:#801100;--b-yellow:#785104;--b-green:#344D01;--b-cyan:#024E4F;--b-blue:#213E86;--b-magenta:#6B1E63;--shot-dark:#24211E;--shot-light:#F0EBE1; color-scheme: light; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) { --bg:#F0EBE1;--float:#E6E0D6;--fg:#252F1E;--hi:#533701;--sel:#D4CAB8;--accent:#A15501;--red:#A23B2A;--yellow:#A16D03;--green:#4C6E03;--cyan:#027071;--blue:#415EA3;--magenta:#894381;--ink-red:#801100;--ink-yellow:#785104;--ink-green:#344D01;--ink-cyan:#024E4F;--ink-blue:#213E86;--ink-magenta:#6B1E63;--b-red:#801100;--b-yellow:#785104;--b-green:#344D01;--b-cyan:#024E4F;--b-blue:#213E86;--b-magenta:#6B1E63;--shot-dark:#24211E;--shot-light:#F0EBE1; color-scheme: light; } }
:root {
  --board: var(--sel);  /* the palette's selection colour */
  --dim: color-mix(in oklab, var(--fg) 74%, var(--bg));
  --serif: "Young Serif", Georgia, serif;
  --sans: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gutter: 88px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-color: var(--dim) var(--board); }
body { margin: 0; background: var(--board); color: var(--fg); font: 17px/1.6 var(--sans);
  font-variant-numeric: lining-nums; -webkit-font-smoothing: antialiased; }
::selection { background: var(--sel); color: var(--hi); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
code, pre, kbd { font-family: var(--mono); }
code { font-size: .88em; background: var(--float); padding: .1em .35em; border-radius: 2px; }
a code { background: none; padding: 0; color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; height: auto; }

/* Only the current variant's chips and origin plate show; without JS the system preference decides. */
[data-theme=dark] .only-light, [data-theme=light] .only-dark { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .only-dark { display: none; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .only-light { display: none; } }

.skip { position: absolute; left: 16px; top: -60px; background: var(--accent); color: var(--bg); padding: .5rem 1rem;
  z-index: 10; }
.skip:focus { top: 16px; }

/* The book: a page on the board, punched holes in the gutter, thumb tabs cut into the fore-edge. */
.book { display: grid; grid-template-columns: minmax(0, 1fr) 112px; max-width: 1320px; margin: 40px auto 64px;
  padding-left: 24px; }
.page { position: relative; background: var(--bg); border-radius: 3px; padding: 56px 72px 40px calc(var(--gutter) + 24px);
  box-shadow: 0 1px 2px rgb(0 0 0 / .18), 0 12px 32px -12px rgb(0 0 0 / .35); min-width: 0;
  grid-column: 1; grid-row: 1; }
.page::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: var(--gutter);
  background: radial-gradient(circle at 50% 120px, var(--board) 11px, transparent 12px) 0 0 / 100% 300px repeat-y;
  border-right: 1px dashed var(--sel); }
.rail { position: sticky; top: 56px; align-self: start; grid-column: 2; grid-row: 1; padding-top: 72px; }
.thumbs { display: flex; flex-direction: column; gap: 6px; }
.thumbs a { display: block; width: 100%; padding: 16px 10px 16px 36px; background: var(--t); color: var(--bg);
  border-radius: 0 6px 6px 0; font: 700 13px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  text-decoration: none; transform: translateX(-24px); transition: transform .4s var(--ease);
  box-shadow: 0 4px 10px -6px rgb(0 0 0 / .4); }
.thumbs a:hover { transform: translateX(-14px); }
.thumbs a[aria-current] { transform: translateX(0); padding-block: 26px; }

/* Title page */
.switch { display: flex; flex-direction: column; gap: 4px; margin: 28px 12px 0 0; }
.switch button { background: var(--bg); border: 0; color: var(--dim); padding: .5rem .7rem; text-align: left;
  font: 600 13px/1.2 var(--sans); border-radius: 3px; box-shadow: 0 4px 10px -6px rgb(0 0 0 / .4);
  transition: background .2s, color .2s; }
.switch button:hover { color: var(--fg); }
.switch button[aria-pressed=true] { background: var(--fg); color: var(--bg); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--hi); text-wrap: balance; }
h1 { font-size: clamp(3.2rem, 7vw, 6rem); line-height: .95; letter-spacing: -.02em; margin: 0 0 .25em; }
h1 .logo { height: .9em; width: auto; vertical-align: -.1em; margin-right: .22em; }  /* sits on the baseline like a capital */
.tagline { font-size: clamp(1.15rem, 1.6vw, 1.4rem); line-height: 1.45; max-width: 34ch; margin: 0 0 40px; }
.title-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 280px); gap: 48px; align-items: start; }
.minis { display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: 44px 44px; grid-auto-flow: column; gap: 4px 6px; margin: 30px 0 28px; }
.mini { background: var(--c); border-radius: 2px; transition: transform .3s var(--ease); }
.minis:hover .mini { transform: translateY(-4px); }

.title-side p { margin: 0 0 1rem; line-height: 1.5; }
.title-side .apps-line { color: var(--dim); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin: 24px 0 0; }
.primary { background: var(--accent); color: var(--bg); padding: .8rem 1.6rem; border-radius: 3px; font-weight: 700;
  text-decoration: none; transition: background .2s; }
.primary:hover { background: color-mix(in oklab, var(--accent), var(--hi) 18%); }

/* Plates: two screenshots split by a handle; drag anywhere on them */
.plate { margin: 0; }
.plate.glide { transition: --x .75s var(--ease); }
.cmp { position: relative; overflow: hidden; border: 1px solid var(--sel); border-radius: 3px; user-select: none;
  background: var(--bg); cursor: ew-resize; touch-action: pan-y; }
/* Each half sits on its own screenshot's background, so a screenshot painting a frame late doesn't flash. */
.plate.dl .cmp { background: linear-gradient(to right, var(--shot-dark) var(--x), var(--shot-light) var(--x)); }
.js .plate.dl .cmp:not(.ready) { background: var(--bg); }  /* the loading text needs one calm ground */
.cmp img { display: block; width: 100%; height: auto; -webkit-user-drag: none; transition: opacity .35s; }
.js .cmp:not(.ready) img, .js .cmp:not(.ready) .handle { opacity: 0; }
/* Loading: the six family chips pulse in turn until both screenshots are decoded. */
.wait { position: absolute; inset: 0; display: none; place-content: center; grid-template-columns: repeat(6, 18px);
  gap: 6px; justify-items: center; }
.js .cmp:not(.ready) .wait { display: grid; }
.wait span { width: 18px; height: 26px; border-radius: 2px; background: var(--c); animation: pulse 1.2s var(--ease) infinite; animation-delay: calc(var(--i) * .1s); }
.wait em { grid-column: 1 / -1; margin-top: 12px; font: 600 13px var(--sans); font-style: normal; color: var(--dim); white-space: nowrap; }
@keyframes pulse { 0%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.cmp .top { position: absolute; inset: 0; height: 100%; clip-path: inset(0 calc(100% - var(--x)) 0 0); }
/* Each shot is clipped to its own side: the two images snap to slightly different pixel rows, and a light
   shot left whole underneath showed through as a 1px line along the dark side's edge. */
.cmp .under { clip-path: inset(0 0 0 var(--x)); }
.handle { position: absolute; top: 0; bottom: 0; left: var(--x); width: 48px; margin-left: -24px; cursor: ew-resize;
  display: grid; place-items: center; outline: none; }
.handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px;
  background: var(--accent); box-shadow: 0 0 0 1px rgb(0 0 0 / .35); }
.knob { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: var(--bg); box-shadow: 0 2px 4px rgb(0 0 0 / .3), 0 8px 18px -6px rgb(0 0 0 / .5);
  transition: transform .2s var(--ease); }
.cmp:hover .knob, .cmp.dragging .knob { transform: scale(1.1); }
.handle:focus-visible .knob { outline: 3px solid var(--hi); outline-offset: 2px; }
.sides { display: flex; justify-content: space-between; margin-bottom: 8px; }
.sides > span { display: flex; gap: 4px; }
.sides .full { display: grid; place-items: center; width: 32px; border: 1px solid var(--sel); border-radius: 3px;
  color: var(--dim); transition: background .2s, color .2s; }
.sides .full:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tag { background: none; color: var(--dim); border: 1px solid var(--sel); border-radius: 3px; padding: .3rem .7rem;
  font: 600 13px var(--sans); transition: background .2s, color .2s; }
.tag:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.notes { margin-top: 40px; scroll-margin-top: 24px; }
.notes > h3:first-child { margin-top: 0; }
.next { margin-top: 2rem; }

/* Sections */
section { padding-top: 84px; }
/* Jumping to a section lands in the middle of the gap above its heading, not on the previous section's tail. */
.chapter { scroll-margin-top: -42px; }
#top { scroll-margin-top: 100vh; }  /* clamps to the very top of the page */
h2 { font-size: clamp(2.2rem, 4vw, 3.2rem); line-height: 1.05; margin: 0 0 .45em; }
h3 { font-size: 1.35rem; margin: 2.2em 0 .6em; }
.lede, .prose p, p.prose { max-width: 66ch; }
.lede { margin: 0 0 1.4rem; }
.aside { color: var(--dim); margin-top: 2rem; max-width: 66ch; }

/* Palette: one hue page per family, chips matte and rectangular */
.hues { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 32px; margin-top: 8px; }
.hue h3 { margin: 1.4em 0 .6em; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ground .chips { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.chip { display: grid; gap: 2px; background: none; border: 0; padding: 0;
  text-align: left; color: var(--fg); }
.chip .sw { height: 104px; background: var(--c); border-radius: 2px; margin-bottom: 8px;
  outline: 1px solid color-mix(in oklab, var(--fg) 12%, transparent); outline-offset: -1px;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease); }
.ground .chip .sw { height: 64px; }
.chip:hover .sw { transform: translateY(-3px); box-shadow: 0 8px 16px -8px rgb(0 0 0 / .45); }
.chip .n { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip code { background: none; padding: 0; font-size: 13px; color: var(--dim); }

/* Tabs */
[role=tablist] { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--sel); margin: 8px 0 24px; }
[role=tab] { background: none; border: 0; padding: calc(.7rem + 3px) 1rem .6rem; color: var(--dim);
  font: 600 15px var(--sans); border-radius: 0; }
[role=tab]:hover { color: var(--fg); }
[role=tab][aria-selected=true] { background: var(--float); color: var(--hi); box-shadow: inset 0 3px var(--accent); }
.js [role=tabpanel]:not(.on) { display: none; }
[role=tabpanel] { padding: 0; }  /* tab panels are sections too: no chapter gap */

pre { background: var(--bg); border: 1px solid var(--sel); border-radius: 3px; padding: 1rem 5.5rem 1rem 1.2rem;
  overflow-x: auto; font-size: 14px; line-height: 1.65; margin: 0 0 1.2rem; }
pre code { background: none; padding: 0; font-size: inherit; color: var(--fg); }
/* Code coloured like the Earth Vivid fish theme: commands green, options magenta, strings yellow,
   operators blue, keys cyan; light mode uses the darker brights so every token stays readable. */
.t-cmd, .t-call { color: var(--ink-green); } .t-opt, .t-num { color: var(--ink-magenta); }
.t-str, .t-val { color: var(--ink-yellow); } .t-op { color: var(--ink-blue); } .t-key, .t-var { color: var(--ink-cyan); }
.t-com { color: var(--dim); font-style: italic; }
.t-path { text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: .2em; } /* fish: valid path */
.code { position: relative; }
.copy { position: absolute; top: .6rem; right: .6rem; background: var(--bg); color: var(--dim); border: 1px solid var(--sel);
  border-radius: 3px; padding: .25rem .6rem; font: 600 13px var(--sans); }
.copy:hover { color: var(--fg); border-color: var(--dim); }
.notes p { max-width: 66ch; }

/* Origin */
.neighbours { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(5, auto); grid-auto-flow: column;
  gap: .4rem 40px; max-width: 680px; padding-left: 1.4em; margin: 0; }
.neighbours span { color: var(--dim); }

footer { margin-top: 84px; padding-top: 20px; border-top: 1px solid var(--sel); color: var(--dim); font-size: .92rem; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); margin: 0; background: var(--hi);
  color: var(--bg); padding: .6rem 1rem; border-radius: 3px; font: 500 13px var(--mono); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .35s var(--ease); z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* The flip: the new variant wipes across the old one. */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
/* Same direction as the plates' handles: to light they slide left, to dark right. */
[data-wipe=light]::view-transition-new(root) { animation: wipe-l .8s var(--ease); }
[data-wipe=dark]::view-transition-new(root) { animation: wipe-r .8s var(--ease); }
@keyframes wipe-r { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes wipe-l { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }

@media (max-width: 1080px) {
  .hues { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .title-grid { grid-template-columns: 1fr; gap: 8px; }
  .title-side { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
  .minis { grid-column: 1 / -1; margin: 20px 0 16px; }
}
@media (max-width: 760px) {
  :root { --gutter: 0px; }
  body { font-size: 16px; }
  .book { display: block; margin: 0; padding: 0; }
  .page { padding: 20px 16px 88px; border-radius: 0; box-shadow: none; } /* room for the floating mode switch */
  .page::before { display: none; }
  .thumbs { flex-direction: row; gap: 3px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
  .thumbs a { flex: 1 0 auto; width: auto; padding: 12px 10px 10px; border-radius: 0 0 6px 6px; transform: translateY(-6px);
    text-align: center; font-size: 11px; letter-spacing: .04em; }
  .thumbs a:hover { transform: translateY(-3px); }
  .thumbs a[aria-current] { transform: none; padding-block: 12px 14px; }
  .rail { position: sticky; top: 0; z-index: 5; padding: 0; background: var(--board); }
  .switch { position: fixed; right: 12px; bottom: 12px; flex-direction: row; margin: 0; padding: 4px; gap: 2px;
    background: var(--board); border-radius: 6px; box-shadow: 0 6px 18px -8px rgb(0 0 0 / .5); z-index: 6; }
  .switch button { box-shadow: none; padding: .45rem .7rem; }
  .title-side { display: block; }
  .hues { grid-template-columns: 1fr; }
  .chip .sw { height: 72px; }
  section { padding-top: 54px; }
  .chapter { scroll-margin-top: 20px; }  /* the tab strip covers the gap's upper half */
  .notes { scroll-margin-top: 64px; }
  .neighbours { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; }
  pre { font-size: 13px; }
  .code pre { padding: 2.7rem 1rem 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
