/* One compact mobile stage, followed immediately by the existing film. */
.mobile-hero-journey {
  display: contents;
}
.mobile-hero-controls,
.mobile-hero-meta {
  display: none;
}

@media (max-width: 767px), (pointer: coarse) and (max-width: 1024px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body.home-page:has(.mobile-hero-journey > .hero[data-hero-mode="nano"]) {
    --mobile-hero-screen: 100vh;
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --nano-ui-gutter: max(20px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    --laser-screen: var(--mobile-hero-screen);
    /* Keep the message close to the header, even on a tall phone screen. */
    --mobile-copy-top: calc(84px + var(--mobile-safe-top));
    --laser-width: calc(100vw - 8px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    --laser-top: calc(var(--mobile-copy-top) + 88px);
    --laser-height: clamp(156px, 44vw, 190px);
    --mobile-material-top: calc(var(--laser-top) + var(--laser-height) + 8px);
    --mobile-controls-top: calc(var(--mobile-material-top) + 28px);
    --mobile-hero-height: calc(var(--mobile-controls-top) + 48px + 64px + var(--mobile-safe-bottom));
  }
  @supports (height: 100svh) {
    body.home-page:has(.mobile-hero-journey > .hero[data-hero-mode="nano"]) {
      --mobile-hero-screen: 100svh;
    }
  }

  .mobile-hero-journey {
    display: block;
    position: relative;
    height: auto;
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] {
    position: relative;
    top: auto;
    height: var(--mobile-hero-height);
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }
  .film-section.is-after-mobile-hero {
    padding: 0 var(--nano-ui-gutter);
  }
  body.home-page:has(.mobile-hero-journey > .hero[data-hero-mode="nano"]) .site-header {
    position: fixed !important;
    top: calc(12px + var(--mobile-safe-top)) !important;
    left: var(--nano-ui-gutter) !important;
    right: var(--nano-ui-gutter) !important;
  }
  body.home-page:has(.mobile-hero-journey > .hero[data-hero-mode="nano"]) .site-brand.site-brand--official {
    --brand-width: 128px;
  }
  body.home-page:has(.mobile-hero-journey > .hero[data-hero-mode="nano"]) .motion-label {
    display: none;
  }
  body.home-page:has(.mobile-hero-journey > .hero[data-hero-mode="nano"]) .site-header .ui-reading-consultation {
    display: none;
  }

  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-intro {
    top: var(--mobile-copy-top);
    left: var(--nano-ui-gutter);
    right: var(--nano-ui-gutter);
    max-width: none;
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-tagline {
    font-size: clamp(24px, 6.6vw, 30px);
    line-height: 1.4;
  }
  /* Text is present from the first paint, including while WebGL is loading. */
  .mobile-hero-journey .hero-intro :is(.m-motion-hero-unit, .m-motion-hero-arrival),
  .mobile-hero-journey .hero-tagline > span,
  .mobile-hero-journey .hero-word .m-motion-line > span {
    opacity: 1 !important;
    transform: none !important;
    translate: none !important;
  }
  .mobile-hero-journey .nano-message-text {
    mask-image: none !important;
    -webkit-mask-image: none !important;
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-intro > .m-motion-hero-unit:has(.pill),
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-bottom,
  .mobile-hero-journey .hero[data-hero-mode="nano"] .passage-explore {
    display: none;
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .laser-frame {
    top: var(--laser-top);
    height: max(1px, var(--laser-height));
    width: var(--laser-width);
    border: 0;
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-word {
    top: calc(var(--laser-top) + var(--laser-height) * .53);
    left: 2%;
    width: 96%;
    height: min(24vw, var(--laser-height));
    font-size: min(21.25vw, calc(var(--laser-height) * 1.05));
  }
  .mobile-hero-journey .hero.has-passage > .ink-canvas {
    translate: none;
    opacity: 1;
  }

  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-media-caption {
    top: var(--mobile-material-top);
    right: auto;
    left: var(--nano-ui-gutter);
    bottom: auto;
    max-width: calc(100% - 2 * var(--nano-ui-gutter));
    font-size: 0;
    line-height: 0;
    gap: 0;
    opacity: 1;
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .nano-finish {
    font-size: 10px;
    line-height: 1.6;
    letter-spacing: .05em;
    border-left: 1px solid var(--blue);
    padding-left: 10px;
  }
  .mobile-hero-controls {
    position: absolute;
    z-index: 5;
    left: var(--nano-ui-gutter);
    right: var(--nano-ui-gutter);
    top: var(--mobile-controls-top);
    bottom: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    align-items: center;
    gap: 18px;
  }
  .mobile-material-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    min-height: 48px;
    padding: 10px 0;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
  }
  .mobile-material-button > span {
    font-size: 21px;
    line-height: 1;
  }
  .mobile-material-button:disabled {
    visibility: hidden;
  }
  .mobile-hero-consultation {
    min-width: 0;
    min-height: 48px;
    padding: 12px 16px;
    gap: 10px;
    font-size: 12px;
    white-space: nowrap;
  }
  .mobile-hero-meta {
    position: absolute;
    z-index: 5;
    left: var(--nano-ui-gutter);
    right: var(--nano-ui-gutter);
    bottom: calc(12px + var(--mobile-safe-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .mobile-hero-hint {
    font-size: 10px;
    line-height: 1.5;
    color: var(--muted);
  }
  .mobile-hero-journey:not(.is-mobile-journey-active) .mobile-hero-hint {
    visibility: hidden;
  }
  .mobile-hero-meta > a {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-height: 44px;
    min-width: 72px;
    font: 9px/1.4 var(--mono);
    letter-spacing: .06em;
  }
  .mobile-hero-meta > a > span:last-child {
    font-size: 22px;
  }
}

/* Match the portrait WebGL cap height while the text fallback is visible. */
@media (max-width: 767px) and (orientation: portrait),
       (pointer: coarse) and (max-width: 1024px) and (orientation: portrait) {
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-word {
    transform: translateY(-50%) scaleY(1.25);
    transform-origin: 50% 100%;
  }
}

/* A low landscape viewport needs one copy line and one control row. */
@media (max-width: 767px) and (max-height: 520px) and (orientation: landscape),
       (pointer: coarse) and (max-width: 1024px) and (max-height: 520px) and (orientation: landscape) {
  body.home-page:has(.mobile-hero-journey > .hero[data-hero-mode="nano"]) {
    --laser-width: calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    --laser-top: calc(116px + var(--mobile-safe-top));
    --laser-height: calc(var(--mobile-hero-screen) - var(--laser-top) - 78px - var(--mobile-safe-bottom));
    --mobile-hero-height: var(--mobile-hero-screen);
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-intro {
    top: calc(70px + var(--mobile-safe-top));
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-tagline {
    font-size: 22px;
    line-height: 1.35;
  }
  .mobile-hero-journey .hero-tagline > span {
    display: inline;
  }
  .mobile-hero-journey .hero[data-hero-mode="nano"] .hero-media-caption,
  .mobile-hero-hint {
    display: none;
  }
  .mobile-hero-controls {
    right: calc(var(--nano-ui-gutter) + 100px);
    top: auto;
    bottom: calc(12px + var(--mobile-safe-bottom));
    grid-template-columns: minmax(120px, 160px) minmax(170px, 210px);
    gap: 24px;
  }
  .mobile-hero-meta {
    left: auto;
  }
}

/* Motion activation and pause never change the stage height or the film position. */
