/* ==========================================================================
   Embedded Player — the public /player/{token} page.

   Deliberately standalone: this file shares nothing with site.css because the
   page runs inside an iframe on someone else's website, where the portal's
   design tokens mean nothing and a stray inherited rule is a support ticket.
   Every colour comes from the theme block on .p-root.
   ========================================================================== */

/* Reset — the host page can't reach in here, but the iframe still gets UA
   defaults, and a stray margin on <body> shows as a black bar. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: #000; overflow: hidden; }

.p-root {
    /* Heights of the stacked bottom chrome. The logo and the "on now" strip
       both sit above the controls, so each layer's offset is derived rather
       than hard-coded per control style. */
    --p-controls-h: 56px;
    /* Set from the strip's measured height at runtime — it grows when a long
       title wraps, and a guessed constant would collide with the logo. */
    --p-now-h: 0px;

    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--p-stage);
    color: var(--p-text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Theme presets ──────────────────────────────────────────────────────────
   --p-accent is overridden inline from the channel's AccentColor when set, so
   it must never be referenced before this block. */

.p-root[data-theme="dark"] {
    --p-stage: #000;
    --p-chrome: rgba(14, 14, 16, 0.92);
    --p-chrome-solid: #0e0e10;
    --p-text: #f5f5f7;
    --p-text-dim: #a1a1aa;
    --p-accent: #6366f1;
    --p-track: rgba(255, 255, 255, 0.22);
    --p-hover: rgba(255, 255, 255, 0.12);
    --p-panel: rgba(16, 16, 18, 0.97);
    --p-border: rgba(255, 255, 255, 0.1);
}

.p-root[data-theme="light"] {
    --p-stage: #000;
    --p-chrome: rgba(255, 255, 255, 0.94);
    --p-chrome-solid: #ffffff;
    --p-text: #18181b;
    --p-text-dim: #52525b;
    --p-accent: #4f46e5;
    --p-track: rgba(0, 0, 0, 0.18);
    --p-hover: rgba(0, 0, 0, 0.07);
    --p-panel: rgba(255, 255, 255, 0.98);
    --p-border: rgba(0, 0, 0, 0.1);
}

.p-root[data-theme="midnight"] {
    --p-stage: #05070f;
    --p-chrome: rgba(11, 17, 36, 0.94);
    --p-chrome-solid: #0b1124;
    --p-text: #e6ecff;
    --p-text-dim: #8ea0c9;
    --p-accent: #3b82f6;
    --p-track: rgba(140, 165, 220, 0.28);
    --p-hover: rgba(120, 150, 220, 0.16);
    --p-panel: rgba(9, 14, 30, 0.97);
    --p-border: rgba(120, 150, 220, 0.18);
}

/* Minimal: no chrome plate at all — controls sit on a gradient scrim so the
   picture runs edge to edge. */
.p-root[data-theme="minimal"] {
    --p-stage: #000;
    --p-chrome: transparent;
    --p-chrome-solid: rgba(0, 0, 0, 0.72);
    --p-text: #ffffff;
    --p-text-dim: rgba(255, 255, 255, 0.72);
    --p-accent: #ffffff;
    --p-track: rgba(255, 255, 255, 0.3);
    --p-hover: rgba(255, 255, 255, 0.16);
    --p-panel: rgba(0, 0, 0, 0.88);
    --p-border: rgba(255, 255, 255, 0.14);
}

/* ── Video stage ────────────────────────────────────────────────────────── */

.p-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--p-stage);
    object-fit: contain;
    display: block;
}

/* Click target for play/pause — sits under the chrome, over the video. */
.p-click { position: absolute; inset: 0; cursor: pointer; }

/* ── Channel logo overlay ───────────────────────────────────────────────── */

.p-logo {
    position: absolute;
    z-index: 3;
    max-width: 22%;
    max-height: 18%;
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
    transition: opacity var(--p-fade, 200ms) ease;
}
.p-logo[data-pos="top-left"]     { top: 14px;    left: 14px; }
.p-logo[data-pos="top-right"]    { top: 14px;    right: 14px; }
.p-logo[data-pos="bottom-left"]  { bottom: 14px; left: 14px; }
.p-logo[data-pos="bottom-right"] { bottom: 14px; right: 14px; }

/* Lift the bottom corners clear of the control bar AND the "on now" strip
   while the chrome is showing; back to the corner once it fades. */
.p-root:not(.p-idle) .p-logo[data-pos^="bottom"] {
    bottom: calc(var(--p-controls-h) + var(--p-now-h) + 12px);
}

/* ── Centre affordances ─────────────────────────────────────────────────── */

.p-center {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.p-bigplay {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 74px;
    height: 74px;
    border: none;
    border-radius: 50%;
    background: var(--p-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    transition: transform 160ms ease, opacity 160ms ease;
}
.p-bigplay:hover { transform: scale(1.07); }
.p-root[data-theme="minimal"] .p-bigplay { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); }
.p-root[data-theme="light"] .p-bigplay { color: #fff; }

.p-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--p-track);
    border-top-color: var(--p-accent);
    border-radius: 50%;
    animation: p-spin 800ms linear infinite;
}
@keyframes p-spin { to { transform: rotate(360deg); } }

/* Status card for offline / fatal-error states. */
.p-status {
    pointer-events: auto;
    max-width: 82%;
    padding: 18px 22px;
    border-radius: 12px;
    background: var(--p-panel);
    border: 1px solid var(--p-border);
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.p-status-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.p-status-text  { color: var(--p-text-dim); font-size: 13px; }
.p-status-retry {
    margin-top: 12px;
    padding: 7px 16px;
    border: none;
    border-radius: 999px;
    background: var(--p-accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

/* ── Unmute prompt ──────────────────────────────────────────────────────────
   Autoplay only works muted, so the player always starts silent — this is the
   one affordance that must never be subtle. */
.p-unmute {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border: none;
    border-radius: 999px;
    background: var(--p-accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    animation: p-pop 260ms ease;
}
@keyframes p-pop { from { opacity: 0; transform: translate(-50%, -8px); } }
.p-unmute:hover { filter: brightness(1.08); }

/* ── Now playing strip ──────────────────────────────────────────────────── */

.p-now {
    position: absolute;
    left: 0; right: 0;
    bottom: var(--p-controls-h);
    z-index: 4;
    padding: 10px 16px;
    background: linear-gradient(to top, var(--p-chrome-solid), transparent);
    transition: opacity var(--p-fade, 200ms) ease, transform var(--p-fade, 200ms) ease;
}
.p-now-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--p-accent);
}
.p-now-title {
    font-size: 14px;
    font-weight: 600;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.p-now-meta { font-size: 12px; color: var(--p-text-dim); }
.p-now-bar {
    margin-top: 6px;
    height: 3px;
    border-radius: 2px;
    background: var(--p-track);
    overflow: hidden;
}
.p-now-fill { height: 100%; background: var(--p-accent); border-radius: 2px; transition: width 1s linear; }

/* ── Controls ───────────────────────────────────────────────────────────── */

.p-controls {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 56px;
    padding: 0 10px;
    background: var(--p-chrome);
    border-top: 1px solid var(--p-border);
    transition: opacity var(--p-fade, 200ms) ease, transform var(--p-fade, 200ms) ease;
}

/* Minimal has no plate — the scrim carries the controls instead. */
.p-root[data-theme="minimal"] .p-controls {
    border-top: none;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78), transparent);
    height: 64px;
}
.p-root[data-theme="minimal"] { --p-controls-h: 64px; }

/* Floating style: a detached pill rather than a full-width strip. */
.p-root[data-control="floating"] .p-controls {
    left: 12px; right: 12px;
    bottom: 12px;
    height: 50px;
    padding: 0 8px;
    border: 1px solid var(--p-border);
    border-radius: 999px;
    background: var(--p-chrome-solid);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.38);
}
.p-root[data-control="floating"] { --p-controls-h: 74px; }   /* 50px pill + 12px inset + gap */

.p-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--p-text);
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
.p-btn:hover { background: var(--p-hover); }
.p-btn:focus-visible { outline: 2px solid var(--p-accent); outline-offset: 2px; }
.p-btn[aria-pressed="true"] { color: var(--p-accent); }
.p-btn svg { width: 20px; height: 20px; display: block; }

.p-spacer { flex: 1 1 auto; }

/* Live pill — the live equivalent of a scrub bar: red dot = at the edge,
   dim = behind it, and behind-the-edge turns the whole pill into the button
   that jumps back. */
.p-live {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    margin-left: 4px;
    padding: 0 11px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--p-text);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    cursor: default;
}
.p-live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    animation: p-pulse 2s ease-out infinite;
}
@keyframes p-pulse {
    70%  { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.p-live.p-behind { background: var(--p-hover); cursor: pointer; }
.p-live.p-behind .p-live-dot { background: var(--p-text-dim); animation: none; box-shadow: none; }
.p-live.p-behind:hover { background: var(--p-accent); color: #fff; }

/* Volume — collapses to zero width until the control area is hovered, so a
   narrow embed isn't dominated by a slider nobody asked for. */
.p-volume {
    flex: none;
    width: 0;
    opacity: 0;
    overflow: hidden;
    transition: width 180ms ease, opacity 180ms ease;
}
.p-vol-wrap:hover .p-volume,
.p-volume:focus-within { width: 72px; opacity: 1; }
.p-vol-wrap { display: flex; align-items: center; }

.p-volume input {
    width: 68px;
    height: 20px;
    margin: 0 4px;
    accent-color: var(--p-accent);
    background: transparent;
    cursor: pointer;
    vertical-align: middle;
}

/* Quality menu — only rendered when the playlist has more than one rendition. */
.p-menu-wrap { position: relative; flex: none; }
.p-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 132px;
    padding: 6px;
    border: 1px solid var(--p-border);
    border-radius: 10px;
    background: var(--p-panel);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}
.p-menu[hidden] { display: none; }
.p-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--p-text);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.p-menu-item:hover { background: var(--p-hover); }
.p-menu-item[aria-checked="true"] { color: var(--p-accent); font-weight: 600; }

/* ── Guide panel ────────────────────────────────────────────────────────── */

.p-guide {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    z-index: 7;
    width: min(340px, 82%);
    display: flex;
    flex-direction: column;
    background: var(--p-panel);
    border-left: 1px solid var(--p-border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.42);
    transform: translateX(100%);
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.p-root.p-guide-open .p-guide { transform: translateX(0); }

.p-guide-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 12px 12px 16px;
    border-bottom: 1px solid var(--p-border);
}
.p-guide-title { font-size: 14px; font-weight: 700; }
.p-guide-sub { font-size: 11px; color: var(--p-text-dim); margin-top: 1px; }

.p-guide-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 0 12px;
}
.p-guide-empty { padding: 22px 16px; color: var(--p-text-dim); font-size: 13px; text-align: center; }

.p-prog {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--p-border);
}
.p-prog:last-child { border-bottom: none; }
.p-prog-time { font-size: 12px; font-weight: 600; color: var(--p-text-dim); padding-top: 1px; }
.p-prog-title { font-size: 13px; font-weight: 600; }
.p-prog-ep { font-size: 12px; color: var(--p-text-dim); margin-top: 1px; }
.p-prog-desc {
    font-size: 12px;
    color: var(--p-text-dim);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
}
.p-prog-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.p-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--p-hover);
    color: var(--p-text-dim);
}

/* The current program leads the list on its own accent-lined card. */
.p-prog.p-onair { background: var(--p-hover); border-left: 3px solid var(--p-accent); padding-left: 13px; }
.p-prog.p-onair .p-prog-time { color: var(--p-accent); }
.p-onair-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--p-accent);
    margin-bottom: 2px;
}

/* ── Auto-hide ──────────────────────────────────────────────────────────── */

.p-root.p-idle .p-controls,
.p-root.p-idle .p-now { opacity: 0; transform: translateY(6px); pointer-events: none; }
.p-root.p-idle .p-click { cursor: none; }
.p-root.p-guide-open .p-controls,
.p-root.p-guide-open .p-now { opacity: 1; transform: none; pointer-events: auto; }

[hidden] { display: none !important; }

/* ── Small embeds ───────────────────────────────────────────────────────────
   A 320-wide sidebar embed is a real placement, so the chrome sheds the
   optional controls rather than wrapping. */
@media (max-width: 480px) {
    .p-root { --p-controls-h: 50px; }
    .p-controls { height: 50px; gap: 0; }
    .p-btn { width: 34px; height: 34px; }
    .p-vol-wrap .p-volume { display: none; }
    .p-now { padding: 8px 12px; }
    .p-now-title { font-size: 13px; }
    .p-bigplay { width: 58px; height: 58px; }
    .p-guide { width: 100%; }
}
@media (max-height: 260px) {
    .p-now { display: none; }
}
