/* ═══════════════════════════════════════════════════════════════════════════
   Science Fiction, Science Fact — segment UI (assets/js/scifact.js)
   The Sci-Fact Log: Log page, cards, episode teaser, write-up dialog, mini-player.
   Uses the brand tokens from tftb-theme.css. Magenta (--a) is a fill/border
   only, never text. Tap targets are >= 44px.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --sf-gold:  oklch(var(--p));
    --sf-green: oklch(var(--s));
    --sf-mint:  oklch(var(--in));
    --sf-mag:   oklch(var(--a));
    --sf-amber: oklch(var(--wa));
    --sf-ink:   oklch(var(--bc));
    --sf-line:  oklch(var(--bc) / .12);
}

/* ── shared atoms ─────────────────────────────────────────────────────────── */
.sf-kicker { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.sf-kicker__label {
    font-family: 'Chakra Petch', system-ui, sans-serif; font-weight: 600;
    font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--sf-gold);
}
.sf-cat {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .72rem; font-weight: 600; letter-spacing: .04em;
    padding: .2rem .6rem; border-radius: 999px;
    border: 1px solid var(--sf-line); color: oklch(var(--bc) / .85);
}
.sf-cat::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--sf-dot, var(--sf-gold)); }
.sf-cat--space-exploration  { --sf-dot: var(--sf-gold); }
.sf-cat--cosmos-physics     { --sf-dot: var(--sf-mint); }
.sf-cat--ai-computing       { --sf-dot: var(--sf-mag); }
.sf-cat--brain-body         { --sf-dot: #F27AA8; }
.sf-cat--robots-machines    { --sf-dot: var(--sf-amber); }
.sf-cat--life-biotech       { --sf-dot: var(--sf-green); }

.sf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .9rem; }
.sf-actions .btn { min-height: 44px; height: auto; }
.sf-hear {
    gap: .5rem; border: 1px solid oklch(var(--p) / .55); background: oklch(var(--p) / .10); color: var(--sf-gold);
    text-transform: none; font-weight: 600;
}
.sf-hear:hover { background: oklch(var(--p) / .2); border-color: var(--sf-gold); }
.sf-hear[aria-pressed="true"] { background: var(--sf-gold); color: oklch(var(--pc)); }
.sf-hear__time { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 500; }
.sf-toggle { text-transform: none; gap: .35rem; }

.sf-subhead {
    font-family: 'Chakra Petch', system-ui, sans-serif; font-weight: 600; font-size: .8rem;
    letter-spacing: .12em; text-transform: uppercase; color: var(--sf-green); margin: 1.25rem 0 .5rem;
}
.sf-lede { font-size: 1.02rem; line-height: 1.7; }
.sf-facts { display: grid; gap: .5rem; }
.sf-facts li { position: relative; padding-left: 1.4rem; line-height: 1.55; }
.sf-facts li::before {
    content: ""; position: absolute; left: .2rem; top: .55em; width: .55rem; height: .55rem;
    border: 2px solid var(--sf-gold); transform: rotate(45deg);
}
.sf-refs { display: grid; gap: .25rem; counter-reset: sfref; }
.sf-refs li { counter-increment: sfref; }
.sf-refs__link {
    display: grid; grid-template-columns: 1.6rem 1fr; column-gap: .4rem; padding: .55rem .5rem;
    border-radius: .5rem; min-height: 44px; text-decoration: none; color: inherit;
}
.sf-refs__link::before { content: counter(sfref); grid-row: span 2; color: var(--sf-gold); font-weight: 700; font-family: 'Chakra Petch', system-ui, sans-serif; }
.sf-refs__link:hover { background: oklch(var(--bc) / .06); }
.sf-refs__title { font-weight: 600; line-height: 1.35; }
.sf-refs__link:hover .sf-refs__title { text-decoration: underline; text-decoration-color: var(--sf-gold); }
.sf-refs__meta { font-size: .8rem; opacity: .65; }

.sf-slot { margin: 0 0 1.5rem; }

/* ── Sci-Fact Log ──────────────────────────────────────────────────────── */
.sf-log { max-width: 72rem; margin: 0 auto; padding: .5rem 0 2rem; }
.sf-log__head { text-align: center; max-width: 42rem; margin: 1rem auto 1.5rem; }
.sf-log__title { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; margin: .35rem 0 .75rem; color: var(--sf-gold); }
.sf-log__intro { font-size: 1.05rem; line-height: 1.65; opacity: .85; }

.sf-chips { display: flex; gap: .5rem; overflow-x: auto; padding: .25rem .1rem 1rem; scrollbar-width: none; }
@media (min-width: 768px) { .sf-chips { flex-wrap: wrap; justify-content: center; overflow: visible; } }
.sf-chips::-webkit-scrollbar { display: none; }
.sf-chip {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; padding: 0 1rem;
    border-radius: 999px; border: 1px solid var(--sf-line); background: oklch(var(--b1));
    font-weight: 600; font-size: .9rem; color: oklch(var(--bc) / .85); cursor: pointer; transition: all .15s;
}
.sf-chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--sf-dot, transparent); }
.sf-chip span { font-size: .75rem; opacity: .6; font-variant-numeric: tabular-nums; }
.sf-chip:hover { border-color: oklch(var(--p) / .5); }
.sf-chip.is-on { background: var(--sf-gold); color: oklch(var(--pc)); border-color: var(--sf-gold); }
.sf-chip.is-on span { opacity: .8; }

.sf-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.sf-grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); }
.sf-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: .55rem; text-align: left;
    padding: 1.1rem 1.15rem 1rem; border-radius: var(--rounded-box, .75rem);
    background: oklch(var(--b1)); border: 1px solid oklch(var(--bc) / .1);
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; cursor: pointer; color: inherit;
}
.sf-card:hover, .sf-card:focus-visible {
    transform: translateY(-2px); border-color: oklch(var(--p) / .55);
    box-shadow: 0 10px 30px -12px oklch(var(--a) / .55);
}
.sf-card__title { font-family: 'Chakra Petch', system-ui, sans-serif; font-weight: 700; font-size: 1.15rem; line-height: 1.25; }
.sf-card__hook {
    font-size: .92rem; line-height: 1.5; opacity: .8;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.sf-card__meta { margin-top: auto; padding-top: .35rem; font-size: .78rem; opacity: .55; }

.sf-teaser {
    display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; width: 100%; text-align: left;
    padding: .85rem 1rem; min-height: 56px; border-radius: .6rem; cursor: pointer; color: inherit;
    background: oklch(var(--b3)); border: 1px solid oklch(var(--p) / .2); transition: border-color .15s;
}
.sf-teaser:hover { border-color: var(--sf-gold); }
.sf-teaser__label { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; color: var(--sf-gold); }
.sf-teaser__title { font-weight: 700; flex: 1 1 14rem; }
.sf-teaser__cta { font-size: .85rem; color: var(--sf-green); font-weight: 600; }

.sf-dossier { max-width: 44rem; padding: 1.75rem 1.5rem 1.5rem; border: 1px solid oklch(var(--p) / .3); }
@media (min-width: 640px) { .sf-dossier { padding: 2rem 2.25rem; } }
.sf-dossier__title { font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.15; padding-right: 2rem; }
.sf-dossier__from { font-size: .88rem; opacity: .7; margin-top: .4rem; }
.sf-prose { margin-top: 1.25rem; display: grid; gap: .9rem; }
.sf-prose p { line-height: 1.75; font-size: 1rem; }
.sf-quote { margin: 1.5rem 0 .5rem; padding: 1rem 1.25rem; border-left: 3px solid var(--sf-mag); background: oklch(var(--b2)); border-radius: 0 .5rem .5rem 0; }
.sf-quote p { font-family: 'Merriweather', serif; font-style: italic; line-height: 1.65; }
.sf-quote footer { margin-top: .5rem; font-size: .82rem; opacity: .7; }

/* ── on-air corrections (write-up dialog) ─────────────────────────────────── */
.sf-corr {
    margin: 1.5rem 0 .25rem; padding: 1rem 1.15rem 1.05rem; border-radius: .6rem;
    background: oklch(var(--wa) / .07); border: 1px solid oklch(var(--wa) / .35);
}
.sf-corr__head {
    font-family: 'Chakra Petch', system-ui, sans-serif; font-weight: 600; font-size: .8rem;
    letter-spacing: .12em; text-transform: uppercase; color: var(--sf-amber);
}
.sf-corr__intro { font-size: .85rem; opacity: .7; margin-top: .15rem; }
.sf-corr__list { display: grid; gap: .85rem; margin-top: .75rem; }
.sf-corr__item { padding-top: .75rem; border-top: 1px solid oklch(var(--wa) / .2); }
.sf-corr__item:first-child { padding-top: 0; border-top: 0; }
.sf-corr__item dt { font-size: .92rem; line-height: 1.5; opacity: .75; }
.sf-corr__item dd { margin-top: .3rem; line-height: 1.6; }
.sf-corr__tag {
    display: inline-block; margin-right: .3rem; padding: .05rem .45rem; border-radius: .3rem;
    font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    background: var(--sf-amber); color: #1b1600; vertical-align: .1em;
}

/* ── segment mini-player ──────────────────────────────────────────────────── */
.sf-mini {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom));
    z-index: 90; display: flex; align-items: center; gap: .75rem; width: min(26rem, calc(100vw - 2rem));
    padding: .5rem .5rem .5rem .6rem; border-radius: 999px; background: oklch(var(--n));
    border: 1px solid oklch(var(--p) / .45); box-shadow: 0 12px 30px rgb(0 0 0 / .45); animation: sf-in .2s ease-out;
}
.sf-mini .btn { width: 44px; height: 44px; min-height: 44px; }
.sf-mini__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sf-mini__label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--sf-gold); font-variant-numeric: tabular-nums; }
.sf-mini__title { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Desktop: player sits bottom-right; phones: centred at the bottom. */
@media (min-width: 1024px) {
    .sf-mini { left: auto; right: 1rem; transform: none; }
}

@keyframes sf-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.sf-mini { animation-name: sf-mini-in; }
@keyframes sf-mini-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sf-card, .sf-mini { transition: none; animation: none; } }
