/*
 * Mobile optimization pass. Loaded after every other stylesheet so
 * equal-specificity overrides win through cascade order alone.
 */

/* Guard horizontal overflow at the root instead of on <main> so the
   sticky site header works on every page, not only the homepage. */
html,
body {
    overflow-x: hidden;
}

@supports (overflow-x: clip) {
    html,
    body {
        overflow-x: clip;
    }
}

main {
    overflow: visible;
}

/* Keep anchor targets clear of the sticky header. */
[id] {
    scroll-margin-top: 96px;
}

/* Balance multi-line display headings where supported. */
.page-hero h1,
.newsletter-copy h1,
.team-hero-copy h1,
.hero-live-copy h1,
.section-heading h2,
.page-heading h2,
.page-cta h2,
.members-heading h2 {
    text-wrap: balance;
}

/* Comfortable tap target for pagination links. */
.pagination a {
    padding: 12px 0 8px;
    display: inline-block;
}

/* Article body robustness on narrow screens (and everywhere else):
   scrollable tables, proportional video embeds, readable code blocks. */
.editorial-post-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

.editorial-post-body th,
.editorial-post-body td {
    border-bottom: 1px solid var(--line);
    min-width: 110px;
    padding: 10px 14px 10px 0;
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
    vertical-align: top;
}

.editorial-post-body th {
    color: var(--black);
    font-weight: 660;
}

.editorial-post-body iframe[src*="youtube"],
.editorial-post-body iframe[src*="youtu.be"],
.editorial-post-body iframe[src*="vimeo"],
.editorial-post-body iframe[src*="wistia"] {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
}

.editorial-post-body pre {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    margin: 0 0 1.5em;
    padding: 16px;
    font-size: 13.5px;
    line-height: 1.6;
    overflow-x: auto;
}

@media (width <= 820px) {
    .menu-button {
        width: 44px;
        height: 44px;
    }

    .site-nav a {
        font-size: 16px;
    }

    /* Subscriber login lives in the drawer once the header button hides.
       The link itself is appended by site.js. */
    .site-nav .site-nav-login {
        border-bottom: 0;
        color: var(--sunny);
        font-weight: 680;
    }

    .site-footer {
        gap: 28px;
        padding-block: 32px;
    }

    .site-footer-nav {
        gap: 2px 14px;
    }

    .site-footer-nav a {
        padding: 12px 4px;
        display: inline-block;
    }

    .site-footer-social a {
        width: 40px;
        height: 40px;
    }
}

.site-nav-login {
    display: none;
}

@media (width <= 820px) {
    .site-nav.is-open .site-nav-login {
        display: block;
    }
}

@media (width <= 620px) {
    /* Phone-scale display typography. The desktop clamps bottom out
       near print sizes (44-72px) that swallow small screens. */
    .page-hero h1,
    .newsletter-copy h1,
    .research-hero h1 {
        font-size: clamp(36px, 10.5vw, 44px);
        letter-spacing: -0.045em;
    }

    .page-hero {
        min-height: 400px;
        padding-top: 60px;
    }

    .page-hero > p:last-child,
    .newsletter-copy > p:last-child {
        margin-top: 20px;
    }

    .research-hero {
        min-height: 320px;
    }

    .delight-hero h1 {
        font-size: clamp(50px, 14.5vw, 60px);
    }

    .page-heading h2,
    .page-cta h2,
    .form-intro h2 {
        font-size: clamp(29px, 8.4vw, 35px);
        letter-spacing: -0.04em;
    }

    .page-heading {
        margin-bottom: 34px;
    }

    .page-cta h2 {
        margin-bottom: 34px;
    }

    .members-heading h2 {
        font-size: clamp(32px, 9vw, 38px);
    }

    .team-hero-copy h1 {
        font-size: clamp(42px, 12.5vw, 54px);
    }

    .team-principle blockquote {
        font-size: clamp(27px, 7.8vw, 33px);
        letter-spacing: -0.04em;
    }

    .research-stream-heading h2,
    .history-copy h2,
    .portal-copy h2,
    .section-heading h2,
    .closing-section h2 {
        font-size: clamp(29px, 8.4vw, 35px);
        letter-spacing: -0.04em;
    }

    .hero-live-copy h1 {
        font-size: clamp(35px, 10.8vw, 44px);
    }

    .gh-content > h1 {
        font-size: clamp(32px, 9.5vw, 40px);
    }

    .editorial-post-body h2 {
        font-size: clamp(26px, 7.5vw, 30px);
    }

    .editorial-post-body h3 {
        font-size: clamp(21px, 6vw, 24px);
    }

    .editorial-post-body blockquote {
        font-size: clamp(21px, 6vw, 26px);
        padding-left: 20px;
    }

    .page-prose p {
        font-size: 17px;
    }

    .page-prose .page-callout,
    .page-quote {
        margin-top: 40px;
        padding: 20px 0 20px 22px;
        font-size: clamp(23px, 6.6vw, 28px);
    }

    .history-page time {
        font-size: 32px;
    }

    /* Tighter vertical rhythm: desktop sections keep 60-120px of
       padding that reads as dead air on a phone. */
    .section,
    .page-section,
    .page-cta,
    .team-members-section,
    .team-principle,
    .portal-section,
    .form-section,
    .articles-section,
    .history-page,
    .page-prose {
        padding-block: 52px;
    }

    .history-band,
    .newsletter-layout {
        padding-block: 46px;
    }

    .research-stream-section {
        padding-block: 44px;
    }

    .team-hero {
        padding-top: 48px;
    }

    /* Collapse the tall fixed-height tiles: content should set the
       height, and numbers should not float 60-90px above headings. */
    .impact-card {
        flex-direction: column;
        min-height: 0;
        padding: 26px 22px;
        display: flex;
    }

    .impact-card h3 {
        margin: 40px 0 14px;
        font-size: 24px;
    }

    .impact-card p {
        margin-bottom: 24px;
    }

    .impact-card a {
        margin-top: auto;
        position: static;
    }

    .service-tile,
    .insight-grid article {
        min-height: 0;
        padding: 26px 22px;
    }

    .use-grid article {
        padding: 28px 22px;
    }

    .service-tile h3,
    .insight-grid h3,
    .use-grid h3 {
        margin: 32px 0 14px;
        font-size: 25px;
    }

    .article-grid article {
        min-height: 0;
        padding: 26px 20px;
    }

    .editorial-empty {
        padding: 28px 22px;
    }

    .editorial-empty h2 {
        margin-top: 32px;
    }

    /* Condensed research-stream cards: list-scale titles, tighter
       chrome, clamped excerpts, shorter image banners. */
    .home-research-stream {
        margin-top: 30px;
    }

    .research-description {
        padding: 22px 20px;
    }

    .creative-research-card-link {
        min-height: 0;
        padding: 20px 18px;
    }

    .creative-research-header {
        gap: 5px;
        padding-bottom: 12px;
    }

    .research-stream-card h2 {
        margin: 12px 0 10px;
        font-size: 22px;
    }

    .research-stream-card-cs p {
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        font-size: 12px;
        line-height: 1.5;
        display: -webkit-box;
        overflow: hidden;
    }

    .creative-research-cta {
        padding-top: 12px;
    }

    .publication-card-image {
        aspect-ratio: 3 / 1;
    }

    .publication-card-copy {
        padding: 16px 18px 18px;
    }

    .publication-source img {
        width: 32px;
        height: 32px;
    }

    /* Publication badge sits on the image banner as a solid chip
       instead of a text row above the title. */
    .publication-card-link {
        position: relative;
    }

    .publication-card-link:has(.publication-card-image) .publication-source {
        z-index: 1;
        background: var(--publication-bg);
        border-radius: 4px;
        padding: 4px 10px 4px 4px;
        position: absolute;
        top: 12px;
        left: 12px;
        box-shadow: 0 2px 12px #00000029;
    }

    .publication-card-link:has(.publication-card-image) .research-card-meta {
        margin-top: 0;
    }

    .research-stream-card-external .research-card-meta {
        margin-top: 12px;
    }

    .publication-card-cta {
        padding-top: 12px;
    }

    .research-stream-empty {
        min-height: 0;
    }

    .coverage-grid li {
        min-height: 120px;
        padding: 20px;
    }

    .coverage-grid strong {
        padding-top: 24px;
    }

    .newsletter-form {
        padding: 26px 20px;
    }

    /* The hero technology-stack diagram: on phones the horizontal
       five-layer strip only shows two layers and hides the rest behind
       an unsignposted scroll. Lay it out vertically instead — every
       layer visible, arrows flowing down the icon column. */
    .hero-stack-scroll {
        margin-top: 28px;
        padding-bottom: 0;
        overflow-x: visible;
    }

    .hero-stack {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .stack-layer {
        border-right: 0;
        border-bottom: 1px solid #d9d3cb;
        grid-template-columns: 44px minmax(0, 1fr);
        align-items: center;
        justify-items: start;
        column-gap: 16px;
        padding: 13px 2px;
    }

    .stack-layer:last-child {
        border-bottom: 0;
    }

    .stack-icon {
        width: 40px;
    }

    .stack-layer > span {
        margin-top: 0;
        font-size: 12px;
    }

    .stack-arrow {
        top: auto;
        right: auto;
        bottom: -14px;
        left: 22px;
        width: 24px;
        padding: 2px 0;
        transform: translateX(-50%) rotate(90deg);
    }
}
