/* --- PREMIUM GALLERY WHEEL --- */

.gallery-wheel-container {
    width: 100%;
    margin-top: var(--space-xl);
    overflow: hidden;
    /* Hide scrollbars completely, we control X-axis */
    touch-action: pan-y;
    /* Allow vertical scroll, block horizontal for JS */
    cursor: grab;
    position: relative;
    padding: var(--space-lg) 0;
    /* Breathing room for scaling */
    user-select: none;
    -webkit-user-select: none;
}

.gallery-wheel-container:active {
    cursor: grabbing;
}

.gallery-wheel-container:focus-visible {
    outline: 3px solid rgba(91, 192, 190, 0.75);
    outline-offset: 6px;
    border-radius: var(--radius-md);
}

.gallery-wheel-container.wheel-active {
    box-shadow: 0 0 0 2px rgba(91, 192, 190, 0.18) inset;
}

.gallery-wheel-hint {
    position: absolute;
    left: 50%;
    bottom: var(--space-md);
    transform: translate(-50%, 0);
    background: rgba(15, 23, 42, 0.82);
    color: var(--clr-white);
    border: 1px solid rgba(125, 211, 209, 0.45);
    border-radius: var(--radius-full);
    padding: 10px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    z-index: 4;
    opacity: 1;
    transition: opacity 240ms ease, transform 240ms ease;
}

.gallery-wheel-hint.is-hidden {
    opacity: 0;
    transform: translate(-50%, 8px);
}

.gallery-track {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    will-change: transform;
    transform-style: preserve-3d;
    padding: 0 50%;
    /* Center the first item initially if needed, or adjust via JS */
    width: max-content;
    /* Ensure track spans all items */
    transition: opacity 220ms ease;
}

.gallery-track.is-filtering {
    opacity: 0.42;
}

/* Responsive Item Sizing */
.gallery-wheel-item {
    flex: 0 0 auto;
    height: 500px;
    width: auto;
    min-width: fit-content;
    /* FORCE container to expand to content width */
    max-width: none;
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--clr-border);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
    will-change: transform, opacity;
    box-shadow: var(--shadow-md);
}

.gallery-wheel-item img {
    height: 100%;
    width: auto;
    /* NO object-fit - let natural aspect ratio dictate width */
    display: block;
    position: relative;
    z-index: 1;
    pointer-events: none;
    user-drag: none;
    -webkit-user-drag: none;
}

/* Text Overlay */
.gallery-wheel-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: var(--space-lg);
    background: linear-gradient(to top, rgba(15, 23, 42, 0.9) 0%, rgba(15, 23, 42, 0) 100%);
    opacity: 0;
    /* Hidden by default until active/hover */
    transform: translateY(10px);
    transition: all 0.3s ease;
    text-align: left;
    z-index: 2;
}

.gallery-wheel-item.active .gallery-wheel-overlay,
.gallery-wheel-item:hover .gallery-wheel-overlay {
    opacity: 1;
    transform: translateY(0);
}

.project-title {
    color: var(--clr-white);
    font-size: 1.2rem;
    margin-bottom: 4px;
    font-weight: 600;
}

.project-category {
    color: var(--clr-teal);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.gallery-wheel-empty {
    width: min(540px, 92vw);
    margin: 0 auto;
    padding: var(--space-xl);
    border: 1px dashed rgba(148, 163, 184, 0.4);
    border-radius: var(--radius-lg);
    text-align: center;
    color: var(--clr-text-muted);
    background: rgba(248, 250, 252, 0.5);
}

/* --- GALLERY LIGHTBOX --- */
.gallery-lightbox {
    border: 0;
    border-radius: 18px;
    width: min(940px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    padding: clamp(14px, 2.2vw, 22px);
    background: rgba(8, 18, 42, 0.96);
    color: var(--clr-white);
    box-shadow: 0 28px 56px -28px rgba(2, 6, 23, 0.95);
    overflow: hidden;
}

.gallery-lightbox::backdrop {
    background: rgba(2, 6, 23, 0.78);
    backdrop-filter: blur(6px);
}

.gallery-lightbox-inner {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 12px;
    height: 100%;
}

.gallery-lightbox-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.7);
    color: var(--clr-white);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gallery-lightbox-close:hover,
.gallery-lightbox-close:focus-visible {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(125, 211, 209, 0.65);
}

.gallery-lightbox-media {
    display: grid;
    place-items: center;
    min-height: 0;
}

.gallery-lightbox-media img {
    width: auto;
    max-width: 100%;
    max-height: min(74vh, 720px);
    object-fit: contain;
    border-radius: 12px;
}

.gallery-lightbox-caption {
    display: grid;
    gap: 4px;
}

.gallery-lightbox-title {
    margin: 0;
    font-size: clamp(1.1rem, 2.4vw, 1.4rem);
    color: var(--clr-white);
}

.gallery-lightbox-category {
    margin: 0;
    font-size: 0.86rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--clr-teal-light);
}

@media (max-width: 1120px) {
    .gallery-wheel-container {
        padding: var(--space-md) 0;
    }

    .gallery-track {
        gap: var(--space-sm);
        padding: 0 50%;
    }

    .gallery-wheel-item {
        width: clamp(220px, 72vw, 360px);
        min-width: clamp(220px, 72vw, 360px);
        height: clamp(240px, 58vh, 420px);
        border-radius: var(--radius-md);
    }

    .gallery-wheel-item::before {
        content: '';
        position: absolute;
        inset: 0;
        background-image: var(--gallery-bg-image);
        background-size: cover;
        background-position: center;
        transform: scale(1.08);
        filter: blur(16px) saturate(1.02);
        opacity: 0.88;
        z-index: 0;
        pointer-events: none;
    }

    .gallery-wheel-item img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        background: transparent;
    }

    .gallery-wheel-item.is-portrait {
        width: clamp(180px, 54vw, 280px);
        min-width: clamp(180px, 54vw, 280px);
        height: auto;
        aspect-ratio: 2 / 3;
    }

    .gallery-wheel-item.is-portrait img {
        object-fit: contain;
        object-position: 50% 50%;
        background: transparent;
    }

    .gallery-wheel-overlay {
        padding: var(--space-md) var(--space-sm);
    }

    .project-title {
        font-size: 1rem;
    }

    .project-category {
        font-size: 0.78rem;
    }

    .gallery-wheel-hint {
        bottom: var(--space-sm);
        font-size: 0.78rem;
        padding: 9px 14px;
    }
}

@media (max-width: 768px) {
    .gallery-lightbox {
        position: fixed;
        inset: 0;
        margin: 0;
        width: 100vw;
        max-width: none;
        height: 100vh;
        max-height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        padding: 0;
        background: rgba(2, 6, 23, 0.98);
    }

    .gallery-lightbox-inner {
        height: 100dvh;
        gap: 0;
    }

    .gallery-lightbox-media {
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    }

    .gallery-lightbox-media img {
        width: 100%;
        height: 100%;
        max-height: none;
        object-position: center;
        border-radius: 0;
    }

    .gallery-lightbox-close {
        top: calc(env(safe-area-inset-top, 0px) + 12px);
        right: 12px;
        width: 42px;
        height: 42px;
        z-index: 2;
        background: rgba(15, 23, 42, 0.74);
        backdrop-filter: blur(4px);
    }

    .gallery-lightbox-caption {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
        background: linear-gradient(180deg, rgba(2, 6, 23, 0) 0%, rgba(2, 6, 23, 0.72) 30%, rgba(2, 6, 23, 0.95) 100%);
        backdrop-filter: blur(2px);
    }

    .gallery-lightbox-title {
        font-size: clamp(1.6rem, 5.6vw, 2rem);
        line-height: 1.08;
        letter-spacing: -0.02em;
        text-shadow: 0 2px 14px rgba(2, 6, 23, 0.55);
    }

    .gallery-lightbox-category {
        font-size: 0.78rem;
        letter-spacing: 0.12em;
        text-shadow: 0 1px 8px rgba(2, 6, 23, 0.52);
    }
}

@media (max-width: 520px) {
    .gallery-wheel-item {
        width: clamp(200px, 78vw, 320px);
        min-width: clamp(200px, 78vw, 320px);
        height: clamp(220px, 56vh, 360px);
    }

    .gallery-wheel-item.is-portrait {
        width: clamp(170px, 60vw, 230px);
        min-width: clamp(170px, 60vw, 230px);
    }

    .gallery-wheel-hint {
        font-size: 0.74rem;
        padding: 8px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-wheel-hint {
        transition: none;
    }
}
