/* YouTube video card + in-place player + floating mini-player.
   The card renders where marketing_manager's youtube_publish.py injects a
   <div class="youtube-video-card" data-youtube-id="..."> right after the H1.
   Playback happens IN the card's own space; scrolling past it shrinks the same
   player into the bottom-right corner and playback continues. */

/* Slot keeps the flow space so the fixed mini-player does not collapse the page.
   aspect-ratio on the slot makes it CLS-safe (height reserved before load). */
.ytv-slot {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 0 0 28px;
}

/* The card fills its slot; when playing it hosts the iframe. */
.ytv-card {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}
.ytv-card:focus-visible {
    outline: 3px solid #dc2626;
    outline-offset: 2px;
}
.ytv-card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ytv-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 68px;
    height: 48px;
    background: #dc2626;
    border-radius: 12px;
    transition: transform 0.15s ease, background 0.15s ease;
}
.ytv-card:hover .ytv-play {
    transform: scale(1.07);
    background: #b91c1c;
}
/* The play glyph is a border triangle, so it MUST be sized 0x0. Without
   width/height (and with inset:0 + margin:auto) the pseudo stretches to the
   whole button, and the 18px white left border then paints a full-height wedge
   out of the pill's left edge instead of a small centred triangle. */
.ytv-play::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 0 12px 18px;
    border-color: transparent transparent transparent #fff;
    /* optical centring: a right-pointing triangle reads left-heavy when its box
       is centred, so nudge it right like YouTube's own glyph */
    transform: translateX(2px);
}
.ytv-label {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 99px;
}

/* Playing: the poster visuals give way to the player, same box, same place. */
.ytv-card.ytv-playing {
    cursor: default;
}
.ytv-card.ytv-playing img,
.ytv-card.ytv-playing .ytv-play,
.ytv-card.ytv-playing .ytv-label {
    display: none;
}
.ytv-card iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Stop control, only while playing */
.ytv-close {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(8, 10, 20, 0.75);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.ytv-close:hover {
    background: rgba(8, 10, 20, 0.95);
}
.ytv-card.ytv-playing .ytv-close {
    display: block;
}

/* Scrolled past while playing: the SAME player, pinned bottom-right.
   The iframe is never moved in the DOM, so playback is uninterrupted. */
.ytv-card.ytv-pip {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 340px;
    max-width: 72vw;
    height: auto;
    aspect-ratio: 16 / 9;
    z-index: 9999;
    border-radius: 10px;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.42);
    background: #000;
}

/* Floating pill (only when the video is NOT playing and the card is out of view) */
.ytv-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 99px;
    padding: 8px 14px 8px 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    text-decoration: none;
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.ytv-fab.ytv-show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.ytv-fab:hover {
    transform: scale(1.04);
}
.ytv-fab-icon {
    width: 44px;
    height: 32px;
    background: #dc2626;
    border-radius: 9px;
    position: relative;
    flex: none;
}
.ytv-fab-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 0 7px 11px;
    border-color: transparent transparent transparent #fff;
}
.ytv-fab-label {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.2;
}
.ytv-fab-label small {
    display: block;
    font-weight: 400;
    color: #64748b;
    font-size: 11px;
}

@media (max-width: 640px) {
    .ytv-fab {
        right: 16px;
        bottom: 16px;
    }
    .ytv-slot {
        margin-bottom: 20px;
    }
    .ytv-card.ytv-pip {
        right: 8px;
        bottom: 8px;
        width: 260px;
        max-width: 82vw;
    }
}
