/* ==========================================================================
   Nagina — "Watch Our Pumps" video slider + popup (home page).
   Every selector is prefixed vs- so nothing collides with style-main.css or the
   utility classes. Loaded only when the section renders.

   Colours follow the admin's theme colour (Appearance → Themes → colour), which the
   layout injects as --theme-primary / --theme-primary-text (partials/storefront-theme-css,
   same source as Nagina's own --ip-theme / --ip-theme-text). No colour is hardcoded here:
   anything drawn ON the primary colour uses the "on primary" text colour.
   ========================================================================== */

/* Tokens are also set on the popup: the script moves it to <body>. */
.vs-section,
.vs-modal {
    --vs-primary: var(--theme-primary, var(--ip-theme));
    --vs-on-primary: var(--theme-primary-text, var(--ip-theme-text, #fff));
    --vs-ink: #111827;
    --vs-muted: #6b7280;
}
.vs-section {
    --vs-gap: 24px;
    --vs-cards: 3;
    --vs-track-pt: 8px;
    position: relative;
    overflow: hidden; /* clips the overflowing track and the full-bleed band */
    background: #fff;
    padding-top: 70px;
}

/* Header ------------------------------------------------------------------ */
.vs-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 40px;
}
.vs-title {
    margin: 0 0 10px;
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--vs-ink);
}
.vs-title span { color: var(--vs-primary); }
.vs-sub {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--vs-muted);
}

/* Arrows ------------------------------------------------------------------ */
.vs-nav { display: flex; gap: 12px; flex: none; }
.vs-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .2s ease, opacity .2s ease, transform .2s ease;
}
.vs-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* Prev on white: neutral border + primary chevron (darkened a touch so light colours stay visible). */
.vs-arrow--prev { background: #fff; border: 1px solid #e5e7eb; color: color-mix(in srgb, var(--vs-primary) 85%, #000); }
.vs-arrow--next { background: var(--vs-primary); border: 1px solid var(--vs-primary); color: var(--vs-on-primary); }
.vs-arrow:hover:not(:disabled) { transform: translateY(-1px); }
.vs-arrow:disabled { opacity: .4; cursor: default; }
.vs-arrow:focus-visible { outline: 2px solid var(--vs-ink); outline-offset: 2px; }
.vs-nav--foot { display: none; }

/* Stage: track + primary band + footer ------------------------------------- */
.vs-stage {
    position: relative;
    container-type: inline-size; /* 100cqw = container content width */
    padding-bottom: 40px;
}
/* Full-bleed band. Starts exactly at the bottom edge of the card thumbnails:
   track top padding + 16:9 of one card's width. */
.vs-band {
    position: absolute;
    z-index: 0;
    top: calc(var(--vs-track-pt) + (100cqw - (var(--vs-cards) - 1) * var(--vs-gap)) / var(--vs-cards) * 9 / 16);
    bottom: 0;
    left: calc(50% - 50vw);
    width: 100vw;
    background: var(--vs-primary);
}

.vs-track {
    position: relative;
    z-index: 1;
    display: flex;
    gap: var(--vs-gap);
    /* Overflow to the viewport's right edge so the next card peeks in. */
    margin-right: calc((100cqw - 100vw) / 2);
    padding: var(--vs-track-pt) calc((100vw - 100cqw) / 2) 32px 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    outline: none;
}
.vs-track::-webkit-scrollbar { display: none; }
.vs-track:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--vs-on-primary) 70%, transparent); }
.vs-track.is-dragging { scroll-snap-type: none; scroll-behavior: auto; cursor: grabbing; }

/* Card: a <div> with a full-card "open" button (title ::after) and a separate
   sound button stacked above it — no nested interactive elements. ---------- */
.vs-card {
    position: relative;
    flex: 0 0 calc((100cqw - (var(--vs-cards) - 1) * var(--vs-gap)) / var(--vs-cards));
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 12px 32px rgba(17, 24, 39, .18);
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform .25s ease, box-shadow .25s ease;
}
.vs-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(17, 24, 39, .22); }
.vs-card:has(.vs-card-open:focus-visible) { outline: 3px solid var(--vs-primary); outline-offset: 3px; }

.vs-thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    background: #f3f4f6;
}
.vs-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.vs-thumb-placeholder {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}
/* Inline muted preview: fades in over the thumbnail once it is really playing. */
.vs-inline {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.vs-card.is-playing .vs-inline { opacity: 1; }
.vs-play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--vs-primary);
    box-shadow: 0 0 0 5px rgba(255, 255, 255, .55);
    transform: translate(-50%, -50%);
    transition: transform .25s ease, opacity .2s ease;
}
.vs-play svg { width: 22px; height: 22px; margin-left: 3px; fill: var(--vs-on-primary); }
.vs-card:hover .vs-play { transform: translate(-50%, -50%) scale(1.06); }
.vs-card.is-playing .vs-play { opacity: 0; }

/* Sound toggle (only while the inline preview plays). Above the open-overlay. */
.vs-sound {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 24, 39, .7);
    color: #fff;
    cursor: pointer;
}
.vs-card.is-playing .vs-sound { display: inline-flex; }
.vs-sound svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vs-sound svg path:first-child { fill: currentColor; }
.vs-sound .vs-sound-on { display: none; }
.vs-sound[aria-pressed="true"] .vs-sound-on { display: block; }
.vs-sound[aria-pressed="true"] .vs-sound-off { display: none; }
.vs-sound:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.vs-card-body {
    display: block;
    flex: 1 1 auto;
    padding: 20px 24px 24px;
}
/* The title is the card's "open video" button; its ::after covers the whole card. */
.vs-card-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: var(--vs-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    outline: none;
}
.vs-card-open::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
}
.vs-card-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.45;
}

/* Footer row on the band: counter + progress (+ arrows on mobile) ---------- */
.vs-foot {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 28px;
    color: var(--vs-on-primary);
}
.vs-count {
    flex: none;
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .5px;
}
.vs-progress {
    position: relative;
    display: block;
    width: 440px;
    max-width: 100%;
    height: 4px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--vs-on-primary) 35%, transparent);
    overflow: hidden;
}
.vs-progress > span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: 4px;
    background: var(--vs-on-primary);
    transition: width .3s ease;
}

/* Everything fits: no arrows / counter / progress. */
.vs-section.is-static .vs-nav,
.vs-section.is-static .vs-count,
.vs-section.is-static .vs-progress { display: none; }

/* Popup ------------------------------------------------------------------- */
.vs-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.vs-modal[hidden] { display: none; }
.vs-modal-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .82); }
.vs-modal-panel {
    position: relative;
    width: 100%;
    max-width: 960px;
    max-height: calc(100vh - 48px);
    overflow: auto;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.vs-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--vs-ink);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    cursor: pointer;
}
.vs-modal-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.vs-modal-close:focus-visible { outline: 2px solid var(--vs-primary); outline-offset: 2px; }
.vs-modal-player { position: relative; aspect-ratio: 16 / 9; background: #000; }
.vs-modal-player video,
.vs-modal-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.vs-modal-error { margin: 16px 24px 0; color: var(--vs-ink); font-weight: 600; }
.vs-modal-body { padding: 20px 24px 24px; }
.vs-modal-title { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.4; color: var(--vs-ink); }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 767px) {
    .vs-section { --vs-gap: 16px; --vs-card-w: 300px; padding-top: 50px; }
    .vs-head { margin-bottom: 28px; }
    .vs-title { font-size: 28px; }
    .vs-sub { font-size: 15px; }
    .vs-nav--head { display: none; }
    .vs-nav--foot { display: flex; margin-left: auto; }
    /* ~300px card, but always leave ~50px for the next card to peek on narrow phones. */
    .vs-band { top: calc(var(--vs-track-pt) + min(var(--vs-card-w), 100cqw - 50px) * 9 / 16); }
    .vs-card { flex-basis: min(var(--vs-card-w), 100cqw - 50px); }
    .vs-card-body { padding: 18px 20px 20px; }
    .vs-card-title { font-size: 16px; }
    .vs-foot { gap: 18px; }
    .vs-progress { width: auto; flex: 1 1 auto; }
    .vs-arrow { width: 44px; height: 44px; }
    /* Mobile arrows sit on the band: outline + filled, both in the on-primary colour. */
    .vs-arrow--prev { background: transparent; border-color: color-mix(in srgb, var(--vs-on-primary) 55%, transparent); color: var(--vs-on-primary); }
    .vs-arrow--next { background: var(--vs-on-primary); border-color: var(--vs-on-primary); color: var(--vs-primary); }
    .vs-modal { padding: 12px; }
    .vs-modal-close { top: 8px; right: 8px; }
    .vs-modal-body { padding: 16px 18px 20px; }
    .vs-modal-title { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
    .vs-track { scroll-behavior: auto; }
    .vs-card, .vs-play, .vs-arrow, .vs-progress > span, .vs-inline { transition: none; }
}
