/* ============================================================
   PDDH Gallery – Estilos frontend
   Todos los selectores están prefijados con .pddh-gallery
   para evitar conflictos con temas y otros plugins.
   ============================================================ */

/* ---- Contenedor principal ---- */
.pddh-gallery {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 0 0 24px;
    font-family: inherit;
    background-color: #f3f2f2;
    padding: 16px;
    -webkit-user-select: none;
       -moz-user-select: none;
            user-select: none;
}

.pddh-gallery *,
.pddh-gallery *::before,
.pddh-gallery *::after {
    box-sizing: inherit;
}

/* ---- Visor principal ---- */
.pddh-gallery__main {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
    border-radius: 4px 4px 0 0;
}

.pddh-gallery__main-track {
    position: relative;
    width: 100%;
    /* La altura se controla por la imagen activa */
}

.pddh-gallery__main-slide {
    display: none;
    width: 100%;
    line-height: 0;
}

.pddh-gallery__main-slide--active {
    display: block;
}

.pddh-gallery__main-slide img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    max-height: 520px;
    margin: 0 auto;
    background: #000;
}

/* ---- Contador ---- */
.pddh-gallery__counter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.88);
    color: #333;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    pointer-events: none;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
    line-height: 1.4;
}

/* ---- Botones de navegación (compartidos) ---- */
.pddh-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(74, 163, 199, 0.82);
    border: none;
    color: #fff;
    font-size: 16px;
    width: 36px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border-radius: 3px;
    transition: background 0.2s, opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.pddh-gallery__nav:hover {
    background: rgba(50, 130, 170, 0.95);
}

.pddh-gallery__nav:focus {
    outline: 2px solid #fff;
    outline-offset: -2px;
}

.pddh-gallery__nav span {
    display: inline-block;
    line-height: 1;
    font-size: 14px;
}

.pddh-gallery__nav--prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.pddh-gallery__nav--next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.pddh-gallery__nav.pddh-gallery__nav--hidden {
    opacity: 0.3;
    pointer-events: none;
}

/* ---- Tira de miniaturas ---- */
.pddh-gallery__thumbs-wrapper {
    position: relative;
    background: #1a1a1a;
    padding: 6px 0;
    display: flex;
    align-items: center;
    border-radius: 0 0 4px 4px;
    overflow: hidden;
}

/* Los botones de nav en la tira son más pequeños */
.pddh-gallery__thumbs-wrapper .pddh-gallery__nav {
    position: relative;
    top: auto;
    transform: none;
    height: 100%;
    min-height: 70px;
    flex-shrink: 0;
    border-radius: 0;
    background: rgba(74, 163, 199, 0.75);
    z-index: 5;
}

.pddh-gallery__thumbs-wrapper .pddh-gallery__nav:hover {
    background: rgba(50, 130, 170, 0.95);
}

/* Viewport de miniaturas (máscara) */
.pddh-gallery__thumbs-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.pddh-gallery__thumbs-track {
    display: flex;
    gap: 4px;
    padding: 4px 0;   /* sin padding horizontal — el JS calcula el ancho exacto */
    transition: transform 0.3s ease;
    will-change: transform;
}

/* ---- Miniatura individual ---- */
/* El ancho se fija vía JS para que exactamente 4 llenen el 100% del viewport */
.pddh-gallery__thumb {
    flex: 0 0 auto;
    height: 145px;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.2s, opacity 0.2s;
    opacity: 0.65;
}

.pddh-gallery__thumb:hover {
    opacity: 0.9;
    border-color: rgba(74, 163, 199, 0.7);
}

.pddh-gallery__thumb--active {
    border-color: #4aa3c7;
    opacity: 1;
}

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

/* ---- Error / vacío ---- */
.pddh-gallery-error {
    color: #c0392b;
    font-style: italic;
    padding: 12px 0;
}

/* ---- Animación de transición de slide ---- */
.pddh-gallery__main-slide {
    animation: none;
}

.pddh-gallery__main-slide--fade-in {
    animation: pddhFadeIn 0.35s ease;
}

@keyframes pddhFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .pddh-gallery__main-slide img {
        max-height: 260px;
    }

    .pddh-gallery__thumb {
        flex: 0 0 calc(33.333% - 3px);
        height: 56px;
    }

    .pddh-gallery__nav {
        width: 28px;
        font-size: 13px;
    }
}
