/* ============================================================
   PEARL RIVERA — Gallery Page
   ============================================================ */

/* ---- Page shell ---- */
.gallery-page {
    position: fixed;
    inset: 0;
    overflow: hidden;
    overscroll-behavior: contain;
    background: #fff;
    /* touch-action: pan-y lets the browser know this surface only needs
       vertical scroll — it disables double-tap zoom and horizontal pan
       gestures that would otherwise fight the scroll on mobile. */
    touch-action: pan-y;
    /* Safe-area aware: the page sits inside a fixed inset:0 box, but on
       iOS the safe-area insets can still nibble the layout on notched
       devices when the gallery swaps viewport heights. */
    height: 100dvh;
    height: 100vh;
}

.gallery-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: bottom;
    z-index: 1;
    pointer-events: none;
}

.gallery-wave {
    position: absolute;
    bottom: 250px;
    left: 0;
    width: 100%;
    height: auto;
    z-index: 2;
    pointer-events: none;
}

/* ---- Content area ---- */
.gallery-content {
    position: relative;
    height: calc(100dvh - 200px);
    margin: 24px var(--container-padding) 0 var(--container-padding);
    z-index: 3;
    display: flex;
    overflow: hidden;
}

/* ---- Sidebar ---- */
.gallery-sidebar {
    flex-shrink: 0;
    width: 420px;
    height: calc(100dvh - 200px);
    align-self: center;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 var(--space-8) 0 0;
    margin-right: var(--space-8);
    gap: var(--space-8);
    scrollbar-width: thin;
    scrollbar-color: var(--pr-3) transparent;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.gallery-sidebar::-webkit-scrollbar {
    width: 4px;
}

.gallery-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-sidebar::-webkit-scrollbar-thumb {
    background: var(--pr-3);
    border-radius: 999px;
}

.gallery-sidebar__top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: 0;
}

.gallery-sidebar__label {
    font-size: 18px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--pr-5);
    line-height: 1;
    text-align: center;
}

.gallery-sidebar__indicator {
    width: 1px;
    height: 80px;
    margin-left: 24px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--pr-5) 20%,
        var(--pr-5) 80%,
        transparent 100%
    );
}

/* ---- Navigation / Tabs ---- */
.gallery-nav {
    flex: 1;
}

.gallery-main__label {
    display: none;
}

.gallery-nav__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 48px;
}

.gallery-nav__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-family-domaine);
    font-size: 36px;
    font-weight: 400;
    text-transform: capitalize;
    color: var(--pr-5);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: 0.5;
    transition:
        opacity var(--transition-base),
        color var(--transition-base);
    line-height: 1;
}

.gallery-nav__item:hover {
    opacity: 0.75;
}

.gallery-nav__item--active {
    opacity: 1;
    color: var(--pr-3);
}

.gallery-nav__pearl {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.gallery-nav__pearl img {
    width: 48px;
    height: 48px;
}

.gallery-nav__text {
    font-size: inherit;
    position: relative;
    z-index: 1;
}

.gallery-nav__item--active .gallery-nav__text {
    padding-left: 56px;
}

/* ---- Gallery main ---- */
.gallery-main {
    flex: 1;
    /* min-height: 0 lets the flex child shrink past its content height
       — without this, long grid content pushes the parent and the
       scroll container fails to register a scrollable area on iOS. */
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    /* Contain the scroll: prevent the page shell from bouncing when
       the user reaches the top/bottom edge of the grid. */
    overscroll-behavior-y: contain;
    /* Legacy iOS momentum. Modern Safari (15+) ignores this and uses
       native momentum, but it's still needed on older WebViews. */
    -webkit-overflow-scrolling: touch;
    padding-right: var(--container-padding);
    padding-bottom: var(--space-6);
    scrollbar-width: thin;
    scrollbar-color: var(--pr-3) transparent;
    /* touch-action: pan-y so vertical drag always scrolls the grid
       instead of being intercepted by ancestor touch handlers. */
    touch-action: pan-y;
}

.gallery-main::-webkit-scrollbar {
    width: 4px;
}

.gallery-main::-webkit-scrollbar-track {
    background: transparent;
}

.gallery-main::-webkit-scrollbar-thumb {
    background: var(--pr-3);
    border-radius: 999px;
}

/* ---- Gallery Grid ---- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

/* ---- Gallery Card ---- */
.gallery-card {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: none;
    padding: 0;
    background: var(--pr-2);
}

.gallery-card.is-visible {
    animation: galleryCardFadeIn 0.35s ease both;
}

@keyframes galleryCardFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-card:not(.is-visible) {
    display: none;
}

.gallery-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.gallery-card__caption {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    max-width: calc(100% - 24px);
    color: #fff;
    font-family: var(--font-family-domaine);
    line-height: 1.15;
    text-align: left;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.gallery-card__caption-name {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: capitalize;
}

.gallery-card__caption-floor {
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}

.gallery-card__zoom {
    position: absolute;
    inset: 0;
    background: rgba(14, 139, 139, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.gallery-card__zoom svg {
    width: 36px;
    height: 36px;
    color: #fff;
}

.gallery-card:hover .gallery-card__img {
    transform: scale(1.05);
}

.gallery-card:hover .gallery-card__zoom {
    opacity: 1;
}

.gallery-card:focus-visible {
    outline: 2px solid var(--pr-3);
    outline-offset: 3px;
}

/* ---- Lightbox ---- */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px) saturate(1.4);
    -webkit-backdrop-filter: blur(4px) saturate(1.4);
}

.gallery-lightbox::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 30%,
        rgba(0, 0, 0, 0.25) 70%,
        rgba(0, 0, 0, 0.7) 100%
    );
    pointer-events: none;
    z-index: 0;
}

.gallery-lightbox[hidden] {
    display: none;
}

.gallery-lightbox__backdrop {
    position: absolute;
    inset: 0;
    z-index: -1;
}

.gallery-lightbox__close {
    position: absolute;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-base);
}

.gallery-lightbox__close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.gallery-lightbox__close svg {
    width: 20px;
    height: 20px;
}

.gallery-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: var(--pr-5);
    color: var(--pr-0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-base);
}

.gallery-lightbox__nav:hover {
    opacity: 0.8;
}

.gallery-lightbox__nav.is-disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.gallery-lightbox__nav svg {
    width: 20px;
    height: 20px;
    color: var(--pr-0);
    stroke: var(--pr-0);
}

.gallery-lightbox__nav--prev {
    left: var(--space-6);
}

.gallery-lightbox__nav--next {
    right: var(--space-6);
}

.gallery-lightbox__img-wrap {
    position: relative;
    z-index: 5;
    max-width: min(1200px, 90vw);
    max-height: calc(100dvh - 180px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
}

.gallery-lightbox__img {
    max-width: 100%;
    max-height: calc(100dvh - 240px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox__caption {
    flex-shrink: 0;
    max-width: 100%;
    padding: 4px 8px;
    color: #fff;
    font-family: var(--font-family-domaine);
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.2;
    text-align: center;
    text-transform: capitalize;
    pointer-events: none;
}

.gallery-lightbox__caption:empty {
    display: none;
}

.gallery-lightbox__floors {
    position: absolute;
    left: 50%;
    bottom: var(--space-3);
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: min(1200px, 90vw);
}

.gallery-lightbox__floors[hidden] {
    display: none;
}

.gallery-lightbox__floor-pill {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-family-body);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease;
}

.gallery-lightbox__floor-pill:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.gallery-lightbox__floor-pill.is-active {
    background: #fff;
    color: #1a1a1a;
    border-color: #fff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1500px) {
    .gallery-wave {
        bottom: 45%;
    }

    .gallery-sidebar {
        width: 360px;
        padding: 0 var(--space-4) 0 0;
    }

    .gallery-nav__item {
        font-size: 32px;
    }

    .gallery-nav__list {
        gap: 48px;
    }

    .gallery-sidebar__indicator {
        height: 32px;
    }

    .gallery-sidebar__top {
        margin-bottom: var(--space-6);
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }
}

@media (max-width: 1100px) {
    .gallery-content {
        flex-direction: column;
        top: 0;
        /* On mobile we want the content column to fill the remaining
           space below the header/sidebar. min-height: 0 ensures the
           flex child can shrink past its content so .gallery-main can
           actually scroll instead of expanding the page. */
        min-height: 0;
    }

    .gallery-sidebar {
        width: 100%;
        height: auto;
        align-self: stretch;
        flex-direction: column;
        padding: 0;
        gap: var(--space-3);
        /* Sidebar is now a static header on mobile — no scroll here,
           the scrolling happens in .gallery-main below. */
        overflow: visible;
    }

    .gallery-sidebar__top {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: var(--space-4);
        margin-bottom: 0;
    }

    .gallery-sidebar__indicator {
        width: 40px;
        height: 1px;
        transform: none;
    }

    .gallery-nav {
        flex: none;
    }

    .gallery-nav__list {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        scroll-snap-type: x mandatory;
        padding-bottom: 4px;
    }
    .gallery-nav__list::-webkit-scrollbar {
        display: none;
    }

    .gallery-nav__item {
        font-size: 16px;
        flex-shrink: 0;
        scroll-snap-align: start;
    }

    .gallery-nav__dot {
        display: none;
    }

    .gallery-nav__pearl {
        width: 24px;
        height: 24px;
    }

    .gallery-nav__pearl img {
        width: 24px;
        height: 24px;
    }

    .gallery-nav__item--active .gallery-nav__text {
        font-size: 16px;
        padding-left: 30px;
    }

    .gallery-main {
        flex: 1;
        /* On mobile, fill the rest of the viewport (sidebar is static
           above). Without an explicit height, iOS treats the flex
           child as having no constrained height and refuses to scroll
           it — content just pushes the page down. */
        min-height: 60vh;
        padding: 20px;
        margin-top: 40px;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }

    .gallery-lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .gallery-lightbox__nav--prev {
        left: var(--space-3);
    }

    .gallery-lightbox__nav--next {
        right: var(--space-3);
    }

    .gallery-lightbox__close {
        top: var(--space-3);
        right: var(--space-3);
    }

    .gallery-lightbox__caption {
        font-size: 15px;
        padding: 2px 6px;
    }

    .gallery-lightbox__floors {
        gap: 6px;
        bottom: var(--space-2);
    }

    .gallery-lightbox__floor-pill {
        padding: 5px 10px;
        font-size: 12px;
    }
}

@media (max-width: 700px) {
    .gallery-content {
        margin-left: 0;
        margin-right: 0;
    }

    .gallery-sidebar {
        padding: 20px;
    }

    .gallery-sidebar__indicator {
        display: none;
    }

    /* ---- Hamburger + Dropdown ---- */
    .gallery-nav__hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 36px;
        height: 36px;
        padding: 6px;
        background: none;
        border: none;
        cursor: pointer;
        margin-left: auto;
    }

    .gallery-nav__hamburger span {
        display: block;
        width: 100%;
        height: 1.5px;
        background: var(--pr-5);
        transition:
            transform 0.2s ease,
            opacity 0.2s ease;
    }

    .gallery-nav__hamburger.is-open span:nth-child(1) {
        transform: translateY(6.5px) rotate(45deg);
    }

    .gallery-nav__hamburger.is-open span:nth-child(2) {
        opacity: 0;
    }

    .gallery-nav__hamburger.is-open span:nth-child(3) {
        transform: translateY(-6.5px) rotate(-45deg);
    }

    .gallery-nav__dropdown-wrap {
        overflow: hidden;
        /* Smooth open/close: JS toggles .is-open, CSS animates
           max-height + opacity. Without this the dropdown snapped
           open which felt jarring on touch devices. */
        max-height: 0;
        opacity: 0;
        transition:
            max-height 0.25s ease,
            opacity 0.2s ease;
    }

    .gallery-nav__dropdown-wrap.is-open {
        max-height: 480px;
        opacity: 1;
    }

    .gallery-nav__dropdown-wrap[hidden] {
        display: none;
    }

    .gallery-nav__dropdown {
        display: flex;
        flex-direction: column;
        gap: 2px;
        margin-top: 12px;
        padding: 8px;
        background: var(--pr-1);
        border: 1px solid var(--pr-2);
        border-radius: 8px;
    }

    .gallery-nav__dropdown-btn {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 10px 12px;
        font-family: var(--font-family-domaine);
        font-size: 16px;
        font-weight: 400;
        color: var(--pr-5);
        background: none;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        text-align: left;
        opacity: 0.5;
        transition:
            background 0.15s ease,
            opacity 0.15s ease;
    }

    .gallery-nav__dropdown-btn:hover {
        background: var(--pr-2);
        opacity: 0.75;
    }

    .gallery-nav__dropdown-btn.is-active {
        opacity: 1;
        background: var(--pr-2);
        font-weight: 500;
    }

    .gallery-nav__dropdown-btn img {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    /* ---- Desktop nav list hidden on mobile ---- */
    .gallery-nav__list {
        display: none;
    }

    /* ---- Gallery header in main ---- */
    .gallery-main__label {
        display: flex;
        align-items: center;
        gap: 10px;
        font-family: var(--font-family-domaine);
        font-size: 28px;
        font-weight: 500;
        color: var(--pr-5);
        margin-bottom: 20px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--pr-2);
    }

    .gallery-main__label img {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    .gallery-main {
        margin-top: 0;
    }

    /* ---- Gallery Nav (horizontal scroll on phones) ---- */
    .gallery-nav__list {
        gap: 8px;
    }

    .gallery-nav__item {
        font-size: 13px;
        padding: 6px 2px;
    }

    .gallery-nav__pearl {
        width: 18px;
        height: 18px;
    }

    .gallery-nav__pearl img {
        width: 18px;
        height: 18px;
    }

    .gallery-nav__item--active .gallery-nav__text {
        font-size: 13px;
        padding-left: 22px;
    }

    .gallery-card__caption {
        padding: 8px 10px;
    }

    .gallery-card__caption-name {
        font-size: 13px;
    }

    .gallery-card__caption-floor {
        font-size: 10px;
    }
}
