/* ============================================================
   STUDIO WESTONIA — Custom Video Player
   Branded controls with W-icon play button
   ============================================================ */

/* --- Player wrapper --- */
.sw-player {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: var(--grey-dark);
    overflow: hidden;
    cursor: pointer;
}

/* --- Lightweight click-to-load poster ---
   Keeps layout stable and avoids loading YouTube JS until user intent. */
.sw-lite {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: #000;
    cursor: pointer;
    overflow: hidden;
}

.sw-lite__poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.sw-lite__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(72px, 10vw, 110px);
    height: clamp(72px, 10vw, 110px);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s ease, background 0.3s ease;
}

.sw-lite__play-icon {
    width: 38%;
    height: auto;
    fill: #fff;
}

@media (hover:hover){
.sw-lite:hover .sw-lite__poster {
    transform: scale(1.04);
}
.sw-lite:hover .sw-lite__play {
    transform: translate(-50%, -50%) scale(1.08);
    background: rgba(0, 0, 255, 1);
}
}

/* When the sw-player is mounted inside a container that already
   reserves its own aspect-ratio (split wrappers, diensten splits,
   or a 9:16 main project video), pin it to fill the parent so the
   default 56.25% padding-bottom doesn't leave a huge gap below a
   9:16 reel. Needed for both .project-video--vertical (main video
   slot set to vertical in the CMS) and the .sw-player-wrap class
   it gets renamed to after mount. */
.project-split__video .sw-player,
.dienst-content-split__img-wrap .sw-player,
.dienst-video-card__embed--vertical .sw-player,
.dienst-content-split__img-wrap--vertical .sw-player,
.project-video--vertical .sw-player,
.sw-player-wrap.project-video--vertical .sw-player {
    position: absolute;
    inset: 0;
    padding-bottom: 0;
    height: 100%;
}

/* Cover-fit the iframe inside any 9:16 vertical container so the
   video area isn't letterboxed with black bars when the underlying
   YouTube upload is actually 16:9 landscape. The iframe gets a
   16/9 aspect-ratio + height 100%, which makes it ~3.16× wider
   than the 9:16 parent. overflow:hidden on the parent then center-
   crops the horizontal overflow.
   - For true 9:16 Shorts: YouTube centers the content inside the
     wider iframe, the container shows exactly the video area.
   - For 16:9 landscape (e.g. the CBC trailer): video fills the
     frame, sides get cropped — reel-style center zoom instead of
     a tiny letterboxed clip. */
.project-split__video--vertical .sw-player iframe,
.project-split__video--vertical > iframe,
.dienst-video-card__embed--vertical .sw-player iframe,
.dienst-video-card__embed--vertical > iframe,
.dienst-content-split__img-wrap--vertical .sw-player iframe,
.dienst-content-split__img-wrap--vertical > iframe,
.sw-player-wrap.project-video--vertical .sw-player iframe,
.project-video--vertical .sw-player iframe,
.project-video--vertical > iframe {
    width: auto;
    height: 100%;
    aspect-ratio: 16 / 9;
    min-width: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sw-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- Big play overlay (center W-icon) --- */
.sw-player__overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                visibility 0.5s;
    cursor: pointer;
}

.sw-player.is-playing .sw-player__overlay {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.sw-player__play-btn {
    position: relative;
    width: clamp(72px, 10vw, 110px);
    height: clamp(72px, 10vw, 110px);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.3s ease,
                border-color 0.3s ease;
}

@media (hover:hover){
.sw-player__play-btn:hover {
    transform: scale(1.12);
    background: rgba(0, 0, 255, 1);
    border-color: rgba(255, 255, 255, 0.6);
}
}

.sw-player__play-btn:active {
    transform: scale(0.95);
}

/* W-icon inside play button */
.sw-player__play-icon {
    width: 38%;
    height: auto;
    fill: #FFFFFF;
    transition: transform 0.3s ease;
}

@media (hover:hover){
.sw-player__play-btn:hover .sw-player__play-icon {
    transform: scale(1.08);
}
}

/* Pulse ring animation */
.sw-player__play-btn::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 255, 0.4);
    animation: swPulse 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes swPulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    70% {
        transform: scale(1.35);
        opacity: 0;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

/* --- Bottom control bar --- */
.sw-player__controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vw, 1rem);
    padding: clamp(0.5rem, 1.5vw, 0.85rem) clamp(0.75rem, 2vw, 1.25rem);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 100%);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

.sw-player:hover .sw-player__controls,
.sw-player.is-playing .sw-player__controls {
    pointer-events: auto;
}

@media (hover:hover){
.sw-player:hover .sw-player__controls {
    opacity: 1;
    transform: translateY(0);
}
}

@media (hover:hover){
.sw-player.is-playing:not(:hover) .sw-player__controls {
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition-delay: 1.5s;
}
}

/* Play/pause toggle in control bar */
.sw-player__toggle {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

@media (hover:hover){
.sw-player__toggle:hover {
    transform: scale(1.15);
}
}

.sw-player__toggle svg {
    width: 20px;
    height: 20px;
    fill: #FFFFFF;
}

.sw-player__toggle .sw-icon-pause {
    display: none;
}

.sw-player.is-playing .sw-player__toggle .sw-icon-play {
    display: none;
}

.sw-player.is-playing .sw-player__toggle .sw-icon-pause {
    display: block;
}

/* Progress bar */
.sw-player__progress {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    overflow: visible;
    transition: height 0.15s ease;
}

@media (hover:hover){
.sw-player:hover .sw-player__progress {
    height: 6px;
}
}

.sw-player__progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: #0000FF;
    border-radius: 2px;
    transition: width 0.1s linear;
}

.sw-player__progress-fill::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0000FF;
    border: 2px solid #FFFFFF;
    z-index: 5;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover:hover){
.sw-player:hover .sw-player__progress-fill::after {
    transform: translateY(-50%) scale(1);
}
}

/* Time display */
.sw-player__time {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.03em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    min-width: 3.5em;
    flex-shrink: 0;
}

/* Volume */
.sw-player__volume {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.sw-player__mute {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

@media (hover:hover){
.sw-player__mute:hover {
    transform: scale(1.15);
}
}

.sw-player__mute svg {
    width: 18px;
    height: 18px;
    fill: #FFFFFF;
}

.sw-player__mute .sw-icon-muted {
    display: none;
}

.sw-player.is-muted .sw-player__mute .sw-icon-volume {
    display: none;
}

.sw-player.is-muted .sw-player__mute .sw-icon-muted {
    display: block;
}

/* Fullscreen */
.sw-player__fullscreen {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

@media (hover:hover){
.sw-player__fullscreen:hover {
    transform: scale(1.15);
}
}

.sw-player__fullscreen svg {
    width: 16px;
    height: 16px;
    stroke: #FFFFFF;
    fill: none;
    stroke-width: 2;
}

/* --- Branding watermark in bottom-right --- */
.sw-player__brand {
    position: absolute;
    bottom: clamp(3rem, 5vw, 4rem);
    right: clamp(0.75rem, 2vw, 1.25rem);
    z-index: 2;
    opacity: 0.12;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@media (hover:hover){
.sw-player:hover .sw-player__brand {
    opacity: 0.06;
}
}

.sw-player__brand svg {
    width: clamp(28px, 4vw, 44px);
    height: auto;
    fill: #FFFFFF;
}

/* --- Loading state --- */
.sw-player__loader {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--grey-dark);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.sw-player.is-ready .sw-player__loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.sw-player__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #0000FF;
    border-radius: 50%;
    animation: swSpin 0.8s linear infinite;
}

@keyframes swSpin {
    to { transform: rotate(360deg); }
}

/* --- Fullscreen mode --- */
.sw-player:fullscreen,
.sw-player:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #000;
}

.sw-player:fullscreen iframe,
.sw-player:-webkit-full-screen iframe {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

.sw-player:fullscreen .sw-player__controls,
.sw-player:-webkit-full-screen .sw-player__controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2147483647;
    padding: 1rem 1.5rem;
}

.sw-player:fullscreen:not(:hover) .sw-player__controls,
@media (hover:hover){
.sw-player:-webkit-full-screen:not(:hover) .sw-player__controls {
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition-delay: 2s;
}
}

.sw-player:fullscreen .sw-player__overlay,
.sw-player:-webkit-full-screen .sw-player__overlay {
    z-index: 2147483646;
}

.sw-player:fullscreen .sw-player__brand,
.sw-player:-webkit-full-screen .sw-player__brand {
    display: none;
}

.sw-player:fullscreen .sw-player__fullscreen svg,
.sw-player:-webkit-full-screen .sw-player__fullscreen svg {
    transform: rotate(180deg);
}

/* --- Nested in a parent that already enforces aspect ratio ---
   Hosts like .dienst-video-card__embed use padding-bottom to lock 16:9
   on the wrapper itself, so the sw-player must absolutely fill it
   instead of adding its own padding-bottom. */
.dienst-video-card__embed .sw-player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding-bottom: 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sw-player__volume {
        display: none;
    }

    .sw-player__controls {
        gap: 0.4rem;
    }
}

@media (max-width: 480px) {
    .sw-player__time {
        display: none;
    }
}
