/* ============================================================
   Componente: Masonería Locales
   Layout masonry-like con CSS Grid + dense packing.
   Rellena izquierda→derecha (no top→bottom como CSS columns).
   Prefijo: .ch-masoneria__*
   ============================================================ */

/* ── Contenedor principal ── */
.ch-masoneria {
    padding: clamp(32px, 5vw, 64px) 0;
    width: 100%;
    box-sizing: border-box;
}

.ch-masoneria__titulo {
    font-family: 'Domaine Disp', serif;
    font-size: clamp(26px, 3vw, 36px);
    font-weight: 600;
    text-align: center;
    margin: 0 0 clamp(24px, 3vw, 40px);
    color: #1B3A2D;
    letter-spacing: -0.01em;
}

/* ── Grid (CSS Grid + dense) ── */
.ch-masoneria__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 260px;
    grid-auto-flow: dense;
    gap: 16px;
}

/* ── Item base ── */
.ch-masoneria__item {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
}

/* ── Tamaños (grid-span) ── */
.ch-masoneria__item--2x1 {
    grid-column: span 2;
}

.ch-masoneria__item--1x2 {
    grid-row: span 2;
}

.ch-masoneria__item--2x2 {
    grid-column: span 2;
    grid-row: span 2;
}

/* ============================================================
   TIPO: IMAGEN
   ============================================================ */
.ch-masoneria__item--imagen {
    background: #eee;
    line-height: 0;
}

.ch-masoneria__img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ch-masoneria__item--imagen:hover .ch-masoneria__img {
    transform: scale(1.04);
}

/* ── Leyenda (overlay con degradado) ── */
.ch-masoneria__caption {
    position: absolute;
    left: 0;
    right: 0;
    padding: clamp(14px, 2vw, 24px) clamp(16px, 2.5vw, 28px);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(13px, 1.1vw, 15px);
    line-height: 1.5;
    letter-spacing: 0.01em;
    z-index: 2;
    transition: opacity 0.35s ease;
}

/* Posición inferior (default) */
.ch-masoneria__caption--inferior {
    bottom: 0;
    padding-top: clamp(32px, 4vw, 56px);
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.72) 0%,
        rgba(0, 0, 0, 0.35) 50%,
        transparent 100%
    );
}

/* Posición superior */
.ch-masoneria__caption--superior {
    top: 0;
    padding-bottom: clamp(32px, 4vw, 56px);
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.72) 0%,
        rgba(0, 0, 0, 0.35) 50%,
        transparent 100%
    );
}

/* Modo hover: ocultar al inicio, transición suave */
.ch-masoneria__caption--hover {
    opacity: 0;
}

.ch-masoneria__item--imagen:hover .ch-masoneria__caption--hover {
    opacity: 1;
}

/* Modo siempre: visible permanente */
.ch-masoneria__caption--siempre {
    opacity: 1;
}

/* En dispositivos touch, siempre visible */
@media (hover: none) {
    .ch-masoneria__caption--hover {
        opacity: 1;
    }
}

/* ============================================================
   TIPO: TEXTO (bloque editorial)
   ============================================================ */
.ch-masoneria__item--texto {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 3vw, 48px) clamp(20px, 3vw, 40px);
}

.ch-masoneria__text-content {
    width: 100%;
}

/* Tipografía display (Domaine) */
.ch-masoneria__text-content--display {
    font-family: 'Domaine Disp', serif;
    font-size: clamp(18px, 1.8vw, 28px);
    line-height: 1.35;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Tipografía body (DM Sans) */
.ch-masoneria__text-content--body {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(14px, 1.1vw, 17px);
    line-height: 1.6;
}

/* Alineación */
.ch-masoneria__text-content--center {
    text-align: center;
}

.ch-masoneria__text-content--left {
    text-align: left;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ── Tablet grande: 3 columnas ── */
@media (max-width: 1200px) {
    .ch-masoneria__grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 240px;
    }
}

/* ── Tablet: 2 columnas ── */
@media (max-width: 768px) {
    .ch-masoneria__grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 220px;
        gap: 12px;
    }

    /* 2x2 → ocupa 2 cols (ancho completo) + 2 filas */
    /* 2x1 → ocupa 2 cols (ancho completo) */
    /* dense se encarga del rellenado */
}

/* ── Mobile: 1 columna — resetear spans de columna ── */
@media (max-width: 480px) {
    .ch-masoneria__grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 240px;
        gap: 12px;
    }

    /* Solo 1 columna disponible: span 2 cols → span 1 */
    .ch-masoneria__item--2x1,
    .ch-masoneria__item--2x2 {
        grid-column: span 1;
    }

    /* Mantener row-span para items altos */
    .ch-masoneria__item--1x2,
    .ch-masoneria__item--2x2 {
        grid-row: span 2;
    }

    .ch-masoneria__caption {
        font-size: 13px;
        padding: 12px 14px;
    }
}

/* ============================================================
   LINK: Card-link overlay (entero clickeable)
   ============================================================ */
.ch-masoneria__card-link {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    text-decoration: none;
    color: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ch-masoneria__card-link:focus-visible {
    outline: 2px solid #1B3A2D;
    outline-offset: -2px;
    border-radius: inherit;
}

/* Cursor pointer en toda la card cuando tiene link entero */
.ch-masoneria__item--has-link {
    cursor: pointer;
}

/* ============================================================
   LINK INDICATOR: Ícono / Pill
   ============================================================ */
.ch-masoneria__link-indicator {
    position: absolute;
    z-index: 4; /* sobre card-link overlay */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: opacity 0.3s ease, background-color 0.25s ease;
    pointer-events: auto;
}

/* ── Posiciones ── */
.ch-masoneria__link-indicator--top-right    { top: 12px;    right: 12px; }
.ch-masoneria__link-indicator--top-left     { top: 12px;    left: 12px;  }
.ch-masoneria__link-indicator--bottom-right { bottom: 12px; right: 12px; }
.ch-masoneria__link-indicator--bottom-left  { bottom: 12px; left: 12px;  }

/* ── Variante: Icon ── */
.ch-masoneria__link-indicator--icon {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.85);
    color: #1B3A2D;
    opacity: 0;
}

.ch-masoneria__link-icon {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.ch-masoneria__item:hover .ch-masoneria__link-indicator--icon {
    opacity: 1;
}

.ch-masoneria__link-indicator--icon:hover {
    background: rgba(255, 255, 255, 1);
}

.ch-masoneria__link-indicator--icon:focus-visible {
    opacity: 1;
    outline: 2px solid #1B3A2D;
    outline-offset: 2px;
}

/* ── Variante: Pill ── */
.ch-masoneria__link-indicator--pill {
    padding: 6px 16px;
    border-radius: 3px;
    background: rgba(27, 58, 45, 0.88);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
    opacity: 0;
}

.ch-masoneria__item:hover .ch-masoneria__link-indicator--pill {
    opacity: 1;
}

.ch-masoneria__link-indicator--pill:hover {
    background: rgba(27, 58, 45, 1);
}

.ch-masoneria__link-indicator--pill:focus-visible {
    opacity: 1;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ── Touch: indicadores siempre visibles ── */
@media (hover: none) {
    .ch-masoneria__link-indicator--icon,
    .ch-masoneria__link-indicator--pill {
        opacity: 1;
    }
}

/* ── Lightbox cursor para items sin link ── */
.ch-masoneria__item--lightbox {
    cursor: zoom-in;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.ch-masoneria-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.88);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 24px;
    box-sizing: border-box;
}

.ch-masoneria-lightbox.is-active {
    opacity: 1;
    visibility: visible;
}

.ch-masoneria-lightbox__img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ch-masoneria-lightbox.is-active .ch-masoneria-lightbox__img {
    transform: scale(1);
}

.ch-masoneria-lightbox__close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
    padding: 0;
}

.ch-masoneria-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ch-masoneria-lightbox__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ============================================================
   TIPO: VIDEO
   ============================================================ */
.ch-masoneria__item--video {
    background: #111;
    line-height: 0;
}

.ch-masoneria__video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* ── Play button (click-to-play mode) ── */
.ch-masoneria__video-play {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.ch-masoneria__video-play:hover {
    background: rgba(0, 0, 0, 0.4);
}

.ch-masoneria__video-play svg {
    width: 56px;
    height: 56px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.25s ease;
}

.ch-masoneria__video-play:hover svg {
    transform: scale(1.1);
}

.ch-masoneria__video-play:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -4px;
    border-radius: inherit;
}

/* Hide play button when playing */
.ch-masoneria__item--video.is-playing .ch-masoneria__video-play {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Cursor on click-to-play video */
.ch-masoneria__item--video.is-playing .ch-masoneria__video {
    cursor: pointer;
}

/* ── Responsive: smaller play button on mobile ── */
@media (max-width: 480px) {
    .ch-masoneria__video-play svg {
        width: 44px;
        height: 44px;
    }
}
