/* The web edition: the book's components (callouts, cards, checklists, code, tables) in the site's language.
   --c is the part's colour, set on the page; everything else comes from site.css tokens. */
:root { --warn: #C2410C; --code-bg: #121A2B; --code-ink: #E3E8F2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --warn: #F59E0B; --code-bg: #0B1220; } }

/* contents */
.book-home { padding-top: 40px; padding-bottom: 80px; }
.book-head { max-width: 760px; }
.book-head h1 { font-size: clamp(40px, 6vw, 72px); max-width: none; }
.book-head .lead { margin-top: 18px; }
.book-head .lead.small { font-size: 17px; margin-top: 10px; }
.owned { margin-top: 18px; font-weight: 600; color: var(--go); }
.toc { margin-top: 48px; display: grid; gap: 36px; }
.toc-part h2 { font-size: 22px; font-stretch: 110%; letter-spacing: -.01em; display: flex; align-items: center; gap: 12px; }
.toc-part h2::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.toc-part ol { list-style: none; margin: 12px 0 0; padding: 0; }
.toc-part a { display: grid; grid-template-columns: 44px 1fr auto; gap: 2px 14px; padding: 14px 0; border-top: 1px solid var(--line); text-decoration: none; }
.toc-part a:hover .tt { text-decoration: underline; text-decoration-thickness: 2px; }
.toc-part .num { grid-row: span 2; font: 400 22px/1.1 var(--hand); color: var(--c); }
.toc-part .tt { font-weight: 650; font-size: 18px; }
.toc-part .tb { grid-column: 2; color: var(--mute); font-size: 15px; }
.toc-part .badge { grid-row: 1 / span 2; grid-column: 3; align-self: center; font-size: 13px; font-weight: 600; color: var(--mute);
  border: 1.5px solid var(--line-2); border-radius: 999px; padding: 4px 10px; }

/* gate: where a preview ends */
.gate { margin: 8px 0 0; padding: 26px; border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.gate.compact { margin-top: 24px; }
.gate h2 { margin: 0 0 6px; font-size: 26px; }
.gate p { color: var(--mute); }
.gate .cta { margin-top: 16px; }
.gate .fine { font-size: 13px; margin-top: 10px; }
.linkish.strong { color: var(--ink); font-weight: 650; font-size: inherit; }
.unlock label { display: block; color: var(--mute); font-size: 15px; }
.unlock .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.unlock input { font: 600 17px/1 "Mona Sans", sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
  background: var(--board); border: 1.5px solid var(--line-2); border-radius: 12px; padding: 12px 14px; flex: 1 1 220px; }
.fade { height: 120px; margin-top: -120px; position: relative; pointer-events: none;
  background: linear-gradient(to bottom, color-mix(in oklab, var(--board) 0%, transparent), var(--board)); }

/* chapter page */
.chapter-wrap { padding-top: 32px; padding-bottom: 80px; }
.ch-head { max-width: 860px; }
.ch-part { font-size: 14px; color: var(--mute); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ch-part a { color: var(--mute); }
.ch-part span { color: var(--c); font-weight: 600; }
.ch-head h1 { font-size: clamp(36px, 5.2vw, 64px); max-width: none; margin-top: 12px; }
.ch-head .lead { margin-top: 14px; }
.ch-grid { display: grid; grid-template-columns: 230px minmax(0, 72ch); gap: clamp(24px, 4vw, 64px); margin-top: 44px; align-items: start; }
.ch-toc { position: sticky; top: 88px; font-size: 14px; max-height: calc(100vh - 110px); overflow: auto; }
.ch-toc b { display: block; color: var(--mute); font-weight: 600; margin-bottom: 8px; }
.ch-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ch-toc a, .ch-toc span { display: block; padding: 6px 10px; border-radius: 10px; text-decoration: none; line-height: 1.35; border-left: 2px solid var(--line); }
.ch-toc a:hover { background: var(--paper); border-left-color: var(--c); }
.ch-toc .locked span { color: var(--mute); opacity: .7; }
.ch-toc .locked span::after { content: " (in the book)"; font-size: 12px; }
@media (max-width: 980px) { .ch-grid { grid-template-columns: minmax(0, 1fr); } .ch-toc { position: static; max-height: none; } }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; max-width: calc(230px + 72ch + 64px); }
.pager a { display: grid; gap: 4px; padding: 18px 20px; border-radius: 18px; background: var(--paper); text-decoration: none; font-weight: 650; box-shadow: var(--shadow); }
.pager a span { font-weight: 500; font-size: 13px; color: var(--mute); }
.pager .next { text-align: right; grid-column: 2; }

/* chapter text */
.content { font-size: 17px; line-height: 1.68; }
.content > :first-child { margin-top: 0; }
.content h2 { font-size: clamp(26px, 2.6vw, 32px); font-stretch: 110%; letter-spacing: -.015em; margin: 56px 0 14px; scroll-margin-top: 90px; }
.content h3 { font-size: 21px; margin: 34px 0 10px; scroll-margin-top: 90px; }
.content h4 { font-size: 17px; font-weight: 700; margin: 0 0 6px; letter-spacing: 0; }
.content p, .content ul, .content ol, .content dl { margin: 0 0 14px; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin: 4px 0; }
.content a { color: inherit; text-decoration-color: var(--c); text-decoration-thickness: 2px; }
.content code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; background: var(--line); border-radius: 5px; padding: .08em .35em; }
.content .lede { font-size: 20px; line-height: 1.55; color: var(--ink); }
.content .muted, .content .hint { color: var(--mute); }
.content .small { font-size: 14px; }
.ic { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.callout, .say, .verdict { margin: 22px 0; padding: 16px 20px 6px; border-radius: 16px; background: var(--paper); border-left: 4px solid var(--line-2); }
.say { border-left-color: var(--c); }
.callout.warn { border-left-color: var(--warn); }
.verdict { border-left-color: var(--go); }
.tag { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 650; margin-bottom: 6px; }
.say .tag { color: var(--c); }
.warn .tag { color: var(--warn); }
.verdict .tag { color: var(--go); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px 4px; margin: 14px 0; }
.two, .three { display: grid; gap: 14px; margin: 18px 0; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two > .card, .three > .card { margin: 0; }
@media (max-width: 760px) { .two, .three { grid-template-columns: 1fr; } }
.chip { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; margin: 2px 4px 2px 0;
  background: color-mix(in oklab, var(--c) 14%, var(--paper)); color: var(--ink); }
.chip.stretch { background: none; border: 1.5px dashed var(--c); }
h3.lvl { display: flex; align-items: center; gap: 10px; }
.level { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--c); color: var(--paper); letter-spacing: .02em; }

.tbl { overflow-x: auto; margin: 18px 0; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); }
.content table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.content th { text-align: left; font-weight: 650; padding: 10px 14px; background: var(--board); border-bottom: 1px solid var(--line); }
.content td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 8px 0; border-top: 1px solid var(--line); }
  table.stack td { border: 0; padding: 4px 14px; }
  table.stack td::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 650; color: var(--mute); }
}

.listhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 28px; }
.listhead h3 { margin: 0; }
.count { font: 400 18px/1 var(--hand); color: var(--c); }
.checks { list-style: none; padding: 0 !important; margin: 12px 0 20px; display: grid; gap: 6px; }
.checks label { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--paper); cursor: pointer; }
.checks input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--c); }
.checks .t { display: block; font-weight: 650; }
.checks .d { display: block; color: var(--mute); font-size: 15px; }
.checks input:checked + span .t { text-decoration: line-through; text-decoration-color: var(--c); }

.qa details, .content details { background: var(--paper); border-radius: 14px; margin: 10px 0; padding: 4px 18px; }
.content summary { cursor: pointer; font-weight: 650; padding: 10px 0; }
.ans { padding-bottom: 6px; color: var(--ink); }
dl.clock { display: grid; grid-template-columns: 112px 1fr; gap: 0; border-top: 1px solid var(--line); }
dl.clock dt, dl.clock dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
dl.clock dt { font-weight: 700; color: var(--c); font-variant-numeric: tabular-nums; }

.codebox { margin: 18px 0; border-radius: 16px; overflow: hidden; background: var(--code-bg); color: var(--code-ink); }
.cb-h { padding: 8px 16px; font-size: 13px; color: #9AA5BA; border-bottom: 1px solid rgb(255 255 255 / .08); }
.codebox pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.codebox code { background: none; padding: 0; font-size: 14px; line-height: 1.6; color: inherit; }
.hljs-keyword, .hljs-built_in { color: #F28FD8; }
.hljs-title, .hljs-title.function_, .hljs-title.class_ { color: #8FB0FF; }
.hljs-string { color: #9BE3B8; }
.hljs-number, .hljs-literal { color: #F7B26A; }
.hljs-comment { color: #7F8AA3; font-style: italic; }
.hljs-params, .hljs-type, .hljs-meta, .hljs-subst { color: #C9D2E3; }
.content pre { overflow-x: auto; max-width: 100%; margin: 18px 0; padding: 14px 16px; border-radius: 14px; background: var(--paper);
  font: 14px/1.6 ui-monospace, "SF Mono", Menlo, monospace; }
.content pre .c { color: var(--mute); }
.codebox pre { background: none; border-radius: 0; }
.content details { max-width: 100%; overflow: hidden; }
.content details .codebox { max-width: 100%; }
