/* PulseTV Shorts — the feed, the action rail and the 9:16 tiles (SV-21..SV-33).
   docs/PULSETV-SHORTS-DESIGN.html Part 5. Dark plum surfaces, Electric Violet for action, Carnival
   Orange only for live, gold focus rings (the app's own :focus-visible), Space Grotesk headings.

   Linked from the page BODY (ShortsFeedPage, ShortsRow), never from <head>: PulseTV's head belongs to
   ShareMeta. Every colour is a token (css/tokens.css, the canonical set, or app.css's --ptv-*);
   washes over artwork are color-mix() of a token, so the design-token ratchet stays where it is. */

/* ── The page around the feed ───────────────────────────────────────────────────────────────── */

/* The feed is the page: no centred column, no padding, no footer under it. */
body:has(.ptv-shorts) .ptv-main,
body.ptv-shorts-on .ptv-main { max-width: none; padding: 0; }
body:has(.ptv-shorts) .ptv-footer,
body.ptv-shorts-on .ptv-footer { display: none; }

.ptv-shorts { position: relative; color: var(--ptv-text); font-family: var(--ptv-font-body); }

.ptv-shorts__status { padding: 32px 24px; color: var(--ptv-muted); text-align: center; }
.ptv-shorts__missing { max-width: 640px; margin: 0 auto; padding: 48px 24px; text-align: center; }
.ptv-shorts__missing p { margin-top: 12px; }

/* ── The feed: one Short at a time, snapped ────────────────────────────────────────────────── */

.ptv-shorts__feed {
    /* Under the sticky header on desktop; pulse-shorts.js measures the header into the variable. */
    height: calc(100dvh - var(--ptv-shorts-offset, 66px));
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.ptv-shorts__feed::-webkit-scrollbar { display: none; }

.ptv-short {
    position: relative;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    overflow: hidden;
    isolation: isolate;
}

/* A blurred wash of the Short's own cover behind the frame. */
.ptv-short__wash {
    position: absolute;
    inset: -48px;
    z-index: 0;
    background-size: cover;
    background-position: center;
    filter: blur(42px) brightness(0.45) saturate(1.2);
    transform: scale(1.08);
}

/* The 9:16 frame, sized by the player's existing rule. */
.ptv-short__frame {
    position: relative;
    z-index: 1;
    height: min(78vh, 860px);
    aspect-ratio: 9 / 16;
    max-width: calc(100vw - 32px);
    border-radius: 18px;
    overflow: hidden;
    background: var(--tv-surface);
    box-shadow: 0 18px 48px var(--tv-shade-40);
}

.ptv-short__poster,
.ptv-short__stage,
.ptv-short__stage > mux-player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.ptv-short__poster { object-fit: cover; display: block; }
.ptv-short__stage > mux-player { --controls: none; --media-object-fit: cover; display: block; }

/* A landscape clip is fitted inside the frame over a blurred fill of itself. */
.ptv-short--landscape .ptv-short__frame {
    background: color-mix(in srgb, var(--tv-bg) 35%, transparent);
    backdrop-filter: blur(24px);
}
.ptv-short--landscape .ptv-short__poster { object-fit: contain; }

/* The tap layer: tap pauses, double-tap likes, long-press opens the sheet (pulse-shorts.js). */
.ptv-short__tap {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
    user-select: none;
}
.ptv-short__tap:focus-visible { outline-offset: -4px; border-radius: 18px; }
.ptv-short--active.ptv-short--paused.ptv-short--playing .ptv-short__tap::after {
    content: "▶";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 28px;
    color: var(--ptv-text);
    background: color-mix(in srgb, var(--tv-bg) 55%, transparent);
}

.ptv-short__burst {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    font-size: 96px;
    line-height: 1;
    color: var(--ptv-text);
    text-shadow: 0 6px 24px var(--tv-violet-line);
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
    pointer-events: none;
}
.ptv-short--burst .ptv-short__burst { animation: ptv-short-burst 0.7s ease-out; }
@keyframes ptv-short-burst {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

.ptv-short__hint {
    display: none;
    position: absolute;
    top: 16px;
    left: 50%;
    z-index: 3;
    transform: translateX(-50%);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ptv-text);
    background: var(--tv-pill-chrome);
    pointer-events: none;
}
.ptv-shorts--muted .ptv-short--active .ptv-short__hint { display: block; }

.ptv-short__rating {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    padding: 2px 8px;
    border-radius: 6px;
    font: 600 12px var(--ptv-font-mono);
    color: var(--ptv-text);
    background: var(--tv-pill-chrome);
    pointer-events: none;
}

.ptv-short__dismissed {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background: color-mix(in srgb, var(--tv-bg) 88%, transparent);
}

/* ── The caption block over the bottom of the frame ────────────────────────────────────────── */

.ptv-short__meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: 64px 16px 16px;
    background: linear-gradient(to top, var(--tv-card-scrim), transparent);
    pointer-events: none;
}
.ptv-short__meta > * { pointer-events: auto; }
.ptv-short__meta p { margin: 0 0 6px; }

.ptv-short__byline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ptv-short__channel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--ptv-font-display);
    font-weight: 600;
    color: var(--ptv-text);
    text-decoration: none;
}
.ptv-short__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    background: var(--brand-gradient);
    color: var(--ptv-text);
}
.ptv-short__caption {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.4;
}
.ptv-short__tags { font-size: 13px; color: var(--tv-text-dim); }
.ptv-short__tag { margin-right: 6px; }
.ptv-short__views::before { content: "· "; }
.ptv-short__tags .ptv-short__views:first-child::before { content: ""; }

/* The related card: the one call to action. */
.ptv-short__related {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--ptv-text);
    text-decoration: none;
    background: color-mix(in srgb, var(--tv-surface) 82%, transparent);
    border: 1px solid var(--tv-control-border);
    backdrop-filter: blur(8px);
}
a.ptv-short__related:hover { border-color: var(--ptv-primary); }
.ptv-short__related-kicker {
    flex: none;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ptv-text);
    background: var(--ptv-primary);
}
.ptv-short__related-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ptv-short__related-label { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptv-short__related-sub { font-size: 12px; color: var(--tv-text-dim); }
.ptv-short__related-go { font-size: 20px; color: var(--tv-text-dim); }

/* ── The action rail: outside the frame on desktop, over it on a phone ─────────────────────── */

.ptv-short__rail {
    position: relative;
    z-index: 4;
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: calc(min(78vh, 860px) * 0.3);
}
.ptv-short__act {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 48px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ptv-text);
    font: 600 12px var(--ptv-font-body);
    cursor: pointer;
}
.ptv-short__act:disabled { opacity: 0.6; cursor: progress; }
.ptv-short__icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 20px;
    background: var(--tv-control-fill);
    border: 1px solid var(--tv-control-border);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.ptv-short__act:hover .ptv-short__icon { border-color: var(--tv-control-border-hover); }
.ptv-short__act--on .ptv-short__icon,
.ptv-short__act--sound[aria-pressed="true"] .ptv-short__icon { background: var(--ptv-primary); border-color: var(--ptv-primary); }

/* ── Desktop chrome: up/down, keys, back ───────────────────────────────────────────────────── */

.ptv-shorts__top { display: none; }

.ptv-shorts__nav {
    position: fixed;
    right: 32px;
    top: 50%;
    z-index: 6;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ptv-shorts__navbtn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--tv-control-border);
    background: var(--tv-control-fill);
    color: var(--ptv-text);
    font-size: 20px;
    cursor: pointer;
}
.ptv-shorts__navbtn:hover { border-color: var(--tv-control-border-hover); background: var(--tv-pill-hover); }

.ptv-shorts__keys {
    position: fixed;
    left: 50%;
    bottom: 14px;
    z-index: 6;
    transform: translateX(-50%);
    margin: 0;
    font: 12px var(--ptv-font-mono);
    color: var(--tv-text-faint);
    pointer-events: none;
}

.ptv-shorts__error {
    position: fixed;
    left: 50%;
    bottom: 48px;
    z-index: 8;
    transform: translateX(-50%);
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--tv-warn);
    background: var(--tv-surface);
    border: 1px solid var(--tv-control-border);
}

/* Promotion and end cards take the frame's shape. */
.ptv-short__frame--promo,
.ptv-short__frame--end {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    text-align: center;
}
.ptv-short__frame--promo .ptv-promo,
.ptv-short__frame--promo .ptv-promo--noimg { grid-template-columns: minmax(0, 1fr); width: 100%; }
.ptv-short__frame--promo .ptv-promo__acts { align-items: stretch; }
.ptv-short__frame--end h2 { font-family: var(--ptv-font-display); font-size: 22px; }

/* ── Sheets: share, and "Not interested" / Report ──────────────────────────────────────────── */

.ptv-shorts__veil {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--tv-bg) 60%, transparent);
}
.ptv-shorts__sheet {
    position: fixed;
    left: 50%;
    bottom: 32px;
    z-index: 51;
    transform: translateX(-50%);
    width: min(480px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    border-radius: 16px;
    background: var(--tv-surface);
    border: 1px solid var(--tv-control-border);
    box-shadow: 0 18px 48px var(--tv-shade-40);
}
.ptv-shorts__close {
    align-self: flex-end;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: var(--tv-control-fill);
    color: var(--ptv-text);
    cursor: pointer;
}
.ptv-shorts__sheetbtn {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--tv-control-border);
    background: var(--tv-control-fill);
    color: var(--ptv-text);
    font: 600 15px var(--ptv-font-body);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.ptv-shorts__sheetbtn:hover { border-color: var(--tv-control-border-hover); }
.ptv-shorts__sheetbtn--quiet { background: none; border-color: transparent; color: var(--ptv-muted); }

/* ── The reconnect notice on the feed: a quiet pill, never a wall ──────────────────────────────
   The Shorts play on in pulse-shorts.js while the circuit reconnects, so the overlay must not
   cover them. Only the server saying the circuit is gone (which reloads anyway) is full screen. */
body:has(.ptv-shorts) #components-reconnect-modal.components-reconnect-show,
body:has(.ptv-shorts) #components-reconnect-modal.components-reconnect-failed {
    inset: auto 0 24px 0;
    background: none;
    backdrop-filter: none;
    pointer-events: none;
}
body:has(.ptv-shorts) #components-reconnect-modal .ptv-reconnect__panel {
    pointer-events: auto;
    padding: 10px 18px;
    border-radius: 999px;
}
body:has(.ptv-shorts) #components-reconnect-modal.components-reconnect-show .ptv-reconnect__retrying {
    display: flex;
    align-items: center;
    gap: 10px;
}
body:has(.ptv-shorts) #components-reconnect-modal .ptv-reconnect__retrying p { display: none; }
body:has(.ptv-shorts) #components-reconnect-modal .ptv-reconnect__retrying h2 { font-size: 14px; margin: 0; }
body:has(.ptv-shorts) #components-reconnect-modal .ptv-reconnect__spinner { width: 16px; height: 16px; margin: 0; border-width: 2px; }

/* ── Phone: full screen, header and footer hidden ──────────────────────────────────────────── */

@media (max-width: 767px) {
    body:has(.ptv-shorts__feed) .ptv-header,
    body.ptv-shorts-on .ptv-header { display: none; }

    .ptv-shorts__feed { height: 100dvh; }
    .ptv-short { gap: 0; }
    .ptv-short__wash { display: none; }
    .ptv-short__frame {
        height: 100%;
        width: 100%;
        max-width: none;
        aspect-ratio: auto;
        border-radius: 0;
        box-shadow: none;
    }
    .ptv-short__meta { padding: 72px 84px 24px 16px; }
    .ptv-short__rail {
        position: absolute;
        right: 10px;
        bottom: 132px;
        margin: 0;
        gap: 16px;
    }
    .ptv-short__icon { background: color-mix(in srgb, var(--tv-bg) 45%, transparent); }

    .ptv-shorts__top {
        display: flex;
        align-items: center;
        gap: 12px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 6;
        padding: 12px 16px;
        background: linear-gradient(to bottom, var(--tv-card-scrim), transparent);
        pointer-events: none;
    }
    .ptv-shorts__top > * { pointer-events: auto; }
    .ptv-shorts__back {
        width: 40px;
        height: 40px;
        display: grid;
        place-items: center;
        border-radius: 50%;
        color: var(--ptv-text);
        text-decoration: none;
        font-size: 20px;
        background: color-mix(in srgb, var(--tv-bg) 45%, transparent);
    }
    .ptv-shorts__title { font-family: var(--ptv-font-display); font-size: 18px; margin: 0; }
    .ptv-short__hint { top: 64px; }
    .ptv-short__rating { top: 64px; }

    .ptv-shorts__nav,
    .ptv-shorts__keys { display: none; }

    .ptv-shorts__sheet { bottom: 0; width: 100%; border-radius: 16px 16px 0 0; padding-bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
    .ptv-short--burst .ptv-short__burst { animation-duration: 0.01s; }
    .ptv-short__icon { transition: none; }
}

/* ── Short tiles: Home, channel page, Search, Explore ──────────────────────────────────────── */

.ptv-shortsrow__grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
/* One row only, and the column count follows the width — never a sideways carousel. */
.ptv-shortsrow__grid--single > li:nth-child(n + 7) { display: none; }

@media (max-width: 1100px) {
    .ptv-shortsrow__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ptv-shortsrow__grid--single > li:nth-child(n + 5) { display: none; }
}
@media (max-width: 640px) {
    .ptv-shortsrow__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .ptv-shortsrow__grid--single > li:nth-child(n + 4) { display: none; }
}

.ptv-shorttile {
    position: relative;
    display: block;
    aspect-ratio: 9 / 16;
    border-radius: 12px;
    overflow: hidden;
    color: var(--ptv-text);
    text-decoration: none;
    background: var(--tv-art-placeholder);
    box-shadow: 0 2px 12px var(--tv-shade-35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ptv-shorttile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--tv-card-glow); }
.ptv-shorttile__art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ptv-shorttile__art--ph { background: var(--tv-art-placeholder); }
.ptv-shorttile__scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--tv-tile-scrim), var(--tv-tile-scrim-fade) 55%);
}
.ptv-shorttile__label {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ptv-shorttile__caption {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
}
.ptv-shorttile__views { font-size: 12px; color: var(--tv-text-dim); }

@media (prefers-reduced-motion: reduce) {
    .ptv-shorttile { transition: none; }
    .ptv-shorttile:hover { transform: none; }
}

.ptv-explore__types { margin: 0 0 20px; }

/* A TV-MA Short behind the neutral age screen: the screen fills the frame, nothing plays. */
.ptv-short__agegate {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--tv-surface);
}
