/* ==========================================================================
   School Tour — campus spaces after the video (/admission/school-tour/).
   Jump bar of spaces, then one block per space: a text card that overlaps a
   photo gallery (2 or 4 photos). Sides alternate; on flipped rows the column
   widths swap too, so the photos are always the wide side. Photos open in
   Magnific Popup (school-tour.js). Loaded only on this page.
   ========================================================================== */

.tour-spaces {
    --ts-navy: var(--dark-blue, #082652);
    --ts-blue: var(--blue, #38a6dd);
    --ts-amber: #f2a93b;
    --ts-ink: #536b8a;
    --ts-overlap: 64px;
    position: relative;
    padding: 40px 0 130px;
    /* clip (not hidden) so the sticky jump bar still sticks; old browsers
       fall back to hidden and simply don't stick. */
    overflow: hidden;
    overflow: clip;
    background:
        radial-gradient(circle at 92% 6%, rgba(242, 169, 59, 0.12), transparent 26%),
        radial-gradient(circle at 4% 42%, rgba(56, 166, 221, 0.12), transparent 30%),
        radial-gradient(circle at 90% 82%, rgba(56, 166, 221, 0.1), transparent 28%),
        linear-gradient(180deg, rgba(239, 246, 252, 0.98) 0%, #ffffff 70%);
}

/* Faint dot grid behind everything. */
.tour-spaces::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(8, 38, 82, 0.07) 1px, transparent 1px);
    background-size: 26px 26px;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
    mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
    pointer-events: none;
}

.tour-spaces__inner {
    position: relative;
    z-index: 1;
    width: 92%;
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: clamp(72px, 9vw, 100px);
}

/* --- Jump bar ------------------------------------------------------------- */
.tour-spaces__nav {
    position: sticky;
    top: 92px;
    z-index: 5;
    align-self: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    max-width: 100%;
    padding: 7px;
    border: 1px solid rgba(8, 38, 82, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 16px 40px rgba(8, 38, 82, 0.12);
}

.tour-spaces__pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    font-family: var(--montserrat);
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ts-navy);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.tour-spaces__pill i {
    color: var(--ts-blue);
    transition: color 0.25s ease;
}

.tour-spaces__pill:hover,
.tour-spaces__pill:focus-visible {
    background: rgba(56, 166, 221, 0.1);
    color: var(--ts-navy);
    outline: none;
}

.tour-spaces__pill.is-active {
    background: linear-gradient(135deg, var(--ts-navy), #12407f);
    color: #fff;
    box-shadow: 0 8px 18px rgba(8, 38, 82, 0.28);
}

.tour-spaces__pill.is-active i {
    color: var(--blue);
}

/* --- One space: text card overlapping the gallery ---------------------------
   Columns are named, so flipping swaps BOTH the side and the width. */
.tour-space {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    grid-template-areas: "copy gallery";
    align-items: center;
    scroll-margin-top: 170px;
}

.tour-space--flip {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-areas: "gallery copy";
}

.tour-space__copy {
    grid-area: copy;
    position: relative;
    z-index: -1;
    margin-right: calc(var(--ts-overlap) * -1);
    padding: 40px 38px 36px;
    border-radius: 28px;
    background: linear-gradient(160deg, #ffffff 0%, #f7fbff 100%);
    border: 1px solid rgba(8, 38, 82, 0.06);
    box-shadow: 0 30px 70px rgba(8, 38, 82, 0.14);
    overflow: hidden;
    padding-right: 88px;
}

.tour-space--flip .tour-space__copy {
    padding-left: 88px;
    padding-right: 38px;
}

.tour-space--flip .tour-space__copy {
    margin-right: 0;
    margin-left: calc(var(--ts-overlap) * -1);
}

/* Accent bar along the edge that meets the photos. */
.tour-space__copy::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0px;
    width: 4px;
    border-radius: 4px 0 0 4px;
    background: linear-gradient(180deg, #d6f2ff, var(--ts-blue));
}

.tour-space--flip .tour-space__copy::before {
    right: 0;
    left: auto;
    border-radius: 0 4px 4px 0;
}

/* Soft glow in the card's corner. */
.tour-space__copy::after {
    content: "";
    position: absolute;
    top: -70px;
    left: -70px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 166, 221, 0.14), transparent 70%);
    pointer-events: none;
}

.tour-space__badge {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.tour-space__icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    font-size: 1.7rem;
    color: #fff;
    background: linear-gradient(135deg, var(--ts-blue), var(--ts-navy));
    box-shadow: 0 14px 28px rgba(56, 166, 221, 0.35);
    transition: transform 0.4s ease;
}

.tour-space:hover .tour-space__icon {
    transform: rotate(-8deg) scale(1.06);
}

.tour-space__num {
    font-family: var(--playfair);
    font-style: italic;
    font-weight: 700;
    font-size: clamp(3rem, 5.4vw, 4.2rem);
    line-height: 1;
    background: linear-gradient(180deg, rgba(56, 166, 221, 0.38), rgba(56, 166, 221, 0.06));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.tour-space__eyebrow {
    position: relative;
    display: block;
    margin-bottom: 8px;
    font-family: var(--montserrat);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ts-blue);
}

.tour-space__title {
    position: relative;
    margin: 0 0 16px;
    padding-bottom: 16px;
    font-family: var(--montserrat);
    font-weight: 700;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    line-height: 1.08;
    letter-spacing: -0.025em;
    color: var(--ts-navy);
}

.tour-space__title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 60px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(268deg, #d6f2ff, var(--ts-blue));
}

.tour-space__desc {
    position: relative;
    margin: 0 0 20px;
    font-family: var(--montserrat_alternates);
    font-size: 0.98rem;
    line-height: 1.85;
    color: var(--ts-ink);
}

.tour-space__meta {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 999px;
    font-family: var(--montserrat);
    font-size: 0.9rem;
    font-weight: 500;
    /* letter-spacing: 0.08em; */
    text-transform: capitalize;
    color: var(--ts-navy);
    background: rgba(56, 166, 221, 0.1);
}

.tour-space__meta i {
    color: var(--ts-blue);
    transition: color 0.25s ease, transform 0.25s ease;
}

/* It's a button now — reset the browser button look and add a clear hover. */
button.tour-space__meta {
    border: 0;
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.tour-space__meta-arrow {
    margin-left: 2px;
}

button.tour-space__meta:hover,
button.tour-space__meta:focus-visible {
    background: var(--ts-navy);
    color: #fff;
    box-shadow: 0 10px 22px rgba(8, 38, 82, 0.25);
    outline: none;
}

button.tour-space__meta:hover i,
button.tour-space__meta:focus-visible i {
    color: var(--blue);
}

button.tour-space__meta:hover .tour-space__meta-arrow,
button.tour-space__meta:focus-visible .tour-space__meta-arrow {
    transform: translateX(4px);
}

/* --- Gallery ---------------------------------------------------------------- */
.tour-space__gallery {
    grid-area: gallery;
    position: relative;
    isolation: isolate;
    display: grid;
    gap: 14px;
}

/* Tinted block offset behind the photos, for depth. */
.tour-space__gallery::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 34px;
    bottom: -26px;
    right: -26px;
    left: 34px;
    border-radius: 32px;
    background:
        radial-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px) 0 0 / 14px 14px,
        linear-gradient(135deg, rgba(56, 166, 221, 0.22), rgba(8, 38, 82, 0.1));
}

.tour-space--flip .tour-space__gallery::before {
    right: 34px;
    left: -26px;
}

.tour-space__photo {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: 22px;
    background: #e3eef8;
    box-shadow: 0 18px 44px rgba(8, 38, 82, 0.16);
    border: 4px solid #fff;
    transition: transform 0.45s ease, box-shadow 0.45s ease;
}

.tour-space__photo:hover {
    transform: translateY(-5px);
    box-shadow: 0 28px 60px rgba(8, 38, 82, 0.24);
}

.tour-space__link {
    position: absolute;
    inset: 0;
    display: block;
    cursor: zoom-in;
}

.tour-space__link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s ease;
}

/* Navy wash + expand icon on hover. */
.tour-space__link::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(8, 38, 82, 0.55));
    opacity: 0;
    transition: opacity 0.35s ease;
}

.tour-space__zoom {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--ts-navy);
    background: #ffffff69;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.tour-space__link:hover img,
.tour-space__link:focus-visible img {
    transform: scale(1.07);
}

.tour-space__link:hover::after,
.tour-space__link:focus-visible::after {
    opacity: 1;
}

.tour-space__link:hover .tour-space__zoom,
.tour-space__link:focus-visible .tour-space__zoom {
    opacity: 1;
    transform: scale(1);
}

.tour-space__link:focus-visible {
    outline: 3px solid var(--ts-blue);
    outline-offset: -3px;
}

/* Photos fade up one after another when the space scrolls into view. */
.tour-space .tour-space__photo {
    opacity: 0;
    translate: 0 26px;
    transition: opacity 0.7s ease, translate 0.7s ease, transform 0.45s ease, box-shadow 0.45s ease;
}

.tour-space.is-visible .tour-space__photo {
    opacity: 1;
    translate: 0 0;
}

.tour-space.is-visible .tour-space__photo:nth-child(2) {
    transition-delay: 0.12s, 0.12s, 0s, 0s;
}

.tour-space.is-visible .tour-space__photo:nth-child(3) {
    transition-delay: 0.24s, 0.24s, 0s, 0s;
}

.tour-space.is-visible .tour-space__photo:nth-child(4) {
    transition-delay: 0.36s, 0.36s, 0s, 0s;
}

/* 2 photos: side by side, the second set lower for rhythm. */
.tour-space--two .tour-space__gallery {
    grid-template-columns: 1fr 1fr;
}

.tour-space--two .tour-space__photo {
    aspect-ratio: 4 / 5;
}

.tour-space--two .tour-space__photo:nth-child(2) {
    margin-top: 64px;
}

/* 4 photos: a large lead photo + three stacked. The lead sits next to the
   text card on both sides, so the card overlaps the big photo, not a thumb. */
.tour-space--four .tour-space__gallery {
    grid-template-columns: 1.45fr 1fr;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    aspect-ratio: 7 / 5;
}

.tour-space--four .tour-space__photo:first-child {
    grid-column: 1;
    grid-row: 1 / -1;
}

.tour-space--four .tour-space__photo:not(:first-child) {
    grid-column: 2;
}

.tour-space--flip.tour-space--four .tour-space__gallery {
    grid-template-columns: 1fr 1.45fr;
}

.tour-space--flip.tour-space--four .tour-space__photo:first-child {
    grid-column: 2;
}

.tour-space--flip.tour-space--four .tour-space__photo:not(:first-child) {
    grid-column: 1;
}

/* 3 photos: one wide on top, two below. */
.tour-space--three .tour-space__gallery {
    grid-template-columns: 1fr 1fr;
}

.tour-space--three .tour-space__photo {
    aspect-ratio: 4 / 3;
}

.tour-space--three .tour-space__photo:first-child {
    grid-column: 1 / -1;
    aspect-ratio: 16 / 7;
}

/* 1 photo: one wide image. */
.tour-space--one .tour-space__photo {
    aspect-ratio: 16 / 10;
}

/* --- Magnific Popup (scoped to this page's popup) -------------------------- */
.tour-mfp.mfp-bg {
    background: #061a3a;
    opacity: 0.94;
}

.tour-mfp .mfp-figure::after {
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    background: transparent;
}

.tour-mfp img.mfp-img {
    border-radius: 18px;
    padding: 40px 0;
}

.tour-mfp .mfp-title {
    font-family: var(--montserrat);
    /* font-weight: 600; */
    /* letter-spacing: 0.02em; */
}

.tour-mfp .mfp-counter {
    font-family: var(--montserrat);
    color: rgba(255, 255, 255, 0.8);
}

.tour-mfp .mfp-close {
    opacity: 1;
    font-size: 2.4rem;
}

.tour-mfp .mfp-arrow {
    opacity: 0.85;
}

.tour-mfp .mfp-arrow:hover {
    opacity: 1;
}

/* Fade, used with removalDelay. */
.mfp-fade.mfp-bg,
.mfp-fade.mfp-wrap .mfp-content {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mfp-fade.mfp-bg.mfp-ready {
    opacity: 0.94;
}

.mfp-fade.mfp-wrap.mfp-ready .mfp-content {
    opacity: 1;
}

.mfp-fade.mfp-bg.mfp-removing,
.mfp-fade.mfp-wrap.mfp-removing .mfp-content {
    opacity: 0;
}

/* --- Tablet ---------------------------------------------------------------- */
@media (max-width: 1199px) {
    .tour-spaces {
        --ts-overlap: 44px;
    }

    .tour-space__copy {
        padding: 32px 28px 30px;
    }
}

/* --- Stacked: photos first, card overlapping their bottom edge ------------- */
@media (max-width: 991px) {
    .tour-spaces__inner {
        width: 94%;
        gap: 72px;
    }

    .tour-spaces__nav {
        top: 76px;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        border-radius: 22px;
        align-self: stretch;
        display: none;
    }

    .tour-spaces__nav::-webkit-scrollbar {
        display: none;
    }

    .tour-space,
    .tour-space--flip {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "gallery" "copy";
    }

    .tour-space__copy,
    .tour-space--flip .tour-space__copy {
        margin: -48px 18px 0;
        z-index: 1;
    }

    .tour-space__copy::before,
    .tour-space--flip .tour-space__copy::before {
        top: 0;
        bottom: auto;
        left: 30px;
        right: 30px;
        width: auto;
        height: 4px;
        border-radius: 0 0 4px 4px;
        background: linear-gradient(90deg, var(--ts-amber), var(--ts-blue));
    }

    .tour-space__gallery::before,
    .tour-space--flip .tour-space__gallery::before {
        top: 24px;
        bottom: -18px;
        left: 24px;
        right: -14px;
    }
}

/* --- Phones ------------------------------------------------------------------ */
@media (max-width: 575px) {
    .tour-spaces {
        padding-bottom: 90px;
    }

    .tour-space__copy,
    .tour-space--flip .tour-space__copy {
        margin: -36px 10px 0;
        padding: 26px 22px 24px;
        border-radius: 22px;
    }

    .tour-space__icon {
        width: 48px;
        height: 48px;
        font-size: 1.15rem;
    }

    .tour-space__gallery {
        gap: 4px;
    }

    .tour-space__photo {
        border-radius: 16px;
        border-width: 1px;
    }

    .tour-space--two .tour-space__photo {
        aspect-ratio: 3 / 4;
    }

    .tour-space--two .tour-space__photo:nth-child(2) {
        margin-top: 32px;
    }

    /* 4 photos: plain 2 x 2 on small screens. */
    .tour-space--four .tour-space__gallery,
    .tour-space--flip.tour-space--four .tour-space__gallery {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: none;
        aspect-ratio: auto;
    }

    .tour-space--four .tour-space__photo,
    .tour-space--four .tour-space__photo:first-child,
    .tour-space--four .tour-space__photo:not(:first-child),
    .tour-space--flip.tour-space--four .tour-space__photo:first-child,
    .tour-space--flip.tour-space--four .tour-space__photo:not(:first-child) {
        grid-column: auto;
        grid-row: auto;
        aspect-ratio: 1 / 1;
    }

    /* Touch screens have no hover — keep the expand hint visible. */
    .tour-space__zoom {
        opacity: 1;
        transform: scale(1);
        width: 34px;
        height: 34px;
        right: 8px;
        bottom: 8px;
        font-size: 0.8rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tour-space .tour-space__photo {
        opacity: 1;
        translate: none;
    }

    .tour-space__photo,
    .tour-space__link img,
    .tour-space__link::after,
    .tour-space__zoom,
    .tour-space__icon,
    .mfp-fade.mfp-bg,
    .mfp-fade.mfp-wrap .mfp-content {
        transition: none;
    }

    .tour-space__photo:hover,
    .tour-space__link:hover img,
    .tour-space:hover .tour-space__icon {
        transform: none;
    }
}