/* ============================================
   BOOKS (Tome Vault): /books + /books/<slug>
   plus the homepage #books teaser.
   Everything is prefixed bk- to stay clear of styles.css.
   ============================================ */

:root {
    --bk-surface: #141414;
    --bk-surface-2: #1B1B1B;
    --bk-muted: #A1A1A1;
    --bk-faint: #6B6B6B;
    --bk-border: rgba(255,255,255,0.07);
    --bk-border-hover: rgba(255,255,255,0.16);
    --bk-epic: #A8FF00;
    --bk-amber: #F59E0B;
    --bk-violet: #A78BFA;
    --bk-read: 'Newsreader', Georgia, 'Times New Roman', serif;
    --bk-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    --bk-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

.books-page { background: var(--bg); color: var(--text); }
/* styles.css sets overflow-x: hidden on html/body, which turns body into a
   scroll container and breaks position: sticky on the chapter menu. clip
   prevents sideways scroll without that side effect. */
html:has(body.books-page), body.books-page { overflow-x: clip !important; }
.books-page :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.bk-wrap { max-width: 1040px; margin: 0 auto; padding-inline: 20px; }

/* ── Nav ─────────────────────────────────── */
.bk-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    background: rgba(10,10,10,0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bk-border);
    padding-top: env(safe-area-inset-top, 0px);
}
.books-page main { padding-top: 56px; }
.bk-nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.bk-nav-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bk-nav-name { font-weight: 800; letter-spacing: -0.01em; }
.bk-tag {
    font-family: var(--bk-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--accent); border: 1px solid rgba(0,212,255,0.35); padding: 3px 8px; border-radius: 4px; white-space: nowrap;
}
.bk-xp { display: flex; align-items: center; gap: 10px; font-family: var(--bk-mono); font-size: 11px; color: var(--bk-muted); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.bk-xp-bar { width: 90px; height: 6px; background: var(--bk-surface-2); border-radius: 3px; overflow: hidden; }
.bk-xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--bk-epic)); transition: width .6s var(--bk-ease); }
@media (max-width: 480px) { .bk-xp-bar { width: 48px; } }

.bk-eyebrow { font-family: var(--bk-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin: 0; }

/* ── Shelf ───────────────────────────────── */
.bk-hero { padding-block: 56px 8px; }
.bk-hero h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.05; letter-spacing: -0.03em; margin: 12px 0 14px; text-wrap: balance; font-weight: 800; }
.bk-intro { color: var(--bk-muted); max-width: 58ch; margin: 0; font-size: 17px; }

.bk-lotd {
    margin-top: 32px; background: var(--bk-surface); border: 1px solid var(--bk-border);
    border-radius: var(--elem-radius-lg, 14px); padding: 24px clamp(18px, 4vw, 32px);
    display: grid; gap: 10px; position: relative; overflow: hidden;
}
.bk-lotd::after {
    content: ""; position: absolute; right: -80px; bottom: -120px; width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(0,212,255,0.16), transparent 70%); pointer-events: none;
}
.bk-lotd-label { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: var(--bk-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bk-epic); }
.bk-lotd-label span:last-child { color: var(--bk-faint); }
.bk-lotd blockquote { margin: 0; font-family: var(--bk-read); font-size: clamp(22px, 3.4vw, 30px); line-height: 1.3; font-style: italic; text-wrap: balance; }
.bk-lotd-cite { margin: 0; color: var(--bk-muted); font-size: 14px; }
.bk-lotd-cite a { color: var(--accent); }

.bk-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0 0; }
.bk-chip {
    background: transparent; border: 1px solid var(--bk-border-hover); border-radius: 999px;
    padding: 6px 14px; font: inherit; font-size: 13px; color: var(--bk-muted); cursor: pointer; transition: all .2s;
}
.bk-chip:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }
.bk-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #031418; font-weight: 600; }

.bk-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 28px 22px; padding-block: 28px 64px; }
.bk-book { display: grid; gap: 12px; align-content: start; }
.bk-book[hidden] { display: none; }

.bk-cover {
    aspect-ratio: 2 / 3; max-width: 100%; border-radius: 4px 10px 10px 4px; position: relative; overflow: hidden;
    padding: 18px 16px 16px 24px; display: flex; flex-direction: column; justify-content: space-between;
    box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 18px 40px -18px rgba(0,0,0,0.9);
    transition: transform .35s var(--bk-ease), box-shadow .35s var(--bk-ease);
}
.bk-cover::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 9px; background: linear-gradient(90deg, rgba(0,0,0,0.45), rgba(255,255,255,0.08) 60%, transparent); }
.bk-book:hover .bk-cover, .bk-teaser-book:hover .bk-cover { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset, 0 28px 50px -18px rgba(0,212,255,0.25); }
.bk-cover-title { font-family: var(--bk-read); font-weight: 600; font-size: 22px; line-height: 1.1; text-wrap: balance; position: relative; }
.bk-cover-author { font-family: var(--bk-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; opacity: .85; position: relative; }
.bk-cover-mark { position: absolute; right: -18px; bottom: 34px; font-family: var(--bk-read); font-size: 140px; line-height: 1; opacity: .13; font-style: italic; }

.bk-book-meta { display: grid; gap: 4px; min-width: 0; }
.bk-book-meta strong { font-size: 15px; font-weight: 600; }
.bk-book-meta > span { font-size: 13px; color: var(--bk-muted); }
.bk-book-meta .bk-rarity {
    justify-self: start; font-family: var(--bk-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 3px; color: var(--accent); background: rgba(0,212,255,0.10);
}

/* ── Book page ───────────────────────────── */
.bk-back { display: inline-flex; gap: 6px; color: var(--bk-muted); font-size: 14px; margin-top: 28px; }
.bk-back:hover { color: var(--text); }
.bk-bhero { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(24px, 5vw, 56px); padding-block: 28px 40px; align-items: end; }
.bk-bhero .bk-cover { width: 220px; }
.bk-bhero h1 { font-family: var(--bk-read); font-weight: 600; font-size: clamp(36px, 6vw, 60px); line-height: 1.02; letter-spacing: -0.02em; margin: 10px 0 6px; text-wrap: balance; }
.bk-byline { color: var(--bk-muted); margin: 0 0 18px; }
.bk-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; font-family: var(--bk-mono); font-size: 12px; color: var(--bk-muted); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.bk-stats b { color: var(--text); font-weight: 700; }
.bk-stars { color: var(--bk-amber); letter-spacing: 2px; }
@media (max-width: 640px) {
    .bk-bhero { grid-template-columns: 1fr; align-items: start; }
    .bk-bhero .bk-cover { width: 150px; }
}

.bk-why { border-left: 2px solid var(--accent); padding: 4px 0 4px 20px; margin: 0 0 48px; max-width: 64ch; }
.bk-why .bk-eyebrow { margin-bottom: 8px; }
.bk-why p:last-child { margin: 0; font-family: var(--bk-read); font-size: 20px; line-height: 1.5; color: #E8E8E8; }

.bk-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px; padding-bottom: 48px; }
.bk-toc { position: sticky; top: 80px; align-self: start; display: grid; gap: 4px; }
.bk-toc .bk-eyebrow { margin-bottom: 8px; color: var(--bk-faint); }
.bk-toc a { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--bk-muted); padding: 6px 10px; border-radius: 6px; }
.bk-toc a:hover, .bk-toc a.is-active { background: var(--bk-surface); color: var(--text); }
.bk-toc a.is-empty { opacity: .5; }
.bk-toc a span { font-family: var(--bk-mono); font-size: 11px; color: var(--bk-faint); font-variant-numeric: tabular-nums; }
@media (max-width: 820px) {
    .bk-layout { grid-template-columns: 1fr; gap: 8px; }
    .bk-toc { position: static; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
    .bk-toc .bk-eyebrow { width: 100%; margin: 0; }
    .bk-toc a { border: 1px solid var(--bk-border); }
}

.bk-sections { min-width: 0; }
.bk-section { scroll-margin-top: 80px; display: grid; gap: 14px; margin-bottom: 44px; }
.bk-section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.bk-section-head h2 { font-size: 22px; letter-spacing: -0.01em; margin: 0; }
.bk-section-head p { margin: 0; color: var(--bk-faint); font-size: 14px; }
.bk-empty { border: 1px dashed var(--bk-border-hover); border-radius: 12px; padding: 16px 20px; color: var(--bk-faint); font-size: 14px; margin: 0; }

.bk-line {
    scroll-margin-top: 90px; background: var(--bk-surface); border: 1px solid var(--bk-border);
    border-radius: var(--elem-radius, 12px); padding: 18px 20px 14px; display: grid; gap: 10px; min-width: 0;
    transition: border-color .25s, background .25s, box-shadow .25s;
}
.bk-line:hover { border-color: var(--bk-border-hover); }
.bk-line.is-read { background: #121518; }
.bk-line.is-flash, .bk-line:target { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,212,255,0.12); }
.bk-line-text { margin: 0; font-family: var(--bk-read); font-size: 19px; line-height: 1.45; text-wrap: pretty; }
.bk-line--quote .bk-line-text { font-style: italic; font-size: 22px; }
.bk-line--quote .bk-line-text::before { content: "\201C"; color: var(--accent); margin-right: 2px; }
.bk-line--quote .bk-line-text::after { content: "\201D"; color: var(--accent); }
.bk-take { font-size: 14px; color: var(--bk-muted); margin: 0; padding-left: 12px; border-left: 2px solid var(--bk-violet); }
.bk-caveat { font-size: 13.5px; color: #F7D9A4; margin: 0; background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25); border-radius: 8px; padding: 8px 12px; }
.bk-take b, .bk-caveat b { font-family: var(--bk-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; margin-right: 6px; font-weight: 700; }
.bk-take b { color: var(--bk-violet); }
.bk-caveat b { color: var(--bk-amber); }
.bk-line-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bk-kind { font-family: var(--bk-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--bk-faint); }
.bk-actions { display: flex; gap: 6px; }
.bk-act { background: transparent; border: 1px solid var(--bk-border); border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 12px; color: var(--bk-muted); cursor: pointer; transition: all .2s; }
.bk-act:hover { color: var(--text); border-color: var(--bk-border-hover); }
.bk-act.is-done { color: var(--bk-epic); border-color: rgba(168,255,0,0.35); }

.bk-related { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 40px; }
.bk-rel { background: var(--bk-surface); border: 1px solid var(--bk-border); border-radius: 12px; padding: 16px 18px; display: grid; gap: 4px; transition: border-color .2s, transform .2s; }
.bk-rel:hover { border-color: var(--bk-border-hover); transform: translateY(-2px); }
.bk-rel span { font-family: var(--bk-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--bk-faint); }
.bk-rel strong { font-size: 15px; }
.bk-rel p { margin: 0; font-size: 13px; color: var(--bk-muted); }

/* ── Subscribe CTA ───────────────────────── */
.bk-cta {
    background: linear-gradient(135deg, rgba(0,212,255,0.08), rgba(168,255,0,0.05));
    border: 1px solid rgba(0,212,255,0.25); border-radius: 16px; padding: 28px clamp(18px, 4vw, 32px);
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 18px; align-items: center; margin-bottom: 64px;
}
.bk-cta h2 { margin: 0 0 4px; font-size: 20px; }
.bk-cta p { margin: 0; color: var(--bk-muted); font-size: 15px; }
@media (max-width: 720px) { .bk-cta { grid-template-columns: 1fr; } }

/* ── Share modal + toast ─────────────────── */
.bk-modal { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.75); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.bk-modal-card { background: var(--bk-surface); border: 1px solid var(--bk-border-hover); border-radius: 16px; padding: 18px; display: grid; gap: 12px; width: min(440px, 100%); max-height: 100%; overflow: auto; }
.bk-modal-card img { width: 100%; border-radius: 10px; display: block; }
.bk-modal-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.bk-modal-row p { margin: 0; font-size: 13px; color: var(--bk-muted); }
.bk-modal-btns { display: flex; gap: 8px; }
.bk-btn { background: var(--accent); color: #031418; border: 0; border-radius: 8px; padding: 9px 14px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; }
.bk-btn--ghost { background: transparent; color: var(--text); border: 1px solid var(--bk-border-hover); }

.bk-toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 110;
    transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
    background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: 999px;
    transition: all .3s var(--bk-ease);
}
.bk-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

.books-page .footer { border-top: 1px solid var(--bk-border); }

/* ── Homepage teaser (#books) ────────────── */
.bk-teaser-section { background: linear-gradient(180deg, transparent 0%, rgba(0, 212, 255, 0.03) 50%, transparent 100%); }
.bk-teaser-sub { text-align: center; max-width: 720px; margin: 0 auto 40px; color: var(--text-muted); font-size: 17px; line-height: 1.65; }
.bk-teaser { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; align-items: center; margin-bottom: 36px; }
.bk-teaser .bk-lotd { margin-top: 0; text-decoration: none; color: inherit; transition: border-color .2s; }
.bk-teaser .bk-lotd:hover { border-color: rgba(0,212,255,0.4); }
.bk-teaser-shelf { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.bk-teaser-book { display: block; }
.bk-teaser-book .bk-cover { padding: 12px 10px 10px 16px; }
.bk-teaser-book .bk-cover-title { font-size: 15px; }
.bk-teaser-book .bk-cover-author { font-size: 8px; }
.bk-teaser-book .bk-cover-mark { font-size: 90px; bottom: 20px; }
.bk-teaser-slot { aspect-ratio: 2 / 3; border: 1px dashed var(--bk-border-hover); border-radius: 4px 10px 10px 4px; display: grid; place-items: center; color: var(--bk-faint); font-family: var(--bk-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; text-align: center; padding: 8px; }
.bk-teaser-cta { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.bk-teaser-btn {
    display: inline-block; background: var(--accent); color: #031418; font-weight: 700; font-size: 16px;
    padding: 16px 36px; border-radius: 10px; transition: transform .1s, box-shadow .15s;
    box-shadow: 0 4px 24px rgba(0, 212, 255, 0.25);
}
.bk-teaser-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0, 212, 255, 0.4); }
.bk-teaser-meta { font-size: 13px; color: var(--text-muted); }
@media (max-width: 760px) {
    .bk-teaser { grid-template-columns: 1fr; }
    .bk-teaser-shelf { max-width: 360px; margin: 0 auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .bk-cover, .bk-line, .bk-toast, .bk-xp-fill, .bk-rel { transition: none; }
}
