/*
    Page structure and responsive changes.

    Components keep their visual rules in base.css. This later layer controls
    their placement without competing specificity or page-specific overrides.
*/
@layer layout {
    /* The natural-height strip completes the first screen on desktop.
       A short/mobile viewport may grow vertically rather than crush content. */
    .hero-screen {
        display: grid;
        grid-template-rows: minmax(min-content, 1fr) auto;
        min-height: calc(100svh - var(--navbar-height));
        background: var(--page-background);
    }

    .background-view {
        position: sticky;
        top: var(--navbar-height);
        align-self: start;
        display: grid;
        justify-items: center;
        padding: var(--hero-logo-top-offset) var(--container-padding) 2rem;
    }
    .background-view h1 {
        width: min(100%, 58rem);
    }
    .hero-logo {
        width: 100%;
        height: auto;
    }

    .feature-strip {
        position: relative;
        z-index: 1;
        display: flex;
        border-block: 1px solid var(--brand-color-dark);
        background: var(--brand-color);
        color: var(--text-on-brand);
    }
    .feature-strip article {
        flex: 1;
        min-width: 0;
        padding: 2rem var(--container-padding);
    }
    .feature-strip article + article {
        border-left: 1px solid var(--border-on-brand);
    }
    .feature-heading {
        display: flex;
        align-items: center;
        gap: var(--space-medium);
        margin-bottom: 1rem;
    }
    .feature-heading svg {
        flex: 0 0 3em;
        width: 3em;
        height: 3em;
        font-size: 1rem;
    }
    .feature-heading h2 {
        font-size: 1.75rem;
        line-height: 1.25;
    }
    .feature-strip p {
        color: var(--text-on-brand-muted);
        font-size: var(--type-body-small);
        line-height: 1.6;
    }

    .content-section,
    .standard-page {
        position: relative;
        background: var(--page-background);
        padding: var(--page-padding) var(--page-inset);
    }
    .content-section {
        z-index: 1;
        display: flex;
        align-items: flex-start;
        gap: 3.5rem;
        padding-block: 5rem;
    }
    .content-column {
        min-width: 0;
    }
    .content-column:first-child {
        flex: 0.9;
    }
    .content-column:last-child {
        flex: 1.1;
    }
    .content-column > * + * {
        margin-top: var(--content-section-gap);
    }

    /* Align unboxed prose with a neighboring card's text, including its
       border. Reusing the padding token preserves alignment on phones. */
    .content-block-inset {
        padding-inline: calc(var(--content-card-padding) + 1px);
    }

    .standard-page-content {
        max-width: var(--container-width);
        margin-inline: auto;
    }
    .standard-page-content > * + * {
        margin-top: var(--page-section-gap);
    }
    .project-page-content {
        max-width: 68rem;
    }
    .news-page-content {
        max-width: 68rem;
    }
    .contact-page-content {
        max-width: 60rem;
    }

    /* The director composition and People list have independent tracks.
       align-items:start prevents the bio from stretching to portrait height. */
    .about-lead {
        display: flex;
        align-items: flex-start;
        gap: 4rem;
    }
    .profile-panel {
        flex: 0 0 20rem;
        min-width: 0;
    }
    .profile-caption {
        margin-top: 1.25rem;
    }
    .profile-caption h2 {
        font-size: 1.75rem;
    }
    .profile-caption p {
        color: var(--text-muted);
        font-size: var(--type-body-small);
        margin-top: 0.3rem;
    }
    .about-card {
        flex: 1;
        min-width: 0;
    }
    .about-card > p {
        max-width: 65ch;
        font-size: 1.3125rem;
        line-height: 1.65;
    }
    .bio-research {
        margin-top: var(--space-large);
    }
    .bio-research h2 {
        font-size: 1.5rem;
    }
    .people-section {
        padding-top: 2rem;
        border-top: 1px solid var(--border-medium);
    }
    .people-section > * + * {
        margin-top: 2rem;
    }
    .people-list {
        display: grid;
        gap: 1.5rem;
    }
    .person-entry {
        display: grid;
        grid-template-columns: 7rem minmax(0, 1fr);
        align-items: start;
        gap: 1.5rem;
    }

    /* Full portraits: no fixed square crop, no decorative picture border. */
    .avatar {
        display: grid;
        place-items: center;
        background: var(--avatar-background);
        color: var(--brand-color);
    }
    .avatar img {
        width: 100%;
        height: auto;
        object-fit: contain;
        object-position: top center;
    }
    .avatar-small {
        aspect-ratio: 1;
    }
    .avatar-small svg {
        width: 45%;
    }

    /* Filter toolbars sit closer to their list than major page sections do. */
    .standard-page-content > .directory-tools {
        margin-top: 1.75rem;
        margin-bottom: 1.75rem;
    }
    /* The hidden empty-state paragraph remains between toolbar and list. */
    .directory-empty + .project-menu {
        margin-top: 1.5rem;
    }

    @media (min-width: 49rem) {
        .page-header:has(.page-actions) {
            grid-template-columns: minmax(0, 1fr) auto;
        }
        .page-header:has(.page-actions) > :not(.page-actions) {
            grid-column: 1;
        }
        .page-header .page-actions {
            grid-column: 2;
            grid-row: 2 / 4;
            align-self: end;
            justify-content: end;
        }
    }

    @media (max-width: 64rem) {
        /* Navigation collapses before labels can collide with the brand.
           Without JavaScript the links remain visible as a wrapping row. */
        .navbar {
            flex-wrap: wrap;
            gap: 0.25rem 0.75rem;
            padding-block: 0.75rem;
        }
        .nav-links {
            width: 100%;
            margin: 0;
            flex-wrap: wrap;
            gap: 0.25rem 1.25rem;
        }
        .site-header[data-menu-ready] .navbar {
            flex-wrap: nowrap;
            padding-block: 0;
        }
        .site-header[data-menu-ready] .nav-menu-button {
            display: block;
        }
        .site-header[data-menu-ready] .nav-links {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            display: none;
            width: auto;
            margin: 0;
            max-height: calc(100dvh - var(--navbar-height));
            overflow-y: auto;
            padding: 1rem var(--container-padding) 1.5rem;
            background: var(--surface-background);
            border-bottom: 1px solid var(--border-medium);
        }
        .site-header[data-menu-ready] .nav-links[data-menu-open="true"] {
            display: grid;
        }
        .nav-submenu {
            position: static;
            display: block;
            width: auto;
            min-width: 0;
            border: 0;
            padding: 0 0 0.5rem 1rem;
            background: transparent;
        }
        .nav-submenu a {
            white-space: normal;
        }
        .nav-item > .nav-menu-link::after {
            display: none;
        }
        .about-lead {
            gap: 2.5rem;
        }
        .profile-panel {
            flex-basis: 16rem;
        }
        .content-section {
            gap: 2rem;
        }
        .feature-strip article {
            padding-inline: 1.25rem;
        }
        .feature-heading {
            flex-direction: column;
            align-items: flex-start;
        }
    }

    @media (max-width: 48rem) {
        .hero-screen {
            display: block;
            min-height: 0;
        }
        .background-view {
            position: relative;
            top: auto;
            padding-bottom: 2.5rem;
        }
        .feature-strip,
        .content-section {
            display: block;
        }
        .feature-strip article {
            padding: 1.75rem var(--container-padding);
        }
        .feature-strip article + article {
            border-left: 0;
            border-top: 1px solid var(--border-on-brand);
        }
        .feature-heading {
            flex-direction: row;
            align-items: center;
        }
        .content-section {
            padding-block: 3rem;
        }
        .content-column + .content-column {
            margin-top: 3rem;
        }
        .page-header {
            padding-bottom: 2rem;
        }
        .page-title {
            max-width: 20ch;
        }
        .about-lead {
            display: block;
        }
        .profile-panel {
            max-width: 22rem;
        }
        .about-card {
            margin-top: 2rem;
        }
        .about-card > p {
            font-size: var(--type-body-small);
        }
        .person-entry {
            grid-template-columns: 3.5rem minmax(0, 1fr);
            gap: 0.75rem;
        }
        .person-name {
            font-size: var(--type-card);
        }
        .person-details {
            padding: 1.25rem;
        }
        .research-card {
            grid-template-columns: minmax(0, 1fr) 36%;
        }
        .research-card-media img {
            min-height: 100%;
        }
        .project-menu-title {
            font-size: var(--type-card);
        }
        .directory-tools {
            align-items: end;
            flex-wrap: wrap;
        }
        .news-post-with-media {
            grid-template-columns: 1fr;
        }
        .news-post-thumbnail {
            max-width: 25rem;
        }
        .contact-list > div {
            grid-template-columns: 1fr;
            gap: 0.35rem;
        }
        .site-footer {
            flex-direction: column;
        }
    }

    @media (max-width: 32rem) {
        .research-card {
            grid-template-columns: 1fr;
        }
        .research-card-media img {
            aspect-ratio: 16 / 9;
            height: auto;
        }
        .person-entry {
            grid-template-columns: 3rem minmax(0, 1fr);
        }
        .person-details {
            padding: 1rem;
        }
    }

    /* A small one-time hint, limited to actual hover devices. Transforms move
       paint only; the strip and content keep their original layout positions. */
    @media (hover: hover) and (prefers-reduced-motion: no-preference) {
        body:not(.has-scrolled) .feature-strip:hover,
        body:not(.has-scrolled)
            .hero-screen:has(.feature-strip:hover)
            + .content-section {
            animation: content-bounce 380ms ease;
        }
    }

    @keyframes content-bounce {
        0%,
        100% {
            transform: translateY(0);
        }
        45% {
            transform: translateY(-0.25rem);
        }
    }
}
