html {
    scroll-behavior: smooth;
}

body.school-gallery-open {
    overflow: hidden;
}

/* ==========================
   Gallery Hero
========================== */

.gallery-hero {
    position: relative;
    overflow: hidden;
    background: #091e41;
    padding: 100px 0 95px;
    text-align: center;
}

.gallery-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(
            180deg,
            rgba(8, 26, 56, 0.35) 0%,
            rgba(8, 26, 56, 0.65) 100%
        ),
        var(--gallery-hero-image)
        center 28% / cover no-repeat;
    transform-origin: center center;
    animation: galleryHeroZoom 9s ease-out forwards;
}

.gallery-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            circle at 50% 40%,
            rgba(255, 255, 255, 0.08),
            transparent 55%
        );
}

.gallery-hero .container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.gallery-hero .eyebrow {
    display: inline-block;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #f2b544;
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(25px);
    animation: galleryHeroFade 0.7s ease forwards 0.2s;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.gallery-hero h1 {
    opacity: 0;
    transform: translateY(35px);
    animation: galleryHeroFade 0.8s ease forwards 0.4s;
    font-size: clamp(28px, 3.4vw, 42px) !important;
    line-height: 1.25;
    max-width: 800px;
    margin: 10px auto 16px auto;
    text-align: center;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
}

@keyframes galleryHeroFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes galleryHeroZoom {
    from {
        transform: scale(1.08);
    }

    to {
        transform: scale(1);
    }
}

/* ==========================
   Scroll Reveal
========================== */

.gallery-reveal,
    .gallery-reveal-left,
    .gallery-reveal-right,
    .gallery-reveal-scale {
        opacity: 0;
        will-change: opacity, transform;
    }

    .gallery-reveal {
        transform: translateY(45px);
        transition:
            opacity 0.8s ease,
            transform 0.8s ease;
    }

    .gallery-reveal-left {
        transform: translateX(-55px);
        transition:
            opacity 0.85s ease,
            transform 0.85s ease;
    }

    .gallery-reveal-right {
        transform: translateX(55px);
        transition:
            opacity 0.85s ease,
            transform 0.85s ease;
    }

    .gallery-reveal-scale {
        transform: scale(0.9);
        transition:
            opacity 0.8s ease,
            transform 0.8s ease;
    }

    .gallery-reveal.active,
    .gallery-reveal-left.active,
    .gallery-reveal-right.active,
    .gallery-reveal-scale.active {
        opacity: 1;
        transform: translate(0) scale(1);
    }

    .gallery-delay-1 {
        transition-delay: 0.06s;
    }

    .gallery-delay-2 {
        transition-delay: 0.12s;
    }

    .gallery-delay-3 {
        transition-delay: 0.18s;
    }

    .gallery-delay-4 {
        transition-delay: 0.24s;
    }

    /* ==========================
       Gallery Heading
    ========================== */

    .gallery-heading-wrap {
        max-width: 760px;
        margin: 0 auto 45px;
        text-align: center;
    }

    .gallery-heading-wrap p {
        max-width: 650px;
        margin-right: auto;
        margin-left: auto;
    }

    .gallery-summary {
        display: inline-flex;
        align-items: center;
        gap: 9px;
        margin-top: 10px;
        padding: 9px 16px;
        color: #0a2248;
        font-size: 13px;
        font-weight: 700;
        background: rgba(10, 34, 72, 0.08);
        border-radius: 30px;
    }

    /* ==========================
       Masonry Gallery
    ========================== */

    .school-gallery-grid {
        column-count: 3;
        column-gap: 24px;
    }

    .school-gallery-card {
        position: relative;
        width: 100%;
        margin: 0 0 24px;
        overflow: hidden;
        background: #e9edf3;
        border-radius: 18px;
        box-shadow: 0 12px 32px rgba(9, 30, 65, 0.1);
        cursor: pointer;
        break-inside: avoid;
        transform: translateZ(0);
        transition:
            transform 0.4s ease,
            box-shadow 0.4s ease;
    }

    .school-gallery-card:hover {
        transform: translateY(-7px);
        box-shadow: 0 22px 50px rgba(9, 30, 65, 0.18);
    }

    .school-gallery-card img {
        display: block;
        width: 100%;
        min-height: 250px;
        max-height: 520px;
        object-fit: cover;
        transition:
            transform 0.8s ease,
            filter 0.45s ease;
    }

    .school-gallery-card:hover img {
        transform: scale(1.07);
        filter: brightness(0.72);
    }

    .school-gallery-card:nth-child(6n + 1) img {
        height: 420px;
    }

    .school-gallery-card:nth-child(6n + 2) img {
        height: 290px;
    }

    .school-gallery-card:nth-child(6n + 3) img {
        height: 350px;
    }

    .school-gallery-card:nth-child(6n + 4) img {
        height: 270px;
    }

    .school-gallery-card:nth-child(6n + 5) img {
        height: 400px;
    }

    .school-gallery-card:nth-child(6n + 6) img {
        height: 320px;
    }

    /* ==========================
       Gallery Card Overlay
    ========================== */

    .school-gallery-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: flex-end;
        padding: 24px;
        background: linear-gradient(
            to top,
            rgba(4, 18, 40, 0.92),
            rgba(4, 18, 40, 0.08) 70%
        );
        opacity: 0;
        transition: opacity 0.4s ease;
    }

    .school-gallery-card:hover .school-gallery-overlay {
        opacity: 1;
    }

    .school-gallery-content {
        width: 100%;
        color: #ffffff;
        transform: translateY(20px);
        transition: transform 0.4s ease;
    }

    .school-gallery-card:hover .school-gallery-content {
        transform: translateY(0);
    }

    .school-gallery-content strong {
        display: block;
        margin-bottom: 6px;
        font-size: 20px;
        line-height: 1.35;
    }

    .school-gallery-content span {
        display: -webkit-box;
        overflow: hidden;
        color: rgba(255, 255, 255, 0.84);
        font-size: 14px;
        line-height: 1.6;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .gallery-expand-icon {
        position: absolute;
        top: 18px;
        right: 18px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 46px;
        height: 46px;
        color: #ffffff;
        font-size: 17px;
        background: rgba(255, 255, 255, 0.18);
        border: 1px solid rgba(255, 255, 255, 0.38);
        border-radius: 50%;
        backdrop-filter: blur(8px);
        opacity: 0;
        transform: scale(0.75);
        transition:
            opacity 0.35s ease,
            transform 0.35s ease;
    }

    .school-gallery-card:hover .gallery-expand-icon {
        opacity: 1;
        transform: scale(1);
    }

    .gallery-collection-chip {
        position: absolute;
        top: 18px;
        left: 18px;
        z-index: 2;
        display: inline-flex;
        align-items: center;
        gap: 7px;
        padding: 7px 12px;
        color: #ffffff;
        font-size: 12px;
        font-weight: 700;
        background: rgba(5, 22, 48, 0.76);
        border-radius: 30px;
        backdrop-filter: blur(8px);
    }

    /* ==========================
       Gallery Modal
    ========================== */

    .school-gallery-modal {
        position: fixed;
        inset: 0;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
        visibility: hidden;
        opacity: 0;
        background: rgba(2, 9, 21, 0.95);
        backdrop-filter: blur(10px);
        transition:
            opacity 0.3s ease,
            visibility 0.3s ease;
    }

    .school-gallery-modal.active {
        visibility: visible;
        opacity: 1;
    }

    .school-gallery-dialog {
        position: relative;
        display: flex;
        flex-direction: column;
        width: min(1200px, 100%);
        height: calc(100vh - 48px);
        height: calc(100dvh - 48px);
        max-height: calc(100vh - 48px);
        overflow: hidden;
        background: #07172f;
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 20px;
        box-shadow: 0 35px 90px rgba(0, 0, 0, 0.5);
        transform: translateY(30px) scale(0.96);
        transition: transform 0.35s ease;
    }

    .school-gallery-modal.active .school-gallery-dialog {
        transform: translateY(0) scale(1);
    }

    .school-gallery-modal-header {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
        padding: 17px 20px;
        background: #ffffff;
        border-bottom: 1px solid #e7ebf1;
    }

    .school-gallery-title-wrap {
        min-width: 0;
    }

    .school-gallery-modal-title {
        margin: 0;
        overflow: hidden;
        color: #0a2248;
        font-size: 20px;
        line-height: 1.35;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .school-gallery-modal-description {
        display: block;
        margin-top: 3px;
        overflow: hidden;
        color: #738094;
        font-size: 13px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .school-gallery-close {
        display: inline-flex;
        flex-shrink: 0;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        color: #0a2248;
        font-size: 20px;
        background: #edf1f6;
        border: 0;
        border-radius: 50%;
        cursor: pointer;
        transition:
            color 0.3s ease,
            background-color 0.3s ease,
            transform 0.3s ease;
    }

    .school-gallery-close:hover {
        color: #ffffff;
        background: #0a2248;
        transform: rotate(90deg);
    }

    .school-gallery-main {
        position: relative;
        display: flex;
        flex: 1;
        align-items: center;
        justify-content: center;
        min-height: 0;
        overflow: hidden;
        background:
            radial-gradient(
                circle at center,
                rgba(255, 255, 255, 0.05),
                transparent 55%
            ),
            #061329;
    }

    .school-gallery-main-image {
        display: block;
        width: 100%;
        height: 100%;
        min-height: 0;
        object-fit: contain;
        animation: schoolGalleryImageFade 0.3s ease;
    }

    @keyframes schoolGalleryImageFade {
        from {
            opacity: 0;
            transform: scale(0.98);
        }

        to {
            opacity: 1;
            transform: scale(1);
        }
    }

    .school-gallery-navigation {
        position: absolute;
        top: 50%;
        z-index: 3;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 52px;
        height: 52px;
        color: #ffffff;
        font-size: 20px;
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.28);
        border-radius: 50%;
        cursor: pointer;
        backdrop-filter: blur(8px);
        transform: translateY(-50%);
        transition:
            background-color 0.3s ease,
            transform 0.3s ease;
    }

    .school-gallery-navigation:hover {
        background: rgba(255, 255, 255, 0.28);
    }

    .school-gallery-navigation.previous {
        left: 22px;
    }

    .school-gallery-navigation.next {
        right: 22px;
    }

    .school-gallery-navigation.previous:hover {
        transform: translateY(-50%) translateX(-4px);
    }

    .school-gallery-navigation.next:hover {
        transform: translateY(-50%) translateX(4px);
    }

    .school-gallery-navigation.hidden {
        display: none;
    }

    .school-gallery-position {
        position: absolute;
        right: 20px;
        bottom: 18px;
        z-index: 3;
        padding: 8px 14px;
        color: #ffffff;
        font-size: 13px;
        font-weight: 700;
        background: rgba(2, 11, 26, 0.74);
        border-radius: 30px;
        backdrop-filter: blur(8px);
    }

    .school-gallery-thumbnails {
        display: flex;
        flex: 0 0 auto;
        gap: 10px;
        padding: 10px 14px;
        overflow-x: auto;
        overflow-y: hidden;
        background: #ffffff;
        scrollbar-width: thin;
    }

    .school-gallery-thumbnail {
        flex: 0 0 86px;
        width: 86px;
        height: 56px;
        padding: 0;
        overflow: hidden;
        background: #e9edf3;
        border: 3px solid transparent;
        border-radius: 9px;
        cursor: pointer;
        transition:
            border-color 0.25s ease,
            transform 0.25s ease;
    }

    .school-gallery-thumbnail:hover,
    .school-gallery-thumbnail.active {
        border-color: #0a2248;
        transform: translateY(-2px);
    }

    .school-gallery-thumbnail img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* ==========================
       Responsive
    ========================== */

    @media (max-width: 991px) {
        .school-gallery-grid {
            column-count: 2;
        }

    }

    @media (max-width: 767px) {
        .gallery-reveal-left,
        .gallery-reveal-right {
            transform: translateY(40px);
        }

        .gallery-reveal-left.active,
        .gallery-reveal-right.active {
            transform: translateY(0);
        }

        .school-gallery-grid {
            column-count: 1;
        }

        .school-gallery-card {
            margin-bottom: 20px;
        }

        .school-gallery-card img,
        .school-gallery-card:nth-child(n) img {
            height: 300px;
            min-height: 300px;
        }

        .school-gallery-overlay {
            opacity: 1;
            background: linear-gradient(
                to top,
                rgba(4, 18, 40, 0.86),
                transparent 68%
            );
        }

        .school-gallery-content {
            transform: translateY(0);
        }

        .gallery-expand-icon {
            opacity: 1;
            transform: scale(1);
        }

        .school-gallery-modal {
            padding: 12px;
        }

        .school-gallery-dialog {
            height: calc(100vh - 24px);
            height: calc(100dvh - 24px);
            max-height: calc(100vh - 24px);
            border-radius: 15px;
        }

        .school-gallery-modal-header {
            padding: 13px 15px;
        }

        .school-gallery-modal-title {
            font-size: 17px;
        }

        .school-gallery-main {
            min-height: 0;
        }

        .school-gallery-main-image {
            height: 100%;
        }

        .school-gallery-thumbnails {
            gap: 7px;
            padding: 8px;
        }

        .school-gallery-thumbnail {
            flex-basis: 72px;
            width: 72px;
            height: 50px;
        }

        .school-gallery-navigation {
            width: 42px;
            height: 42px;
            font-size: 17px;
        }

        .school-gallery-navigation.previous {
            left: 10px;
        }

        .school-gallery-navigation.next {
            right: 10px;
        }
    }

    @media (max-width: 480px) {
        .school-gallery-card img,
        .school-gallery-card:nth-child(n) img {
            height: 250px;
            min-height: 250px;
        }

        .school-gallery-overlay {
            padding: 18px;
        }

        .school-gallery-content strong {
            font-size: 18px;
        }

        .gallery-expand-icon {
            top: 14px;
            right: 14px;
            width: 40px;
            height: 40px;
        }

        .gallery-collection-chip {
            top: 14px;
            left: 14px;
        }

        .school-gallery-main {
            min-height: 0;
        }

        .school-gallery-main-image {
            height: 100%;
        }

    }

    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            scroll-behavior: auto !important;
            transition-duration: 0.01ms !important;
        }

        .gallery-reveal,
        .gallery-reveal-left,
        .gallery-reveal-right,
        .gallery-reveal-scale {
            opacity: 1;
            transform: none;
        }
    }
