/*
 * Shared play/stop control for the "image, video on demand" pattern
 * (video-reveal.js). One small button, top-right corner of whichever
 * element directly parents the <video> — every one of those parents is
 * already positioned (relative/sticky/absolute) per component, so no
 * positioning context needs to be added here.
 *
 * Always visible whenever the media has a video — it's the only way to
 * start one. `data-state` (idle / loading / playing) is set by
 * video-reveal.js and only swaps the icon inside.
 */

.video-toggle {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    z-index: 2;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-pill);

    background: rgba(36, 27, 20, 0.55);
    color: var(--bg-cream);
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;

    transition:
        background var(--transition-fast),
        transform var(--transition-fast);
}

.video-toggle:hover,
.video-toggle:focus-visible {
    background: rgba(36, 27, 20, 0.8);
    transform: scale(1.08);
}

.video-toggle:focus-visible {
    outline: 2px solid var(--bg-cream);
    outline-offset: 2px;
}

.video-toggle[data-state="idle"] i {
    /* The fa-play triangle's visual weight sits left of its own bounding
       box center — nudge it right so it reads as centered inside the
       circle. fa-stop is a symmetric square and needs no nudge. */
    margin-left: 1px;
}

.video-toggle__spinner {
    display: block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--bg-cream);
    border-radius: 50%;
    animation: video-toggle-spin 0.8s linear infinite;
}

@keyframes video-toggle-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .video-toggle__spinner {
        animation-duration: 2.4s;
    }
}
