/* tesl full-screen player — minimalist dark theme, red accent */
:root {
    --accent: #e82127;
    --accent-bright: #ff3b40;
    --ui-font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    font-family: var(--ui-font);
    font-weight: 300;
    overflow: hidden;
}

#player-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

#vp9-canvas {
    display: block;
    object-fit: contain;
    image-rendering: auto;
    background: #000;
}

/* Status pill — uppercase, tracked, understated */
.status {
    position: fixed;
    top: 18px;
    left: 20px;
    z-index: 30;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    pointer-events: none;
}

.status.status--terminal-error {
    left: 50%;
    width: calc(100vw - 32px);
    max-width: 760px;
    box-sizing: border-box;
    transform: translateX(-50%);
    padding: 14px 18px;
    font-size: clamp(14px, 1.6vw, 16px);
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: 0.015em;
    text-transform: none;
    white-space: normal;
    overflow-wrap: anywhere;
    color: #fff;
    background: rgba(45, 5, 9, 0.94);
    border: 1px solid rgba(255, 84, 95, 0.95);
    border-left: 6px solid #ff3347;
    border-radius: 6px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.58);
}

/* Unmute button */
#unmute-btn {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 30;
    padding: 8px 16px;
    font-family: var(--ui-font);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s ease;
}
#unmute-btn:hover { background: var(--accent-bright); }
#unmute-btn.hidden { display: none; }

/* Start / retry overlay */
#play-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    background: rgba(0, 0, 0, 0.78);
    cursor: pointer;
}
#play-overlay.hidden { display: none; }
.play-btn {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 24px 0 24px 42px;
    border-color: transparent transparent transparent var(--accent);
    filter: drop-shadow(0 0 18px rgba(232, 33, 39, 0.55));
    transition: transform 0.15s ease;
}
#play-overlay:hover .play-btn { transform: scale(1.08); }
.play-label {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.8);
}

/* Controls bar — hover works for desktops; touch/pause/scrub state is driven by
   vp9.js so the controls do not depend on a hover capability (#63). */
.player-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px 18px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
    opacity: 0;
    transition: opacity 0.25s ease;
}
body:hover .player-controls,
body.controls-visible .player-controls,
body.controls-pinned .player-controls { opacity: 1; }

/* Tesla's in-car Chromium is primarily touch-driven and may never establish a
   persistent hover. Keep the controls discoverable on non-hover devices even
   after the temporary interaction timer expires. */
@media (hover: none) {
    .player-controls { opacity: 1; }
}

.ctrl-btn {
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 2px;
    padding: 7px 11px;
    font-family: var(--ui-font);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.ctrl-btn:hover { border-color: var(--accent); color: #fff; }
.ctrl-time {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.7);
    min-width: 46px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.seek-wrap {
    position: relative;
    flex: 1;
    height: 22px;
    display: flex;
    align-items: center;
}
.seek-track {
    position: absolute;
    left: 0; right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 2px;
}
/* Download frontier of a progressive first play — sits under .seek-played. */
.seek-buffered {
    position: absolute;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    background: rgba(255, 255, 255, 0.45);
    border-radius: 2px;
}
.seek-played {
    position: absolute;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    background: var(--accent);
    border-radius: 2px;
}
.seek-slider {
    position: absolute;
    left: 0; right: 0;
    width: 100%;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}
.seek-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px; height: 13px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(232, 33, 39, 0.6);
}
.seek-slider::-moz-range-thumb {
    width: 13px; height: 13px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
}

.ctrl-group { display: flex; align-items: center; gap: 8px; }
.ctrl-icon {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
}

/* Volume slider — red accent thumb */
#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 3px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 2px;
    cursor: pointer;
}
#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--accent);
}
#volume-slider::-moz-range-thumb {
    width: 11px; height: 11px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
}

/* Custom quality popup (replaces a native <select>, which the Tesla browser
   won't drop down). Button toggles a DOM menu that opens UPWARD (controls sit at
   the screen bottom). */
.quality-menu { position: relative; display: inline-block; }
.quality-btn {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 2px;
    padding: 6px 9px;
    font-family: var(--ui-font);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease;
}
.quality-btn:hover,
.quality-btn[aria-expanded="true"] { border-color: var(--accent); }
.quality-btn:focus { outline: none; border-color: var(--accent); }
.quality-options {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 96px;
    padding: 4px;
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 3px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    z-index: 50;
}
.quality-options.hidden { display: none; }
.quality-option {
    background: transparent;
    color: #fff;
    border: none;
    border-radius: 2px;
    padding: 8px 11px;
    font-family: var(--ui-font);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.12s ease;
}
.quality-option:hover { background: rgba(255, 255, 255, 0.12); }
.quality-option.current { color: var(--accent); }

#vp9-audio { display: none; }

/* ── Live mode ──────────────────────────────────────────────────────────── */
/* LIVE badge — red dot, top-centre, only shown for live streams */
.live-badge {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    pointer-events: none;
}
.live-badge.hidden { display: none; }
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(232, 33, 39, 0.8);
    animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* When live, there is no timeline or pause operation: hide seeking, skip, time,
   and play/pause chrome. Canvas taps reveal the remaining usable controls. */
body.live .seek-wrap,
body.live #time-current,
body.live #time-total,
body.live #btn-back,
body.live #btn-fwd,
body.live #play-pause-btn {
    display: none;
}

/* The timeline (flex:1) normally separates play/pause on the left from the
   volume + quality controls on the right. With it gone in live mode, pin those
   controls to the right so they stay put instead of collapsing to the left. */
body.live .vol-group {
    margin-left: auto;
}

/* ── Playlist panel ─────────────────────────────────────────────────────────
   Semi-transparent panel on the right listing the playlist's videos. Collapses
   to a small re-open tab so it never blocks the video. */
#playlist-panel.hidden, #playlist-show.hidden { display: none; }
#playlist-panel {
    position: fixed;
    top: 56px;
    right: 12px;
    bottom: 84px;        /* clear of the bottom controls bar */
    z-index: 25;
    width: 300px;
    max-width: 42vw;
    display: flex;
    flex-direction: column;
    background: rgba(12, 12, 14, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    overflow: hidden;
    font-family: var(--ui-font);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    transition: transform 0.22s ease, opacity 0.22s ease;
}
#playlist-panel.collapsed {
    transform: translateX(calc(100% + 16px));
    opacity: 0;
    pointer-events: none;
}
#playlist-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex: 0 0 auto;
}
#playlist-title {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#playlist-toggle, #playlist-show {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 5px 9px;
}
#playlist-toggle:hover, #playlist-show:hover { background: rgba(255, 255, 255, 0.18); }
#playlist-show {
    position: fixed;
    top: 56px;
    right: 12px;
    z-index: 25;
    font-size: 16px;
    padding: 8px 11px;
}
#playlist-items {
    overflow-y: auto;
    overflow-anchor: none;
    padding: 6px;
    flex: 1 1 auto;
}
.playlist-spacer {
    width: 1px;
    pointer-events: none;
}
.playlist-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px;
    min-height: 52px;
    box-sizing: border-box;
    border-radius: 8px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.82);
    cursor: pointer;
}
.playlist-item:hover { background: rgba(255, 255, 255, 0.08); }
.playlist-item.current {
    background: rgba(232, 33, 39, 0.18);
    box-shadow: inset 0 0 0 1px var(--accent-bright);
    color: #fff;
}
.pl-index {
    flex: 0 0 18px;
    text-align: right;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
}
.playlist-item.current .pl-index { color: var(--accent-bright); }
.pl-thumb {
    flex: 0 0 auto;
    width: 72px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}
.pl-title {
    font-size: 12px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Release version (#37) — tiny, unobtrusive, always readable for debugging. */
.build-ver {
    position: absolute;
    right: 10px;
    top: 8px;
    z-index: 5;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    pointer-events: none;
    user-select: none;
}
