/* Mobile scenes share the stable layout viewport measured by scene-viewport.js.
   Browser chrome changes do not alter either the pin height or scroll runway. */
@media (max-width: 800px) {
  .neural-hero.hero,
  .experience.building-story {
    min-height: 0;
    padding: 0;
    overflow: visible;
  }
  .neural-hero.hero {
    height: calc(var(--scene-viewport-height, 100svh) * 2.65 - var(--scene-header-height, 70px));
  }
  .experience.building-story {
    height: calc(var(--scene-viewport-height, 100svh) * 3.15 - var(--scene-header-height, 70px));
  }
  .neural-stage,
  .building-stage {
    position: sticky;
    top: var(--scene-header-height, 70px);
    height: calc(var(--scene-viewport-height, 100svh) - var(--scene-header-height, 70px));
    min-height: 0;
    max-height: none;
    overflow: visible;
  }
  .neural-stage {
    padding: 16px 20px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .neural-stage > .audience-switch {
    flex: 0 0 auto;
    width: min(100%, 460px);
    max-width: 460px;
    margin: 0 auto 15px;
    padding: 3px;
  }
  .neural-stage > .audience-switch button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 10px;
    line-height: 1.4;
    white-space: normal;
  }
  .neural-stage .centered-hero-title { flex: 0 0 auto; width: 100%; }
  .neural-stage .centered-hero-title > .eyebrow { margin-bottom: 8px; font-size: 7.5px; line-height: 1.4; }
  .neural-stage .centered-hero-title h1 {
    max-width: 620px;
    margin: 0 auto;
    font-size: clamp(36px, 7.8vw, 62px);
    line-height: 1.04;
    white-space: normal;
  }
  .neural-stage .centered-hero-title > p:not(.eyebrow) {
    max-width: 440px;
    margin: 10px auto 0;
    font-size: 11px;
    line-height: 1.55;
  }
  .neural-stage .brain-universe {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-height: none;
    height: auto;
    margin: 5px 0 0;
    overflow: visible;
  }
  .neural-stage .brain-parallax { inset: 0 0 20px; }
  .brain-parallax canvas { touch-action: pan-y pinch-zoom; }
  .neural-stage .neural-footer { flex: 0 0 auto; gap: 2px; margin: 3px 0 0; width: 100%; }
  .neural-stage .story-chapters { width: min(100%, 380px); justify-content: space-between; gap: 12px; }
  .neural-stage .story-chapters button { min-height: 44px; padding: 10px 2px; font-size: 9px; }
  .neural-stage .hero-next { min-height: 34px; padding: 6px 3px; font-size: 10px; line-height: 1.3; }

  /* All four callouts use one safe capsule position. A hotspot never pushes a
     bubble above the title or outside the viewport on a small screen. */
  .neural-stage .neural-topic { position: static; z-index: auto; }
  .neural-stage .topic-node { position: absolute; z-index: 4; width: 36px; height: 36px; padding: 10px; }
  .neural-stage .topic-coverage .topic-node { left: 25%; top: 30%; }
  .neural-stage .topic-connection .topic-node { right: 25%; top: 30%; }
  .neural-stage .topic-clarity .topic-node { left: 29%; top: 58%; }
  .neural-stage .topic-value .topic-node { right: 29%; top: 58%; }
  .neural-stage .neural-topic .brain-bubble {
    position: absolute;
    z-index: 6;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0 9px;
    width: min(360px, calc(100% - 12px));
    max-width: 100%;
    left: 50%;
    right: auto;
    top: auto;
    bottom: 2px;
    padding: 12px 14px;
    border-radius: 11px;
    background: #101e32f5;
    transform: translate(-50%, 9px) scale(.97);
    transform-origin: center bottom;
    box-shadow: 0 10px 28px #0208173b;
  }
  .neural-stage .neural-topic.is-active .brain-bubble { transform: translate(-50%, 0) scale(1); }
  .neural-stage .brain-bubble::after { display: none; }
  .neural-stage .brain-bubble .bubble-index { grid-column: 1; margin: 0; font-size: 6.5px; line-height: 1.5; letter-spacing: .07em; white-space: nowrap; }
  .neural-stage .brain-bubble h2 { grid-column: 2; margin: 0; font-size: 16px; line-height: 1.2; letter-spacing: -.035em; }
  .neural-stage .brain-bubble p { grid-column: 1 / -1; margin: 6px 0 0; font-size: 10px; line-height: 1.55; }
  .neural-stage .brain-bubble > .bubble-cta { grid-column: 1 / -1; min-height: 30px; margin-top: 5px; padding: 3px 0; font-size: 10px; }

  .building-stage {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 15px 22px 14px;
  }
  .building-heading.section-heading { flex: 0 0 auto; align-items: flex-start; margin: 0 0 12px; gap: 0; }
  .building-heading h2 { font-size: 28px; line-height: 1.1; }
  .building-heading .eyebrow { margin: 0 0 6px; font-size: 6.5px; line-height: 1.4; letter-spacing: .1em; }
  .building-heading > p { display: none; }
  .building-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 11px; width: 100%; min-height: 0; }
  .building-visual { width: 100%; min-width: 0; max-width: 480px; margin: 0 auto; }
  .building-visual-heading { padding: 7px 0 0; font-size: 6px; line-height: 1.4; letter-spacing: .08em; }
  .building-art {
    width: min(100%, clamp(200px, calc((var(--scene-viewport-height, 100svh) - 412px) * 1.16), 420px));
    min-width: 0;
    max-width: 420px;
    height: auto;
    aspect-ratio: 720 / 620;
    margin: 0 auto;
  }
  .building-network-layer > svg { overflow: visible; }
  .network-legend { gap: 12px; padding-top: 6px; font-size: 6.5px; line-height: 1.4; }
  .network-legend > span { min-width: 0; gap: 5px; }
  .network-legend i { flex: 0 0 12px; width: 12px; }
  .network-sequence { flex: none; font-size: 7px; }
  .building-narrative { width: 100%; max-width: 480px; min-width: 0; margin: 0 auto; padding: 0; }
  .building-step-nav {
    position: static;
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin: 0 0 8px;
  }
  .building-step-nav button { width: 44px; height: 44px; min-width: 44px; padding: 0; font-size: 10px; }
  .building-step-nav button:not(:last-child)::after { left: 43px; top: 21px; width: 9px; }
  .building-copy-stack { min-height: 0; padding: 0; }
  .building-feature .eyebrow { min-height: 0; max-width: none; margin: 0 0 6px; padding: 0; font-size: 6.5px; line-height: 1.5; }
  .building-feature h3 { margin: 0 0 8px; font-size: 25px; line-height: 1.13; }
  .building-feature h3 br { display: none; }
  .building-feature > p:not(.eyebrow) { max-width: none; margin: 0; font-size: 10px; line-height: 1.7; }
  .building-feature ul { display: flex; flex-wrap: wrap; gap: 2px 13px; margin: 8px 0 0; }
  .building-feature li { font-size: 8px; line-height: 1.5; padding: 0; }
  .building-feature li::before { margin-right: 5px; }
  .building-progress { margin-top: 9px; height: 2px; }
  .building-note { max-width: none; margin: 7px 0 0; font-size: 6.5px; line-height: 1.55; }
  .building-point { min-height: 30px; gap: 5px; }
  .point-label { font-size: 6px; padding: 6px 7px; letter-spacing: .035em; }
}

/* overflow:clip clips the artwork without creating a sticky scroll container.
   Older engines keep visible overflow; overflow:hidden is intentionally absent. */
@supports (overflow: clip) {
  @media (max-width: 800px) {
    .neural-hero.hero,
    .experience.building-story { overflow: clip; }
  }
}

@media (max-width: 480px) {
  .neural-stage,
  .building-stage { top: var(--scene-header-height, 64px); height: calc(var(--scene-viewport-height, 100svh) - var(--scene-header-height, 64px)); }
  .neural-stage { padding: 10px 16px 8px; }
  .neural-stage > .audience-switch { max-width: 390px; margin-bottom: 9px; }
  .neural-stage > .audience-switch button { padding: 7px 6px; font-size: 8.5px; gap: 4px; }
  .neural-stage > .audience-switch button > span { font-size: 13px; }
  .neural-stage .centered-hero-title > .eyebrow { font-size: 6.5px; margin-bottom: 6px; letter-spacing: .12em; }
  .neural-stage .centered-hero-title h1 { max-width: 390px; font-size: clamp(36px, 10.5vw, 47px); line-height: 1.04; }
  .neural-stage .centered-hero-title > p:not(.eyebrow) { max-width: 300px; margin-top: 8px; font-size: 10px; line-height: 1.5; }
  .neural-stage .brain-universe { margin-top: 3px; }
  .neural-stage .story-chapters { gap: 10px; }
  .neural-stage .story-chapters button { font-size: 8px; }
  .neural-stage .hero-next { font-size: 9px; }
  .neural-stage .neural-topic .brain-bubble { width: calc(100% - 8px); gap: 0 7px; padding: 10px 12px; }
  .neural-stage .brain-bubble h2 { font-size: 15px; }
  .neural-stage .brain-bubble .bubble-index { font-size: 6px; }
  .neural-stage .brain-bubble p { font-size: 9.5px; line-height: 1.5; }
  .building-stage { padding: 12px 17px; }
  .building-heading h2 { font-size: 25px; }
  .building-heading .eyebrow { font-size: 6px; }
  .building-layout { gap: 9px; }
  .building-step-nav { gap: 7px; }
  .building-step-nav button:not(:last-child)::after { width: 8px; }
  .building-feature h3 { font-size: 23px; }
  .building-feature > p:not(.eyebrow) { font-size: 10px; line-height: 1.65; }
  .building-feature li { font-size: 7.5px; }
}

/* A 568px portrait viewport still keeps the art, all narrative copy, and the
   five direct-access stages on screen. Only decorative category eyebrows fold. */
@media (max-width: 599px) and (max-height: 700px) and (min-height: 501px) {
  .neural-stage { padding-top: 8px; padding-bottom: 6px; }
  .neural-stage > .audience-switch { margin-bottom: 7px; }
  .neural-stage .centered-hero-title h1 { font-size: clamp(34px, 10.1vw, 41px); }
  .neural-stage .centered-hero-title > p:not(.eyebrow) { margin-top: 6px; }
  .neural-stage .neural-footer { gap: 0; margin-top: 0; }
  .neural-stage .hero-next { min-height: 31px; }
  .neural-stage .brain-parallax { bottom: 18px; }
  .building-stage { justify-content: center; padding: 8px 16px; }
  .building-heading.section-heading { margin-bottom: 7px; }
  .building-heading h2 { font-size: 22px; line-height: 1.08; }
  .building-heading .eyebrow { margin-bottom: 4px; font-size: 5.8px; }
  .building-layout { gap: 7px; }
  .building-visual-heading { padding-top: 4px; font-size: 5.5px; }
  .building-art { width: min(100%, clamp(200px, calc((var(--scene-viewport-height, 100svh) - 414px) * 1.16), 360px)); }
  .network-legend { padding-top: 4px; font-size: 6px; gap: 10px; }
  .network-sequence { font-size: 6px; }
  .building-step-nav { gap: 7px; margin-bottom: 4px; }
  .building-feature .eyebrow { display: none; }
  .building-feature h3 { font-size: 21px; line-height: 1.12; margin-bottom: 6px; }
  .building-feature > p:not(.eyebrow) { font-size: 9.5px; line-height: 1.65; }
  .building-feature ul { margin-top: 6px; gap: 1px 10px; }
  .building-feature li { font-size: 7.3px; line-height: 1.5; }
  .building-progress { margin-top: 7px; }
  .building-note { margin-top: 6px; font-size: 6.2px; line-height: 1.5; }
}

/* Tablet portrait has room for architecture and narrative side by side. */
@media (min-width: 600px) and (max-width: 800px) and (min-height: 501px) {
  .building-stage { padding: 24px 27px; justify-content: center; }
  .building-heading.section-heading { margin-bottom: 23px; }
  .building-heading h2 { font-size: 34px; }
  .building-heading .eyebrow { font-size: 7px; margin-bottom: 8px; }
  .building-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: center; }
  .building-art { width: 100%; max-width: 430px; }
  .building-visual-heading { font-size: 5.5px; }
  .network-legend { flex-wrap: wrap; gap: 7px 12px; }
  .network-sequence { margin-left: 0; }
  .building-step-nav { gap: 5px; margin-bottom: 15px; }
  .building-step-nav button:not(:last-child)::after { width: 6px; }
  .building-feature h3 { font-size: 26px; margin-bottom: 10px; }
  .building-feature > p:not(.eyebrow) { font-size: 11px; line-height: 1.75; }
  .building-feature ul { display: block; margin-top: 12px; }
  .building-feature li { font-size: 9px; padding: 2px 0; }
  .building-note { font-size: 7px; margin-top: 11px; }
}

/* Very short landscape screens use ordinary page flow. The JS helper still
   advances the story while scrolling, without trapping content in a pin. */
@media (max-height: 500px) and (max-width: 1100px),
       (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  .neural-hero.hero,
  .experience.building-story { height: auto; min-height: 0; overflow: visible; }
  .neural-stage,
  .building-stage { position: relative; top: 0; height: auto; min-height: 0; max-height: none; }
  .neural-stage { padding-top: 16px; padding-bottom: 20px; }
  .neural-stage .brain-universe { flex: none; width: min(100%, 680px); height: 330px; min-height: 0; margin-top: 8px; }
  .neural-stage .brain-parallax { inset: 0 0 20px; }
  .neural-stage .neural-footer { margin-top: 4px; }
  .building-stage { padding-top: 25px; padding-bottom: 35px; }
  .building-art { width: min(100%, 390px); min-width: 0; }
  .building-copy-stack { min-height: 0; }
  .building-narrative { padding-top: 0; }
}

/* Keep the reduced-motion escape authoritative after every size override. */
@media (prefers-reduced-motion: reduce) {
  .neural-hero.hero,
  .experience.building-story { height: auto !important; min-height: 0 !important; overflow: visible; }
  .neural-stage,
  .building-stage { position: relative !important; top: 0 !important; height: auto !important; min-height: 0 !important; max-height: none; }
  .neural-stage .brain-universe { flex: none; height: clamp(300px, 55vw, 460px); min-height: 0; }
  .brain-parallax,
  .centered-hero-title,
  .hero-atmosphere,
  .building-art { transform: none !important; }
  .building-art { width: min(100%, 440px); min-width: 0; }
  .building-feature .eyebrow { display: block; }
  .building-feature.is-active,
  .brain-bubble,
  .network-conduit,
  .network-unit,
  .wifi-field { animation: none !important; transition: none !important; }
}
