/**
 * Inline Video Player — frontend styles
 */

.ivp-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9; /* default, override via Elementor sizing controls */
    overflow: hidden;
    background: #000;
    cursor: pointer;
}

/* Poster: getoond totdat preview-player geladen is, en als fallback.
   !important nodig om WordPress' default `img { height: auto }` te overschrijven. */
.ivp-poster {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    max-width: none !important;
    z-index: 1;
    transition: opacity 0.4s ease;
}

/* Stage containers — videos en iframes worden hierin gemount */
.ivp-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 2;
}

.ivp-stage[hidden] {
    display: none;
}

/* Dual mode + YouTube/Vimeo main: stageMain ligt als transparante overlay bovenop
   stagePreview. Heeft layout (geen display:none) zodat het iframe correct kan initialiseren,
   en ontvangt klikken zodat YouTube/Vimeo's iframe-gesture vereiste vervuld wordt voor
   afspelen-mét-geluid. Bij klik wordt de wrapper .ivp-main-active, dan zwapt de zichtbaarheid. */
.ivp-stage--overlay {
    z-index: 4;
    opacity: 0;
    /* pointer-events default (auto) — JS zet dit op 'none' zodra de swap actief is */
}

.ivp-wrapper.ivp-main-active .ivp-stage--overlay {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.ivp-wrapper.ivp-main-active .ivp-stage-preview {
    visibility: hidden;
}

/* Poster-start: poster boven de (vooraf aangemaakte, gepauzeerde) speler houden
   tot er op play geklikt wordt. */
.ivp-wrapper.ivp-poster-hold .ivp-poster {
    z-index: 3;
    opacity: 1;
}

/* Native video: object-fit cover doet het werk */
.ivp-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Iframe (YouTube/Vimeo): JS berekent width/height/transform voor cover-effect.
   Fallback voor het korte moment voordat JS de fit toepast. */
.ivp-stage iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    border: 0;
    display: block;
    max-width: none;
}

/* Play button overlay */
.ivp-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 4;
}

.ivp-play:hover {
    transform: translate(-50%, -50%) scale(1.08);
}

.ivp-play:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px;
}

.ivp-play-default svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.35));
}

.ivp-play-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.ivp-wrapper.is-playing .ivp-play {
    opacity: 0;
    pointer-events: none;
}

/* Custom controls (pause + close) */
.ivp-control {
    position: absolute;
    width: 44px;
    height: 44px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.25s ease, background-color 0.2s ease;
}

.ivp-control:hover {
    background-color: rgba(0, 0, 0, 0.75);
}

.ivp-control:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.ivp-control[hidden] {
    display: none;
}

/* Force SVG sizing — some themes have svg { width: 100% } defaults */
.ivp-control svg {
    width: 20px;
    height: 20px;
    display: block;
    flex-shrink: 0;
    color: inherit;
}

.ivp-pause {
    bottom: 16px;
    left: 16px;
}

.ivp-close {
    top: 16px;
    right: 16px;
}

.ivp-wrapper.is-playing .ivp-control {
    opacity: 1;
}

.ivp-wrapper.is-playing.is-idle .ivp-control {
    opacity: 0;
}

.ivp-wrapper.is-playing:hover .ivp-control {
    opacity: 1;
}

/* Poster-only fallback (geen video bron beschikbaar) */
.ivp-wrapper.ivp-poster-only {
    cursor: default;
}

.ivp-wrapper.ivp-poster-only .ivp-poster {
    opacity: 1;
    z-index: 1;
}

/* Placeholder (alleen editor) */
.ivp-placeholder {
    background-color: #f1f1f1;
    border: 2px dashed #ccc;
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Responsive: control buttons compacter op mobiel */
@media (max-width: 767px) {
    .ivp-control {
        width: 38px;
        height: 38px;
    }
    .ivp-pause {
        bottom: 12px;
        left: 12px;
    }
    .ivp-close {
        top: 12px;
        right: 12px;
    }
}

/* === Bedieningsbalk: tijdlijn + volume (self-hosted & Vimeo) === */
.ivp-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    box-sizing: border-box;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.ivp-wrapper.is-playing .ivp-bar {
    opacity: 1;
    pointer-events: auto;
}

.ivp-wrapper.is-playing.is-idle .ivp-bar {
    opacity: 0;
    pointer-events: none;
}

.ivp-wrapper.is-playing:hover .ivp-bar {
    opacity: 1;
    pointer-events: auto;
}

/* Hoge specificiteit + !important: thema's stylen vaak álle <button>-elementen
   (achtergrond, border-radius, padding, kleur). Dit forceert onze knoppen terug
   naar een kale icoonknop, zodat het thema ze niet als gekleurde "pil" overschrijft
   en het icoon niet groen-op-groen onzichtbaar wordt. */
.ivp-wrapper .ivp-bar .ivp-bar-btn {
    flex: 0 0 auto !important;
    width: 34px !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 34px !important;
    min-height: 0 !important;
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer;
    color: #fff !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1 !important;
    text-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.ivp-wrapper .ivp-bar .ivp-bar-btn svg {
    width: 22px !important;
    height: 22px !important;
    display: block !important;
    color: #fff !important;
    fill: currentColor !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Onderdelen die expliciet currentColor gebruiken (volume-golven, dempkruis) */
.ivp-wrapper .ivp-bar .ivp-bar-btn svg [fill="none"] {
    fill: none !important;
}

.ivp-bar-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.ivp-time {
    flex: 0 0 auto;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    min-width: 38px;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.ivp-timeline {
    position: relative;
    flex: 1 1 auto;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
}

.ivp-timeline-played {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: #fff;
    border-radius: 3px;
}

.ivp-timeline-handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.ivp-timeline:hover .ivp-timeline-handle {
    opacity: 1;
}

.ivp-wrapper .ivp-bar .ivp-volume {
    -webkit-appearance: none !important;
    appearance: none !important;
    flex: 0 0 auto;
    width: 80px;
    height: 4px;
    border: 0 !important;
    border-radius: 2px !important;
    box-shadow: none !important;
    background: rgba(255, 255, 255, 0.3) !important;
    cursor: pointer;
    padding: 0 !important;
    margin: 0 !important;
}

.ivp-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.ivp-volume::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

@media (max-width: 767px) {
    .ivp-bar {
        gap: 6px;
        padding: 6px 8px;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
    }
    .ivp-wrapper .ivp-bar .ivp-bar-btn {
        width: 28px !important;
        height: 28px !important;
    }
    .ivp-wrapper .ivp-bar .ivp-bar-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
    .ivp-volume {
        width: 48px;
        height: 3px;
    }
    .ivp-volume::-webkit-slider-thumb {
        width: 10px;
        height: 10px;
    }
    .ivp-volume::-moz-range-thumb {
        width: 10px;
        height: 10px;
    }
    .ivp-timeline {
        height: 5px;
    }
    .ivp-time {
        font-size: 10px;
        min-width: 28px;
    }
}
