/* ─────────────────────────────  Fonts  ───────────────────────────── */
@font-face {
    font-family: 'AlphaLyrae';
    src: url('/fonts/AlphaLyrae-Medium.woff2') format('woff2'),
         url('/fonts/AlphaLyrae-Medium.woff') format('woff');
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: 'TX02';
    src: url('/fonts/TX-02-Regular.woff2') format('woff2'),
         url('/fonts/TX-02-Regular.woff') format('woff');
    font-weight: 400;
    font-display: swap;
}

/* ─────────────────────────────  Theme tokens  ───────────────────────────── */
:root[data-theme='light'] {
    --bg: #f5f5f5;          /* lighter surface (was pure white) */
    --bg-tint: #f5f5f4;
    --ink: #141414;
    --muted: #8a8987;
    --line: rgba(20, 20, 20, 0.08);
    --line-strong: rgba(20, 20, 20, 0.14);
    --glass: rgba(255, 255, 255, 0.55);
    --glass-edge: rgba(255, 255, 255, 0.7);
    --glass-panel: rgba(255, 255, 255, 0.66);
    --goo-fill: rgba(255, 255, 255, 0.82);
    --glass-active: #141414;
    --glass-active-ink: #ffffff;
    --scrim: rgba(255, 255, 255, 0.38);
    --card: #ffffff;
    --card-shadow: 0 24px 70px -20px rgba(20, 20, 20, 0.32), 0 4px 14px -6px rgba(20, 20, 20, 0.18);
    --placeholder: #ebeae8;
    /* Controls bar + dropdown menus MATCH the surface: light page → light bar with dark controls. */
    --bar-bg: #ffffff;
    --bar-ink: #141414;
    --bar-muted: #8a8987;
    --bar-line: rgba(20, 20, 20, 0.08);
    --bar-line-strong: rgba(20, 20, 20, 0.14);
    --bar-active: #141414;
    --bar-active-ink: #ffffff;
}
:root[data-theme='dark'] {
    --bg: #0a0a0b;
    --bg-tint: #141416;
    --ink: #f3f2f0;
    --muted: #8c8b90;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.18);
    --glass: rgba(22, 22, 24, 0.5);
    --glass-edge: rgba(255, 255, 255, 0.18);
    --glass-panel: rgba(24, 24, 27, 0.72);
    --goo-fill: rgba(30, 30, 34, 0.86);
    --glass-active: #f3f2f0;
    --glass-active-ink: #0a0a0b;
    --scrim: rgba(8, 8, 9, 0.42);
    --card: #161618;
    --card-shadow: 0 28px 80px -20px rgba(0, 0, 0, 0.7), 0 4px 16px -6px rgba(0, 0, 0, 0.5);
    --placeholder: #1d1d20;
    /* Dark page → dark bar with light controls (matches the surface). */
    --bar-bg: #1c1c1e;
    --bar-ink: #f3f2f0;
    --bar-muted: #8c8b90;
    --bar-line: rgba(255, 255, 255, 0.10);
    --bar-line-strong: rgba(255, 255, 255, 0.18);
    --bar-active: #f3f2f0;
    --bar-active-ink: #0a0a0b;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* `display` rules below would otherwise override the `hidden` attribute — force it. */
[hidden] { display: none !important; }

/* Off-screen container for the liquid-glass SVG filter. */
.lg-defs { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.5s ease, color 0.5s ease;
}

/* ─────────────────────────────  Canvas  ───────────────────────────── */
#scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
}
#scene.is-grabbing { cursor: grabbing; }
#scene.is-hovering { cursor: pointer; }

/* ─────────────────────────────  Top bar  ───────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 26px;
    pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.wordmark {
    font-family: 'AlphaLyrae', 'Inter', sans-serif;
    font-size: 19px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink);
    text-decoration: none;
    transition: opacity 0.2s ease;
}
.wordmark:hover { opacity: 0.55; }
.wordmark svg { display: block; }

/* ─────────────────────────────  Intro / description  ───────────────────────────── */
.intro {
    position: fixed;
    left: 26px;
    top: 70px;                  /* sits just under the logo in the topbar */
    z-index: 6;
    max-width: 300px;
    pointer-events: none;       /* let globe drags pass through the empty area */
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.intro > * { pointer-events: auto; }

/* The blurb belongs to the full-globe view only — fade it out in the zoomed-in
   views (the 2nd/3rd switcher options, 'near' and 'row'). */
body:not(:has(#view-seg .vseg-btn[data-view="globe"].is-active)) .intro {
    opacity: 0;
    visibility: hidden;
}
.intro__desc {
    font-size: 14.5px;
    line-height: 1.5;
    letter-spacing: -0.01em;
    color: var(--muted);
    text-wrap: pretty;
}
.intro__cta { white-space: nowrap; } /* keep "or hit Surprise me" together on one line */
/* "Surprise me" shimmers a flowing gradient (same palette as the button's rainbow glow), clipped to
   the text. The gradient starts and ends on the same colour, so the loop is seamless. */
.intro__feat {
    font-weight: 600;
    background: linear-gradient(100deg, #ff5159, #d048ff, #6c73ff, #407cff, #54ff9c, #c1ea68, #ff5159);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: intro-shimmer 4s linear infinite reverse;
}
@keyframes intro-shimmer { to { background-position: 200% center; } }
.intro__by {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 6px;                   /* even spacing: Made by · logo · Felix Joy */
    font-size: 13px;
    letter-spacing: -0.01em;
    color: var(--muted);
}
.intro__author {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s ease;
}
.intro__author:hover { opacity: 0.6; }
.intro__author img { display: block; }

.icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--glass);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    color: var(--ink);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.2s ease, background 0.2s ease;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.icon-btn:active { transform: translateY(0) scale(0.96); }

.i-moon { display: none; }
:root[data-theme='dark'] .i-sun { display: none; }
:root[data-theme='dark'] .i-moon { display: block; }

/* ─────────────────────────────  Right rail: theme + view tabs  ───────────────────────────── */
/* Vertical segmented controls (same language as the All/Movies/TV seg), stacked on the right. */
.rail {
    position: fixed;
    top: 22px;
    right: 26px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}
.vseg {
    position: relative;            /* anchor for the sliding indicator */
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
.vseg-ind {                        /* the pill that glides behind the active segment (placed by JS) */
    position: absolute;
    left: 3px; right: 3px; top: 3px;
    height: 0;
    z-index: 0;
    border-radius: 11px;
    background: var(--glass-active);
    transform: translateY(0);
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}
.vseg-btn {
    position: relative;            /* sit above the indicator */
    z-index: 1;
    display: grid;
    place-items: center;
    width: 34px; height: 34px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.18s ease;
}
.vseg-btn:hover { color: var(--ink); }
.vseg-btn.is-active { color: var(--glass-active-ink); }

/* ─────────────────────────────  Tooltip  ───────────────────────────── */
.tooltip {
    position: fixed;
    z-index: 7;
    transform: translate(-50%, -130%);
    padding: 7px 11px;
    border-radius: 10px;
    background: var(--glass-active);
    color: var(--glass-active-ink);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: -0.01em;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.14s ease;
}
.tooltip.is-on { opacity: 1; }
.tooltip .t-star { color: #f5b301; }
:root[data-theme='light'] .tooltip .t-star { color: #f5b301; }

/* ─────────────────────────────  Status pill  ───────────────────────────── */
.status {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--glass);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 9px;
}
.status .spin {
    width: 13px; height: 13px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Non-blocking loader for filter changes — small, pinned to the top, globe stays visible. */
.status--mini {
    top: 20px;
    bottom: auto;
    transform: translate(-50%, 0);
    padding: 7px 14px;
    font-size: 12px;
}

/* ─────────────────────────────  Controls  ───────────────────────────── */
.controls {
    position: fixed;
    left: 50%;
    bottom: 0;                 /* flush with the bottom edge — no gap */
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    flex-wrap: nowrap; /* keep everything on one line (desktop); wraps only on mobile */
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: calc(100vw - 24px);
    padding: 9px;
    border-radius: 22px 22px 0 0;   /* rounded top only; square where it meets the page edge */

    /* ── Solid bar — INVERTS the surface: near-black bar on the light theme, light-grey bar on the
          dark theme. Remap the generic tokens to the inverted "bar" set so every inner control
          (tabs, triggers, sliders, text) flips with it. ── */
    --ink: var(--bar-ink);
    --muted: var(--bar-muted);
    --line: var(--bar-line);
    --line-strong: var(--bar-line-strong);
    --glass-active: var(--bar-active);
    --glass-active-ink: var(--bar-active-ink);
    --bg: var(--bar-bg);          /* range-thumb border blends into the bar */
    background: var(--bar-bg);
    border: 1px solid var(--line-strong);
    box-shadow: none;

    /* ── Previous OpenGlass bar — kept for revert (also re-enable the #controls registration in
          glass.js). To restore: delete the solid-dark block above and uncomment this. ──
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px) saturate(1.9);
    backdrop-filter: blur(16px) saturate(1.9);
    backdrop-filter: blur(4px) var(--lg-filter);
    border: 1px solid var(--glass-edge);
    box-shadow:
        0 24px 50px -20px rgba(10, 10, 20, 0.45),
        inset 1.8px 1.8px 3px -0.5px rgba(255, 255, 255, 0.95),
        inset -2px -2px 5px -1px rgba(0, 0, 0, 0.16),
        inset 0 0 0 1px rgba(255, 255, 255, 0.22),
        inset 0 0 26px rgba(255, 255, 255, 0.1);
    */
}
/* Two-row wrappers: invisible on desktop (children lay out directly in the bar), real rows on mobile. */
.controls__row { display: contents; }

/* Segmented type control */
.seg {
    position: relative;        /* anchor for the sliding indicator */
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: var(--line);
    flex-shrink: 0;
}
/* The moving pill that glides behind the active label (positioned by movorb.js). */
.seg-ind {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 0;
    width: 0;
    z-index: 0;
    border-radius: 9px;
    background: var(--glass-active);
    transform: translateX(0);
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
                width 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
}
.seg-btn {
    position: relative;        /* sit above the indicator */
    z-index: 1;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: 9px;
    cursor: pointer;
    transition: color 0.18s ease;
    white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active {
    color: var(--glass-active-ink);   /* background is now the sliding .seg-ind */
}

/* Genre / language dropdowns (open upward) */
.dropdown { position: relative; flex-shrink: 0; }
.dd-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 11px;
    border-radius: 11px;
    border: 0;
    background: var(--line);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s ease, color 0.18s ease;
}
.dd-btn:hover { background: var(--line); }
.dd-chev { opacity: 0.5; transition: transform 0.22s ease; }
.dropdown.open .dd-btn { background: var(--glass-active); color: var(--glass-active-ink); }
.dropdown.open .dd-chev { transform: rotate(180deg); opacity: 0.9; }

/* The React mount points behave as transparent flex items so the .dropdown inside
   participates directly in the controls bar layout. */
.dd-mount { display: contents; }

/* Dropdown panel — solid dark menu matching the controls bar. motion/react owns
   opacity/transform (the spring "ooze"), so no CSS transition/transform here. */
.dd-panel {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    min-width: 186px;
    max-height: 264px;
    overflow-y: auto;
    padding: 6px;
    border-radius: 18px;

    /* ── Solid menu — same inverted colours as the bar (portaled to <body>, so it carries its own
          token remap). The OpenGlass version is commented below (also re-enable the .dd-panel
          registration in glass.js to restore it). ── */
    --ink: var(--bar-ink);
    --muted: var(--bar-muted);
    --line: var(--bar-line);
    --line-strong: var(--bar-line-strong);
    --glass-active: var(--bar-active);
    --glass-active-ink: var(--bar-active-ink);
    background: var(--bar-bg);
    border: 1px solid var(--line-strong);
    box-shadow: none;

    /* ── Previous OpenGlass panel — kept for revert. ──
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px) saturate(1.9);
    backdrop-filter: blur(16px) saturate(1.9);
    backdrop-filter: blur(4px) var(--lg-filter);
    border: 1px solid var(--glass-edge);
    box-shadow:
        0 22px 44px -18px rgba(10, 10, 20, 0.5),
        inset 1.8px 1.8px 3px -0.5px rgba(255, 255, 255, 0.95),
        inset -2px -2px 5px -1px rgba(0, 0, 0, 0.16),
        inset 0 0 0 1px rgba(255, 255, 255, 0.22),
        inset 0 0 26px rgba(255, 255, 255, 0.1);
    */

    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    z-index: 10;
}
.dd-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 11px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.14s ease;
}
.dd-option:hover { background: var(--line); }
.dd-option.is-active { background: var(--glass-active); color: var(--glass-active-ink); }
.dd-check { opacity: 0; flex-shrink: 0; }
.dd-option.is-active .dd-check { opacity: 1; }

/* Sliders (rating + count) */
.rating, .count {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 10px;
    flex-shrink: 0;
}
.rating-icon { color: #f5b301; font-size: 13px; }
.count-icon { color: var(--muted); display: inline-flex; }
.controls input[type='range'] {
    appearance: none;
    -webkit-appearance: none;
    width: 72px;
    height: 4px;
    border-radius: 999px;
    background: var(--line-strong);
    cursor: pointer;
}
.controls input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px; height: 15px;
    border-radius: 50%;
    background: var(--ink);
    border: 2px solid var(--bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    cursor: grab;
}
.controls input[type='range']::-moz-range-thumb {
    width: 15px; height: 15px;
    border-radius: 50%;
    background: var(--ink);
    border: 2px solid var(--bg);
    cursor: grab;
}
.rating-val, .count-val {
    font-family: 'TX02', ui-monospace, monospace;
    font-size: 12.5px;
    color: var(--ink);
    min-width: 28px;
    text-align: right;
}

/* Surprise me — styled after walloflove's "Create your guestbook" CTA: a glossy white→grey pill
   with a layered shadow + 1px ring, a blurred rainbow glow hugging the bottom (hue-shifts on
   hover), an inset gloss highlight, and a shimmering label. This is the dark-theme look (white
   pill); the light theme overrides it to a black pill below — both read as the primary action. */
.surprise {
    /* Shimmer gradient shared by the label (clipped to text) and sparkle (clipped to its mask), so
       both sweep in lockstep. Three identical periods of solid base with a narrow, crisp highlight
       streak — the base stays fully readable; only the thin band shines as it passes. Loops
       seamlessly (identical periods). Light theme overrides it to near-white text + silver streak. */
    --shimmer: linear-gradient(100deg,
        #3f3f3f 0%, #3f3f3f 14%, #d4d4d4 16.67%, #3f3f3f 19.33%,
        #3f3f3f 47.33%, #d4d4d4 50%, #3f3f3f 52.67%,
        #3f3f3f 80.67%, #d4d4d4 83.33%, #3f3f3f 86%, #3f3f3f 100%);
    position: relative;
    overflow: hidden;
    isolation: isolate;       /* local stacking context so the glow can't bleed onto the bar */
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    padding: 8px 16px;
    border: 0;
    border-radius: 12px;      /* walloflove --radius-input */
    background: linear-gradient(to top, #e6e6e6, #ffffff);
    box-shadow:
        0 1px 3px 0 rgba(0, 0, 0, 0.13),
        0 0 0 1px rgba(0, 0, 0, 0.08),
        0 7px 20px -5px rgba(0, 0, 0, 0.10),
        0 6px 14px -5px rgba(0, 0, 0, 0.14),
        inset 0 1.5px 0 0 rgba(255, 255, 255, 0.45),
        inset 0 -1.5px 0 0 rgba(255, 255, 255, 0.45);
    color: #3f3f3f;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;  /* tracking-tight */
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, opacity 0.18s ease;
}
.surprise > * { position: relative; z-index: 1; } /* keep icon + label above the glow */
.surprise:hover {
    transform: translateY(-1px);
    box-shadow:
        0 2px 4px 0 rgba(0, 0, 0, 0.14),
        0 0 0 1px rgba(0, 0, 0, 0.08),
        0 12px 26px -6px rgba(0, 0, 0, 0.16),
        0 8px 16px -6px rgba(0, 0, 0, 0.16),
        inset 0 1.5px 0 0 rgba(255, 255, 255, 0.5),
        inset 0 -1.5px 0 0 rgba(255, 255, 255, 0.5);
}
.surprise:active { transform: translateY(0) scale(0.97); }
.surprise:focus-visible { outline: 2px solid #6c73ff; outline-offset: 2px; }

/* Blurred rainbow glow along the bottom edge — behind the label, above the gradient body. */
.surprise::before {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 60%;
    z-index: 0;
    background: linear-gradient(90deg, #ff5159 0%, #d048ff 20%, #6c73ff 40%, #407cff 60%, #54ff9c 80%, #c1ea68 100%);
    filter: blur(12px);
    opacity: 0.32;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.surprise:hover::before { opacity: 0.6; animation: surprise-hue 4s linear infinite; }
@keyframes surprise-hue {
    from { filter: blur(12px) hue-rotate(0deg); }
    to   { filter: blur(12px) hue-rotate(360deg); }
}

/* Shimmering label — the 300%-wide periodic gradient slides exactly two periods per loop, so the
   highlight stream is continuous: no center stall, no jump back to the start. Solid on hover. */
.surprise-label {
    background-image: var(--shimmer);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: surprise-shimmer 3.6s linear infinite;
}
/* 100% → 0% lands on an identical frame (periods repeat), so the loop has no visible seam. */
@keyframes surprise-shimmer {
    from { background-position: 100% 0; }
    to   { background-position: 0% 0; }
}
.surprise:hover .surprise-label {
    animation: none;
    -webkit-text-fill-color: #3f3f3f;
    text-shadow: 0 0.5px 0 #fff;
}

/* Sparkle gets the SAME shimmer: the gradient is masked to the star shape (rather than clipped to
   text) and runs the same animation, so icon + label sweep together. Solid fill on hover. */
.surprise-spark {
    --spark-mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3E%3Cpath%20d='M12%202.2l1.7%205.2a4%204%200%200%200%202.7%202.7l5.2%201.7-5.2%201.7a4%204%200%200%200-2.7%202.7L12%2021.4l-1.7-5.2a4%204%200%200%200-2.7-2.7L2.4%2011.8l5.2-1.7a4%204%200%200%200%202.7-2.7L12%202.2z'/%3E%3Ccircle%20cx='19'%20cy='5'%20r='1.5'/%3E%3C/svg%3E");
    display: block;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    background-image: var(--shimmer);
    background-size: 300% 100%;
    -webkit-mask: var(--spark-mask) center / contain no-repeat;
            mask: var(--spark-mask) center / contain no-repeat;
    animation: surprise-shimmer 3.6s linear infinite;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.surprise:hover .surprise-spark {
    transform: rotate(18deg) scale(1.12);
    animation: none;
    background-image: none;
    background-color: #3f3f3f;
}
.surprise.is-busy { opacity: 0.72; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
    .surprise-label { animation: none; -webkit-text-fill-color: #3f3f3f; }
    .surprise-spark { animation: none; background-image: none; background-color: #3f3f3f; }
    .surprise:hover::before { animation: none; }
}

/* Light theme → black pill. Same decorative gradients (rainbow bottom glow kept as-is, label
   shimmer kept but recolored light so it reads on black); body flips white→grey to a glossy black,
   gloss insets toned down, and the label/sparkle go light. Dark theme keeps the white pill above. */
:root[data-theme='light'] .surprise {
    background: linear-gradient(to top, #050505, #262626);
    box-shadow:
        0 1px 3px 0 rgba(0, 0, 0, 0.30),
        0 0 0 1px rgba(0, 0, 0, 0.20),
        0 7px 20px -5px rgba(0, 0, 0, 0.22),
        0 6px 14px -5px rgba(0, 0, 0, 0.26),
        inset 0 1.5px 0 0 rgba(255, 255, 255, 0.22),
        inset 0 -1.5px 0 0 rgba(255, 255, 255, 0.06);
    color: #f5f5f5;
}
:root[data-theme='light'] .surprise:hover {
    box-shadow:
        0 2px 4px 0 rgba(0, 0, 0, 0.32),
        0 0 0 1px rgba(0, 0, 0, 0.20),
        0 12px 26px -6px rgba(0, 0, 0, 0.30),
        0 8px 16px -6px rgba(0, 0, 0, 0.30),
        inset 0 1.5px 0 0 rgba(255, 255, 255, 0.28),
        inset 0 -1.5px 0 0 rgba(255, 255, 255, 0.08);
}
/* Near-white text with a crisp silver streak sweeping across it; one override feeds label + sparkle. */
:root[data-theme='light'] .surprise {
    --shimmer: linear-gradient(100deg,
        #f2f2f2 0%, #f2f2f2 14%, #a0a0a0 16.67%, #f2f2f2 19.33%,
        #f2f2f2 47.33%, #a0a0a0 50%, #f2f2f2 52.67%,
        #f2f2f2 80.67%, #a0a0a0 83.33%, #f2f2f2 86%, #f2f2f2 100%);
}
:root[data-theme='light'] .surprise:hover .surprise-label {
    -webkit-text-fill-color: #ffffff;
    text-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.55);
}
:root[data-theme='light'] .surprise:hover .surprise-spark { background-color: #ffffff; }
/* Rainbow glow reads brighter against the black body so it's more visible than on the white pill. */
:root[data-theme='light'] .surprise::before { opacity: 0.5; }
:root[data-theme='light'] .surprise:hover::before { opacity: 0.85; }
@media (prefers-reduced-motion: reduce) {
    :root[data-theme='light'] .surprise-label { -webkit-text-fill-color: #f0f0f0; }
    :root[data-theme='light'] .surprise-spark { background-color: #f0f0f0; }
}

/* ═════════════════════════  Control panel (right) — panel.js  ═════════════════════════ */
/* Vertically-centred glass panel anchored to the right. The mount is a non-interactive
   full-height flex column so the panel can centre without a transform (leaving transform free
   for motion's entrance). */
#panel-mount {
    position: fixed;
    top: 0; bottom: 0; right: 22px;
    z-index: 6;
    display: flex;
    align-items: center;
    pointer-events: none;
}
.pnl {
    pointer-events: auto;
    width: 300px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border-radius: 30px;
    /* Frosted fallback; glass.js sets --lg-filter (OpenGlass refraction) + the rim/glare overlay. */
    background: var(--glass-panel);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    backdrop-filter: blur(16px) saturate(1.6);
    backdrop-filter: blur(5px) var(--lg-filter);
    border: 1px solid var(--glass-edge);
    scrollbar-width: none;
}
.pnl::-webkit-scrollbar { width: 0; }

.pnl-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 10px 6px 2px;
}

/* Type tabs — sliding indicator glides under the labels (concentric: 16 − 4 padding = 12). */
.pnl-tabs {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 4px;
    border-radius: 16px;
    background: var(--line);
}
.pnl-tab {
    position: relative;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 9px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: color 0.18s ease;
}
.pnl-tab:hover { color: var(--ink); }
.pnl-tab.is-active { color: var(--glass-active-ink); }
.pnl-tab-ind {
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: 12px;
    background: var(--glass-active);
}
.pnl-tab-label { position: relative; z-index: 1; }

/* Rows — dropdown rows + fader sliders share this 52px rounded chip (concentric: 30 − 14 = 16). */
.pnl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 0 16px;
    border-radius: 16px;
    background: var(--line);
}
.pnl-row-label {
    font-size: 14px;
    color: var(--ink);
    opacity: 0.7;
}
.pnl-row--dd {
    width: 100%;
    appearance: none;
    border: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
    color: var(--ink);
    transition: background 0.18s ease;
}
.pnl-row--dd:hover { background: var(--line-strong); }
.pnl-row-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
}
.pnl-chev { opacity: 0.5; transition: transform 0.22s ease; }
.pnl-row--dd.open .pnl-chev { transform: rotate(180deg); opacity: 0.85; }

/* Fader slider — the whole row is the track; fill + handle line show the value. */
.pnl-fader {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 0 16px;
    border-radius: 16px;
    background: var(--line);
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
    touch-action: none;
}
.pnl-fader-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: var(--line-strong);
    pointer-events: none;
    transition: width 0.12s ease;
}
.pnl-fader-handle {
    position: absolute;
    top: 9px; bottom: 9px;
    width: 2px;
    border-radius: 2px;
    background: var(--ink);
    opacity: 0.5;
    transform: translateX(-1px);
    pointer-events: none;
    transition: left 0.12s ease;
}
.pnl-fader.is-dragging .pnl-fader-fill,
.pnl-fader.is-dragging .pnl-fader-handle { transition: none; }
.pnl-fader-label,
.pnl-fader-value { position: relative; z-index: 1; pointer-events: none; }
.pnl-fader-label { font-size: 14px; color: var(--ink); opacity: 0.7; }
.pnl-fader-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* ─────────────────────────────  Focus / lightbox  ───────────────────────────── */
.focus {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
}
.focus[hidden] { display: none; }

/* Uniform blur veil over the globe. Two deliberate choices fix earlier bugs:
   1. No radial vignette — that darkened ring read as a "weird box" behind the card.
   2. Only OPACITY is transitioned, never backdrop-filter. Animating backdrop-filter leaves a blur
      layer stuck on screen during close; with a constant blur, fading opacity fades the blur too. */
.focus__scrim {
    position: absolute;
    inset: 0;
    background: var(--scrim);
    -webkit-backdrop-filter: blur(16px) saturate(1.1);
    backdrop-filter: blur(16px) saturate(1.1);
    opacity: 0;
    transition: opacity 0.4s ease;
    cursor: zoom-out;
}
.focus.is-open .focus__scrim { opacity: 1; }

/* ONE cohesive glass card. It's a transparent positioning stage (poster slot + text slot); the glass
   surface is .focus__bg behind both, so the poster reads as embedded in the card — not a second card.
   No close button: click the scrim or press Esc (hint sits on the overlay). */
/* Transparent stage — its size comes from .focus__panel; the poster floats on top of it. */
.focus__card {
    position: relative;
    z-index: 1;
}

/* The glass panel IS the card surface AND the clip container: it holds the poster-column spacer + the
   text, and a single clip-path wipe reveals the glass and the text together, so the text appears as
   the advancing edge passes over it. No backdrop-filter / box-shadow here — clip-path doesn't clip
   either in Chrome (they'd render as a full rectangle that lingers on close); depth is filter:
   drop-shadow(), which IS applied after the clip and follows the rounded shape. The full-screen scrim
   supplies the blur behind the glass. */
.focus__panel {
    display: flex;
    align-items: flex-start;
    gap: 22px;
    width: min(92vw, 660px);
    padding: 16px;
    border-radius: 32px;
    background: var(--glass-panel);
    border: 1px solid var(--glass-edge);
    filter: drop-shadow(0 20px 40px rgba(10, 10, 20, 0.3));
    /* Pure clip-path wipe — no opacity fade, so the panel visibly retracts toward the poster rather
       than vanishing. The CLOSE transition lives here (destination = base state): fast + ease-IN so it
       finishes quickly with NO slow tail. The old ease-out tail left a sliver of glass lingering /
       creeping left after close. */
    clip-path: inset(0 100% 0 0 round 32px);
    transition: clip-path 0.3s cubic-bezier(0.4, 0, 1, 1);
}
.focus.is-open .focus__panel {
    clip-path: inset(0 0 0 0 round 32px);
    /* OPEN transition (destination = is-open): the slower ease-out reveal, after the poster lands. */
    transition: clip-path 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.18s;
}
/* Invisible spacer reserving the poster's column inside the panel (the real poster floats on top). */
.focus__poster-slot {
    flex: 0 0 auto;
    width: 224px;
    aspect-ratio: 2 / 3;
}

/* Poster floats above the panel (not clipped) at the spacer's position; its transform is driven from
   JS (FLIP out of / back into the globe). */
.focus__poster-wrap {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 2;
    opacity: 0;
    will-change: transform;
}

/* ── Holographic poster (left column) ──
   The wrapper tilts toward the pointer (--rx/--ry); two pointer-driven overlays sit on top:
   a rainbow iridescence (.focus__holo) and a moving specular glare (.focus__glare). */
.focus__poster {
    position: relative;
    flex: 0 0 auto;
    width: 224px;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 2 / 3;
    background: var(--placeholder);
    /* Soft, close shadow so the poster reads as raised *on* the glass card — not a separate card. */
    box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--line);
    transform: perspective(820px) rotateX(var(--ry, 0deg)) rotateY(var(--rx, 0deg));
    transition: transform 0.2s ease;
    will-change: transform;
}
.focus__poster img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.focus__poster img.is-loaded { opacity: 1; }
/* Edge outline must be pure black/white (never a tinted neutral, which reads as dirt on the edge). */
:root[data-theme='light'] .focus__poster { box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
:root[data-theme='dark']  .focus__poster { box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.12); }

.focus__holo, .focus__glare {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.focus__holo {
    background:
        repeating-linear-gradient(115deg,
            rgba(255, 0, 128, 0.40) 0%,
            rgba(255, 213, 0, 0.34) 10%,
            rgba(0, 255, 162, 0.36) 20%,
            rgba(0, 170, 255, 0.38) 30%,
            rgba(180, 0, 255, 0.38) 40%,
            rgba(255, 0, 128, 0.40) 50%);
    background-size: 260% 260%;
    background-position: var(--hx, 30%) var(--hy, 30%);
    mix-blend-mode: color-dodge;
    filter: saturate(1.5) brightness(1.05);
    opacity: 0.30;
    transition: opacity 0.25s ease;
}
.focus__glare {
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 42%);
    mix-blend-mode: soft-light;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.focus__poster:hover .focus__holo { opacity: 0.5; }
.focus__poster:hover .focus__glare { opacity: 1; }

/* ── Details (the text, inside the clipped panel) ──
   No own entrance — the panel's clip-path wipe reveals these lines as its edge passes over them, so
   the text is uncovered *by* the expanding card. Synopsis + providers load asynchronously (after the
   wipe finishes), so they fade in via .is-in instead of popping. */
.focus__info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 4px 4px 2px 0;
}
.focus__name {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-wrap: balance;
}
.focus__sub {
    margin-top: 8px;
    font-size: 13.5px;
    color: var(--muted);
    letter-spacing: -0.01em;
}
.focus__sub .s-star { color: #f5b301; }
.focus__synopsis, .focus__watch {
    opacity: 0;
    transition: opacity 0.4s ease;
}
.focus__synopsis.is-in, .focus__watch.is-in { opacity: 1; }
.focus__synopsis {
    margin-top: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink);
    text-wrap: pretty;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.focus__watch { margin-top: 16px; }
.focus__watch-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 9px;
}
.focus__providers { display: flex; flex-wrap: wrap; gap: 8px; }
.provider {
    display: inline-flex;
    width: 38px; height: 38px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-tint);
    border: 1px solid var(--line);
    transition: transform 0.16s ease, scale 0.15s ease, border-color 0.2s ease;
}
.provider:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.provider:active { scale: 0.96; } /* tactile press */
.provider img { width: 100%; height: 100%; object-fit: cover; display: block; }

.focus__imdb {
    margin-top: 18px;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 11px;
    background: var(--glass-active);
    color: var(--glass-active-ink);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    transition: transform 0.18s ease, scale 0.15s ease;
}
.focus__imdb:hover { transform: translateY(-1px); }
.focus__imdb:active { scale: 0.96; } /* tactile press — never below 0.95 */

/* Dismissal hint — on the overlay (not inside the card), centred near the bottom. Fades in last,
   after the card has opened, and out immediately on close. var(--ink) keeps it legible in both themes. */
.focus__hint {
    position: absolute;
    left: 0; right: 0;
    bottom: 28px;
    z-index: 2;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--ink);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.focus.is-open .focus__hint { opacity: 0.55; transition-delay: 0.5s; }
.focus__hint kbd {
    font: inherit;
    padding: 1.5px 6px;
    border-radius: 6px;
    background: var(--bg-tint);
    border: 1px solid var(--line);
}

/* Close button — top-right of the card. Hidden on desktop (the Esc hint covers it there); revealed
   on mobile in the responsive block below. Sibling of the panel/poster, so the clip never affects it. */
.focus__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 4;
    display: none;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--glass-edge);
    border-radius: 50%;
    background: var(--glass-panel);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--ink);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.focus.is-open .focus__close { opacity: 1; transition-delay: 0.25s; }

/* ─────────────────────────────  Responsive  ───────────────────────────── */
@media (max-width: 720px) {
    /* Wide, full-width bottom bar arranged as two rows. */
    .controls {
        left: 0; right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
        border-radius: 18px 18px 0 0;
    }
    .controls__row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }
    /* Row 2: let the rating/count sliders share the width so they + Surprise fit on one line. */
    .controls__row:last-child .rating,
    .controls__row:last-child .count { flex: 1; min-width: 0; gap: 7px; padding: 0 4px; }
    .controls__row:last-child input[type='range'] { width: auto; flex: 1; min-width: 40px; }
    .surprise { flex-shrink: 0; }

    .dd-panel { max-height: 50vh; }
    .topbar { padding: 16px 18px; }

    /* Theme + view settings: a horizontal row of horizontal pill groups, pinned to the top. */
    .rail { top: 16px; right: 16px; flex-direction: row; align-items: center; gap: 8px; }
    .vseg { flex-direction: row; }
    .vseg-ind { display: none; } /* the JS-placed sliding pill is vertical-only; use a static active fill instead */
    .vseg-btn.is-active { background: var(--glass-active); }

    .intro { display: none; }   /* hide blurb on mobile */

    /* Detail card: no keyboard on touch, so swap the "Press Esc" hint for a tappable close button. */
    .focus__hint { display: none; }
    .focus__close { display: grid; }
}

/* Control panel becomes a bottom sheet on phones. */
@media (max-width: 560px) {
    #panel-mount { right: 0; left: 0; align-items: flex-end; justify-content: center; }
    .pnl {
        width: calc(100vw - 24px);
        max-height: 62vh;
        margin-bottom: 14px;
        border-radius: 26px;
    }
}

/* Focus card stacks: poster on top, details below. */
@media (max-width: 560px) {
    .focus__panel {
        flex-direction: column;
        align-items: center;
        width: min(86vw, 340px);
        gap: 14px;
    }
    .focus__poster-slot { width: 168px; }
    .focus__poster { width: 168px; }
    .focus__poster-wrap { left: calc(50% - 84px); } /* centred over the slot (84 = half of 168) */
    .focus__info { width: 100%; padding: 2px 2px 0; }
    .focus__name { font-size: 20px; }
    .focus__imdb { margin-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}
