/* ═══════════════════════════════════════════════════════════════════════════
   PLAYER CHROME — the preview player, the shot bar, the playhead, the
   graphics lane, the HUD, the crop overlay and the Titles player.

   ALL OF IT USED TO BE WRITTEN BY JAVASCRIPT. previewPlayer.js held 27
   `style.cssText = '…'` strings and 21 calls to `_isLightMode()` that picked a
   colour in code, so the only way to restyle the lane was to edit a string
   literal inside a function — and a reskin that edited CSS alone would have
   left every one of them behind.

   Nothing here is new design. Every value is the one the JS was writing,
   named. What the JS still sets is what only it can know: a block's left and
   width, a segment's flex, a graphic's transform. Those are DATA. Colour,
   type, spacing and radius are not, and they are here.

   THE THEME. previewPlayer's light/dark test is not `body.dark-mode` alone --
   it is "not .pv-active AND not .dark-mode AND not .main-content.console-dark-
   mode". That rule stays in one place, `_isLightMode()`, which now also
   reflects its answer onto the body as `.vp-dark`. Every rule below keys off
   that class, so the three conditions are still decided once, in the function
   that always decided them.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── the player shell ──────────────────────────────────────────────────── */
#previewWrapper {
    display: flex; flex-direction: column; align-items: center;
    height: 100%; padding: 0;
    background: var(--vp-wrapper-bg);
}
#previewMonitor {
    width: 100%; flex: 1; min-height: 0;
    background: var(--vp-monitor-bg);
    overflow: hidden; position: relative;
}
/* The monitor's own light-mode toggle (the checkbox in the toolbar) is a
   USER choice, not the app theme, so it is its own class. */
#previewMonitor.vp-monitor-light { background: var(--vp-monitor-bg-light) !important; }
#previewWrapper.vp-monitor-light { background: var(--vp-monitor-bg-light) !important; }
.vp-monitor-vignette {
    position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background: var(--vp-monitor-vignette);
}
.vp-video {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: contain;
}

/* ── format tabs ───────────────────────────────────────────────────────── */
#previewFormatTabs {
    display: flex; padding: 0;
    background: var(--vp-tabs-bg);
    border-top: 1px solid var(--vp-tabs-border);
}
#previewFormatTabs .format-tab {
    width: 25%; flex: none; box-sizing: border-box; text-align: center;
    border-top: none; border-left: none; border-right: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--vp-tab-idle);
    font: 700 var(--fs-10)/1 var(--ff-mono);
    padding: var(--sp-7) 0;
    cursor: pointer; transition: all 0.15s;
}
#previewFormatTabs .format-tab.is-active {
    border-bottom-color: var(--vp-accent);
    background: var(--vp-tab-active-bg);
    color: var(--vp-accent);
}

/* ── hover scrub (sprite and video) ────────────────────────────────────── */
.vp-scrub-video {
    width: 100%; height: 100%; object-fit: contain;
    position: absolute; top: 0; left: 0; background: var(--c-black);
}
.vp-scrub-sprite {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-position: 0 0;
}

/* ── the re-render overlay ─────────────────────────────────────────────── */
.vp-reframe-overlay {
    position: absolute; inset: 0;
    background: var(--vp-scrim);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 20;
}
.vp-reframe-overlay .vp-reframe-label {
    color: var(--vp-accent-fixed); font-family: var(--ff-mono);
    font-size: var(--fs-14); letter-spacing: 2px;
}
.vp-reframe-overlay .vp-reframe-spinner {
    color: var(--vp-accent-fixed); font-size: var(--fs-20); margin-top: var(--sp-8);
    animation: vpReframePulse 1s infinite;
}
@keyframes vpReframePulse { 0%,100% { opacity: 1 } 50% { opacity: 0.3 } }

/* ── the shot bar ──────────────────────────────────────────────────────── */
#shotSegmentBar, .vp-shotbar {
    width: 100%; height: 20px; display: flex; gap: var(--sp-1);
    border-radius: var(--r-2); overflow: hidden;
    margin-top: var(--sp-2); pointer-events: auto; position: relative;
}
.vp-shot {
    position: relative; cursor: pointer; pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    transition: filter 0.15s;
    background: var(--shot-unknown);
}
.vp-shot:hover { filter: brightness(1.4); }
/* THESE FOUR COLOURS ARE MEANING, NOT DECORATION. They say how the crop for
   that shot was chosen, and the bar is read at a glance -- keep four
   distinguishable hues. previewPlayer's `_segColorMap` is now `data-method`. */
.vp-shot[data-method="auto-track"],
.vp-shot[data-method="landmark"],
.vp-shot[data-method="person-bbox"]   { background: var(--shot-tracked); }
.vp-shot[data-method="static"]        { background: var(--shot-static); }
.vp-shot[data-method="saliency"]      { background: var(--shot-saliency); }
.vp-shot[data-method="global-average"]{ background: var(--shot-global); }
.vp-shot .seg-label {
    font: 600 var(--fs-8)/1 var(--ff-mono);
    color: var(--shot-label);
    pointer-events: none;
}

/* ── the playhead ──────────────────────────────────────────────────────── */
#nlePlayhead {
    position: absolute; left: 0; top: -3px; width: 2px; height: calc(100% + 6px);
    background: var(--vp-playhead); pointer-events: none; z-index: 12;
    transition: left 0.05s linear;
}
.vp-playhead-cap {
    position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 4px solid transparent; border-right: 4px solid transparent;
    border-top: 4px solid var(--vp-playhead);
}

/* ── the graphics lane ─────────────────────────────────────────────────── */
#graphicsLane { width: 100%; margin-top: var(--sp-3); }
#graphicsLaneTrack {
    position: relative; width: 100%; height: 22px; margin-top: var(--sp-2);
    border-radius: var(--r-2); overflow: hidden;
    background: var(--lane-bg);
}
.vp-lane-tick {
    position: absolute; top: 0; bottom: 0; width: 1px;
    background: var(--lane-tick);
}
.vp-lane-block {
    position: absolute; top: 2px; height: 18px; border-radius: var(--r-2);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    font: 600 7.5px/1 var(--ff-mono);
    color: var(--lane-block-text);
    background: var(--lane-block-colour);
    border: 1px dashed var(--lane-block-colour);
    opacity: 0.42;
    pointer-events: none; cursor: default;
}
/* A PLACED block is the only way back to its card, so it is the only one that
   takes a click. There is nothing to undo about a guess. */
.vp-lane-block.is-pinned {
    border-style: solid; opacity: 0.95;
    pointer-events: auto; cursor: pointer;
}
/* Dimmed while a chip is armed: the drop zones draw their shot numbers across
   the same 22px, and at full strength the two sets of labels collided. */
#graphicsLaneTrack.is-armed .vp-lane-block            { opacity: 0.15; pointer-events: none; cursor: default; }
#graphicsLaneTrack.is-armed .vp-lane-block.is-pinned  { opacity: 0.30; }
.lane-span-handle {
    position: absolute; top: 0; bottom: 0; width: 7px;
    cursor: ew-resize; z-index: 3;
    background: var(--lane-handle);
}
.lane-span-handle.vp-handle-w { left: -1px; }
.lane-span-handle.vp-handle-e { right: -1px; }
.vp-lane-drop {
    position: absolute; top: 0; bottom: 0; cursor: pointer;
    border-left: 1px solid var(--lane-drop-border);
    display: flex; align-items: center; justify-content: center;
    font: 700 8.5px/1 var(--ff-mono);
    color: var(--lane-drop-text);
    text-shadow: var(--lane-drop-shadow);
    background: transparent;
}
.vp-lane-drop:hover { background: var(--lane-drop-hover); }

/* ── the lane's notes and controls ─────────────────────────────────────── */
.vp-lane-note {
    margin-top: var(--sp-3);
    font: 500 8.5px/1.4 var(--ff-mono);
    letter-spacing: 0.2px;
    color: var(--vp-note);
}
#graphicsLaneVersionNote {
    margin-top: var(--sp-4);
    display: flex; flex-wrap: wrap; gap: var(--sp-6) var(--sp-10);
    align-items: center;
    font: 500 8.5px/1.5 var(--ff-mono);
    letter-spacing: 0.2px;
    color: var(--vp-note);
}
.vp-version-cell { display: inline-flex; align-items: center; gap: var(--sp-5); }
.vp-version-btn {
    padding: var(--sp-1) var(--sp-6); border-radius: var(--r-3); cursor: pointer;
    font: 600 8.5px/1.5 var(--ff-mono);
    border: 1px solid var(--vp-version-bd);
    background: transparent;
    color: var(--vp-version-fg);
}
.vp-version-btn.is-on {
    cursor: default;
    border-color: var(--vp-version-on-bd);
    background: var(--vp-version-on-bg);
    color: var(--vp-version-on-fg);
}
#graphicsLaneRenderBtn {
    padding: var(--sp-3) var(--sp-8); border-radius: var(--r-2); cursor: pointer;
    margin-right: var(--sp-4);
    font: 600 var(--fs-9)/1 var(--ff-mono); letter-spacing: 0.04em;
}

/* ── the DRAFT overlay ─────────────────────────────────────────────────── */
#graphicsDraftLayer { position: absolute; inset: 0; pointer-events: none; z-index: 11; }
#graphicsDraftLayer img { position: absolute; object-fit: contain; }
#graphicsDraftLayer img.vp-draft-full { inset: 0; width: 100%; height: 100%; }
#graphicsDraftBadge {
    position: absolute; bottom: var(--sp-8); left: var(--sp-8); z-index: 12;
    background: var(--vp-draft-bg); color: var(--vp-draft-fg);
    padding: var(--sp-2) var(--sp-7); border-radius: var(--r-2);
    font: 700 var(--fs-9)/1 var(--ff-mono); letter-spacing: 0.08em;
    pointer-events: none;
}

/* ── the subject-selector modal ────────────────────────────────────────── */
.vp-modal-scrim {
    position: fixed; inset: 0;
    background: var(--vp-modal-scrim); z-index: 10000;
    display: flex; align-items: center; justify-content: center;
}
.vp-modal {
    background: var(--vp-modal-bg);
    border: 1px solid var(--vp-modal-border);
    border-radius: var(--r-12); padding: var(--sp-32);
    min-width: 340px; max-width: 420px; text-align: center;
    font-family: var(--ff-mono-sf);
}

/* ── the master badge ──────────────────────────────────────────────────── */
.vp-master-badge {
    margin-left: auto; margin-right: var(--sp-10);
    font: 600 var(--fs-10)/1 var(--ff-mono);
    letter-spacing: 0.4px; white-space: nowrap;
}

/* ── the toolbar's state dots ──────────────────────────────────────────── */
.vp-dot { background: var(--vp-dot-off); box-shadow: none; }
.vp-dot.is-on { background: var(--vp-accent); box-shadow: var(--vp-dot-glow); }
.vp-dot.vp-dot-sm.is-on { box-shadow: var(--vp-dot-glow-sm); }

/* ── the cascade's one control ─────────────────────────────────────────────
   The AI Sync button's rules were here (#cascadeCutdownsBtn, #aiSyncDot) and
   are deleted with it (item 5 step 3): it was a second switch over one
   behaviour, and after step 2 it governed nothing. The one control is a
   checkbox in the toolbar, styled inline beside the master switcher. */

/* ── the transport buttons ─────────────────────────────────────────────────
   Moved out of the <style id="previewPlayerCSS"> block previewPlayer.js used
   to write into #consoleDropZone on every render. The !importants are not
   decoration: `#previewWrapper button{background:none!important}` and the
   app-wide `.dark-mode .main-content:not(…) button{background:#444;color:#FFF;
   border:1px solid rgba(255,255,255,.3)}` (v1-main.css) both beat an ordinary
   rule, which is why these were written as !important in the first place.
   Measured in the browser, not guessed. */
#previewWrapper button { background: none !important; outline: none !important; box-shadow: none !important; }
#previewFrameBack, #previewFrameFwd { color: var(--pp-btn) !important; border: none !important; }
#previewPlayPause      { color: var(--pp-play) !important; border: none !important; }
#previewLoopBtn        { color: var(--pp-pill) !important; border: 1px solid var(--pp-pill-bd) !important; }
#previewSpeedBtn       { color: var(--pp-speed) !important; border: 1px solid var(--pp-speed-bd) !important; }
#previewMuteBtn        { color: var(--pp-btn) !important; border: none !important; }
#nleToolbarToggle      { color: var(--pp-accent) !important; border: 1px solid var(--pp-accent-bd) !important; }
#previewFullscreenBtn  { color: var(--pp-fs) !important; border: none !important; }
#masterSwitcherBtn     { background: none !important; border: 1px solid var(--pp-master-bd) !important; }
#previewXmlBtn.vbtn        { background: var(--vb-sec-bg) !important; border: 1px solid var(--vb-sec-bd) !important; color: var(--vb-sec-tx) !important; }
#previewXmlBtn.vbtn:hover  { background: var(--vb-sec-bg-h) !important; }
#previewApproveBtn.vbtn       { background: var(--vb-apr-bg) !important; border: 1px solid var(--vb-apr-bd) !important; color: var(--vb-apr-tx) !important; }
#previewApproveBtn.vbtn:hover { background: var(--vb-apr-bg-h) !important; }

/* ── the graphics chips and RENDER ROW ─────────────────────────────────────
   Was a <style id="vsnLaneStyle"> previewPlayer.js appended to <head> once.
   The id-led selectors are load-bearing: the chips live in the CHAT card, not
   in #graphicsLane, and in the pipeline view React re-renders that card from
   outerHTML into a different subtree, so only a rule that reaches it anywhere
   AND out-specifies the app-wide `button` rules keeps them from coming out as
   the browser's default grey buttons. The per-chip colours stay as custom
   properties on the element: they are the role's colour and the armed chip
   inverts, so they are data. */
#vsnGraphicsCard .lane-chip {
    background: var(--chip-bg) !important;
    color: var(--chip-fg) !important;
    border: 1px solid var(--chip-bd) !important;
    box-shadow: none !important;
}
#vsnGraphicsCard .lane-chip:hover { filter: brightness(1.25); }
#previewTransportBar #graphicsLaneRenderBtn {
    background: var(--vp-render-bg) !important;
    color: var(--vp-render-fg) !important;
    border: 1px solid var(--vp-render-bd) !important;
}
#previewTransportBar #graphicsLaneRenderBtn:hover { background: var(--vp-render-bg-h) !important; }
#previewTransportBar #graphicsLaneRenderBtn:disabled { opacity: 0.6; }

/* ── the chip itself ───────────────────────────────────────────────────── */
.lane-chip {
    display: inline-flex; align-items: center; gap: var(--sp-4);
    max-width: 160px;
    padding: var(--sp-2) var(--sp-7); margin: 0 var(--sp-4) var(--sp-4) 0;
    border-radius: var(--r-4); cursor: pointer;
    font: 600 9.5px/1.5 var(--ff-mono); letter-spacing: 0.02em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── the HUD ───────────────────────────────────────────────────────────── */
#timecodeHUD {
    position: absolute; top: var(--sp-8); left: var(--sp-8);
    display: flex; gap: var(--sp-6); align-items: center;
    z-index: 10; pointer-events: none;
}
.vp-hud-chip {
    background: var(--vp-hud-bg);
    border: 1px solid var(--vp-hud-border);
    padding: var(--sp-3) var(--sp-8); border-radius: var(--r-2);
    font: 500 var(--fs-11)/1 var(--ff-mono);
    letter-spacing: 0.5px;
}
#hudShotNumber { font-weight: 600; color: var(--vp-hud-shot); }
#hudTimecode   { color: var(--vp-hud-tc); }
#hudSafe {
    position: absolute; top: var(--sp-8); right: var(--sp-8);
    font: 500 var(--fs-9)/1 var(--ff-mono);
    color: var(--vp-hud-safe);
    z-index: 10; pointer-events: none;
}
#textOverlayPreview { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

/* ── the grid, the safe zones and the crop overlay ─────────────────────── */
#ruleOfThirdsGrid, #safeZonesOverlay {
    display: none; position: absolute; inset: 0; pointer-events: none; z-index: 9;
}
.vp-grid-v, .vp-grid-h { position: absolute; background: var(--vp-grid-line); }
.vp-grid-v { top: 0; bottom: 0; width: 1px; }
.vp-grid-h { left: 0; right: 0; height: 1px; }
.vp-grid-v.vp-grid-1 { left: 33.33%; }
.vp-grid-v.vp-grid-2 { left: 66.66%; }
.vp-grid-h.vp-grid-1 { top: 33.33%; }
.vp-grid-h.vp-grid-2 { top: 66.66%; }
.vp-safe-action {
    position: absolute; top: 5%; left: 5%; right: 5%; bottom: 5%;
    border: 1px solid var(--vp-safe-action);
}
.vp-safe-title {
    position: absolute; top: 10%; left: 10%; right: 10%; bottom: 10%;
    border: 1px dashed var(--vp-safe-title);
}
.vp-safe-label {
    position: absolute; font-size: var(--fs-9); font-family: var(--ff-mono-plain);
    padding: var(--sp-2) var(--sp-4);
}
.vp-safe-label.is-action { top: 5%;  right: 5.5%;  color: var(--vp-safe-action-fg); }
.vp-safe-label.is-title  { top: 10%; right: 10.5%; color: var(--vp-safe-title-fg); }
