/**
 * Galería Masonry Lafase – Estilos Premium
 *
 * @package GaleriaMasonryLafase
 * @project Lafase
 * @author  Jaicer
 * @version 1.0.0
 */

/* ══════════════════════════════════════════════════════════════════
   TOKENS
══════════════════════════════════════════════════════════════════ */
:root {
    --gml-accent: #1a3d6e;
    --gml-accent-light: #2a5fa8;
    --gml-gold: #c9a84c;
    --gml-white: #ffffff;
    --gml-dark: #0a0a12;
    --gml-overlay: rgba(10, 10, 18, 0.92);
    --gml-radius: 0px;         /* sin bordes redondeados */
    --gml-radius-lg: 0px;
    --gml-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    --gml-shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.32);
    --gml-gap: 8px;            /* gap reducido */
    --gml-duration: 0.35s;
    --gml-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --gml-font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ══════════════════════════════════════════════════════════════════
   SCROLLBAR — evita el salto de layout al abrir el lightbox
   scrollbar-gutter:stable reserva siempre el espacio de la scrollbar,
   así overflow:hidden no desplaza el contenido.
══════════════════════════════════════════════════════════════════ */
html {
    scrollbar-gutter: stable;
}

/* ══════════════════════════════════════════════════════════════════
   SECCIÓN WRAPPER
══════════════════════════════════════════════════════════════════ */
.gml-section {
    padding:  0;
    background: transparent;   /* sin fondo gris */
    margin-bottom: 80px;       /* más margin inferior */
    font-family: var(--gml-font);
}

/* ── Header / Título ─────────────────────────────────────────── */
.gml-header {
    text-align: center;
    margin-bottom: 48px;
    padding: 0 20px;
}

.gml-title {
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 700;
    color: var(--gml-accent);
    letter-spacing: -0.02em;
    margin: 0 0 14px;
    line-height: 1.2;
}

.gml-title-line {
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--gml-accent), var(--gml-gold));
    border-radius: 2px;
    margin: 0 auto;
}

/* ══════════════════════════════════════════════════════════════════
   GRID MASONRY – posicionamiento JS absoluto
══════════════════════════════════════════════════════════════════ */
.gml-masonry {
    position: relative;    /* contenedor para items absolutos */
    padding: 0 20px;
    max-width: 1320px;
    margin: 0 auto;
    /* altura la fija el JS = columna más alta */

    /* Oculto hasta que el masonry JS termine de posicionar */
    opacity: 0;
    transition: opacity 0.35s ease;
}

/* Se añade por JS cuando runMasonry() completa */
.gml-masonry.gml--ready {
    opacity: 1;
}

/* ── Item: posición absoluta, JS asigna top/left/width ─────────── */
.gml-item {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    /* top / left / width / height los pone el JS */
}

/* ── Trigger (botón raíz) ───────────────────────────────────── */
.gml-trigger {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    height: 100%;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

.gml-trigger:focus-visible {
    outline: 3px solid var(--gml-accent-light);
    outline-offset: 3px;
    border-radius: var(--gml-radius);
}

/* ── Thumb wrap ─────────────────────────────────────────────── */
.gml-thumb-wrap {
    position: relative;
    overflow: hidden;
    border-radius: var(--gml-radius);  /* 0px = sin bordes */
    background: transparent;           /* sin fondo gris */
    box-shadow: none;
    flex: 1;              /* crece para llenar toda la celda asignada por JS */
    transition: box-shadow var(--gml-duration) var(--gml-ease),
        transform var(--gml-duration) var(--gml-ease);
}

.gml-trigger:hover .gml-thumb-wrap,
.gml-trigger:focus-visible .gml-thumb-wrap {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--gml-shadow-hover);
}

/* ── Thumbnail image ────────────────────────────────────────── */
.gml-thumb {
    display: block;
    width: 100%;
    height: 100%;          /* llena la celda asignada por el masonry JS */
    object-fit: cover;     /* recorta proporcionalmente sin distorsión */
    transition: transform var(--gml-duration) var(--gml-ease),
        filter var(--gml-duration) var(--gml-ease);
    will-change: transform;
    vertical-align: bottom;
}

.gml-trigger:hover .gml-thumb,
.gml-trigger:focus-visible .gml-thumb {
    transform: scale(1.06);
    filter: brightness(0.88);
}

/* ── Overlay ────────────────────────────────────────────────── */
.gml-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 18, 0);
    transition: background var(--gml-duration) var(--gml-ease);
    border-radius: inherit;
}

.gml-trigger:hover .gml-overlay,
.gml-trigger:focus-visible .gml-overlay {
    background: rgba(10, 10, 18, 0.38);
}

/* ── Icono zoom (imagen) ─────────────────────────────────────── */
.gml-icon-zoom {
    width: 44px;
    height: 44px;
    fill: white;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity var(--gml-duration) var(--gml-ease),
        transform var(--gml-duration) var(--gml-ease);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.gml-trigger:hover .gml-icon-zoom,
.gml-trigger:focus-visible .gml-icon-zoom {
    opacity: 1;
    transform: scale(1);
}

/* ── Video overlay ──────────────────────────────────────────── */
.gml-overlay--video {
    background: rgba(10, 10, 18, 0.22);
    flex-direction: column;
    gap: 10px;
}

.gml-play-btn {
    width: 72px;
    height: 72px;
    transition: transform var(--gml-duration) var(--gml-ease),
        filter var(--gml-duration) var(--gml-ease);
    filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.5));
}

.gml-trigger:hover .gml-play-btn {
    transform: scale(1.12);
    filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.6));
}

/* ── Badge ──────────────────────────────────────────────────── */
.gml-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.gml-badge--video {
    background: rgba(201, 168, 76, 0.88);
    color: var(--gml-dark);
}

/* MP4 sin miniatura: caja oscura con icono play centrado */
.gml-thumb-wrap--novideo {
    background: linear-gradient(135deg, #0d1b2a 0%, #1a3d6e 100%);
    aspect-ratio: 16 / 9;
    min-height: 160px;
}

.gml-thumb-wrap--novideo .gml-overlay--video {
    background: transparent;
}

/* ── Caption bajo imagen ────────────────────────────────────── */
.gml-caption {
    font-size: 0.78rem;
    color: #555;
    margin: 8px 4px 0;
    line-height: 1.4;
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════
   LIGHTBOX
══════════════════════════════════════════════════════════════════ */
.gml-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--gml-font);
}

.gml-lightbox[hidden] {
    display: none !important;
}

/* ── Backdrop ─────────────────────────────────────────────────── */
.gml-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: var(--gml-overlay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: gmlFadeIn var(--gml-duration) var(--gml-ease) forwards;
}

/* ── Container ──────────────────────────────────────────────── */
.gml-lightbox__container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 16px 80px;
    box-sizing: border-box;
}

/* ── Barra superior ─────────────────────────────────────────── */
.gml-lightbox__bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
}

.gml-lightbox__counter {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    letter-spacing: 0.05em;
}

.gml-lightbox__close {
    width: 42px;
    height: 42px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--gml-duration) var(--gml-ease),
        transform var(--gml-duration) var(--gml-ease);
    padding: 0;
}

.gml-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.gml-lightbox__close svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* ── Stage (imagen / video) ─────────────────────────────────── */
/* position:absolute con inset fijo → el stage siempre ocupa el mismo
   espacio, la imagen no empuja el layout al cargarse (sin salto). */
.gml-lightbox__stage {
    position: absolute;
    inset: 56px 80px 56px 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: gmlZoomIn var(--gml-duration) var(--gml-ease) forwards;
    overflow: hidden;
}

.gml-lightbox__stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--gml-radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    display: block;
    /* fade-in controlado por clase, no por JS inline */
    transition: opacity 0.28s ease;
}

/* ── Video iframe / mp4 ─────────────────────────────────────── */
.gml-lightbox__video-wrap {
    width: 100%;
    max-width: 960px;
    aspect-ratio: 16 / 9;
    border-radius: var(--gml-radius);
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    background: #000;
}

.gml-lightbox__video-wrap iframe,
.gml-lightbox__video-wrap video {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── Navegación ─────────────────────────────────────────────── */
.gml-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--gml-duration) var(--gml-ease),
        transform var(--gml-duration) var(--gml-ease);
    padding: 0;
    z-index: 2;
}

.gml-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.26);
}

.gml-lightbox__prev {
    left: 16px;
}

.gml-lightbox__prev:hover {
    transform: translateY(-50%) translateX(-2px);
}

.gml-lightbox__next {
    right: 16px;
}

.gml-lightbox__next:hover {
    transform: translateY(-50%) translateX(2px);
}

.gml-lightbox__nav svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* ── Caption lightbox ───────────────────────────────────────── */
.gml-lightbox__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 80px;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
    min-height: 56px;
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════
   ANIMACIONES
══════════════════════════════════════════════════════════════════ */
@keyframes gmlFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes gmlZoomIn {
    from {
        opacity: 0;
        transform: scale(0.93);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes gmlZoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.93);
    }
}

.gml-lightbox.is-closing .gml-lightbox__backdrop {
    animation: gmlFadeIn var(--gml-duration) var(--gml-ease) reverse forwards;
}

.gml-lightbox.is-closing .gml-lightbox__stage {
    animation: gmlZoomOut var(--gml-duration) var(--gml-ease) forwards;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .gml-masonry {
        column-count: 2;
    }
}

@media (max-width: 640px) {
    /* Responsive – el JS elige columnas según ancho */
    .gml-section {
        padding: 48px 0 0;
        margin-bottom: 48px;
    }

    .gml-lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .gml-lightbox__prev {
        left: 8px;
    }

    .gml-lightbox__next {
        right: 8px;
    }

    .gml-lightbox__caption {
        padding: 20px 56px;
        font-size: 0.82rem;
    }

    .gml-lightbox__container {
        padding: 50px 8px 70px;
    }
}

/* ── Sin galería (estado vacío) ──────────────────────────────── */
.gml-section:empty {
    display: none;
}

/* ══════════════════════════════════════════════════════════════════
   MODO FULLVIEW: imagen completa + carrusel de miniaturas
══════════════════════════════════════════════════════════════════ */

.gml-section--fullview {
    padding: 72px 0 80px;
    background: transparent;
    margin-bottom: 80px;
    font-family: var(--gml-font);
}

/* Contenedor principal fullview */
.gml-fv {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ── Imagen principal ────────────────────────────────────── */
.gml-fv__main {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
    /* Proporción 16:9 como base; la imagen la puede alterar */
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.gml-fv__img {
    display: block;
    width: 100%;
    max-height: 78vh;
    object-fit: contain;   /* muestra la imagen completa sin recortar */
    transition: opacity 0.28s ease;
}

.gml-fv__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
    color: rgba(255,255,255,0.9);
    font-size: 0.88rem;
    font-style: italic;
    min-height: 44px;
    pointer-events: none;
}

/* ── Flechas de navegación ────────────────────────────── */
.gml-fv__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(255,255,255,0.14);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--gml-duration) var(--gml-ease),
                transform var(--gml-duration) var(--gml-ease);
    padding: 0;
    z-index: 2;
}

.gml-fv__nav svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.gml-fv__prev { left: 12px; }
.gml-fv__next { right: 12px; }

.gml-fv__nav:hover {
    background: rgba(255,255,255,0.28);
}
.gml-fv__prev:hover { transform: translateY(-50%) translateX(-2px); }
.gml-fv__next:hover { transform: translateY(-50%) translateX(2px); }

/* ── Strip de miniaturas ─────────────────────────────── */
.gml-fv__strip-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.25) transparent;
}

.gml-fv__strip-wrap::-webkit-scrollbar {
    height: 4px;
}
.gml-fv__strip-wrap::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.25);
    border-radius: 2px;
}

.gml-fv__strip {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    /* no wrap: scroll horizontal */
    flex-wrap: nowrap;
}

.gml-fv__thumb {
    flex: 0 0 auto;
    width: 100px;
    height: 70px;
    padding: 0;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    overflow: hidden;
    border-radius: 0;
    transition: border-color var(--gml-duration) var(--gml-ease),
                opacity var(--gml-duration) var(--gml-ease);
    opacity: 0.55;
}

.gml-fv__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.gml-fv__thumb:hover {
    opacity: 0.85;
}

.gml-fv__thumb--active {
    border-color: var(--gml-accent);
    opacity: 1;
}

/* Responsive fullview */
@media (max-width: 640px) {
    .gml-fv__main  { min-height: 220px; }
    .gml-fv__img   { max-height: 55vh; }
    .gml-fv__thumb { width: 72px; height: 52px; }
    .gml-fv__nav   { width: 36px; height: 36px; }
    .gml-fv__prev  { left: 6px; }
    .gml-fv__next  { right: 6px; }
}