/* askNib books — one sheet of askNib paper (ADR-014).
   The drawings are inked straight onto it, draw themselves in as you arrive and bleed past the text. Three hands,
   never swapped: EB Garamond is the printed page, Caveat is Nib's marker (only where it touches paper), and
   Shantell Sans is askNib's own voice in the chrome. */
:root {
  color-scheme: light;
  --paper: #FAF4E1; --ink: #3A241C; --ink-2: #655443; --ink-3: #8C7A64;
  --accent: #D9482F; --accent-soft: rgba(217, 72, 47, .1); --hl: rgba(240, 190, 60, .45);
  --blue: #4A5FD5; --green: #3D7A47; --gold: #BD7F2E;
  --hand: "Caveat", cursive;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --ui: "Shantell Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --col: 34rem;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
body { margin: 0; color: var(--ink); background-color: var(--paper); font-family: var(--serif); font-size: 1.3rem; line-height: 1.62; font-variant-numeric: oldstyle-nums proportional-nums; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: inherit; text-decoration-color: rgba(58, 36, 28, .35); text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--accent); }
canvas { display: block; }
[hidden] { display: none !important; }
/* dark (#315): ONE root transform, the Dark Reader model, and only when the reader chose it elsewhere (theme.js).
   Photos counter-invert back to true pixels. The canvases here are Nib's ink, not photos, so they invert with the
   page, the way the board's own ink does. */
html[data-theme="dark"]{ filter:invert(1) hue-rotate(180deg) sepia(.08) brightness(.96); }
html[data-theme="dark"] img, html[data-theme="dark"] video, html[data-theme="dark"] svg image{ filter:invert(1) hue-rotate(180deg); }
.bleed { display: block; width: 100vw; position: relative; left: 50%; margin-left: -50vw; }

/* ---------------------------------------------------------------- chrome: askNib's own voice, quiet, flush on the paper */
.booknav { font-family: var(--ui); font-size: .92rem; display: flex; align-items: baseline; gap: .55rem; padding: 18px 22px 0; color: var(--ink-3); flex-wrap: wrap; }
.booknav .wm { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.12rem; letter-spacing: -.01em; }
.booknav .wm b { color: var(--accent); font-weight: 700; }
.booknav a { color: var(--ink-2); text-decoration: none; }
.booknav a:hover { color: var(--accent); }
.booknav .sep { color: var(--ink-3); opacity: .6; }
.booknav .grow { flex: 1; }

/* ---------------------------------------------------------------- the opening */
.hero { padding-top: 34px; text-align: center; }
.hero .kick { font-size: 1.12rem; color: var(--ink-2); margin: 0; }
.hero h1 { font-weight: 500; font-size: clamp(2.3rem, 5.6vw, 4.4rem); line-height: 1.04; letter-spacing: -.02em; margin: .1em auto .14em; max-width: 19ch; padding: 0 14px; text-wrap: balance; }
.hero .dek { font-size: 1.42rem; color: var(--ink-2); margin: 0 auto; max-width: 30rem; line-height: 1.35; padding: 0 18px; }
.sig { width: 300px; height: 64px; margin: 4px auto 0; }
.playline { margin: .4rem auto 0; display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: 0 18px; }
.playch { font-family: var(--hand); font-weight: 700; font-size: 1.65rem; color: #fff; background: var(--accent); border: 0; border-radius: 999px; padding: .15rem 1.1rem .25rem; cursor: pointer; box-shadow: 0 6px 14px -8px rgba(217, 72, 47, .8); transition: transform .15s; }
.playch:hover { transform: translateY(-1px); }
.playline span { font-size: 1rem; color: var(--ink-3); }

/* the short answer: what an answer engine quotes, and what a hurried reader needs; set like the rest, marked by Nib */
.short { margin: 1.6rem auto 0; padding: 0; }
.short .lbl { font-family: var(--hand); font-weight: 700; font-size: 1.45rem; color: var(--accent); display: block; line-height: 1; margin-bottom: .1rem; transform: rotate(-1.2deg); transform-origin: left; }
.short p { margin: 0; font-size: 1.24rem; line-height: 1.5; color: var(--ink); text-indent: 0 !important; }

/* ---------------------------------------------------------------- the column */
.col { width: min(var(--col), 100% - 40px); margin: 0 auto; position: relative; }
.col > p { margin: 0; text-indent: 1.4em; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.col > p.ni, .col > p.lead, .col > h2 + p, .col > .short + p { text-indent: 0; }
.lead { font-size: 1.42rem; line-height: 1.55; margin-bottom: .9em !important; }
.lead::first-letter { font-size: 3.4em; line-height: .8; float: left; margin: .06em .08em 0 -.02em; color: var(--accent); font-weight: 500; }
h2 { font-weight: 500; font-size: 1.72rem; line-height: 1.2; margin: 2.6rem 0 .6rem; text-align: center; }
h3 { font-weight: 600; font-size: 1.3rem; margin: 1.8rem 0 .3rem; }
.hint { text-align: center; font-size: 1.06rem; color: var(--ink-2); margin: .2rem auto 1.2rem !important; text-indent: 0 !important; padding: 0 18px; }
.deep { font-size: 1.12rem; color: var(--ink-2); }
blockquote { margin: 1.1rem 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--ink-3); font-style: italic; color: var(--ink-2); }
blockquote cite { display: block; font-style: normal; font-size: 1rem; color: var(--ink-3); margin-top: .2rem; }
.col code, .nextup code, .tasks code { font-family: var(--mono); font-size: .8em; font-variant-numeric: normal; padding: 0 .08em; }
.nib-note code { font-family: var(--mono); font-size: .66em; font-weight: 600; }
sup.fn a { text-decoration: none; color: var(--accent); font-size: .78em; padding: 0 .1em; }

/* live prose */
.play { font: inherit; color: var(--accent); background: none; border: 0; border-bottom: 1.5px dashed var(--accent); cursor: pointer; padding: 0 .12em; }
.play:hover { background: var(--accent-soft); }
.n { color: var(--accent); border-bottom: 1.5px dashed var(--accent); cursor: ew-resize; white-space: nowrap; user-select: none; -webkit-user-select: none; touch-action: none; padding: 0 .05em; border-radius: 2px; transition: background .15s; }
.n:hover, .n:focus-visible, .n.drag { background: var(--accent-soft); outline: none; }
.n.wiggle { animation: nudge 1.8s ease-in-out; }
@keyframes nudge { 0%, 100% { background: transparent } 30%, 70% { background: var(--accent-soft) } }
.v { font-weight: 600; white-space: nowrap; }
.t { border-bottom: 1px solid var(--hl); cursor: default; transition: background .15s; }
.t.lit, .t:hover, .mark { background: linear-gradient(transparent 58%, var(--hl) 58%); border-bottom-color: transparent; }
/* a highlighter swipe someone left on the page */
mark.hl { color: inherit; background: linear-gradient(100deg, transparent .2em, var(--hl) .3em, rgba(240, 190, 60, .38) 80%, transparent calc(100% - .1em)); background-size: 100% 62%; background-position: 0 72%; background-repeat: no-repeat; padding: 0 .12em; margin: 0 -.12em; }

/* guess first */
.choices { text-align: center !important; text-indent: 0 !important; margin: .7em 0 .9em !important; line-height: 2.1; }
.choices button { font-size: 1.12rem; background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: .05em .4em; border-radius: 4px; }
.choices button:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.choices button:disabled { cursor: default; }
.choices button.picked { color: var(--paper); background: var(--accent); }
.choices button.answer { box-shadow: inset 0 0 0 1.5px currentColor; color: var(--green); }
.choices span { color: var(--ink-3); }
/* hidden until guessed, but only when the page's script is running: without it the answer is simply there */
html:not(.nb-js) .js-only { display: none; } /* controls that only a running page can use */
.nb-js .reveal { opacity: 0; max-height: 0; overflow: hidden; transition: opacity .7s, max-height .9s; }
.nb-js .reveal.on { opacity: 1; max-height: 40em; }
.nb-js .nib-note.reveal.on { overflow: visible; } /* a note that waits for a guess keeps its hook when it shows */

/* code: monospace on the paper, no box; the running line is highlighted; red tokens are switches */
.code { font-family: var(--mono); font-size: .86rem; line-height: 1.62; margin: 1.1rem 0; padding: 0; white-space: pre; overflow-x: auto; font-variant-numeric: normal; tab-size: 4; }
.code .ln { display: block; padding: 0 .6rem 0 2.6rem; position: relative; border-radius: 3px; transition: background .25s; }
.code .ln::before { content: attr(data-n); position: absolute; left: .3rem; width: 1.6rem; text-align: right; color: var(--ink-3); opacity: .7; }
.code .ln.on { background: rgba(240, 190, 60, .3); }
.code .ln.on::after { content: "◂"; position: absolute; right: .2rem; color: var(--accent); }
.code .kw { color: var(--blue); }
.code .cm { color: var(--ink-3); font-style: italic; }
.code .tog { font: inherit; color: var(--accent); background: var(--accent-soft); border: 0; border-bottom: 1.5px dashed var(--accent); border-radius: 2px; padding: 0 .1em; cursor: pointer; }
.code .tog.changed { background: rgba(217, 72, 47, .22); }

/* controls in the flow: Nib's step / back / run, set like words */
.controls { display: flex; justify-content: center; gap: 1.2rem; flex-wrap: wrap; margin: .3rem 0 1rem; text-indent: 0 !important; font-size: 1.08rem; color: var(--ink-2); }
.controls button { font: inherit; color: var(--accent); background: none; border: 0; border-bottom: 1.5px dashed var(--accent); cursor: pointer; padding: 0 .12em; }
.controls button:disabled { color: var(--ink-3); border-color: transparent; cursor: default; }
.controls input { font: inherit; width: 8.5rem; background: transparent; border: 0; border-bottom: 1.5px solid var(--ink-2); padding: 0 .2rem; text-align: center; color: var(--ink); }
.controls input:focus { outline: none; border-bottom-color: var(--accent); }

/* check yourself */
.tasks { list-style: none; padding: 0; margin: .6rem 0 0; }
.tasks li { position: relative; padding: .35rem 0 .35rem 2.6rem; }
.tasks li svg.tick { position: absolute; left: 0; top: .45rem; width: 28px; height: 28px; overflow: visible; color: var(--accent); }
.tasks li .why { display: block; color: var(--ink-2); font-size: 1.08rem; max-height: 0; opacity: 0; overflow: hidden; transition: opacity .6s, max-height .7s; }
.tasks li.done .why { max-height: 10em; opacity: 1; }
.tasks li.done > .q { color: var(--ink-2); }
.score { text-align: center !important; text-indent: 0 !important; color: var(--ink-2); font-size: 1.08rem; margin-top: .6rem !important; }
.explain textarea { width: 100%; min-height: 5.4rem; margin: .5rem 0 .3rem; padding: .5rem .6rem; background: transparent; border: 1px solid var(--ink-3); border-radius: 6px; resize: vertical; line-height: 1.45; font-size: 1.12rem; }
.explain .askbtn { font-size: 1.06rem; }

/* ---------------------------------------------------------------- Nib's margin notes: someone has been through this page before you */
.nib-note { font-family: var(--hand); font-weight: 600; font-size: 1.42rem; line-height: 1.12; color: var(--accent); margin: .5rem 0 1rem 1.2rem; max-width: 19rem; transform: rotate(-1.6deg); position: relative; }
.nib-note.blue { color: var(--blue); } .nib-note.green { color: var(--green); } .nib-note.ink { color: var(--ink-2); }
.nib-note::before { content: ""; position: absolute; left: -1.1rem; top: .35rem; width: .7rem; height: .7rem; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; border-radius: 0 0 0 6px; opacity: .8; }
.nib-note.in-margin { position: absolute; left: calc(100% + 2.4rem); width: min(15rem, calc((100vw - var(--col)) / 2 - 4rem)); margin: 0; transform: rotate(-2.4deg); }
.nib-note.in-margin.left { left: auto; right: calc(100% + 2.4rem); transform: rotate(2deg); text-align: right; }
.nib-note.in-margin::before { left: -1.5rem; top: .5rem; width: 1rem; height: 0; border-bottom: 0; border-radius: 0; border-top: 2px solid currentColor; border-left: 0; }
.nib-note.in-margin.left::before { left: auto; right: -1.5rem; }

/* ---------------------------------------------------------------- the play bar, Nib's puppet, Ask Nib */
.nibbar { position: fixed; z-index: 40; left: 50%; top: 12px; transform: translateX(-50%); width: min(46rem, calc(100vw - 20px)); display: flex; align-items: center; gap: .7rem; padding: .45rem .7rem .45rem .5rem; background: var(--paper); border: 1.5px solid rgba(58, 36, 28, .22); border-radius: 14px; box-shadow: 0 14px 30px -20px rgba(58, 36, 28, .7); }
.nibbar > svg { flex: none; width: 22px; height: 52px; transform: rotate(-12deg); }
.nibbar-text { flex: 1; min-width: 0; }
.nibbar .novoice { margin: .15rem 0 0; font-size: .9rem; color: var(--ink-3); }
.nibbar .cap { margin: 0; font-size: 1.08rem; line-height: 1.38; color: var(--ink); }
.nibbar .cap.fresh { animation: capIn .45s ease-out; }
@keyframes capIn { from { opacity: 0; transform: translateY(3px) } to { opacity: 1; transform: none } }
.nibbar button { flex: none; background: none; border: 0; cursor: pointer; font-family: var(--hand); font-weight: 700; font-size: 1.2rem; color: var(--accent); padding: .1rem .3rem; white-space: nowrap; }
.nibbar .nb-sound { color: var(--ink-3); }
.reading { background: linear-gradient(rgba(240, 190, 60, .16), rgba(240, 190, 60, .16)); box-shadow: 0 0 0 8px rgba(240, 190, 60, .16); border-radius: 3px; transition: background .4s, box-shadow .4s; }
.puppet { position: absolute; z-index: 35; width: 30px; height: 70px; margin: -66px 0 0 -4px; pointer-events: none; opacity: 0; transform: rotate(24deg); transform-origin: 4px 66px; transition: left .7s cubic-bezier(.3, .7, .3, 1), top .7s cubic-bezier(.3, .7, .3, 1), opacity .3s; filter: drop-shadow(0 4px 5px rgba(58, 36, 28, .25)); }
.puppet svg { width: 100%; height: 100%; }
.puppet.on { opacity: 1; }
.puppet.follow { transition: opacity .3s; }
.nibseat { position: fixed; right: 18px; bottom: 18px; z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; cursor: pointer; color: var(--accent); }
.nibseat svg { width: 34px; height: 78px; transform: rotate(-14deg); transition: transform .2s; filter: drop-shadow(0 4px 5px rgba(58, 36, 28, .18)); }
.nibseat:hover svg, .nibseat[aria-expanded="true"] svg { transform: rotate(-6deg) translateY(-5px); }
.nibseat span { font-family: var(--hand); font-weight: 700; font-size: 1.15rem; background: var(--paper); padding: 0 5px; border-radius: 4px; }
.askcard { position: absolute; z-index: 31; width: min(20rem, calc(100vw - 24px)); padding: .6rem .8rem .7rem; background: var(--paper); border: 1px solid var(--ink-3); border-radius: 8px; box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .6); }
.askcard .k { font-size: 1rem; color: var(--ink-2); margin: 0 0 .3rem; }
.askcard .q { font-size: .98rem; color: var(--ink-3); margin: -.1rem 0 .35rem; }
.askcard form { display: flex; gap: .4rem; align-items: center; border-bottom: 1.5px solid var(--ink-2); }
.askcard input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 1.08rem; padding: .2rem 0; }
.askcard button { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 1.04rem; }
.askpin { position: absolute; z-index: 31; background: var(--paper); border: 1px solid var(--ink-3); border-radius: 6px; padding: .1rem .55rem; color: var(--accent); cursor: pointer; font-size: 1rem; box-shadow: 0 8px 20px -14px rgba(0, 0, 0, .6); }
.note { position: relative; margin: 1rem 0 1.2rem; max-width: 22rem; }
.note.wide { max-width: none; }
.note.margin { position: absolute; width: min(19rem, calc((100vw - var(--col)) / 2 - 3rem)); margin: 0; }
.note .qline { font-size: 1rem; color: var(--ink-3); margin: 0 0 .2rem; }
.note .qline b { color: var(--accent); font-weight: 500; font-family: var(--hand); font-size: 1.3rem; }
.note canvas { width: 100%; height: auto; }
.note .say { font-size: 1.06rem; color: var(--ink-2); margin: .3rem 0 0; line-height: 1.45; }
.note .say a.signin { color: var(--accent); font-weight: 600; white-space: nowrap; }
canvas.overfig { z-index: 5; }
.note.figure-note { max-width: 26rem; margin: .6rem auto 1rem; }
.note .think { color: var(--accent); font-family: var(--hand); font-size: 1.35rem; }
.note .verdict { font-family: var(--hand); font-size: 1.5rem; margin: .2rem 0 0; color: var(--ink-2); }
.note .verdict[data-v="right"] { color: var(--pistachio, #5c8a3a); }
.note .verdict[data-v="almost"] { color: var(--caramel, #b8742a); }
.note .think i { font-style: normal; animation: blink 1.2s infinite; } .note .think i:nth-child(2) { animation-delay: .2s } .note .think i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%, 100% { opacity: .15 } 50% { opacity: 1 } }

/* ---------------------------------------------------------------- the ending */
.coda { text-align: center !important; text-indent: 0 !important; font-size: 1.36rem; line-height: 1.5; margin: 2.4rem auto 0 !important; max-width: 31rem; }
.end { display: block; margin: 60px auto 26px; color: var(--ink-3); }
.nextup { text-align: center; margin: 0 auto 1.6rem; max-width: 34rem; padding: 0 18px; }
.nextup .lbl { font-family: var(--hand); font-weight: 700; font-size: 1.4rem; color: var(--accent); }
.nextup a { display: block; font-size: 1.32rem; margin: .2rem 0; }
.sources { width: min(var(--col), 100% - 40px); margin: 0 auto 1.4rem; font-size: 1rem; color: var(--ink-2); }
.sources h2 { font-size: 1.2rem; margin: 1rem 0 .3rem; }
.sources ol { padding-left: 1.3rem; margin: 0; }
.sources li { margin: .2rem 0; }
.colophon { text-align: center; color: var(--ink-3); font-size: 1rem; margin: 0 auto 80px; max-width: 30rem; padding: 0 18px; }

@media (max-width: 640px) {
  body { font-size: 1.14rem; }
  .col > p { text-align: left; }
  .puppet { width: 20px; height: 47px; margin: -44px 0 0 -3px; transform-origin: 3px 44px; }
  .nibbar { top: auto; bottom: 10px; } .nibbar > svg { display: none; } .nibbar .cap { font-size: 1rem; }
  .nibseat { right: 8px; bottom: 10px; } .nibseat svg { width: 26px; height: 60px; } .nibseat span { display: none; }
  .code { font-size: .74rem; }
  .code .ln { padding-left: 2rem; }
}
@media (prefers-reduced-motion: reduce) { .nb-js .reveal, .tasks li .why { transition: none; } }

/* ---------------------------------------------------------------- the shelf: /books and each set */
.shelf .hero { padding-top: 42px; }
.shelf .hero h1 { max-width: 16ch; }
.shelfset { margin: 2.6rem 0 0; }
.shelfset h2 { text-align: left; margin: 0 0 .1rem; font-size: 1.9rem; }
.shelfset h2 a { text-decoration: none; }
.shelfset h2 a:hover { color: var(--accent); }
.shelfset .blurb { margin: 0 0 .6rem; color: var(--ink-2); font-size: 1.12rem; }
.pagelist { list-style: none; margin: .4rem 0 0; padding: 0; counter-reset: pg; }
.pagelist li { counter-increment: pg; position: relative; padding: .55rem 0 .55rem 2.4rem; border-top: 1px solid rgba(58, 36, 28, .12); }
.pagelist li::before { content: counter(pg); position: absolute; left: .2rem; top: .45rem; font-family: var(--hand); font-weight: 700; font-size: 1.6rem; color: var(--accent); }
.pagelist a { font-size: 1.3rem; text-decoration: none; line-height: 1.3; }
.pagelist a:hover { color: var(--accent); }
.pagelist p { margin: .15rem 0 0; color: var(--ink-2); font-size: 1.04rem; line-height: 1.45; }
.bookfoot { font-family: var(--ui); font-size: .9rem; text-align: center; color: var(--ink-3); padding: 0 18px 48px; }
.bookfoot a { color: var(--ink-2); text-decoration: none; }
.bookfoot a:hover { color: var(--accent); }
.nextup { margin-top: 2.4rem; }
.nextup .also { margin: .4rem 0 0; font-size: 1.02rem; color: var(--ink-2); }
