/* =====================================================================================
   Galería de la ficha de producto (reemplaza a Fotorama). Interfaz mínima:
   escenario cuadrado con fotos deslizables (scroll-snap), dos flechas y miniaturas.
   ===================================================================================== */

.destec-galeria {
    --destec-galeria-acento: #FFB700;
    --destec-galeria-radio: 1rem;
    position: relative;
}

/* Escenario cuadrado: reserva el espacio antes de que carguen las fotos (sin saltos de diseño) */
.destec-galeria__escenario {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--destec-galeria-radio);
    overflow: hidden;
    background-color: #fff;
}

/* Franja deslizable: funciona con dedo, trackpad y rueda aunque no haya JS */
.destec-galeria__pista {
    display: flex;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.destec-galeria__pista::-webkit-scrollbar {
    display: none;
}

.destec-galeria__pista:focus-visible {
    outline: 3px solid var(--destec-galeria-acento);
    outline-offset: -3px;
    border-radius: var(--destec-galeria-radio);
}

.destec-galeria__foto {
    flex: 0 0 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}

.destec-galeria__foto img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Flechas: redondas y discretas. Con mouse aparecen al pasar por la galería o al enfocarla;
   en pantallas táctiles quedan siempre visibles */
.destec-galeria__flecha {
    position: absolute;
    top: 50%;
    width: 2.5rem;
    height: 2.5rem;
    margin-top: -1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    color: #57575A;
    background-color: rgba(255, 255, 255, .9);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    opacity: 0;
    transition: opacity .15s ease, background-color .15s ease;
}

.destec-galeria__flecha--prev {
    left: .5rem;
}

.destec-galeria__flecha--next {
    right: .5rem;
}

.destec-galeria:hover .destec-galeria__flecha,
.destec-galeria:focus-within .destec-galeria__flecha {
    opacity: 1;
}

.destec-galeria__flecha:hover {
    background-color: #fff;
    color: #000;
}

.destec-galeria__flecha:focus-visible,
.destec-galeria__miniatura:focus-visible {
    opacity: 1;
    outline: 3px solid var(--destec-galeria-acento);
    outline-offset: 2px;
}

@media (hover: none), (pointer: coarse) {
    .destec-galeria__flecha {
        opacity: 1;
    }
}

/* Miniaturas: fila deslizable; la activa lleva el borde del color de acento */
.destec-galeria__miniaturas {
    display: flex;
    gap: .5rem;
    margin-top: .5rem;
    padding: .25rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.destec-galeria__miniatura {
    flex: 0 0 auto;
    width: 4rem;
    height: 4rem;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: .5rem;
    background-color: #fff;
    opacity: .7;
    transition: opacity .15s ease, border-color .15s ease;
}

.destec-galeria__miniatura:hover,
.destec-galeria__miniatura[aria-current="true"] {
    opacity: 1;
}

.destec-galeria__miniatura[aria-current="true"] {
    border-color: var(--destec-galeria-acento);
}

.destec-galeria__miniatura img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: .25rem;
}

/* ---------------------------------------------------------------- Etapa G2 */

/* La foto del escenario se puede ampliar: cursor "acercar" con mouse */
.destec-galeria[data-destec-galeria] .destec-galeria__foto img {
    cursor: zoom-in;
}

/* Botón "Ampliar" (esquina superior derecha), visible igual que las flechas */
.destec-galeria__ampliar {
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    color: #57575A;
    background-color: rgba(255, 255, 255, .9);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    opacity: 0;
    transition: opacity .15s ease;
}

.destec-galeria:hover .destec-galeria__ampliar,
.destec-galeria:focus-within .destec-galeria__ampliar,
.destec-galeria__ampliar:focus-visible {
    opacity: 1;
}

.destec-galeria__ampliar:focus-visible {
    outline: 3px solid var(--destec-galeria-acento);
    outline-offset: 2px;
}

@media (hover: none), (pointer: coarse) {
    .destec-galeria__ampliar {
        opacity: 1;
    }
}

/* Pantalla completa (<dialog> nativo) sobre fondo blanco, como las fotos de los productos */
html.destec-galeria-abierta {
    overflow: hidden;
    /* Mantiene el espacio de la barra de scroll: la página no se corre al abrir y la foto vuelve
       exactamente a su lugar al cerrar */
    scrollbar-gutter: stable;
}

.destec-galeria__dialogo {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background-color: #fff;
    overflow: hidden;
}

/* Sin velo propio: el fondo blanco del <dialog> aparece y se va con la transición de apertura y cierre */
.destec-galeria__dialogo::backdrop {
    background-color: transparent;
}

.destec-galeria__visor {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
    cursor: zoom-in;
    /* Evita la selección de texto y el arrastre nativo mientras se arrastra la foto */
    user-select: none;
    -webkit-user-select: none;
}

.destec-galeria__visor--zoom {
    cursor: grab;
}

.destec-galeria__visor--zoom:active {
    cursor: grabbing;
}

.destec-galeria__visor-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
}

/* Zoom de a un paso (botones + −, teclas y doble clic): transición suave */
.destec-galeria__visor-img--suave {
    transition: transform .25s ease;
}

/* Botón de zoom sin más recorrido (ya está en el mínimo o en el máximo) */
.destec-galeria__boton[aria-disabled="true"] {
    opacity: .4;
    cursor: default;
}

/* Barra superior: contador, zoom y cerrar */
.destec-galeria__barra {
    position: absolute;
    top: .75rem;
    right: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    z-index: 1;
}

.destec-galeria__contador {
    padding: 0 .5rem;
    font-size: .875rem;
    color: #57575A;
}

.destec-galeria__boton {
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    color: #57575A;
    background-color: rgba(255, 255, 255, .9);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.destec-galeria__boton:hover {
    color: #000;
    background-color: #fff;
}

.destec-galeria__boton:focus-visible {
    outline: 3px solid var(--destec-galeria-acento, #FFB700);
    outline-offset: 2px;
}

.destec-galeria__ir {
    position: absolute;
    top: 50%;
    margin-top: -1.375rem;
    z-index: 1;
}

.destec-galeria__ir--prev {
    left: .75rem;
}

.destec-galeria__ir--next {
    right: .75rem;
}

/* Sin animaciones si el sistema pide reducir movimiento */
@media (prefers-reduced-motion: reduce) {
    .destec-galeria__flecha,
    .destec-galeria__miniatura,
    .destec-galeria__ampliar,
    .destec-galeria__visor-img--suave {
        transition: none;
    }
}
