/* =========================================================
   Galería: carrusel continuo + visor (lightbox) con zoom
   Usado por index.html junto con js/gallery.js
   ========================================================= */

:root {
    --g-navy: #0a183d;
    --g-pink: #fc0254;
    --g-item-h: clamp(200px, 24vw, 380px);
    --g-gap: clamp(10px, 1.2vw, 20px);
    --g-side: clamp(16px, 4vw, 72px);
}

/* ---------- Ancho útil de la página en pantallas grandes ---------- */

@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

@media (min-width: 1700px) {
    .container {
        max-width: 1560px;
    }
}

/* ---------- Bloque de galería a todo lo ancho ---------- */

.gallery-wide {
    width: 100%;
    padding: 0 0 1em;
}

.gallery-heading {
    margin: 1.6em var(--g-side) 0.9em;
    font-size: 1.15rem;
}

.gallery-sub {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0.15em 0.6em;
    border-radius: 999px;
    background: var(--g-pink);
    color: #fff;
    font-size: 0.75em;
    font-weight: 600;
    vertical-align: middle;
}

/* "Para recordar": fila amplia con proporción fija, sin alturas rígidas */
.gallery-wide .article_gallery {
    max-width: 1680px;
    margin: 0 auto;
    padding: 0 var(--g-side);
    gap: var(--g-gap);
}

.gallery-wide .article_gallery figure {
    margin: 0;
}

.gallery-wide .img_gallery {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    padding: 0;
    border-radius: 10px;
}

/* ---------- Botón-imagen (cursor y foco) ---------- */

.gallery-item {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.gallery-item img {
    display: block;
    transition: transform 0.45s ease, filter 0.45s ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
    transform: scale(1.04);
    filter: brightness(1.05);
}

.gallery-item:focus-visible {
    outline: 3px solid var(--g-pink);
    outline-offset: 3px;
}

/* ---------- Carrusel ---------- */

.marquee {
    position: relative;
    width: 100%;
}

.marquee-viewport {
    overflow: hidden;
    width: 100%;
    touch-action: pan-y;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--g-side), #000 calc(100% - var(--g-side)), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--g-side), #000 calc(100% - var(--g-side)), transparent 100%);
}

.marquee-viewport.is-dragging {
    cursor: grabbing;
}

.marquee-viewport.is-dragging .gallery-item {
    cursor: grabbing;
}

.marquee-track {
    display: flex;
    gap: var(--g-gap);
    width: max-content;
    margin: 0;
    padding: 0 0 0 var(--g-side);
    list-style: none;
    will-change: transform;
}

.marquee-item {
    flex: 0 0 auto;
    height: var(--g-item-h);
}

.marquee-item img {
    height: 100%;
    width: auto;
    background: #e9ecf2;
    user-select: none;
    -webkit-user-drag: none;
}

.marquee-arrow {
    position: absolute;
    top: calc(var(--g-item-h) / 2);
    z-index: 2;
    width: 48px;
    height: 48px;
    margin-top: -24px;
    border: 0;
    border-radius: 50%;
    background: rgba(10, 24, 61, 0.82);
    color: #fff;
    font-size: 32px;
    line-height: 44px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.marquee-arrow:hover,
.marquee-arrow:focus-visible {
    background: var(--g-pink);
    transform: scale(1.06);
}

.marquee-prev {
    left: calc(var(--g-side) / 2);
}

.marquee-next {
    right: calc(var(--g-side) / 2);
}

.marquee-toggle {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin: 0.9em auto 0;
    padding: 0.45em 1.1em;
    border: 1px solid #cfd5e2;
    border-radius: 999px;
    background: #fff;
    color: var(--g-navy);
    font: 500 0.9rem "Montserrat", sans-serif;
    cursor: pointer;
}

.marquee-toggle:hover,
.marquee-toggle:focus-visible {
    border-color: var(--g-pink);
    color: var(--g-pink);
}

.marquee-toggle-icon {
    width: 10px;
    height: 12px;
    border-left: 3px solid currentColor;
    border-right: 3px solid currentColor;
}

.marquee-toggle[aria-pressed="true"] .marquee-toggle-icon {
    border: 0;
    border-left: 10px solid currentColor;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 0;
}

/* ---------- Visor (lightbox) ---------- */

.lightbox {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(6, 12, 30, 0.94);
    color: #fff;
    overflow: hidden;
}

.lightbox:not([open]) {
    display: none;
}

.lightbox::backdrop {
    background: rgba(6, 12, 30, 0.6);
}

.lightbox[open] {
    animation: lb-in 0.22s ease-out;
}

@keyframes lb-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-stage {
    position: absolute;
    inset: 56px 72px 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    cursor: zoom-in;
    transition: transform 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}

.lightbox.is-zoomed .lightbox-img {
    cursor: zoom-out;
    transform: scale(var(--lb-zoom, 2.5));
    transition: transform 0.3s ease, transform-origin 0.05s linear;
}

.lightbox-btn {
    position: absolute;
    z-index: 2;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 30px;
    line-height: 46px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.lightbox-btn:hover,
.lightbox-btn:focus-visible {
    background: var(--g-pink);
    outline: none;
}

.lightbox-close {
    top: 10px;
    right: 12px;
}

.lightbox-prev,
.lightbox-next {
    top: 50%;
    margin-top: -24px;
    font-size: 38px;
    line-height: 44px;
}

.lightbox-prev {
    left: 12px;
}

.lightbox-next {
    right: 12px;
}

.lightbox-counter,
.lightbox-hint {
    position: absolute;
    left: 0;
    right: 0;
    margin: 0;
    text-align: center;
    font: 500 0.85rem "Montserrat", sans-serif;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

.lightbox-counter {
    top: 22px;
}

.lightbox-hint {
    bottom: 18px;
}

html.lightbox-open {
    overflow: hidden;
}

/* ---------- Móvil ---------- */

@media (max-width: 767px) {
    :root {
        --g-item-h: 220px;
    }
    .marquee-arrow {
        display: none;
    }
    .lightbox-stage {
        inset: 56px 8px 48px;
    }
    .lightbox-hint {
        display: none;
    }
    .lightbox-prev,
    .lightbox-next {
        top: auto;
        bottom: 8px;
        margin-top: 0;
    }
    .gallery-wide .article_gallery {
        justify-content: center;
    }
    .gallery-wide .article_gallery figure {
        max-width: 520px;
    }
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
    .gallery-item img,
    .lightbox-img,
    .lightbox[open] {
        transition: none;
        animation: none;
    }
}
