.svp-player {
    position: relative;
    overflow: hidden;
    background: #000;
    width: 100%;
    max-width: 100%;
    aspect-ratio: var(--svp-ratio);
    border-radius: var(--svp-radius, 0px);
}

.svp-player iframe {
    border-radius: var(--svp-radius, 0px);
}

/*
 * Rounded corners must not survive into fullscreen — the video fills the screen
 * and the radius cuts black wedges out of its corners. The element that goes
 * fullscreen is Plyr's inner `.plyr` container, never this wrapper, so the
 * wrapper is not what gets reset. The iframe is named separately because the
 * custom property inherits into it and it carries a radius of its own.
 *
 * The three blocks are deliberately not merged into one comma list: a selector
 * the browser does not recognise invalidates the entire rule it appears in, and
 * the class-only block below must keep working in a browser that knows neither
 * `:fullscreen` nor the prefixed form.
 */
.svp-player .plyr--fullscreen-fallback,
.svp-player .plyr--fullscreen-fallback iframe {
    border-radius: 0;
}

.svp-player .plyr:fullscreen,
.svp-player .plyr:fullscreen iframe {
    border-radius: 0;
}

.svp-player .plyr:-webkit-full-screen,
.svp-player .plyr:-webkit-full-screen iframe {
    border-radius: 0;
}

/*
 * The 16/9 fallback is only for boxes whose ratio is not knowable up front:
 * fixed-ratio players, and iframe embeds before a ratio is resolved. An
 * original-mode player deliberately gets no fallback — `aspect-ratio: var()`
 * with the variable unset is invalid at computed-value time and resolves to
 * `auto`, so the box takes its height from the media instead of being forced
 * into a shape the video does not have.
 */
.svp-player[data-svp-ratio-mode="fixed"],
.svp-player[data-svp-mode^="iframe-"] {
    aspect-ratio: var(--svp-ratio, 16 / 9);
}

/*
 * Once the box matches the media there is nothing to letterbox, so the black
 * backdrop is only wanted while loading. Plyr paints its own background on the
 * wrapper and poster, hence the extra selectors — they are set through Plyr's
 * own custom property rather than fought with !important.
 */
.svp-player[data-svp-ratio-mode="original"]:not(.svp-pending),
.svp-player[data-svp-ratio-mode="original"] .plyr,
.svp-player[data-svp-ratio-mode="original"] .plyr__video-wrapper,
.svp-player[data-svp-ratio-mode="original"] .plyr__poster {
    --plyr-video-background: transparent;
    background: transparent;
}

.svp-editor-notice {
    background: #fff3cd;
    color: #856404;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid #ffeeba;
}

.svp-player .plyr,
.svp-player iframe {
    transition: opacity 0.5s ease;
}

.svp-player.svp-pending .plyr,
.svp-player.svp-pending iframe {
    opacity: 0 !important;
}

.svp-video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.svp-player.svp-pending .svp-video-loading {
    display: flex;
    opacity: 1;
    animation: svp-loading-appear 0.3s ease 0.6s backwards;
}

@keyframes svp-loading-appear {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.svp-video-loading-spinner {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: svp-loading-spin 0.8s linear infinite;
}

@keyframes svp-loading-spin {
    to { transform: rotate(360deg); }
}

/* Native player fit styles */
.svp-player .plyr video {
    object-fit: contain;
    width: 100%;
    height: 100%;
}

/* Iframe sizing */

.svp-player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* YouTube Facade */
.svp-yt-facade {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    z-index: 1;
}

.svp-yt-facade-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px;
    height: 48px;
    background: rgba(255, 0, 0, 0.8);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.2s;
}

.svp-yt-facade-play:hover {
    background: #ff0000;
}

.svp-yt-facade-play svg {
    width: 32px;
    height: 32px;
}
