/*
  Herrera Inmobiliaria — Galería de propiedad (piloto: Mansilla3043.html)
  gallery.css: carrusel + lightbox. Reutilizable en cualquier ficha futura
  que incluya un bloque `.property-gallery[data-gallery]`.

  Arquitectura "segura por defecto" (mismo principio que .motion-enabled en
  css/animations.css): sin JS, o si property-gallery.js no llega a correr,
  las fotos se muestran todas en una secuencia simple — nunca dependen de
  JS para ser visibles. Recién cuando property-gallery.js las conecta con
  éxito agrega `.is-ready` al contenedor, y ahí el CSS pasa al carrusel de
  una sola imagen activa con controles.
*/

.property-gallery {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* ---------- Figura principal ---------- */
.property-gallery__figure {
    position: relative;
    margin: 0;
}

.property-gallery__trigger {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    cursor: default;
}

.property-gallery__image {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: var(--space-3);
    background-color: var(--color-fondo-claro);
}

.property-gallery__image:last-child {
    margin-bottom: 0;
}

.property-gallery__nav,
.property-gallery__counter,
.property-gallery__thumbs {
    display: none;
}

/* ---------- Estado activo: carrusel de una imagen ---------- */
.property-gallery.is-ready .property-gallery__figure {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background-color: var(--color-fondo-claro);
}

@media (min-width: 768px) {
    .property-gallery.is-ready .property-gallery__figure {
        aspect-ratio: 16 / 10;
    }
}

.property-gallery.is-ready .property-gallery__trigger {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

.property-gallery.is-ready .property-gallery__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin-bottom: 0;
    opacity: 0;
    transition: opacity var(--hover-duration) var(--hover-ease);
    pointer-events: none;
}

.property-gallery.is-ready .property-gallery__image[data-active] {
    opacity: 1;
    pointer-events: auto;
}

.property-gallery.is-ready .property-gallery__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: rgba(45, 44, 44, 0.55);
    color: var(--color-blanco);
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.property-gallery.is-ready .property-gallery__nav svg {
    width: 18px;
    height: 18px;
}

.property-gallery.is-ready .property-gallery__nav--prev {
    left: var(--space-3);
}

.property-gallery.is-ready .property-gallery__nav--next {
    right: var(--space-3);
}

@media (hover: hover) and (pointer: fine) {
    .property-gallery.is-ready .property-gallery__nav:hover {
        background-color: var(--color-carbon);
    }
}

.property-gallery.is-ready .property-gallery__nav:active {
    transform: translateY(-50%) scale(0.94);
}

.property-gallery.is-ready .property-gallery__counter {
    display: inline-flex;
    position: absolute;
    bottom: var(--space-3);
    right: var(--space-3);
    z-index: 2;
    padding: 4px 10px;
    font-size: var(--fs-label);
    font-weight: var(--fw-semibold);
    color: var(--color-blanco);
    background-color: rgba(45, 44, 44, 0.55);
}

/* ---------- Miniaturas ---------- */
.property-gallery.is-ready .property-gallery__thumbs {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.property-gallery__thumbs li {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.property-gallery__thumbs button {
    display: block;
    width: 72px;
    height: 54px;
    padding: 0;
    border: 2px solid transparent;
    background: none;
    cursor: pointer;
    overflow: hidden;
    opacity: 0.65;
    transition: opacity var(--transition-fast), border-color var(--transition-fast);
}

.property-gallery__thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.property-gallery__thumbs button[aria-current="true"] {
    opacity: 1;
    border-color: var(--color-verde);
}

@media (hover: hover) and (pointer: fine) {
    .property-gallery__thumbs button:hover {
        opacity: 1;
    }
}

.property-gallery__thumbs button:focus-visible {
    opacity: 1;
}

@media (min-width: 768px) {
    .property-gallery__thumbs button {
        width: 92px;
        height: 68px;
    }
}

/* ---------- Lightbox (creado por property-gallery.js) ---------- */
.property-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    background-color: rgba(20, 20, 19, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility 0s linear var(--transition-base);
}

.property-lightbox.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity var(--transition-base), visibility 0s linear 0s;
}

.property-lightbox__dialog {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.property-lightbox__image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.property-lightbox__close,
.property-lightbox__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--color-blanco);
    transition: background-color var(--transition-fast);
}

.property-lightbox__close {
    top: var(--space-4);
    right: var(--space-4);
    width: 44px;
    height: 44px;
}

.property-lightbox__close svg {
    width: 20px;
    height: 20px;
}

.property-lightbox__nav {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
}

.property-lightbox__nav svg {
    width: 22px;
    height: 22px;
}

.property-lightbox__nav--prev {
    left: var(--space-4);
}

.property-lightbox__nav--next {
    right: var(--space-4);
}

@media (hover: hover) and (pointer: fine) {
    .property-lightbox__close:hover,
    .property-lightbox__nav:hover {
        background-color: rgba(255, 255, 255, 0.25);
    }
}

.property-lightbox__counter {
    position: absolute;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--fs-small);
    font-weight: var(--fw-semibold);
    color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 599px) {
    .property-lightbox {
        padding: var(--space-3);
    }

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

    .property-lightbox__close {
        width: 40px;
        height: 40px;
        top: var(--space-3);
        right: var(--space-3);
    }
}

@media (prefers-reduced-motion: reduce) {
    .property-lightbox,
    .property-gallery.is-ready .property-gallery__image {
        transition: none;
    }
}
