/* Mobile-only enhancement layer. Keep desktop rules and interactions unchanged. */
@media (max-width: 800px) {
    body {
        background-attachment: scroll;
    }

    .shell {
        width: calc(100% - 2rem);
    }

    .header-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 44px;
        gap: 0.5rem 1rem;
        padding: 0.75rem 0;
    }

    .header-row nav {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.25rem;
        width: 100%;
    }

    .header-row nav a {
        justify-content: center;
        padding: 0.35rem 0.15rem;
        text-align: center;
        overflow-wrap: anywhere;
    }

    .home, .page {
        padding-top: 2rem;
    }

    .intro-grid h1, .page-title h1 {
        font-size: clamp(2rem, 8vw, 3.6rem);
        line-height: 1.06;
        overflow-wrap: anywhere;
    }

    .page-title {
        padding-bottom: 2rem;
    }

    .section, .feature {
        padding: 2.5rem 0;
    }

    .feature > *, .two-col > *, .image-story > *,
    .about-title > *, .stage-layout > *, .results-layout > *,
    .practice > *, .facts div {
        min-width: 0;
    }

    .page p, .page li, .facts dd, figcaption, .site-footer {
        overflow-wrap: anywhere;
    }

    .identity-badge {
        width: clamp(140px, 32vw, 180px);
        max-width: 100%;
    }

    .quick-links {
        gap: 0.5rem 1rem;
        align-items: center;
    }

    .quick-links a, .identity-link, .facts > a, .results-layout > div > a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .trace {
        margin-top: 2rem;
    }

    .destination {
        padding: 1.5rem 0;
    }

    .destination-preview {
        height: auto;
        max-height: 260px;
        aspect-ratio: 16 / 9;
    }

    .hero-image {
        padding: 2rem 0;
    }

    .hero-image img, .image-story img {
        height: auto;
    }

    .image-story figure {
        margin-inline: 0;
        min-width: 0;
    }

    .company-logo-link {
        min-width: 0;
        max-width: 100%;
    }

    .company-logo-link img {
        width: min(220px, 100%);
        height: auto;
    }

    .company-media {
        min-width: 0;
        padding: 0.5rem;
    }

    .company-media video, .company-media img {
        width: 100%;
        max-width: 100%;
        height: auto;
        object-fit: contain;
    }

    .about-title img {
        flex-shrink: 0;
    }

    .research-reading-layout {
        display: block;
    }

    .stage-layout, .results-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
    }

    .stage-picker {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stage-picker button {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .research-toc ol {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .research-toc a {
        height: 100%;
        padding: 0.65rem;
        gap: 0.5rem;
        font-size: 0.85rem;
        overflow-wrap: anywhere;
    }

    /* In-flow sticky navigation cannot cover the footer or the end of Notebook. */
    .research-rail-track {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--paper);
        border-bottom: 1px solid var(--line);
    }

    .research-rail {
        position: static !important;
        top: auto !important;
        bottom: auto;
        left: auto;
        width: 100%;
        max-height: none;
        transform: none;
        padding: 0.5rem !important;
        border: 0;
        overflow: visible;
    }

    .research-rail p {
        margin: 0;
    }

    .research-rail ol {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.25rem 0.75rem;
        overflow: visible;
    }

    .research-rail a {
        min-height: 44px;
        padding: 0.4rem;
        border-left: 0;
        border-bottom: 2px solid var(--line);
        overflow-wrap: anywhere;
    }

    .research-rail a[aria-current="location"] {
        transform: none;
        border-bottom-color: var(--accent);
    }

    .research-section {
        scroll-margin-top: 12rem;
    }

    .research-page {
        padding-bottom: 3rem;
    }

    .footer-links {
        gap: 0.25rem 1.25rem;
    }
}

@media (max-width: 600px) {
    .about-title {
        display: block;
    }

    .about-title img {
        margin-bottom: 1.25rem;
    }
}

/* Touch users cannot hover to discover the matching About/GitHub link. */
@media (max-width: 800px) and (hover: none) {
    .identity-link {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Do not spend most of a short landscape viewport on sticky navigation. */
@media (max-width: 800px) and (max-height: 500px) {
    .research-rail-track {
        position: static;
    }

    .research-section {
        scroll-margin-top: 1rem;
    }
}
