/* Marquee + lightbox + column/credits chrome for VoodMedia gallery blocks.
   Column counts use --vmedia-columns so Grapes canvas + public pages keep the
   chosen count without waiting for Tailwind JIT (sm/lg breakpoints used to make
   “3 columns” render as 2 until a settings remount). */

.vmedia-gallery-block .vmedia-gallery-cols {
    display: grid;
    grid-template-columns: repeat(var(--vmedia-columns, 3), minmax(0, 1fr));
}

.vmedia-gallery-block .vmedia-gallery-masonry-cols {
    column-count: var(--vmedia-columns, 3);
    column-gap: 1rem;
}

.vmedia-gallery-block .vmedia-gallery-masonry-cols.gap-2 { column-gap: 0.5rem; }
.vmedia-gallery-block .vmedia-gallery-masonry-cols.gap-4 { column-gap: 1rem; }
.vmedia-gallery-block .vmedia-gallery-masonry-cols.gap-6 { column-gap: 1.5rem; }

@media (max-width: 639px) {
    .vmedia-gallery-block .vmedia-gallery-cols[data-vmedia-columns]:not([data-vmedia-columns="1"]) {
        grid-template-columns: 1fr;
    }

    .vmedia-gallery-block .vmedia-gallery-masonry-cols[data-vmedia-columns]:not([data-vmedia-columns="1"]) {
        column-count: 1;
    }
}

.vmedia-gallery-block .gap-2 { gap: 0.5rem; }
.vmedia-gallery-block .gap-4 { gap: 1rem; }
.vmedia-gallery-block .gap-6 { gap: 1.5rem; }
.vmedia-gallery-block .rounded-xl { border-radius: 0.75rem; }
.vmedia-gallery-block .rounded-none { border-radius: 0; }
.vmedia-gallery-block .aspect-square { aspect-ratio: 1 / 1; }
.vmedia-gallery-block .aspect-video { aspect-ratio: 16 / 9; }
.vmedia-gallery-block .aspect-\[4\/3\] { aspect-ratio: 4 / 3; }
.vmedia-gallery-block .aspect-\[3\/4\] { aspect-ratio: 3 / 4; }
.vmedia-gallery-block .aspect-\[21\/9\] { aspect-ratio: 21 / 9; }
.vmedia-gallery-block .aspect-\[5\/4\] { aspect-ratio: 5 / 4; }
.vmedia-gallery-block .aspect-auto { aspect-ratio: auto; }
.vmedia-gallery-block .object-cover { object-fit: cover; }
.vmedia-gallery-block .break-inside-avoid { break-inside: avoid; }
.vmedia-gallery-block .min-w-0 { min-width: 0; }
.vmedia-gallery-block .w-full { width: 100%; }
.vmedia-gallery-block .h-auto { height: auto; }
.vmedia-gallery-block .block { display: block; }
.vmedia-gallery-block .overflow-hidden { overflow: hidden; }
.vmedia-gallery-block .m-0 { margin: 0; }
.vmedia-gallery-block .mb-2 { margin-bottom: 0.5rem; }
.vmedia-gallery-block .mb-4 { margin-bottom: 1rem; }
.vmedia-gallery-block .mb-6 { margin-bottom: 1.5rem; }
.vmedia-gallery-block .relative { position: relative; }
.vmedia-gallery-block .cursor-zoom-in { cursor: zoom-in; }

@media (min-width: 640px) {
    .vmedia-gallery-block .sm\:aspect-video { aspect-ratio: 16 / 9; }
}

.vmedia-gallery-item__caption {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--color-vp-text-2, #475569);
}

.vmedia-gallery-item__caption--below {
    margin-top: 0.5rem;
}

.vmedia-gallery-item__caption--above {
    margin-bottom: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.5rem;
    color: #fff;
    background: var(--vmedia-caption-bg, rgba(0, 0, 0, 0.72));
}

.vmedia-gallery-item__caption--overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    padding: 0.65rem 0.85rem;
    color: #fff;
    background: var(--vmedia-caption-bg, rgba(0, 0, 0, 0.82));
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.vmedia-gallery-item__frame {
    isolation: isolate;
}

.vmedia-gallery-item__media {
    position: relative;
    line-height: 0;
}

.vmedia-gallery-item.is-credits-open,
.vmedia-gallery-item:has(.vmedia-gallery-credits.is-open),
.vb-image.is-credits-open,
.vb-image:has(.vmedia-gallery-credits.is-open),
[data-vb-image].is-credits-open,
[data-vb-image]:has(.vmedia-gallery-credits.is-open) {
    z-index: 4;
    position: relative;
}

.vmedia-gallery-marquee {
    position: relative;
    overflow: hidden;
}

.vmedia-gallery-marquee__track {
    display: flex;
    width: max-content;
    gap: 1rem;
    animation: vmedia-marquee-scroll var(--vmedia-marquee-duration, 40s) linear infinite;
    animation-direction: var(--vmedia-marquee-direction, normal);
    will-change: transform;
}

.vmedia-gallery-marquee[data-vmedia-pause="1"]:hover .vmedia-gallery-marquee__track {
    animation-play-state: paused;
}

.vmedia-gallery-marquee__item {
    margin: 0;
    flex: 0 0 auto;
    width: min(22rem, 70vw);
}

.vmedia-gallery-marquee__fade {
    pointer-events: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4rem;
    z-index: 1;
}

.vmedia-gallery-marquee__fade--left {
    left: 0;
    background: linear-gradient(to right, var(--color-vp-bg, #fff), transparent);
}

.vmedia-gallery-marquee__fade--right {
    right: 0;
    background: linear-gradient(to left, var(--color-vp-bg, #fff), transparent);
}

@keyframes vmedia-marquee-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .vmedia-gallery-marquee__track {
        animation: none;
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
    }
}

.vmedia-gallery-dialog {
    padding: 0;
    border: none;
    background: transparent;
    margin: 0;
    max-width: none;
    width: 100vw;
    height: 100vh;
    overflow: visible;
}

.vmedia-gallery-dialog:not([open]) {
    display: none;
}

.vmedia-gallery-dialog[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vmedia-gallery-dialog::backdrop {
    background: rgba(15, 23, 42, 0.88);
}

.vmedia-gallery-dialog__viewport {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: clamp(0.5rem, 2vw, 1.25rem);
    box-sizing: border-box;
}

.vmedia-gallery-dialog__row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.5rem, 1.5vw, 1.25rem);
    /* Hug the image — do not force a full-bleed wide shell. */
    width: auto;
    max-width: 96vw;
    max-height: 96vh;
}

.vmedia-gallery-dialog__stage {
    flex: 0 1 auto;
    width: fit-content;
    max-width: min(calc(96vw - 6.5rem), 1480px);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    border-radius: 1rem;
    background: #0b1220;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.vmedia-gallery-dialog__media {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
    line-height: 0;
    background: #0b1220;
}

.vmedia-gallery-dialog__image {
    display: block;
    width: auto;
    height: auto;
    max-width: min(calc(96vw - 6.5rem), 1480px);
    max-height: min(88vh, calc(100dvh - 5rem));
    margin: 0;
    object-fit: contain;
    opacity: 0;
    transition: opacity 120ms ease;
}

.vmedia-gallery-dialog__caption {
    margin: 0;
    padding: 0.875rem 1.25rem;
    text-align: center;
    font-size: 0.9375rem;
    line-height: 1.5;
    font-weight: 600;
    color: #fff;
    background: var(--vmedia-caption-bg, rgba(0, 0, 0, 0.86));
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
}

.vmedia-gallery-dialog__caption[hidden] {
    display: none;
}

/* Credits: full-bleed top strip + corner “i” (no floating mega-tooltip) */
.vmedia-gallery-credits {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    line-height: normal;
}

.vmedia-gallery-credits__btn {
    pointer-events: auto;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, #fff 40%, var(--color-vp-brand-1, #3451b2));
    /* Brand accent on the “i” — small enough that contrast on the badge stays ok. */
    background: color-mix(in srgb, var(--color-vp-brand-1, #3451b2) 78%, #000);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    font-style: italic;
    font-family: ui-serif, Georgia, serif;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.vmedia-gallery-credits__btn--on-dark,
.vmedia-gallery-credits--on-dark .vmedia-gallery-credits__btn {
    border-color: rgba(255, 255, 255, 0.45);
    background: color-mix(in srgb, var(--color-vp-brand-1, #3451b2) 72%, #000);
    color: #fff;
}

.vmedia-gallery-credits__panel {
    pointer-events: auto;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    z-index: 1;
    min-width: 0;
    max-width: none;
    width: auto;
    box-sizing: border-box;
    padding: 0.5rem 2.4rem 0.5rem 0.75rem;
    border-radius: 0;
    /*
     * Dark strip + light brand tint — keeps white text/links readable on any
     * theme brand (coral, yellow, lime, …). Brand remains as a subtle hue only.
     */
    background: color-mix(in srgb, #0b1220 78%, var(--color-vp-brand-1, #3451b2));
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.4;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vmedia-gallery-credits__panel[hidden] {
    display: none !important;
}

.vmedia-gallery-credits__panel a {
    color: #fff;
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.72);
    text-underline-offset: 0.14em;
}

.vmedia-gallery-credits__panel a:hover {
    color: #fff;
    text-decoration-color: #fff;
}

.vmedia-gallery-dialog__credits {
    border-radius: 0;
    /* Shared scale: band height = button + vertical padding so “i” sits fully inside. */
    --vmedia-lb-credits-pad: clamp(0.55rem, 1.25vw + 0.3rem, 0.9rem);
    --vmedia-lb-credits-btn: clamp(1.85rem, 2.6vw + 0.65rem, 2.4rem);
    --vmedia-lb-credits-fs: clamp(0.875rem, 1.05vw + 0.5rem, 1.0625rem);
}

/* Lightbox: larger credits band + type; “i” stays inside the black strip */
.vmedia-gallery-dialog__credits .vmedia-gallery-credits__btn {
    top: var(--vmedia-lb-credits-pad);
    right: var(--vmedia-lb-credits-pad);
    width: var(--vmedia-lb-credits-btn);
    height: var(--vmedia-lb-credits-btn);
    font-size: clamp(0.9rem, 1.15vw + 0.4rem, 1.125rem);
}

.vmedia-gallery-dialog__credits .vmedia-gallery-credits__panel {
    padding: var(--vmedia-lb-credits-pad)
        calc(var(--vmedia-lb-credits-btn) + var(--vmedia-lb-credits-pad) * 2)
        var(--vmedia-lb-credits-pad)
        clamp(0.85rem, 2vw, 1.35rem);
    min-height: calc(var(--vmedia-lb-credits-btn) + var(--vmedia-lb-credits-pad) * 2);
    display: flex;
    align-items: center;
    font-size: var(--vmedia-lb-credits-fs);
    line-height: 1.45;
    font-weight: 600;
}

.vmedia-gallery-dialog__close,
.vmedia-gallery-dialog__nav {
    border: none;
    cursor: pointer;
}

.vmedia-gallery-dialog__close {
    position: absolute;
    top: clamp(0.5rem, 2vw, 1.25rem);
    right: clamp(0.5rem, 2vw, 1.25rem);
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    font-size: 1.75rem;
    line-height: 1;
    color: #fff;
}

.vmedia-gallery-dialog__nav {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    font-size: 1.75rem;
    line-height: 1;
    color: #0f172a;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

@media (min-width: 1024px) {
    .vmedia-gallery-dialog__stage {
        max-width: min(calc(94vw - 7rem), 1520px);
    }

    .vmedia-gallery-dialog__image {
        max-width: min(calc(94vw - 7rem), 1520px);
        max-height: min(92vh, calc(100dvh - 3.5rem));
    }
}

@media (max-width: 639px) {
    .vmedia-gallery-dialog__viewport {
        padding: 0.4rem;
        align-items: center;
    }

    .vmedia-gallery-dialog__row {
        width: auto;
        max-width: 100vw;
        max-height: 100dvh;
        gap: 0;
    }

    .vmedia-gallery-dialog__stage {
        width: fit-content;
        max-width: calc(100vw - 0.75rem);
        border-radius: 0.75rem;
    }

    .vmedia-gallery-dialog__image {
        max-width: calc(100vw - 0.75rem);
        max-height: calc(100dvh - 7.5rem);
    }

    .vmedia-gallery-dialog__caption {
        padding: 0.7rem 0.9rem;
        font-size: 0.875rem;
    }

    .vmedia-gallery-dialog__nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        z-index: 3;
        width: 2.4rem;
        height: 2.4rem;
        font-size: 1.35rem;
        background: rgba(255, 255, 255, 0.92);
    }

    .vmedia-gallery-dialog__nav[data-vmedia-gallery-prev] {
        left: 0.25rem;
    }

    .vmedia-gallery-dialog__nav[data-vmedia-gallery-next] {
        right: 0.25rem;
    }

    .vmedia-gallery-dialog__close {
        top: 0.4rem;
        right: 0.4rem;
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.4rem;
    }

    .vmedia-gallery-credits__btn {
        width: 1.35rem;
        height: 1.35rem;
        top: 0.4rem;
        right: 0.4rem;
    }

    .vmedia-gallery-dialog__credits {
        --vmedia-lb-credits-pad: 0.5rem;
        --vmedia-lb-credits-btn: 1.9rem;
        --vmedia-lb-credits-fs: 0.8125rem;
    }

    .vmedia-gallery-dialog__credits .vmedia-gallery-credits__btn {
        width: var(--vmedia-lb-credits-btn);
        height: var(--vmedia-lb-credits-btn);
        font-size: 0.95rem;
        top: var(--vmedia-lb-credits-pad);
        right: var(--vmedia-lb-credits-pad);
    }

    .vmedia-gallery-dialog__credits .vmedia-gallery-credits__panel {
        padding: var(--vmedia-lb-credits-pad)
            calc(var(--vmedia-lb-credits-btn) + var(--vmedia-lb-credits-pad) * 2)
            var(--vmedia-lb-credits-pad)
            0.7rem;
        min-height: calc(var(--vmedia-lb-credits-btn) + var(--vmedia-lb-credits-pad) * 2);
        font-size: var(--vmedia-lb-credits-fs);
    }

    .vmedia-gallery-credits__panel {
        padding: 0.4rem 2.1rem 0.4rem 0.55rem;
        font-size: 0.7rem;
    }
}
