/* ==========================================================
   PAOREEL STUDIOS V3
   GALLERY
========================================================== */

/* Stack Boundary Fix: Establishes a clean stacking context for GSAP pinning */
.gallery-section {
    position: relative;
    z-index: 2;
    background: transparent;
    width: 100%;
    overflow: hidden; /* Allows pin-spacer to measure accurate heights */
}

/* Disable inner card scale recalculations while actively dragging */
.gallery-section.is-dragging .gallery-card,
.gallery-section.is-dragging .gallery-image img {
    transform: none !important;
    cursor: grabbing !important;
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    z-index: 0;
    pointer-events: none;
}

.gallery-intro,
.gallery-viewport {
    position: relative;
    z-index: 2;
}

/* Ensure GSAP Pin-Spacer matches section layering */
.pin-spacer {
    z-index: 2 !important;
}

/* ==========================================================
   GALLERY INTRO
========================================================== */

.gallery-intro {
    position: relative;
    z-index: 1; /* Kept strictly under gallery-viewport layer when unrolling */
    display: grid;
    grid-template-columns: 1.4fr .9fr;
    align-items: end;
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto 2.5rem;
    padding: 0 var(--content-padding, 2rem);
    perspective: 1000px; /* Required for intro title 3D rotateX transforms */
}

/* ==========================================================
   LEFT
========================================================== */

.gallery-intro-left {
    max-width: 620px;
}

.gallery-copy {
    font-size: 1.05rem;
    line-height: 2;
    letter-spacing: .01em;
    color: var(--color-light-text, #ccc);
}

/* ==========================================================
   RIGHT
========================================================== */

.gallery-intro-right {
    justify-self: end;
    text-align: left;
}

.gallery-title {
    font-size: clamp(2.8rem, 5vw, 5rem);
    font-weight: 300;
    line-height: 1.08;
    letter-spacing: -.05em;
}

.gallery-title .word {
    display: inline-block;
    white-space: nowrap;
}

.gallery-title .word span {
    display: inline-block;
    will-change: transform, opacity;
    transform-style: preserve-3d;
}

/* ==========================================================
   VIEWPORT
========================================================== */

.gallery-viewport {
    position: relative;
    z-index: 3;
    width: 100%;
    height: 580px; /* Increased from 480px to accommodate taller cards + captions */
    overflow: hidden;
    display: flex;
    align-items: center;
    cursor: grab;
    user-select: none;
    touch-action: pan-y;
    padding-left: 5vw;
}

.gallery-marquee {
    display: flex;
    flex-wrap: nowrap;
    width: max-content;
    will-change: transform;
}

.gallery-viewport:active {
    cursor: grabbing;
}

/* ==========================================================
   TRACK
========================================================== */

.gallery-track {
    display: flex;
    flex-wrap: nowrap;
    gap: 24px; /* Increased from 16px to match JS gap variable */
    flex: none;
    margin-right: 24px;
}

.gallery-track,
.gallery-track-clone {
    display: flex;
    flex-wrap: nowrap;
    gap: 24px; /* Increased from 16px to match JS gap variable */
    flex: none;
}

/* ==========================================================
   ITEM
========================================================== */

.gallery-item {
    position: relative;
    flex: 0 0 400px !important; /* Increased from 320px to match JS itemWidth */
    width: 400px !important;
    max-width: 400px;
    height: 550px; /* Increased total item container height */
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: grab;
    /* Allows GSAP to stack items neatly without z-index collisions */
    transform-origin: center center;
}

/* ==========================================================
   CARD
========================================================== */

.gallery-card {
    position: relative;
    width: 100%;
    height: 510px; /* Increased card height (leaves ~40px for caption) */
    overflow: hidden;
    border-radius: 12px;
    background: #222;
    box-shadow: -8px 8px 25px rgba(0, 0, 0, .60);
    transform-origin: center center;
    will-change: transform, filter;
    /* Smooth transition for hover/active scale on the card */
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), 
                box-shadow 0.3s cubic-bezier(0.25, 1, 0.5, 1),
                filter 0.3s ease;
}

/* Hover: Depresses/minimizes the card and changes cursor */
.gallery-item:hover .gallery-card {
    cursor: grab;
    transform: scale(0.95);
    filter: brightness(0.95);
    box-shadow: -4px 4px 15px rgba(0, 0, 0, .40);
}

/* Active / Click: Depresses further when held down */
.gallery-item:active .gallery-card {
    cursor: grabbing;
    transform: scale(0.92);
}

/* ==========================================================
   IMAGE
========================================================== */

.gallery-image {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

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

/* ==========================================================
   CAPTION
========================================================== */

.gallery-item span {
    display: block;
    margin-top: 10px;
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #888;
}