/* A reading-first layout for phones, zoomed windows and short landscape screens. */
.chapter-picker,
.mobile-scale-hint { display: none; }

@media (max-width: 1000px) {
  .nav-shell { height: 64px; gap: 12px; }
  .nav-shell .brand { gap: 8px; }
  .nav-shell .brand-name { font-size: 14px; }
  .nav-shell .brand-mark { width: 27px; height: 27px; }
  .nav-actions { gap: 7px; margin-left: auto; }
  .nav-actions .language-switch,
  .nav-actions .menu-toggle { min-width: 44px; min-height: 44px; }
  .nav-actions .language-switch { font-size: 13px; padding-inline: 5px; }
  .nav-actions .menu-toggle { display: flex; }
  .site-header .nav-links {
    display: none; position: absolute; inset: 64px 0 auto; margin: 0;
    flex-direction: column; gap: 0; padding: 8px 22px 16px;
    background: #fff; border-bottom: 1px solid var(--line);
    max-height: calc(100svh - 64px); overflow-y: auto;
  }
  .site-header .nav-links.open { display: flex; }
  .site-header .nav-links a { font-size: 16px; min-height: 48px; padding: 12px 6px; }

}

@media (max-width: 800px), (max-width: 1000px) and (max-height: 500px) {
  /* One stable return target and one current-section control, instead of stacked rows. */
  .scroll-chapter-nav.compact-chapters {
    position: sticky; top: 70px; display: grid;
    grid-template-columns: var(--return-slot, 0px) minmax(0, 1fr);
    column-gap: 0; row-gap: 0; padding: 6px 8px;
    border-radius: var(--radius-panel); margin-bottom: 20px;
  }
  .scroll-chapter-nav.compact-chapters::before { grid-column: 1; grid-row: 1; min-height: 44px; }
  .scroll-chapter-nav.compact-chapters::after { display: none; }
  .compact-chapters .chapter-picker { display: block; grid-column: 2; grid-row: 1; min-width: 0; }
  .chapter-picker summary {
    min-height: 44px; display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: var(--radius-pill); cursor: pointer;
    background: #f0eaf7; color: #59378a; list-style: none;
    font: 500 14px/1.5 var(--font);
  }
  .chapter-picker summary::-webkit-details-marker { display: none; }
  .chapter-picker summary::after {
    content: ''; width: 7px; height: 7px; flex: none; margin-left: auto;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg); transition: transform .18s ease;
  }
  .chapter-picker[open] summary::after { transform: translateY(2px) rotate(225deg); }
  .chapter-picker summary:focus-visible { outline: 3px solid #6940ab; outline-offset: 3px; }
  .chapter-picker-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chapter-picker-count { flex: none; color: #756585; font-size: 12px; font-variant-numeric: tabular-nums; }
  body .compact-chapters .chapter-picker > .chapter-links {
    position: absolute; inset: calc(100% + 6px) 0 auto; display: flex;
    flex-direction: column; flex-wrap: nowrap; gap: 3px; padding: 7px; margin: 0;
    max-height: min(420px, calc(100svh - 150px)); overflow-y: auto;
    border: 1px solid #e0d7ea; border-radius: var(--radius-panel);
    background: #fff; box-shadow: 0 12px 28px #35244412;
  }
  body .chapter-picker:not([open]) > .chapter-links { display: none; }
  body .compact-chapters .chapter-picker > .chapter-links a[data-mobile-label] {
    display: flex; flex: none; min-height: 44px; justify-content: flex-start;
    padding: 10px 14px; font: 400 14px/1.6 var(--font);
    white-space: normal; overflow-wrap: normal; text-align: left; border-radius: var(--radius-item);
  }
  body .compact-chapters .chapter-picker > .chapter-links a[data-mobile-label]::before { display: none; }
  .chapter-return { max-width: min(160px, 42vw); min-height: 44px; padding: 10px 12px; font-size: 13px; }
  html.motion-nav-page { scroll-padding-top: calc(84px + var(--chapter-nav-height, 58px)); }
  .site-header.menu-open ~ .chapter-return { visibility: hidden; }
  body:has(.site-header.menu-open) .scroll-chapter-nav { visibility: hidden; }

  /* Keep small-screen reading crisp while retaining the site's restrained motion. */
  .motion-enabled .motion-enter { opacity: 1; transform: translateY(calc((1 - var(--enter, 1)) * 12px)); }
  .motion-enabled .motion-enter.motion-settled { transform: none; }
}

@media (max-width: 600px) {
  .catalog-hero { padding-top: 112px; }
  .study-main { padding-top: 104px; }
  body main :is(.catalog-hero h1, .study-hero h1, .void-hero h1, .contact-intro h1) {
    font-size: clamp(34px, 8.8vw, 42px); line-height: 1.16; letter-spacing: -.045em;
  }
  body main :is(.catalog-lead, .study-lead, .method-module-heading > p,
    .solution-copy > p, .platform-section-heading > p, .data-overview-intro > p,
    .training-overview-intro > p, .training-outcome > p, .research-theme-heading > p,
    .research-study-copy > p:not(.research-method), .mptt-section-intro > p,
    .study-section > p, .case-context .narrative-heading > p,
    .characterization-heading > p, .characterization-case-panel > p,
    .characterization-software > div > p, .characterization-outlook p,
    .characterization-inverse p:not(.scale-stage-label), .method-scale-step > p) {
    font-size: 16px; line-height: 1.85;
  }
  body main :is(.scale-route p, .case-reading-path p, .showcase-benefits p,
    .gallery-result-copy, .gallery-detail-points span, .scale-step-links a span,
    .application-scope p, .platform-capabilities p, .platform-validation-grid p,
    .platform-model-matching p, .platform-use-paths p, .platform-design-route p,
    .characterization-capabilities p, .characterization-case-pair p, .study-three p,
    .study-two p, .mechanism-route p, .scale-use-paths p, .design-evidence p) {
    font-size: 14px; line-height: 1.8;
  }
  body main :is(.section-kicker, .platform-step, .research-method, .study-fullname,
    .solution-label, .scale-stage-label, .research-publications-intro) { font-size: 13px; line-height: 1.65; }
  body main :is(.text-link, .scale-step-links a, .home-inline-link, .home-path-cta) {
    font-size: 14px; line-height: 1.7; min-height: 44px; padding-block: 8px;
  }
  body main :is(.gallery-science-figure figcaption, .data-source-picture > figcaption,
    .method-preview-caption, .mptt-viewer-caption, .mptt-geometry > figcaption,
    .study-figure figcaption, .recording-bar p, .recording-bar > a,
    .research-media-footer > span, .void-legend, .void-values dt) { font-size: 12px; line-height: 1.65; }
  .mptt-choice legend { font-size: 13px; }
  .mptt-choice span { font-size: 14px; padding-inline: 12px; }
  .void-controls input[type=range] { height: 44px; margin-block: 4px; }
  .void-transport { flex-wrap: wrap; }
  .void-transport button { min-height: 44px; font-size: 14px; }
  .void-time-ticks, .void-explorer > figcaption > span { font-size: 12px; }
  .preview-case-options button, .recording-options button, .training-modes button,
  .research-case-controls button[data-case], .research-filters button {
    min-height: 44px; font-size: 14px; line-height: 1.6;
  }
  .research-case-controls .timed-gallery-controls > span { font-size: 13px; }
  .data-source-options button { min-height: 76px; }
  .data-source-options button > span:first-child { font-size: 15px; }
  .data-source-options button > span:nth-child(2) { font-size: 13px; }
  .characterization-case-layout.timed-gallery .characterization-case-options > [data-test-case] > span:first-child { font-size: 14px; }
  .contact-person .contact-affiliation, .contact-person p { font-size: 14px; line-height: 1.8; }
  .footer-tagline, .site-footer .footer-contact a { font-size: 14px; line-height: 1.8; }
  .site-footer .footer-links a { min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; }

  /* Four choices stay visible; the selected choice's description has its own reading line. */
  .model-scale-path { gap: 6px; }
  .model-scale-path button { min-height: 56px; height: 100%; padding: 10px 12px; gap: 0; }
  .model-scale-path .scale-choice-title { font-size: 15px; line-height: 1.5; min-height: 0; transform: none; }
  .model-scale-path .scale-choice-description { display: none; }
  .model-scale-path .scale-choice-progress { margin-top: 7px; }
  .method-gallery-nav .mobile-scale-hint { display: block; font-size: 14px; line-height: 1.65; min-height: 3.3em; margin: 12px 8px 0; color: var(--story-copy); }
  .method-gallery-controls { padding: 10px 8px 0; }
  .method-gallery .method-scale-step, #numerical-methods .method-gallery .method-scale-step { min-height: 0; }
  .gallery-detail-points strong { font-size: 15px; }
}

@media (max-width: 360px) {
  .chapter-picker-count { display: none; }
  .chapter-picker summary { padding-inline: 10px; }
  .nav-shell { gap: 6px; }
  .nav-actions { gap: 2px; }
  .nav-shell .brand { gap: 7px; }
  .nav-shell .brand-name { font-size: 13px; }
}

@media (max-height: 500px) and (max-width: 1000px) {
  /* Leave more space for content in landscape and at high browser zoom. */
  .site-header { position: absolute; }
  .site-header.menu-open { position: fixed; }
  .scroll-chapter-nav.compact-chapters { top: 8px; }
  html.motion-nav-page { scroll-padding-top: calc(22px + var(--chapter-nav-height, 58px)); }
  body .compact-chapters .chapter-picker > .chapter-links { max-height: calc(100svh - 88px); }
}

/* Short desktop windows retain one chapter row while the global header scrolls away. */
@media (min-width: 1001px) and (max-height: 600px) {
  body:has(.scroll-chapter-nav) .site-header { position: absolute; }
  .scroll-chapter-nav.has-chapter-return { position: sticky; top: 8px; }
  html.motion-nav-page { scroll-padding-top: calc(22px + var(--chapter-nav-height, 66px)); }
}

@media (prefers-reduced-motion: reduce) {
  .chapter-picker summary::after { transition: none; }
  .motion-enabled .motion-enter { transform: none; }
}

@media (max-width: 600px) {
  .paper-journal, .paper-authors, .paper-meta, .research-count { font-size: 13px; line-height: 1.7; }
  .paper-row .paper-link { min-height: 44px; align-items: center; font-size: 14px; }
}

@media (max-width: 600px) {
  .site-footer .footer-links { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
  .site-footer .footer-links a { font-size: 13px; }
  .site-footer .footer-grid { gap: 22px; }
  input, select, textarea { font-size: 16px; }
}

@media (max-width: 800px), (max-width: 1000px) and (max-height: 500px) {
  .menu-toggle span { transition: transform .18s ease, opacity .18s ease; }
  .menu-open .menu-toggle span:first-child { transform: translateY(7.5px) rotate(45deg); }
  .menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
  .menu-open .menu-toggle span:last-child { transform: translateY(-7.5px) rotate(-45deg); }
}
@media (prefers-reduced-motion: reduce) { .menu-toggle span { transition: none; } }

@media (max-width: 800px), (max-width: 1000px) and (max-height: 500px) {
  .nav-shell .brand { opacity: 1; transition: opacity .2s ease, visibility 0s; }
  .site-header.has-docked-return:not(.menu-open) .brand { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease, visibility 0s .2s; }
}
@media (max-width: 800px), (max-width: 1000px) and (max-height: 500px) {
  .site-header.has-docked-return ~ .chapter-return { z-index: 101; }
}
@media (max-width: 800px), (max-width: 1000px) and (max-height: 500px) {
  body .compact-chapters .chapter-picker > .chapter-links { max-height: var(--chapter-list-space, min(420px, calc(100svh - 150px))); }
  body .compact-chapters .chapter-picker.opens-up > .chapter-links { inset: auto 0 calc(100% + 6px); }
}
@media (prefers-reduced-motion: reduce) { .nav-shell .brand { transition: none !important; } }
