/* ========================================================
   JENNIFER GORI — DYNAMIC EDITORIAL GALLERY V2
   ======================================================== */

.gallery-section {
    position: relative;
    padding: 150px 5% 82px;
    background: var(--cream);
    overflow: hidden;
}

.gallery-section::before {
    content: "";
    position: absolute;
    width: 520px;
    height: 520px;
    left: -330px;
    top: 130px;
    border: 1px solid rgba(145,123,94,.10);
    border-radius: 50%;
    pointer-events: none;
}

.gallery-inner {
    position: relative;
    z-index: 2;
    max-width: 1450px;
    margin: auto;
}

.gallery-heading {
    display: grid;
    grid-template-columns: 1fr .75fr;
    gap: 70px;
    align-items: end;
    margin-bottom: 85px;
}

.gallery-title {
    max-width: 780px;
    font-family: var(--serif);
    font-size: clamp(46px,4.8vw,74px);
    font-weight: 500;
    line-height: 1.04;
    letter-spacing: -2.3px;
}

.gallery-title em {
    display: block;
    color: var(--champagne);
    font-weight: 500;
}

.gallery-intro {
    max-width: 500px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.9;
}


/* ========================================================
   THREE-FRAME FEATURE GALLERY
   ======================================================== */

.dynamic-gallery {
    display: grid;
    grid-template-columns: minmax(0,1.45fr) minmax(310px,.65fr);
    gap: 22px;
    align-items: stretch;
}

.dynamic-gallery-side {
    display: grid;
    grid-template-rows: 1.18fr .82fr;
    gap: 22px;
}

.dynamic-gallery-frame {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    background: #e9e3d8;
    overflow: hidden;
    cursor: pointer;
    isolation: isolate;
}

.dynamic-gallery-main {
    aspect-ratio: 16 / 10;
    border-radius: 0 78px 0 0;
}

.dynamic-gallery-portrait {
    border-radius: 62px 0 0 0;
}

.dynamic-gallery-secondary {
    border-radius: 0 0 58px 0;
}


/* ========================================================
   IMAGE LAYERS / CROPPING
   ======================================================== */

.dynamic-gallery-image-layer {
    position: absolute;
    inset: 0;
    display: block;
    overflow: hidden;
}

.dynamic-gallery-image-layer.current {
    z-index: 1;
    opacity: 1;
}

.dynamic-gallery-image-layer.next {
    z-index: 2;
    opacity: 0;
    transform: scale(1.018);
}

.dynamic-gallery-image-layer img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(.86) contrast(.98);
    transition:
        transform 1s cubic-bezier(.22,.61,.36,1),
        filter .7s ease;
}

/* Main frame — balanced crop */
.dynamic-gallery-main .dynamic-gallery-image-layer img {
    object-position: center 30%;
}

/* Upper-right — protect faces */
.dynamic-gallery-portrait .dynamic-gallery-image-layer img {
    object-position: center 15%;
}

/* Lower-right — protect faces */
.dynamic-gallery-secondary .dynamic-gallery-image-layer img {
    object-position: center 20%;
}


/* ========================================================
   CROSSFADE
   ======================================================== */

.dynamic-gallery-frame.is-transitioning
.dynamic-gallery-image-layer.current {
    opacity: 0;
    transform: scale(1.018);
    transition:
        opacity 1.05s cubic-bezier(.22,.61,.36,1),
        transform 1.25s cubic-bezier(.22,.61,.36,1);
}

.dynamic-gallery-frame.is-transitioning
.dynamic-gallery-image-layer.next {
    opacity: 1;
    transform: scale(1);
    transition:
        opacity 1.05s cubic-bezier(.22,.61,.36,1),
        transform 1.25s cubic-bezier(.22,.61,.36,1);
}

.dynamic-gallery-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background:
        linear-gradient(
            180deg,
            rgba(31,30,27,0) 62%,
            rgba(31,30,27,.12) 100%
        );
}


/* ========================================================
   HOVER
   ======================================================== */

.gallery-view-mark {
    position: absolute;
    right: 20px;
    bottom: 20px;
    z-index: 5;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(248,245,239,.90);
    box-shadow: 0 12px 30px rgba(38,34,29,.12);
    opacity: 0;
    transform: translateY(9px) scale(.96);
    transition:
        opacity .35s ease,
        transform .35s ease;
}

.gallery-view-mark span {
    font-family: var(--serif);
    font-size: 24px;
    line-height: 1;
    color: var(--ink);
}

.dynamic-gallery-frame:hover .gallery-view-mark {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.dynamic-gallery-frame:not(.is-transitioning):hover
.dynamic-gallery-image-layer.current img {
    transform: scale(1.022);
    filter: saturate(.97) contrast(1);
}


/* ========================================================
   FOOTER / VIEW FULL GALLERY
   ======================================================== */

.gallery-footer {
    margin-top: 32px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 50px;
}

.gallery-quote {
    max-width: 720px;
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.gallery-quote-mark {
    color: var(--champagne);
    font-family: var(--serif);
    font-size: 48px;
    line-height: .8;
}

.gallery-quote p {
    font-family: var(--serif);
    font-size: clamp(20px,2vw,28px);
    line-height: 1.38;
    color: var(--ink);
}

.gallery-view-all {
    position: relative;

    flex-shrink: 0;

    display: grid;
    grid-template-columns: auto auto;
    align-items: center;

    column-gap: 18px;
    row-gap: 3px;

    width: fit-content;
    min-width: 0;
    min-height: 0;

    margin: 0;
    padding: 0 0 8px;

    border: 0 !important;
    border-radius: 0 !important;

    outline: 0;

    background: transparent !important;
    box-shadow: none !important;

    appearance: none;
    -webkit-appearance: none;

    color: var(--ink);

    cursor: pointer;
    text-align: left;

    font-family: var(--sans);
}


/* Main label */

.gallery-view-all > span:first-child {
    font-size: 11px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: 1.7px;
}


/* Photo count */

.gallery-view-all-count {
    grid-column: 1;

    color: var(--champagne);

    font-size: 8px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: 1.4px;
}


/* Arrow */

.gallery-view-all-arrow {
    grid-column: 2;
    grid-row: 1 / 3;

    display: inline-block;

    font-size: 27px;
    line-height: 1;

    transition:
        transform .3s ease;
}


/* Animated underline — appears only on hover */

.gallery-view-all::after {
    content: "";

    position: absolute;

    left: 0;
    bottom: 0;

    width: 100%;
    height: 1px;

    background: var(--champagne);

    transform: scaleX(0);
    transform-origin: right;

    transition:
        transform .38s cubic-bezier(.77,0,.18,1);
}


/* Hover: line + arrow only */

.gallery-view-all:hover,
.gallery-view-all:focus {
    color: var(--ink);

    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.gallery-view-all:hover::after,
.gallery-view-all:focus-visible::after {
    transform: scaleX(1);
    transform-origin: left;
}

.gallery-view-all:hover .gallery-view-all-arrow,
.gallery-view-all:focus-visible .gallery-view-all-arrow {
    transform: translateX(7px);
}

.gallery-view-all:focus-visible {
    outline: none;
}

.gallery-rotation-status {
    margin-top: 16px;
    margin-left: auto;
    width: fit-content;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #777168;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 1.3px;
}

.gallery-rotation-line {
    width: 70px;
    height: 1px;
    overflow: hidden;
    background: rgba(90,84,76,.15);
}

.gallery-rotation-line > span {
    display: block;
    width: 0%;
    height: 100%;
    background: var(--champagne);
    transition: width .55s ease;
}

.gallery-empty {
    padding: 60px 0;
    color: var(--muted);
}


/* ========================================================
   FULL GALLERY OVERLAY
   ======================================================== */

.gallery-all-overlay {
    position: fixed;
    inset: 0;
    z-index: 2100;
    background: #f3efe8;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(18px);
    transition:
        opacity .45s ease,
        visibility .45s ease,
        transform .45s cubic-bezier(.22,.61,.36,1);
}

.gallery-all-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.gallery-all-header {
    height: 118px;
    padding: 24px 5%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    border-bottom: 1px solid rgba(70,66,60,.14);
    background: rgba(243,239,232,.96);
}

.gallery-all-eyebrow {
    margin-bottom: 3px;
    color: var(--champagne);
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2.5px;
}

.gallery-all-header h2 {
    font-family: var(--serif);
    font-size: clamp(26px,3vw,42px);
    font-weight: 500;
    line-height: 1;
}

.gallery-all-close {
    display: flex;
    align-items: center;
    gap: 13px;
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.gallery-all-close span:first-child {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.6px;
}

.gallery-all-close span:last-child {
    font-size: 31px;
    line-height: 1;
}

.gallery-all-scroll {
    height: calc(100vh - 118px);
    overflow-y: auto;
    padding: 45px 5% 80px;
}

.gallery-all-grid {
    max-width: 1450px;
    margin: auto;
    columns: 3;
    column-gap: 22px;
}

.gallery-all-item {
    position: relative;
    width: 100%;
    margin: 0 0 22px;
    padding: 0;
    display: inline-block;
    break-inside: avoid;
    border: 0;
    background: transparent;
    overflow: hidden;
    cursor: pointer;
}

.gallery-all-item:nth-child(4n+1) {
    border-radius: 0 45px 0 0;
}

.gallery-all-item:nth-child(4n+2) {
    border-radius: 35px 0 0 0;
}

.gallery-all-item:nth-child(4n+3) {
    border-radius: 0 0 35px 0;
}

.gallery-all-item:nth-child(4n) {
    border-radius: 0 0 0 35px;
}

.gallery-all-item img {
    display: block;
    width: 100%;
    height: auto;
    filter: saturate(.90) contrast(.99);
    transition:
        transform .8s cubic-bezier(.22,.61,.36,1),
        filter .6s ease;
}

.gallery-all-item:hover img {
    transform: scale(1.025);
    filter: saturate(1) contrast(1);
}

.gallery-all-item-number {
    position: absolute;
    right: 12px;
    bottom: 10px;
    min-width: 33px;
    height: 27px;
    padding: 0 8px;
    display: grid;
    place-items: center;
    background: rgba(248,245,239,.90);
    color: var(--ink);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 1px;
}


/* ========================================================
   LIGHTBOX
   ======================================================== */

.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2300;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 42px 84px 28px;

    background: rgba(25,25,22,.96);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity .42s ease,
        visibility .42s ease;
}

.gallery-lightbox.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* Main lightbox content */

.gallery-lightbox-content {
    width: min(1220px, 86vw);
    max-height: calc(100dvh - 70px);

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 14px;
}

.gallery-lightbox-image-wrap {
    width: 100%;
    min-height: 0;
    max-height: calc(100dvh - 235px);

    display: flex;
    align-items: center;
    justify-content: center;

    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.gallery-lightbox-image-wrap img {
    display: block;

    max-width: 100%;
    max-height: calc(100dvh - 235px);

    width: auto;
    height: auto;

    object-fit: contain;

    box-shadow: 0 28px 80px rgba(0,0,0,.36);

    -webkit-user-drag: none;
    user-select: none;
}


/* Counter + progress */

.gallery-lightbox-meta {
    width: min(760px, 100%);

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 14px;
}

.gallery-lightbox-counter {
    flex-shrink: 0;

    display: flex;
    align-items: center;

    gap: 5px;

    color: rgba(255,255,255,.70);

    font-size: 9px;
    font-weight: 600;

    letter-spacing: 1.5px;
}

.gallery-lightbox-progress {
    width: min(220px, 32vw);
    height: 1px;

    overflow: hidden;

    background: rgba(255,255,255,.16);
}

.gallery-lightbox-progress span {
    display: block;

    width: 0%;
    height: 100%;

    background: var(--champagne);

    transition: width .35s ease;
}


/* Thumbnail rail */

.gallery-lightbox-thumbnails {
    width: min(760px, 100%);

    display: flex;
    align-items: center;

    gap: 8px;

    padding: 2px 2px 6px;

    overflow-x: auto;
    overflow-y: hidden;

    scroll-behavior: smooth;
    scroll-snap-type: x proximity;

    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;

    scrollbar-width: none;
}

.gallery-lightbox-thumbnails::-webkit-scrollbar {
    display: none;
}

.gallery-lightbox-thumb {
    position: relative;

    flex: 0 0 74px;

    width: 74px;
    height: 54px;

    padding: 0;

    border: 1px solid rgba(255,255,255,.16);
    border-radius: 0;

    background: rgba(255,255,255,.04);

    overflow: hidden;
    opacity: .58;

    cursor: pointer;

    scroll-snap-align: center;

    transition:
        opacity .28s ease,
        border-color .28s ease,
        transform .28s ease;
}

.gallery-lightbox-thumb img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    filter: saturate(.82) contrast(.97);

    transition:
        filter .28s ease,
        transform .45s cubic-bezier(.22,.61,.36,1);
}

.gallery-lightbox-thumb:hover {
    opacity: .88;
}

.gallery-lightbox-thumb:hover img {
    transform: scale(1.035);
}

.gallery-lightbox-thumb.is-active {
    opacity: 1;
    border-color: var(--champagne);
    transform: translateY(-2px);
}

.gallery-lightbox-thumb.is-active img {
    filter: saturate(1) contrast(1);
}


/* Close */

.gallery-lightbox-close {
    position: absolute;
    top: 24px;
    right: 32px;

    width: 48px;
    height: 48px;

    border: 0;

    background: transparent;
    color: white;

    font-size: 38px;
    line-height: 1;

    cursor: pointer;
}


/* Previous / next */

.gallery-lightbox-nav {
    position: absolute;
    top: 50%;

    transform: translateY(-50%);

    width: 50px;
    height: 50px;

    border: 1px solid rgba(255,255,255,.24);
    border-radius: 50%;

    background: rgba(255,255,255,.05);
    color: white;

    font-size: 21px;

    cursor: pointer;

    transition:
        background .3s ease,
        border-color .3s ease;
}

.gallery-lightbox-nav:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.55);
}

.gallery-lightbox-prev {
    left: 25px;
}

.gallery-lightbox-next {
    right: 25px;
}


/* ========================================================
   RESPONSIVE — TABLET
   ======================================================== */

@media (max-width: 1050px) {

    .gallery-heading {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .dynamic-gallery {
        grid-template-columns: 1.25fr .75fr;
    }

    .dynamic-gallery-main {
        aspect-ratio: 4 / 3;
    }

    .gallery-all-grid {
        columns: 2;
    }

}


/* ========================================================
   RESPONSIVE — SMALL TABLET
   ======================================================== */

@media (max-width: 780px) {

    .dynamic-gallery {
        grid-template-columns: 1fr;
    }

    .dynamic-gallery-main {
        aspect-ratio: 4 / 3;
        border-radius: 0 55px 0 0;
    }

    .dynamic-gallery-side {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: none;
    }

    .dynamic-gallery-portrait,
    .dynamic-gallery-secondary {
        aspect-ratio: 4 / 5;
    }

    .gallery-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .gallery-view-all {
        margin-left: auto;
    }

}


/* ========================================================
   RESPONSIVE — MOBILE
   ======================================================== */

@media (max-width: 620px) {

    /* ====================================================
       MAIN GALLERY SECTION
       ==================================================== */

    .gallery-section {
        padding: 62px 6% 40px;
    }

    .gallery-heading {
        margin-bottom: 48px;
    }

    .dynamic-gallery,
    .dynamic-gallery-side {
        gap: 14px;
    }

    .dynamic-gallery-main {
        aspect-ratio: 1 / 1;
        border-radius: 0 42px 0 0;
    }

    .dynamic-gallery-portrait,
    .dynamic-gallery-secondary {
        aspect-ratio: 3 / 4;
    }

    .dynamic-gallery-portrait {
        border-radius: 35px 0 0 0;
    }

    .dynamic-gallery-secondary {
        border-radius: 0 0 35px 0;
    }

    .gallery-quote p {
        font-size: 19px;
    }


    /* ====================================================
       FULL GALLERY HEADER
       ==================================================== */

    .gallery-all-header {
        height: 92px;
        padding: 18px 6%;
    }


    /* ====================================================
       FULL GALLERY SCROLL AREA
       ==================================================== */

    .gallery-all-scroll {
        height: calc(100vh - 92px);

        padding:
            20px 5%
            45px;
    }


    /* ====================================================
       MOBILE THUMBNAIL GRID
       3 thumbnails per row
       ==================================================== */

    .gallery-all-grid {
        columns: initial;

        display: grid;

        grid-template-columns:
            repeat(3, minmax(0, 1fr));

        gap: 8px;

        width: 100%;
    }


    /* ====================================================
       THUMBNAIL
       ==================================================== */

    .gallery-all-item {
        position: relative;

        display: block;

        width: 100%;

        margin: 0;

        aspect-ratio: 1 / 1;

        overflow: hidden;

        border-radius: 0;

        background: #e9e3d8;
    }


    /* Alternate corners for editorial feel */

    .gallery-all-item:nth-child(6n+1) {
        border-radius: 0 18px 0 0;
    }

    .gallery-all-item:nth-child(6n+2) {
        border-radius: 14px 0 0 0;
    }

    .gallery-all-item:nth-child(6n+3) {
        border-radius: 0 0 14px 0;
    }

    .gallery-all-item:nth-child(6n+4) {
        border-radius: 0 14px 0 0;
    }

    .gallery-all-item:nth-child(6n+5) {
        border-radius: 0 0 0 14px;
    }

    .gallery-all-item:nth-child(6n) {
        border-radius: 14px 0 14px 0;
    }


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

    .gallery-all-item img {
        width: 100%;
        height: 100%;

        object-fit: cover;

        object-position: center;

        display: block;

        filter:
            saturate(.90)
            contrast(.99);
    }


    /* ====================================================
       IMAGE NUMBER
       Keep 01 / 02 / 03...
       ==================================================== */

    .gallery-all-item-number {
        right: 5px;
        bottom: 5px;

        min-width: 24px;
        height: 20px;

        padding: 0 5px;

        background:
            rgba(248,245,239,.92);

        font-size: 7px;

        letter-spacing: .7px;
    }


    /* ====================================================
       LIGHTBOX
       ==================================================== */

    .gallery-lightbox {
        padding:
            58px 12px
            16px;
    }

    .gallery-lightbox-content {
        width: 100%;
        max-height: calc(100dvh - 74px);
        gap: 12px;
    }

    .gallery-lightbox-image-wrap {
        width: 100%;
        max-height: calc(100dvh - 245px);
        touch-action: pan-y;
    }

    .gallery-lightbox-image-wrap img {
        max-height: calc(100dvh - 245px);
    }

    .gallery-lightbox-meta {
        width: calc(100% - 20px);
        gap: 11px;
    }

    .gallery-lightbox-progress {
        flex: 1;
        width: auto;
        max-width: 190px;
    }

    .gallery-lightbox-thumbnails {
        width: 100%;
        gap: 7px;
        padding: 3px 10px 7px;
        scroll-padding-inline: 10px;
    }

    .gallery-lightbox-thumb {
        flex-basis: 66px;
        width: 66px;
        height: 52px;
    }

    .gallery-lightbox-close {
        top: 10px;
        right: 10px;
        width: 42px;
        height: 42px;
        font-size: 34px;
    }

    .gallery-lightbox-prev {
        left: 6px;
    }

    .gallery-lightbox-next {
        right: 6px;
    }

    .gallery-lightbox-nav {
        width: 38px;
        height: 38px;
        background: rgba(25,25,22,.54);
        backdrop-filter: blur(7px);
        -webkit-backdrop-filter: blur(7px);
    }

}


/* ========================================================
   VERY SMALL MOBILE
   ======================================================== */

@media (max-width: 390px) {

    .gallery-all-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 9px;
    }

}
