/**
 * SR Product Gallery Video — frontend styles
 * Loaded only on single product pages that actually have a video.
 */

/* ── Play badge on the LAST regular gallery thumbnail ──
   The theme's own thumbnail is kept as is; a small, minimal play icon is
   layered on top. It never captures clicks. */
.flex-control-thumbs li.sr-thumb-has-video {
    position: relative !important;
}
.sr-thumb-has-video .sr-play-overlay {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    z-index: 2 !important;
}
.sr-play-circle {
    width: 26px !important;
    height: 26px !important;
    max-width: 60% !important;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}

/* ── Modal overlay ──
   Printed at the end of <body> AND force-reparented there by JS,
   so nothing above it in the DOM can ever turn this fixed overlay
   into a clipped, mispositioned box. Visibility is controlled with the
   `hidden` attribute (no inline styles, so strict CSP setups are fine). */
#sr-video-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: srFadeIn 0.22s ease;
}
#sr-video-modal[hidden] { display: none; }
#sr-video-modal:focus { outline: none; }
@keyframes srFadeIn { from { opacity: 0; } to { opacity: 1; } }

#sr-video-close {
    position: fixed;
    top: 20px; right: 20px;
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
    padding: 0;
    transition: background 0.2s;
}
#sr-video-close:hover { background: rgba(255,255,255,0.28); }
#sr-video-close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}
#sr-video-close svg {
    width: 16px; height: 16px;
    stroke: #fff; stroke-width: 1.8; fill: none;
}

#sr-video-body {
    width: min(90vw, 900px);
}
/* Portrait videos are sized by viewport height instead of width,
   so a tall 9:16 box doesn't get forced into a wide container. */
#sr-video-body.sr-portrait {
    width: auto;
    height: min(85vh, 850px);
}

/* ── Play button over the LAST gallery image ──
   Minimalist: a light, softly rounded square with a thin outline play
   triangle, centred on the image (no text).
   Injected INSIDE the last gallery slide, so it only shows while that image
   is on screen. Clicks are resolved by frontend.js using the pointer
   position (capture phase), so theme / zoom overlays can't steal the tap.
   Every rule is !important so theme or page-builder CSS can't restyle it.
   The ::before pseudo-element is an invisible, larger touch target. */
.sr-video-cta {
    --sr-cta-size: 64px;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    z-index: 100 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--sr-cta-size) !important;
    height: var(--sr-cta-size) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    border: 0 !important;
    border-radius: 16px !important;
    outline: 0 !important;
    background: rgba(238, 238, 240, 0.88) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    backdrop-filter: blur(10px) !important;
    color: #111 !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10) !important;
    font-size: 0 !important;
    line-height: 0 !important;
    text-decoration: none !important;
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    animation: none !important;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease !important;
}
/* Invisible oversized hit area (easier to tap on phones) */
.sr-video-cta::before {
    content: '' !important;
    position: absolute !important;
    inset: -12px !important;
    border-radius: 24px !important;
    background: transparent !important;
}
.sr-video-cta::after { content: none !important; display: none !important; }

.sr-video-cta .sr-cta-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
}
.sr-video-cta .sr-cta-icon::before,
.sr-video-cta .sr-cta-icon::after { content: none !important; display: none !important; }
.sr-video-cta .sr-cta-label { display: none !important; }
.sr-video-cta svg {
    display: block !important;
    width: 34px !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 0 !important;
    color: inherit !important;
    pointer-events: none !important;
    filter: none !important;
    overflow: visible !important;
}
.sr-video-cta svg path {
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.7 !important;
    stroke-linejoin: round !important;
    stroke-linecap: round !important;
}

.sr-video-cta:hover,
.sr-video-cta:focus-visible {
    background: rgba(250, 250, 251, 0.97) !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18) !important;
    transform: translate(-50%, -50%) scale(1.05) !important;
}
.sr-video-cta:active { transform: translate(-50%, -50%) scale(0.96) !important; }
.sr-video-cta:focus-visible {
    outline: 2px solid #2563eb !important;
    outline-offset: 3px !important;
}

@media (max-width: 480px) {
    .sr-video-cta { --sr-cta-size: 56px; border-radius: 14px !important; }
    .sr-video-cta svg { width: 30px !important; height: 30px !important; }
}

/* ── Responsive iframe / video wrapper ──
   .sr-landscape → 16:9 box, sized by width (the usual case).
   .sr-portrait  → 9:16 box, sized by height instead — so a
   vertical video gets a tall, narrow box instead of a wide
   16:9 frame with huge black bars on the sides. */
.sr-embed-wrap {
    position: relative;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto;
}
.sr-embed-wrap.sr-landscape {
    width: 100%;
    aspect-ratio: 16 / 9;
}
.sr-embed-wrap.sr-portrait {
    width: auto;
    height: 100%;
    aspect-ratio: 9 / 16;
    max-width: 95vw;
}
.sr-embed-wrap iframe,
.sr-embed-wrap video {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    border: none;
    display: block;
    background: #000;
}

/* ── Respect "reduce motion" ── */
@media (prefers-reduced-motion: reduce) {
    #sr-video-modal { animation: none; }
    #sr-video-close { transition: none; }
    .sr-video-cta:hover,
    .sr-video-cta:focus-visible,
    .sr-video-cta:active { transform: translate(-50%, -50%) !important; transition: none !important; }
}
