/* ============================================
   INDEX2 — full-bleed cards, manifest-driven media
   One content column: same horizontal inset as index.html
   ============================================ */

/* Document scroll: avoid `html:has()` (Safari can treat it as a broad invalidation source). */
html.index2-doc {
    scroll-behavior: auto;
}

body.index2-page {
    --index2-content-max: 1920px;
    /* Inner breathing room inside the hero column (same value top + bottom) */
    --index2-hero-pad-y: clamp(0.85rem, 1.35vw + 0.45rem, 1.45rem);
    /* Matches horizontal container inset — included in hero padding so top/bottom match visually */
    --index2-hero-edge: 2rem;
    display: block;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    margin: 0;
    min-height: 100vh;
    /* scroll: fixed backgrounds + hover layers often jank mouse-wheel scrolling */
    background-attachment: scroll;
    overflow-x: hidden;
}

body.index2-page main {
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Single gutter for hero + cards (matches index: 2rem desktop, var(--padding) mobile) */
body.index2-page .container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

@media (min-width: 769px) {
    /* Avoid double-stacking top inset: hero handles top edge; keeps space above/below hero text symmetric */
    body.index2-page .container {
        padding-top: 0;
        padding-bottom: 2rem;
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Hero: left edge matches cards; text column is 80% width (capped at 80% of content max) */
body.index2-page .typewriter-text {
    box-sizing: border-box;
    align-self: stretch;
    width: 80%;
    max-width: calc(var(--index2-content-max) * 0.8);
    margin-left: calc((100% - min(100%, var(--index2-content-max))) / 2);
    margin-right: auto;
    text-align: left;
    font-size: clamp(20px, 2.8vw + 10px, 48px);
    font-weight: 450;
    line-height: 1.2;
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding-top: calc(var(--index2-hero-edge) + var(--index2-hero-pad-y) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--index2-hero-edge) + var(--index2-hero-pad-y) + env(safe-area-inset-bottom, 0px));
    min-height: 0;
    font-optical-sizing: auto;
    font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-wrap: pretty;
    /* No `contain: layout` here — WebKit scroll anchoring + wheel/trackpad scroll can “fight” it. */
}

@media (max-width: 768px) {
    body.index2-page {
        /* Same vertical gap: hero → first tile meta, and between tiles */
        --index2-mobile-vertical-gap: 48px;
    }

    body.index2-page .container {
        width: 100% !important;
        max-width: 100% !important;
        /* Top inset is on `.typewriter-text` (with `--index2-mobile-vertical-gap`) so hero top/bottom stay symmetric */
        /* Bottom inset lives on `.index2-footer-contact` so we don’t stack 2rem + 6rem under the Contact link */
        padding: 0 16px 0 16px !important;
        margin: 0 !important;
    }

    /* ~10% wider than 80%: 88% of row, cap at 88% of content max */
    body.index2-page .typewriter-text {
        width: 88%;
        max-width: calc(var(--index2-content-max) * 0.88);
        margin-left: calc((100% - min(100%, var(--index2-content-max))) / 2);
        margin-right: auto;
        font-size: clamp(20px, 4.2vw + 8px, 34px);
        line-height: 1.2;
        padding-top: calc(var(--index2-mobile-vertical-gap) + env(safe-area-inset-top, 0px));
        padding-bottom: calc(var(--index2-mobile-vertical-gap) + env(safe-area-inset-bottom, 0px));
    }
}

/* --- Card stack --- */
.index2-cards {
    width: 100%;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    padding-bottom: 6rem;
    display: none;
}

.index2-cards.index2-cards--ready {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    /* Bottom breathing room lives on `.index2-footer-contact` so gap tile → Contact matches meta → media */
    padding-bottom: 0;
}

/* Footer Contact — same type rhythm as `.index2-card__meta-col:nth-child(1)`; shown when cards are ready */
.index2-footer-contact {
    display: none;
    width: 100%;
    max-width: var(--index2-content-max);
    margin: 0 auto;
    box-sizing: border-box;
    /* Top = meta→media gap on 3-up; bottom = former `.index2-cards` tail padding */
    padding: 20px 24px 6rem;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
}

.index2-cards.index2-cards--ready ~ .index2-footer-contact {
    display: flex;
}

.index2-footer-contact__link {
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: clamp(12px, 1.15vw, 18px);
    line-height: 1.45;
    color: var(--index2-dynamic-text, inherit);
    font-optical-sizing: auto;
    font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.index2-footer-contact__link:hover,
.index2-footer-contact__link:focus-visible {
    text-decoration: none;
}

@media (min-width: 701px) and (max-width: 1100px) {
    .index2-footer-contact {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* Narrow phones: align with tile edge (container gutter only); looser top rhythm */
@media (max-width: 760px) {
    .index2-footer-contact {
        padding-left: 0;
        padding-right: 0;
        padding-top: clamp(16px, 2.5vw, 24px);
    }

    .index2-footer-contact__link {
        line-height: 100%;
    }
}

/* Mobile: one inter-tile gap below Contact + home indicator (replaces 6rem + container 2rem stack) */
@media (max-width: 768px) {
    .index2-footer-contact {
        padding-bottom: calc(var(--index2-mobile-vertical-gap) + env(safe-area-inset-bottom, 0px));
    }
}

/* Case cards (01 / 03): pointer + subtle hover shadow on desktop (no zoom) */
body.index2-page .index2-card--interactive {
    cursor: pointer;
}

body.index2-page .index2-card--interactive .index2-card__media-frame {
    transition: box-shadow 0.28s ease;
}

@media (min-width: 1025px) {
    body.index2-page .index2-card--interactive:hover .index2-card__media-frame {
        box-shadow:
            0 8px 20px rgba(0, 0, 0, 0.125),
            0 4px 8px rgba(0, 0, 0, 0.084);
    }

    body.index2-page[data-time="evening"] .index2-card--interactive:hover .index2-card__media-frame,
    body.index2-page[data-time="night"] .index2-card--interactive:hover .index2-card__media-frame {
        box-shadow:
            0 8px 24px rgba(0, 0, 0, 0.366),
            0 4px 10px rgba(0, 0, 0, 0.23);
    }

    /* Drawer open: drop animated shadows so the overlay does not repaint heavy glows underneath */
    body.index2-page.drawer-open .index2-card--interactive .index2-card__media-frame {
        transition: none !important;
    }

    body.index2-page.drawer-open:not([data-time="evening"]):not([data-time="night"]) .index2-card--interactive .index2-card__media-frame {
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.063) !important;
    }

    body.index2-page[data-time="evening"].drawer-open .index2-card--interactive .index2-card__media-frame,
    body.index2-page[data-time="night"].drawer-open .index2-card--interactive .index2-card__media-frame {
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.209) !important;
    }
}

body.index2-page .index2-card--interactive {
    position: relative;
    z-index: 1;
}

.index2-card {
    container-type: inline-size;
    container-name: index2-card;
    width: 100%;
    max-width: var(--index2-content-max);
    /* Vertical gap between tiles: reacts to both width and height */
    margin: 0 auto clamp(68px, 4.2vw + 2.4vh, min(14vw, 228px));
    box-sizing: border-box;
}

.index2-card:last-child {
    margin-bottom: 0;
}

/* Meta row: 3 columns (wide); third column may wrap — full text stays legible */
.index2-card__meta {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 0.98fr) minmax(0, 1.1fr);
    gap: 1rem 1.5rem;
    padding: 0 24px;
    box-sizing: border-box;
    width: 100%;
    max-width: var(--index2-content-max);
    margin: 0 auto;
}

/* Mid-width cards: keep 3 columns on one line with tighter horizontal rhythm */
@container index2-card (max-width: 1100px) and (min-width: 701px) {
    .index2-card__meta {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr) minmax(0, 1.08fr);
        gap: 0.65rem 0.75rem;
        padding: 0 16px;
    }

    .index2-card__meta-col {
        font-size: clamp(11px, 1.2vw + 7px, 16px);
    }
}

.index2-card__meta-col {
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: clamp(12px, 1.15vw, 18px);
    line-height: 1.45;
    /* 2px closer to the media tile than the previous 22px rhythm */
    padding-bottom: 20px;
    color: var(--index2-dynamic-text, inherit);
    font-optical-sizing: auto;
    font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
    -webkit-font-smoothing: antialiased;
    min-width: 0;
    word-wrap: break-word;
}

.index2-card__meta-col.is-typing {
    min-height: 1.45em;
}

/* Brand column: medium weight */
.index2-card__meta-col:nth-child(1) {
    font-weight: 500;
}

/* Stacked meta only when the card column is fairly narrow (keeps 3-up longer on tablets) */
@container index2-card (max-width: 700px) {
    .index2-card__meta {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
        padding: 0;
        text-align: left;
    }

    .index2-card .index2-card__meta .index2-card__meta-col {
        line-height: 100%;
        padding-bottom: 4px;
        text-align: left;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    /* Meta → media gap on narrow non-mobile layouts (mobile uses padding on the third line instead) */
    .index2-card__media-frame {
        margin-top: 12px;
    }

    .index2-card .index2-card__meta .index2-card__meta-col:last-child {
        padding-bottom: 0;
    }
}

@supports not (container-type: inline-size) {
    @media (max-width: 720px) {
        .index2-card__meta {
            display: grid;
            grid-template-columns: 1fr;
            gap: 0;
            padding: 0;
            text-align: left;
        }

        .index2-card .index2-card__meta .index2-card__meta-col {
            line-height: 100%;
            padding-bottom: 4px;
            text-align: left;
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
        }

        .index2-card .index2-card__meta .index2-card__meta-col:last-child {
            padding-bottom: 12px;
        }

        .index2-card__media-frame {
            margin-top: 0;
        }
    }

    /* Approximate “compressed 3-up” when container queries are unavailable */
    @media (min-width: 721px) and (max-width: 940px) {
        .index2-card__meta {
            grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr) minmax(0, 1.08fr);
            gap: 0.65rem 0.75rem;
            padding: 0 16px;
        }

        .index2-card__meta-col {
            font-size: clamp(11px, 1.35vw + 8px, 16px);
        }
    }
}

@media (max-width: 768px) {
    .index2-card {
        margin-bottom: var(--index2-mobile-vertical-gap);
    }
}

/*
 * Narrow viewports: when the third label wraps, meta + media can look like two equal bands.
 * Add more space above the meta block than below it so the copy clearly belongs to the tile under it.
 */
@media (max-width: 750px) {
    body.index2-page .index2-card__meta {
        padding-top: clamp(14px, 4vw + 8px, 26px);
    }

    body.index2-page .index2-card__meta-col {
        padding-bottom: 11px;
    }

    body.index2-page .index2-card .index2-card__meta .index2-card__meta-col:last-child {
        padding-bottom: 7px;
    }
}

/* Mobile: ~48px hero + inter-tile rhythm; drop the extra meta top band so spacing matches margin-bottom */
@media (max-width: 768px) {
    body.index2-page .index2-card__meta {
        padding-top: 0;
    }

    /* Beats @media (max-width: 750px) on stacked cards; third line gets 12px above the media frame */
    @container index2-card (max-width: 700px) {
        body.index2-page .index2-card .index2-card__meta .index2-card__meta-col {
            padding-bottom: 4px;
        }

        body.index2-page .index2-card .index2-card__meta .index2-card__meta-col:last-child {
            padding-bottom: 12px;
        }

        .index2-card__media-frame {
            margin-top: 0;
        }
    }
}

@supports not (container-type: inline-size) {
    @media (max-width: 720px) {
        body.index2-page .index2-card .index2-card__meta .index2-card__meta-col {
            padding-bottom: 4px;
        }

        body.index2-page .index2-card .index2-card__meta .index2-card__meta-col:last-child {
            padding-bottom: 12px;
        }

        .index2-card__media-frame {
            margin-top: 0;
        }
    }
}

/* Outer frame: shadow lives here — inner `.index2-card__media` uses overflow:hidden and would clip box-shadow */
.index2-card__media-frame {
    --index2-media-radius: clamp(16px, calc(16px + (100vw - 375px) * 24 / 1545), 40px);
    width: 100%;
    max-width: var(--index2-content-max);
    margin: 0 auto;
    border-radius: var(--index2-media-radius);
    position: relative;
    box-sizing: border-box;
    aspect-ratio: 16 / 9;
    box-shadow:
        0 2px 14px rgba(0, 0, 0, 0.086),
        0 1px 4px rgba(0, 0, 0, 0.062);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

body.index2-page[data-time="evening"] .index2-card__media-frame,
body.index2-page[data-time="night"] .index2-card__media-frame {
    box-shadow:
        0 2px 16px rgba(0, 0, 0, 0.266),
        0 1px 5px rgba(0, 0, 0, 0.19);
}

/* Clip + bleed live on the inner shell only */
.index2-card__media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    background: transparent;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Case study pill — index .video-flag look; align with meta inset (24px); only hide on large desktop hover */
body.index2-page .index2-card__case-link {
    position: absolute;
    top: 24px;
    left: 24px;
    transform: translate(-2px, -2px);
    z-index: 25;
    box-sizing: border-box;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    font: inherit;
    text-align: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(17px) saturate(180%);
    -webkit-backdrop-filter: blur(17px) saturate(180%);
    color: #ffffff;
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: 14px;
    line-height: 1;
    padding: 8px 14px;
    border-radius: 999px;
    font-optical-sizing: auto;
    font-variation-settings: "slnt" 0, "wdth" 100, "GRAD" 0, "ROND" 0;
    white-space: nowrap;
    text-decoration: none;
    border: 0.5px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.12),
        0 1px 2px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

@media (max-width: 768px) {
    body.index2-page .index2-card__case-link {
        top: clamp(10px, 3vw, 18px);
        left: clamp(10px, 3vw, 18px);
        font-size: clamp(11px, 3vw, 13px);
        padding: 6px 11px;
    }
}

/* Large desktop only: reveal pill on hover/focus (tablets & phones always show — fixes “invisible” pill) */
@media (hover: hover) and (pointer: fine) and (min-width: 1025px) {
    body.index2-page .index2-card__media .index2-card__case-link {
        opacity: 0;
        pointer-events: none;
    }

    body.index2-page .index2-card__media:hover .index2-card__case-link,
    body.index2-page .index2-card__media:focus-within .index2-card__case-link,
    body.index2-page .index2-card__case-link:focus {
        opacity: 1;
        pointer-events: auto;
    }
}

body.index2-page .index2-card__case-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.95);
    outline-offset: 2px;
}

/* Bleed past clip by 1px to hide subpixel gaps (hairlines) at rounded edges */
.index2-card__media video {
    position: absolute;
    inset: -1px;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    object-fit: cover;
    display: block;
    pointer-events: none;
    background: transparent;
}

.index2-card__media .index2-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.index2-slideshow {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.index2-slide {
    opacity: 0;
    transition: opacity 1.15s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.index2-slide.index2-slide--visible {
    opacity: 1;
    z-index: 2;
}

.index2-card__static-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

@supports (image-rendering: high-quality) {
    .index2-card__static-img,
    .index2-card__media .index2-slide {
        image-rendering: high-quality;
    }
}

.index2-cards__error {
    padding: 2rem 0;
    font-family: var(--font-primary);
    font-size: 15px;
    opacity: 0.7;
    text-align: center;
    max-width: 40rem;
    margin: 0 auto;
    color: var(--index2-dynamic-text, inherit);
}

@media (prefers-reduced-motion: reduce) {
    body.index2-page .typewriter-text {
        transition: none;
    }

    .index2-slide {
        transition: none;
    }

    body.index2-page .index2-card__case-link {
        transition: none;
    }
}
