/* ==========================================================================
   Book quizzes (/books/ and /books/<slug>/)
   Built on the tokens in site.css and the article layout in article.css.
   The quiz lives inside .prose, so its list and spacing rules are reset here.
   ========================================================================== */

.c-yellow { color: var(--yellow); }
.c-indigo { color: #8f99ff; }
.c-red { color: #ff6b6f; }
.c-slate { color: #aeb8c8; }

/* ---------- Typographic covers (never the publisher's cover) ---------- */

.book-cover {
    --c1: #1b1640; --c2: #4b3fb0;
    container-type: inline-size;
    position: relative; flex-shrink: 0;
    width: 136px; aspect-ratio: 2 / 3;
    border-radius: 4px 12px 12px 4px;
    background: linear-gradient(165deg, var(--c2) -30%, var(--c1) 72%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 24px 44px -20px rgba(0, 0, 0, 0.9), 0 2px 6px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    color: #fff;
}
/* Padding in cqw has to live inside the container, not on it */
.book-cover-in {
    position: relative; z-index: 1; height: 100%;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 11cqw 10cqw 10cqw 13cqw;
}
/* Spine */
.book-cover::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6cqw;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), rgba(255, 255, 255, 0.1) 60%, transparent);
}
.book-cover-title {
    font-size: 13.5cqw; font-weight: 700; line-height: 1.04; letter-spacing: -0.035em;
    text-wrap: balance; overflow-wrap: anywhere; hyphens: auto;
}
.book-cover-author {
    font-size: 6.4cqw; font-weight: 600; letter-spacing: 0.02em; line-height: 1.25;
    color: rgba(255, 255, 255, 0.72);
}

.tint-violet { --c1: #17123a; --c2: #5446c4; }
.tint-pink { --c1: #2e0b1d; --c2: #b43a74; }
.tint-orange { --c1: #2e1504; --c2: #c06a18; }
.tint-yellow { --c1: #29220a; --c2: #a68d22; }
.tint-green { --c1: #0c2611; --c2: #3e8f42; }
.tint-cyan { --c1: #052529; --c2: #188a94; }
.tint-blue { --c1: #081d35; --c2: #2f72b6; }
.tint-indigo { --c1: #121637; --c2: #4c56c9; }
.tint-red { --c1: #2f0b0d; --c2: #c23b40; }
.tint-slate { --c1: #14181f; --c2: #5b6677; }

.book-cover--small { width: 64px; border-radius: 3px 8px 8px 3px; }
.book-cover--card { width: 100%; }

/* ---------- Page header ---------- */

.book-head { display: flex; align-items: flex-end; gap: clamp(20px, 3vw, 32px); margin-bottom: 24px; }
.book-head-text { min-width: 0; }
.page-book .article-head .headline { margin-bottom: 10px; }
.page-book .article-head .eyebrow { font-size: 17px; margin-bottom: 10px; }
.book-facts { font-size: 17px; color: var(--text-2); font-weight: 500; }
.book-facts-note { color: var(--text-3); font-weight: 400; }
.page-book .book-lede { font-size: clamp(18px, 1.6vw, 21px); margin-bottom: 10px; }
.page-book .book-lede.is-challenge { color: var(--text); font-weight: 600; }
.book-meta { font-size: 14px; color: var(--text-3); padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.book-meta a { color: var(--blue); }
.prose .book-cheat { margin-top: 16px; font-size: 16px; color: var(--text-2); }
.prose .book-byline { margin-top: 28px; padding: 22px 0 0; border-top: 1px solid var(--line); border-bottom: 0; font-size: 14px; }

/* The quiz, the result card and the header already offer the app: no sticky bar here */
.page-book .dock { display: none !important; }

/* ---------- Quiz ---------- */

.bq {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 3.2vw, 34px);
    font-size: 17px; line-height: 1.45; color: var(--text);
    scroll-margin-top: 84px;
}
.bq [hidden] { display: none !important; }
.prose .bq ol, .prose .bq ul { list-style: none; padding: 0; margin: 0; }
.prose .bq li + li { margin-top: 0; }
.prose .bq > * + * { margin-top: 0; }

.bq-banner {
    display: flex; gap: 12px; align-items: center;
    padding: 14px 16px; margin-bottom: 20px; border-radius: 16px;
    background: rgba(123, 108, 246, 0.1); border: 1px solid rgba(123, 108, 246, 0.35);
    font-size: 15px; line-height: 1.45; color: var(--text);
}

.bq-progress { display: none; gap: 4px; margin-bottom: 22px; }
.bq.is-live .bq-progress { display: flex; }
.bq.is-done .bq-progress { display: none; }
.bq-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--line-strong); transition: background-color 0.3s ease; }
.bq-progress i.is-current { background: rgba(255, 255, 255, 0.55); }
.bq-progress i.is-right { background: var(--green); }
.bq-progress i.is-wrong { background: var(--pink); }

/* Without JavaScript every question is listed, with its answer behind a toggle */
.bq-q + .bq-q { border-top: 1px solid var(--line); margin-top: 28px !important; padding-top: 28px; }
.bq.is-live .bq-q + .bq-q { border-top: 0; margin-top: 0 !important; padding-top: 0; }
.bq.is-live .bq-answer { display: none; }

.bq-num { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.prose .bq-prompt {
    font-size: clamp(21px, 2.3vw, 26px); font-weight: 700; letter-spacing: -0.022em; line-height: 1.25;
    color: var(--text); margin: 0 0 20px; text-wrap: pretty;
}
.bq-prompt:focus { outline: none; }

.bq-choices { display: grid; gap: 10px; }
.bq-choice {
    width: 100%; min-height: 60px;
    display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: center;
    padding: 12px 16px 12px 13px; border-radius: 16px;
    border: 1px solid var(--line-strong); background: var(--surface-2);
    font: inherit; font-size: 17px; line-height: 1.4; text-align: left; color: var(--text);
    transition: border-color 0.2s ease, background-color 0.2s ease, opacity 0.3s ease, transform 0.25s var(--ease);
    -webkit-tap-highlight-color: transparent;
}
.bq-choice:disabled { cursor: default; }
.bq-choice:not(:disabled):not(.is-locked) { cursor: pointer; }
.bq-choice:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.bq-key {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.03);
    font-size: 14px; font-weight: 700; color: var(--text-2);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
@media (hover: hover) {
    .bq-choice:not(:disabled):not(.is-locked):hover { border-color: rgba(255, 255, 255, 0.3); background: #1f1f26; }
    .bq-choice:not(:disabled):not(.is-locked):hover .bq-key { border-color: rgba(255, 255, 255, 0.4); color: var(--text); }
}
.bq-choice:not(.is-locked):active { transform: scale(0.985); }

.bq-choice.is-right { border-color: rgba(127, 210, 124, 0.75); background: rgba(127, 210, 124, 0.1); }
.bq-choice.is-right .bq-key { background: var(--green); border-color: transparent; color: #000; }
.bq-choice.is-wrong { border-color: rgba(245, 96, 154, 0.75); background: rgba(245, 96, 154, 0.1); }
.bq-choice.is-wrong .bq-key { background: var(--pink); border-color: transparent; color: #000; }
.bq-choice.is-dim { opacity: 0.45; }

.bq-feedback {
    margin-top: 16px !important; padding: 18px 20px; border-radius: 16px;
    background: var(--bg-raised);
    animation: bq-in 0.4s var(--ease) both;
}
.bq-verdict { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.bq-feedback.is-right .bq-verdict { color: var(--green); }
.bq-feedback.is-wrong .bq-verdict { color: var(--pink); }
.bq-explain { margin-top: 6px; font-size: 16px; line-height: 1.55; color: var(--text-2); }
.bq-next { margin-top: 16px; height: 48px; font-size: 16px; padding: 0 22px; }

.bq-answer { margin-top: 14px !important; font-size: 16px; }
.bq-answer summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.bq-answer p { margin-top: 8px; color: var(--text-2); }

@keyframes bq-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Result ---------- */

.bq-result { text-align: center; scroll-margin-top: 84px; animation: bq-in 0.5s var(--ease) both; }
.bq-result:focus { outline: none; }

.bq-score { position: relative; width: 168px; height: 168px; margin: 4px auto 22px; }
.bq-score svg { width: 100%; height: 100%; display: block; }
.bq-score-arc { transition: stroke-dashoffset 1.2s var(--ease) 0.15s; }
.bq-score-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.bq-score-num b { font-size: 60px; font-weight: 700; letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.bq-score-num span { font-size: 15px; color: var(--text-3); margin-top: 4px; font-weight: 600; }

.prose .bq-headline { font-size: clamp(26px, 3vw, 32px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; margin: 0; text-wrap: balance; }
.bq-versus { margin-top: 10px !important; font-size: 17px; font-weight: 600; color: var(--text); }
.bq-sub { margin: 10px auto 0 !important; max-width: 48ch; font-size: 16px; line-height: 1.55; color: var(--text-2); text-wrap: pretty; }

.bq-recap { margin: 26px auto 0 !important; max-width: 520px; text-align: left; }
.bq-recap-slipped { padding: 16px 18px; border-radius: 16px; background: rgba(245, 96, 154, 0.07); border: 1px solid rgba(245, 96, 154, 0.25); }
.prose .bq-recap-slipped h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--pink); }
.bq-recap-slipped li { font-size: 16px; line-height: 1.4; }
.prose .bq-recap-slipped li + li { margin-top: 8px; }
.prose .bq-recap-slipped a:not(.btn) { color: var(--text); text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.25); text-underline-offset: 3px; }
.prose .bq-recap-slipped a:not(.btn):hover { text-decoration-color: var(--text); }
.prose .bq-recap-kept { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--text-3); text-align: center; }
.bq-recap-kept b { color: var(--green); font-weight: 600; }

.bq-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px !important; }
.bq-actions .btn { height: 48px; font-size: 16px; padding: 0 22px; }
.bq-actions .btn svg { width: 18px; height: 18px; }
.bq-minor { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; margin-top: 14px !important; }
.bq-link {
    background: none; border: 0; padding: 6px 2px; font: inherit; font-size: 14px; font-weight: 500;
    color: var(--text-3); text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.2); text-underline-offset: 3px; cursor: pointer;
}
.bq-link:hover { color: var(--text-2); }

.bq .bq-keep { margin: 26px 0 0 !important; text-align: left; }

/* ---------- Article sections ---------- */

.book-ideas { list-style: none; padding: 0 !important; counter-reset: idea; border-top: 1px solid var(--line); }
.prose .book-ideas li + li { margin-top: 0; }
.book-ideas li { counter-increment: idea; padding: 22px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; transition: background-color 0.6s ease; }
.book-ideas li:target { background: linear-gradient(90deg, rgba(123, 108, 246, 0.1), transparent 80%); }
.prose .book-ideas h3 { margin: 0; display: flex; gap: 12px; align-items: baseline; font-size: 21px; letter-spacing: -0.02em; line-height: 1.3; }
.book-ideas h3::before { content: counter(idea, decimal-leading-zero); flex-shrink: 0; font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--text-3); font-variant-numeric: tabular-nums; }
.prose .book-ideas p { margin-top: 8px; font-size: 18px; line-height: 1.6; color: #d2d2d7; }

.book-sources { font-size: 15px; color: var(--text-3); }
.book-sources summary { list-style: none; cursor: pointer; font-weight: 600; color: var(--text-2); }
.book-sources summary::-webkit-details-marker { display: none; }
.book-sources summary::after { content: ' +'; color: var(--text-3); }
.book-sources[open] summary::after { content: ' −'; }
.book-sources ul { margin-top: 10px; }

.book-keep { grid-template-columns: auto 1fr auto; }
.book-keep .book-cover--small { width: 52px; }

/* Book club questions */
.book-discussion { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 24px 22px; }
.prose .book-discussion ol { list-style: none; padding: 0; counter-reset: dq; }
.prose .book-discussion li + li { margin-top: 0; }
.book-discussion li { counter-increment: dq; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 17px; line-height: 1.55; color: var(--text); }
.book-discussion li::before { content: counter(dq); font-size: 14px; font-weight: 600; color: var(--text-3); padding-top: 3px; font-variant-numeric: tabular-nums; }
.book-discussion-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px !important; }
.book-discussion-actions .btn { height: 44px; font-size: 15px; padding: 0 18px; }
.book-discussion-actions .btn svg { width: 17px; height: 17px; }

/* Picking questions (/book-club-questions/) */
.book-discussion-actions--top { align-items: center; margin: 16px 0 4px !important; }
.prose .book-discussion-hint { flex-basis: 100%; margin: 0 0 2px; font-size: 14px; color: var(--text-3); }
.has-picks .book-discussion-hint { color: var(--green); }
.dq-pick { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; cursor: pointer; }
.dq-pick input {
    appearance: none; -webkit-appearance: none; margin: 3px 0 0; width: 20px; height: 20px; border-radius: 6px;
    border: 1.5px solid var(--line-strong); background: var(--surface-2); cursor: pointer;
    display: grid; place-items: center; transition: background-color 0.15s ease, border-color 0.15s ease;
}
.dq-pick input::after { content: ""; width: 10px; height: 6px; border: 2px solid #000; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.dq-pick input:checked { background: var(--green); border-color: transparent; }
.dq-pick input:checked::after { opacity: 1; }
.dq-pick input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.has-picks .book-discussion li:not(.is-picked) .dq-text, .has-picks li:not(.is-picked) .dq-text { color: var(--text-2); }

/* Grouped list (/book-club-questions/): numbering runs across the groups */
.book-discussion--grouped { counter-reset: dq; padding-top: 4px; }
.prose .book-discussion--grouped ol { counter-reset: none; }
.prose .book-discussion--grouped h3 { margin: 22px 0 2px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--orange); }
.book-discussion--grouped h3:first-child { margin-top: 16px; }

/* Per-book cards on /book-club-questions/ */
.book-club-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.book-club-card { display: flex; flex-direction: column; padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.prose .book-club-card h3 { margin: 0; font-size: 19px; letter-spacing: -0.015em; line-height: 1.25; }
.prose .book-club-card h3 a:not(.btn) { color: var(--text); text-decoration: none; }
.prose .book-club-card h3 a:not(.btn):hover { text-decoration: underline; text-decoration-color: var(--text-3); }
.prose .book-club-author { margin-top: 2px; font-size: 14px; color: var(--text-3); }
.prose .book-club-sample { margin-top: 10px; font-size: 16px; line-height: 1.5; color: var(--text-2); flex: 1; }
.prose .book-club-more { display: inline-block; margin-top: 12px; font-size: 15px; font-weight: 600; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Printing the questions: book-quiz.js builds .print-sheet, and only it prints */
.print-sheet { display: none; }
@media print {
    html.print-discussion body > *:not(.print-sheet) { display: none !important; }
    html.print-discussion body { background: #fff; }
    html.print-discussion .print-sheet { display: block; color: #000; font-family: var(--font); }
    .print-sheet h1 { font-size: 20pt; letter-spacing: -0.02em; margin: 0; }
    .print-sheet p { font-size: 9pt; color: #555; margin: 4pt 0 16pt; }
    .print-sheet ol { margin: 0; padding-left: 18pt; }
    .print-sheet li { font-size: 12pt; line-height: 1.45; padding: 7pt 0; border-bottom: 1px solid #ddd; break-inside: avoid; }
}

/* ---------- Grids of books ---------- */

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 28px 22px; padding: 8px 0 24px; }
.book-grid--related { grid-template-columns: repeat(3, minmax(0, 180px)); }
.book-card { display: flex; flex-direction: column; gap: 14px; color: var(--text); }
.book-card .book-cover { transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease); }
.book-card:hover .book-cover { transform: translateY(-5px) rotate(-0.6deg); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 34px 50px -22px rgba(0, 0, 0, 0.95); }
.book-card-text { display: flex; flex-direction: column; gap: 3px; }
.book-card-text b { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.book-card-text span { font-size: 14px; color: var(--text-3); }
.book-all { margin-top: 8px; font-size: 15px; }
.book-all a { color: var(--blue); }

.page-books .book-grid { max-width: 780px; margin: 8px auto 0; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 30px 20px; }
@media (max-width: 860px) { .page-books .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- "Keep this book" sheet ---------- */

.bq-sheet {
    margin: auto; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
    padding: 28px; border-radius: 28px;
    background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
    box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.8);
}
.bq-sheet::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.bq-sheet[open] { animation: bq-in 0.35s var(--ease) both; }
.bq-sheet-close {
    position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%;
    background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text-2); font-size: 22px; line-height: 1;
}
.bq-sheet h2 { margin-top: 18px; font-size: 24px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
.bq-sheet-text { margin-top: 8px; font-size: 16px; line-height: 1.5; color: var(--text-2); }
.bq-sheet-steps { list-style: none; counter-reset: s; margin-top: 22px; display: flex; flex-direction: column; gap: 18px; }
.bq-sheet-steps li { counter-increment: s; position: relative; padding-left: 40px; }
.bq-sheet-steps li::before {
    content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center; background: var(--text); color: #000; font-weight: 700; font-size: 14px;
}
.bq-sheet-steps b { display: block; font-size: 17px; line-height: 26px; }
.bq-sheet-steps span { display: block; font-size: 14px; color: var(--text-3); margin-top: 2px; }
.bq-sheet-stores, .bq-sheet-steps .btn { margin-top: 12px; }
.bq-sheet-stores { display: flex; flex-wrap: wrap; gap: 10px; }
.bq-sheet .store { height: 52px; padding: 0 18px; }
.bq-sheet .store b { font-size: 17px; }
.bq-sheet-steps .btn { height: 48px; font-size: 16px; }

/* ---------- Toast ---------- */

.bq-toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    padding: 12px 18px; border-radius: 999px; background: var(--text); color: #000;
    font-size: 15px; font-weight: 600; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
    transition: opacity 0.3s ease, transform 0.4s var(--ease);
}
.bq-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
    .book-cover { width: 104px; }
    .book-cover--small { width: 56px; }
    .book-cover--card { width: 100%; }
    .book-head { align-items: flex-end; gap: 18px; }
    .page-book .article-head .headline { font-size: clamp(32px, 9vw, 40px); }
    .book-facts { font-size: 15px; }
    .bq { padding: 18px 16px 20px; border-radius: 26px; margin-left: calc(var(--gutter) * -0.4); margin-right: calc(var(--gutter) * -0.4); }
    .bq-choice { font-size: 16px; min-height: 56px; gap: 12px; padding: 11px 14px 11px 11px; }
    .bq-actions .btn { width: 100%; }
    .prose .book-ideas h3 { font-size: 19px; }
    .prose .book-ideas p { font-size: 17px; }
    .book-cover:not(.book-cover--card):not(.book-cover--small) { width: 84px; }
    .page-book .article { padding-top: 96px; }
    .page-book .crumbs { margin-bottom: 18px; }
    .page-book .book-head { margin-bottom: 16px; }
    .page-book .book-lede { font-size: 17px; }
    .book-meta { padding-bottom: 20px; }
    .book-grid, .page-books .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 16px; }
    .book-grid--related { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .book-grid--related .book-card-text span { display: none; }
    .book-grid--related .book-card-text b { font-size: 14px; }
    .book-keep { grid-template-columns: auto 1fr; }
    .book-club-grid { grid-template-columns: 1fr; }
    .book-keep .btn { grid-column: 1 / -1; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .bq-feedback, .bq-result, .bq-sheet[open] { animation: none; }
    .bq-score-arc { transition: none; }
}
