/* Media owns its ratio; the iframe never imposes a competing minimum height. */
.journey .film-player {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 0;
}
.journey .film-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
}

@media (max-width: 900px) {
  :root {
    --mobile-header: calc(68px + env(safe-area-inset-top, 0px));
    --mobile-media: min(56svh, 75vw, 360px);
    --mobile-gutter: clamp(20px, 6vw, 48px);
    --chapter-inset: var(--mobile-header);
    --chapter-outset: max(0px, calc(100% - var(--mobile-header) - var(--mobile-media)));
    --compact-reveal: 1;
  }
  html { scroll-padding-top: var(--mobile-header); }
  .journey-header, .journey-header.scrolled {
    padding: calc(12px + env(safe-area-inset-top, 0px)) max(5%, env(safe-area-inset-right, 0px)) 12px max(5%, env(safe-area-inset-left, 0px));
  }
  /* A bounded image window shows much more of each film than a tall phone crop.
     Its lower edge dissolves into the copy, keeping one continuous picture plane. */
  .sequence-screen {
    height: calc(var(--mobile-header) + var(--mobile-media));
    margin-bottom: calc(-1 * (var(--mobile-header) + var(--mobile-media)));
    z-index: 2;
    pointer-events: auto;
  }
  .sequence-screen .opening-poster, .sequence-screen .opening-video {
    top: var(--mobile-header);
    bottom: auto;
    height: var(--mobile-media);
    overflow: hidden;
  }
  .scene-image { top: var(--mobile-header); bottom: auto; height: var(--mobile-media); }
  .sequence-screen .opening-poster img, .scene-image img {
    width: 100%;
    height: var(--mobile-media);
    object-fit: cover;
    object-position: center;
  }
  .scene-image img { position: static; }
  .sequence-screen .opening-video iframe {
    width: 100%;
    height: max(var(--mobile-media), 56.25vw);
    min-width: calc(var(--mobile-media) * 16 / 9);
    transform: translate(-50%, -50%);
  }
  .scene-image-food img { object-fit: contain; }
  .sequence-shade {
    top: var(--mobile-header);
    bottom: auto;
    height: calc(var(--mobile-media) + 1px);
    background: linear-gradient(0deg, var(--ink), #0a0a0bb3 15%, #0a0a0b1a 50%, transparent 75%);
  }
  .opening, .no-motion .opening {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: auto;
    min-height: 0;
    padding: calc(var(--mobile-header) + var(--mobile-media) + 20px) var(--mobile-gutter) max(24px, env(safe-area-inset-bottom, 0px));
    gap: 24px;
  }
  .opening-intro, .opening-foot {
    position: relative;
    inset: auto;
    width: 100%;
  }
  .opening-intro h1 {
    font-size: clamp(48px, 10vw, 76px);
    letter-spacing: -.035em;
    line-height: 1.02;
    margin: 20px 0;
  }
  .opening-intro p { margin: 0; max-width: 34ch; }
  .opening-intro p br { display: none; }
  .opening-foot { align-items: end; gap: 24px; }
  .opening-foot h2 { font-size: 28px; margin: 10px 0 14px; }
  .opening-actions { height: auto; max-width: none; gap: 18px; }
  .opening-actions .continue-link { max-width: none; }
  #background-toggle { max-width: none; }
  .film-story, .food-scene, .no-motion .film-story {
    height: auto;
    min-height: 0;
    align-items: start;
    padding: calc(var(--mobile-media) + 20px) var(--mobile-gutter) 44px;
  }
  /* The shared picture already has its own space. Overlap the empty image
     reservation with the outgoing chapter instead of adding a second blank run.
     Only the copy receives input, so the overlapping padding cannot block CTAs. */
  .film-story { margin-top: calc(24px - var(--mobile-media)); pointer-events: none; }
  .scene-copy { padding-top: 0; width: 100%; max-width: none; pointer-events: auto; }
  .scene-copy a, .scene-copy button, .opening-foot a, .opening-foot button {
    scroll-margin-top: calc(var(--mobile-header) + var(--mobile-media) + 20px);
  }
  .no-motion .film-story { margin-top: 0; pointer-events: auto; }
  .scene-prelude { font-size: 15px; line-height: 1.5; margin-bottom: 12px; max-width: 36ch; }
  .scene-copy .eyebrow { display: block; }
  .scene-copy h2 { margin: 16px 0; }
  .scene-copy>p { margin-bottom: 18px; max-width: 34ch; }
  .scene-next { margin-top: 16px; }
  .scene-number, .food-frame { bottom: 16px; right: var(--mobile-gutter); }
  .stills-chapter { scroll-margin-top: 0; }
  .play-disc { width: 44px; height: 44px; }
  /* This decorative edge follows the viewport, not the inset reserved for controls. */
  .reading-progress { bottom: 0; }
  .project-dialog, .info-dialog {
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top, 0px)) - max(24px, env(safe-area-inset-bottom, 0px)));
    overscroll-behavior: contain;
  }
  .journey .gallery-stage>img {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    min-height: 0;
    max-height: none;
    object-fit: contain;
  }
  .journey .dialog-close, .has-films .dialog-close {
    width: 44px;
    height: 44px;
  }
  .has-films .dialog-close { margin: 8px 8px -52px 0; }
  .gallery-thumbnails { touch-action: pan-x; }
  .no-motion .opening, .no-motion .film-story {
    background-color: var(--ink);
    background-size: 100% 100%, 100% auto;
    background-position: center, center var(--mobile-header);
    background-repeat: no-repeat;
  }
}

@media (max-width: 600px) {
  .opening-foot { display: grid; grid-template-columns: 1fr; gap: 20px; }
  .opening-actions { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
  #background-toggle { font-size: 12px; letter-spacing: .08em; padding: 10px; white-space: nowrap; }
  .opening-actions .continue-link { font-size: 12px; max-width: 130px; }
  .opening-foot h2 { font-size: 26px; }
  .selection-heading { margin-bottom: 30px; }
  .stills-chapter { padding-top: 48px; padding-bottom: 48px; }
  .closing-note { padding-top: 48px; padding-bottom: 48px; }
  .journey .contact { padding-top: 48px; padding-bottom: 48px; }
  .stills-grid { gap: 28px 14px; }
  .stills-toolbar { font-size: 10px; letter-spacing: .08em; }
  .collection-invitation { margin-top: 28px; padding-top: 24px; }
  .site-footer { align-items: start; }
  .site-footer .footer-brand { width: auto; }
  .site-footer .back-top { width: 100%; margin-left: 0; }
  .film-player-links { padding: 16px; }
  .film-player-links a { min-height: 44px; display: inline-flex; align-items: center; }
  .film-picker { gap: 12px; }
  .modal-copy, .has-gallery .modal-copy { padding: 22px 20px; }
}

@media (max-width: 480px) {
  .stills-grid { grid-template-columns: minmax(0, 1fr); }
  .still-piece, .still-piece:nth-child(-n+2) { grid-column: 1; }
}

/* Landscape phones use a short, wide composition rather than a portrait height. */
@media (max-width: 1000px) and (max-height: 600px) and (orientation: landscape) {
  :root { --mobile-header: calc(60px + env(safe-area-inset-top, 0px)); --chapter-inset: var(--mobile-header); --chapter-outset: 0px; --compact-reveal: 0; }
  html { scroll-padding-top: var(--mobile-header); }
  .journey-header, .journey-header.scrolled { padding-top: 8px; padding-bottom: 8px; }
  .journey-header nav sup, .journey-header .header-contact { display: none; }
  .sequence-screen { height: 100svh; margin-bottom: -100svh; z-index: -1; pointer-events: none; }
  .scene-copy a, .scene-copy button, .opening-foot a, .opening-foot button { scroll-margin-top: var(--mobile-header); }
  .sequence-screen .opening-poster, .sequence-screen .opening-video { top: 0; height: 100svh; }
  .scene-image { top: 0; height: 100svh; }
  .sequence-screen .opening-poster img, .scene-image img { top: 0; height: 100svh; object-fit: cover; }
  .sequence-screen .opening-video iframe { width: max(100vw, 177.78svh); height: max(100svh, 56.25vw); min-width: 0; }
  .sequence-shade { inset: 0; height: auto; background: linear-gradient(90deg, #0a0a0be6, #0a0a0b66 70%), linear-gradient(0deg, var(--ink), transparent 50%); }
  .opening, .no-motion .opening {
    height: auto;
    min-height: 100svh;
    padding: calc(var(--mobile-header) + 22px) 6% 24px;
    gap: 26px;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    align-items: end;
  }
  .opening-intro, .opening-foot { position: relative; inset: auto; width: 100%; }
  .opening-intro h1 { font-size: 48px; margin: 16px 0; }
  .opening-intro p { font-size: 15px; max-width: 30ch; }
  .opening-foot { display: block; }
  .opening-actions { margin-top: 20px; flex-direction: row; align-items: center; gap: 16px; }
  .opening-foot h2 { font-size: 26px; }
  #background-toggle { font-size: 12px; white-space: nowrap; padding: 8px; }
  .continue-link { font-size: 12px; max-width: 110px; }
  .film-story, .food-scene, .no-motion .film-story { height: auto; min-height: 100svh; margin-top: 0; pointer-events: auto; padding: calc(var(--mobile-header) + 32px) 6% 42px; }
  .scene-copy { max-width: 600px; }
  .scene-prelude { margin-bottom: 12px; font-size: 15px; }
  .scene-copy h2, #holy-forever h2 { font-size: 40px; margin: 16px 0; }
  .scene-copy>p { font-size: 15px; margin-bottom: 16px; }
  .scene-next { margin-top: 12px; }
  .scene-number { bottom: 20px; }
  .journey .film-player { width: min(100%, calc((100dvh - 72px) * 16 / 9)); margin-inline: auto; }
  .journey .gallery-stage>img { height: calc(100dvh - 96px); width: 100%; aspect-ratio: auto; }
  .no-motion .opening, .no-motion .film-story { background-size: cover; background-position: center; }
}
