/* ===========================================================================
   Shared video modal - the one <dialog> every module opens a YouTube frame in.
   Markup: includes/video-gallery/render.php::wwh_video_gallery_render_modal()
   Closing: js/wwh-dialog.js. Root font-size is 9px, so this file works in px.
   Canonical breakpoints used here: 768. Never 991, never 480.
   It also owns the --vg-* tokens, because css/video-gallery.css needs them too
   and a second copy there would drift the day one value changes. Every consumer
   therefore enqueues this file, and the gallery declares it as a dependency.
   =========================================================================== */

:root {
    /* Own prefix on purpose: the --exp-* tokens of the Experiences page also
       sit on :root and must not be redefined from here. */
    --vg-navy: #0a2540;
    --vg-navy-mid: #153354;
    --vg-ink: #1e2a3d;
    --vg-sky: #78c5db;
    --vg-slate: #5a6b82;
    --vg-focus: #66b2e8;
    --vg-line: rgba(0, 0, 0, .08);
    --vg-radius: 12px;
    --vg-gap: 28px;
    --vg-shadow: 0 10px 30px rgba(0, 0, 0, .1);
    --vg-shadow-hover: 0 18px 44px rgba(0, 0, 0, .18);
    --vg-shadow-modal: 0 20px 60px rgba(0, 0, 0, .35);
    --vg-ease: cubic-bezier(.22, .61, .36, 1);
    --vg-dur-card: .25s;
    --vg-dur-media: .5s;
    --vg-dur-reveal: .7s;
    --vg-dur-modal: .4s;
}

dialog.vg-modal {
    /* padding stays 0: js/wwh-dialog.js closes when the click target IS the
       DIALOG element, so any padding would turn the dialog's own inner edge
       into a close zone. Spacing belongs on .vg-modal-inner. */
    padding: 0;
    border: 0;
    width: 100%;
    max-width: min(920px, 92vw);
    max-height: 90vh;
    overflow: hidden;
    background: #fff;
    border-radius: var(--vg-radius);
    box-shadow: var(--vg-shadow-modal);
    opacity: 0;
    transform: translateY(16px) scale(.97);
    /* allow-discrete + @starting-style animate the open of a <dialog>
       (Chrome 117+, Firefox 129+, Safari 17.5+). Older browsers open
       instantly, which is what they did before. */
    transition: opacity var(--vg-dur-modal) var(--vg-ease),
                transform var(--vg-dur-modal) var(--vg-ease),
                overlay var(--vg-dur-modal) allow-discrete,
                display var(--vg-dur-modal) allow-discrete;
}
dialog.vg-modal[open] {
    opacity: 1;
    transform: translateY(0) scale(1);
}
@starting-style {
    dialog.vg-modal[open] {
        opacity: 0;
        transform: translateY(16px) scale(.97);
    }
}
dialog.vg-modal::backdrop {
    background: rgba(0, 15, 30, .75);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--vg-dur-modal) var(--vg-ease),
                overlay var(--vg-dur-modal) allow-discrete,
                display var(--vg-dur-modal) allow-discrete;
}
dialog.vg-modal[open]::backdrop { opacity: 1; }
@starting-style {
    dialog.vg-modal[open]::backdrop { opacity: 0; }
}

.vg-modal-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.vg-modal-title {
    margin: 0;
    /* Right padding keeps the text clear of the close button. */
    padding: 18px 64px 14px 20px;
    font-family: "Montserrat-Bold", sans-serif;
    font-size: 21.6px;
    line-height: 1.3;
    color: var(--vg-ink);
}

.vg-modal-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    /* The title row measures 18 + 14 padding + a 28px line box = 60px. Without
       this cap a 16:9 player exceeds the dialog's 90vh on a short viewport and
       overflow:hidden cuts the bottom off the video. */
    max-height: calc(90vh - 72px);
    background-color: var(--vg-navy);
}
.vg-modal-player iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.vg-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 2;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .35);
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.vg-modal-close:hover { background: rgba(0, 0, 0, .55); }
.vg-modal-close:focus { outline: none; }
.vg-modal-close:focus-visible {
    outline: 3px solid var(--vg-focus);
    outline-offset: 3px;
}


/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 768px) {
    .vg-modal-title { padding: 16px 60px 12px 16px; }
}

/* --- Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    dialog.vg-modal,
    dialog.vg-modal[open] {
        transition: none;
        transform: none;
    }
    dialog.vg-modal::backdrop,
    dialog.vg-modal[open]::backdrop { transition: none; }
}
