/* =========================================================
   Photo Gallery — Coverflow 3D
   ========================================================= */

   .photo-gallery {
    --pg-active-size: 58%;
    --pg-side-size: 42%;
    --pg-active-max-height: 460px;
    --pg-side-max-height: 320px;
    --pg-gap: clamp(16px, 4vw, 48px);
    --pg-shadow-color: 255, 255, 255;
    --pg-radius: 18px;
    --pg-transition: 600ms cubic-bezier(0.22, 1, 0.36, 1);

    position: relative;
    width: 100%;
    height: clamp(460px, 66vw, 720px);
    margin: 0 auto;
    overflow: hidden;
    outline: none;
    background: transparent;
    perspective: 1600px;
    touch-action: pan-y;
    user-select: none;
}

.photo-gallery__track {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

/* Each photo: image on top, caption below, in column layout */
.photo-gallery__item {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    max-width: 88%;
    margin: 0;
    cursor: pointer;
    will-change: transform, opacity;
    transition:
        transform var(--pg-transition),
        opacity var(--pg-transition);
    /* default: hidden far away, will be repositioned by JS via --pg-x/--pg-scale/--pg-rot */
    transform: translate(-50%, -50%)
        translateX(var(--pg-x, 0px))
        translateZ(var(--pg-z, -200px))
        rotateY(var(--pg-rot, 0deg))
        scale(var(--pg-scale, 0.7));
    opacity: var(--pg-opacity, 0);
    z-index: var(--pg-z-index, 1);
}

.photo-gallery__item.is-active {
    cursor: default;
}

.photo-gallery__img {
    display: block;
    height: var(--pg-side-size);
    max-height: var(--pg-side-max-height);
    width: auto;
    max-width: 100%;
    object-fit: contain;
    pointer-events: none;
    border-radius: var(--pg-radius);
    transition: height var(--pg-transition), box-shadow var(--pg-transition);
    box-shadow:
        0 30px 60px -15px rgba(var(--pg-shadow-color), 0.35),
        0 12px 30px -10px rgba(0, 0, 0, 0.08);
}

.photo-gallery__item.is-active .photo-gallery__img {
    height: var(--pg-active-size);
    max-height: var(--pg-active-max-height);
    box-shadow:
        0 40px 80px -10px rgba(var(--pg-shadow-color), 0.55),
        0 16px 40px -12px rgba(0, 0, 0, 0.12);
}

/* Caption: debajo de la foto, solo visible para la foto activa */
.photo-gallery__caption {
    margin-top: 16px;
    max-width: 40ch;
    text-align: center;
    color: var(--pg-caption-color, #1f2430);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 400ms ease 150ms, transform 400ms ease 150ms;
    pointer-events: none;
}

.photo-gallery__item.is-active .photo-gallery__caption {
    opacity: 1;
    transform: translateY(0);
}

.photo-gallery__title {
    margin: 0 0 4px;
    font-size: clamp(1rem, 1.6vw, 1.35rem);
    font-weight: 600;
    line-height: 1.25;
}

.photo-gallery__description {
    margin: 0;
    font-size: clamp(0.8rem, 1.1vw, 0.95rem);
    line-height: 1.4;
    opacity: 0.75;
}

/* Navigation buttons */
.photo-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: #222;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 50;
    transition: background 200ms ease, transform 200ms ease, opacity 200ms ease;
}

.photo-gallery__nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.08);
}

.photo-gallery__nav:focus-visible {
    outline: 3px solid #4f9dff;
    outline-offset: 2px;
}

.photo-gallery__nav:disabled {
    opacity: 0.35;
    cursor: default;
    transform: translateY(-50%);
}

.photo-gallery__nav--prev { left: clamp(8px, 2vw, 24px); }
.photo-gallery__nav--next { right: clamp(8px, 2vw, 24px); }

/* Dots */
.photo-gallery__dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 50;
}

.photo-gallery__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    padding: 0;
    transition: background 200ms ease, transform 200ms ease;
}

.photo-gallery__dot.is-active {
    background: rgba(0, 0, 0, 0.75);
    transform: scale(1.3);
}

.photo-gallery__dot:focus-visible {
    outline: 2px solid #4f9dff;
    outline-offset: 2px;
}

/* Visually-hidden live region for screen readers */
.photo-gallery__sr-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* Dragging state: disable transitions on the item being dragged for 1:1 tracking */
.photo-gallery.is-dragging .photo-gallery__item {
    transition: none;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .photo-gallery__item,
    .photo-gallery__caption,
    .photo-gallery__nav,
    .photo-gallery__dot {
        transition-duration: 1ms !important;
    }
}

/* Responsive tuning */
@media (max-width: 900px) {
    .photo-gallery {
        --pg-active-size: 54%;
        --pg-side-size: 38%;
        --pg-active-max-height: 380px;
        --pg-side-max-height: 260px;
        height: clamp(420px, 82vw, 600px);
    }
}

@media (max-width: 560px) {
    .photo-gallery {
        --pg-active-size: 48%;
        --pg-side-size: 34%;
        --pg-active-max-height: 320px;
        --pg-side-max-height: 220px;
        height: clamp(400px, 100vw, 520px);
    }

    .photo-gallery__nav {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .photo-gallery__description {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}