/* Phone composition: keep the journey within a clear, touch-safe frame. */
@media (max-width: 760px) {
  :root { --phone-gutter: 24px; }

  .site-header,
  body[data-reading="true"] .site-header {
    padding: max(20px, env(safe-area-inset-top)) var(--phone-gutter) 14px;
    align-items: center;
    gap: 18px;
  }
  .site-header .brand { flex: 0 0 auto; font-size: 15px; }
  .site-header .header-actions {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(12px, 3.5vw, 20px);
    min-width: 0;
    flex-wrap: nowrap;
  }
  .site-header .agency-nav,
  .site-header .header-actions .menu-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 44px;
    margin: 0;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
  }
  body[data-reading="true"] .site-header .menu-link { display: none; }

  /* The replay is a final-screen action, not a fourth header item. */
  .final-scene .final-bottom {
    top: auto;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: var(--phone-gutter);
    left: auto;
    max-width: calc(100% - 108px);
    justify-content: flex-end;
  }
  .final-scene .replay {
    min-height: 44px;
    padding: 10px 15px;
    border: 1px solid #fff2df6b;
    border-radius: 999px;
    background: #fff8efeb;
    color: #8f2e22;
    font-size: 12px;
    white-space: nowrap;
  }

  /* The full side rail belongs to larger screens. The next/explore actions
     below each chapter keep navigation available without crossing the work. */
  .flight-nav { display: none !important; }

  .chapter-copy:has(.curved-heading) {
    top: clamp(94px, 12vh, 116px);
    width: calc(100vw - 48px);
    max-width: calc(100vw - 48px);
  }
  .chapter-copy .chapter-title.curved-heading,
  .final-scene .wordmark.curved-heading {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
  }
  .curved-heading-art { width: 100%; max-width: 100%; }
  .chapter-copy:has(.curved-heading) .chapter-line {
    width: min(100%, 33ch);
    margin: 6px auto 0;
    font-size: 13px;
    line-height: 1.5;
  }
  .chapter-scroll-guide {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 24px;
    font-size: 11px;
  }
  .chapter-scroll-guide > * { gap: 6px; white-space: nowrap; }
  .chapter-scroll-guide svg { width: 15px; height: 20px; flex: 0 0 auto; }
  .final-scene:has(.curved-heading) {
    padding: clamp(94px, 12vh, 116px) var(--phone-gutter) 0;
  }
  .final-scene:has(.curved-heading) .wordmark {
    width: 100%;
    max-width: 100%;
  }
  .final-scene:has(.curved-heading) .final-tagline { margin-top: 6px; }

  .chapter-work,
  .chapter-work[data-mode="brands"],
  .chapter-work[data-mode="campaign"],
  .chapter-work[data-treatment="website-capture"] {
    top: 40vh;
    top: 40svh;
    width: calc(100vw - 48px);
    max-width: calc(100vw - 48px);
  }
  .chapter-work .scene-layout,
  .chapter-work[data-treatment="website-capture"] .scene-layout {
    grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
    gap: 16px;
    min-height: 0;
    align-items: start;
  }
  .chapter-work .scene-context { grid-column: 1; padding-top: 0; }
  .chapter-work .scene-visual,
  .chapter-work[data-treatment="website-capture"] .scene-visual,
  .chapter-work[data-treatment="greggs-campaign"] .scene-visual {
    grid-column: 2;
    width: 100%;
    max-width: 100%;
  }
  .chapter-work .scene-project-title { font-size: clamp(17px, 4.6vw, 21px); line-height: 1.15; }
  .chapter-work .scene-explanation { max-width: 23ch; font-size: 11px; line-height: 1.5; }
  .chapter-work .scene-art-button { width: 100%; transform: none; }
  .chapter-work .scene-switcher { max-width: 100%; }

  /* One even wall instead of two squeezed wings against the screen edges. */
  .chapter-work[data-mode="brands"] .scene-layout { display: block; }
  .chapter-work[data-mode="brands"] .brand-wall {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: clamp(38px, 5svh, 46px);
    gap: 12px 14px;
    width: 100%;
    margin: 0;
  }
  .chapter-work[data-mode="brands"] .brand-wall-wing { display: contents; }
  .chapter-work[data-mode="brands"] .brand-slot { min-width: 0; max-width: 100%; gap: 3px; }
  .chapter-work[data-mode="brands"] .brand-slot img { max-width: 100%; object-fit: contain; }
  .chapter-work[data-mode="brands"] .brand-image-window { max-width: 100%; }
  .chapter-work[data-mode="brands"] .brand-wordmark { min-width: 0; overflow-wrap: anywhere; }

  .chapter-work[data-mode="campaign"] .scene-layout { display: block; }
  .chapter-work[data-mode="campaign"] .scene-visual { width: 100%; max-width: 100%; }
  .chapter-work[data-mode="campaign"] .campaign-series {
    grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
    width: 100%;
    padding: 4px 5px;
  }
  .chapter-work[data-mode="campaign"] .campaign-wing { gap: 9px; }
  .chapter-work[data-mode="campaign"] .greggs-poster { max-height: 10.5svh; max-width: 100%; }
  .chapter-work[data-mode="campaign"] .scene-switcher {
    width: calc(50% - 32px);
    max-width: calc(50% - 32px);
    margin: 10px 0 0;
  }
  .chapter-work[data-mode="campaign"] .scene-pick {
    min-height: 44px;
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    white-space: normal;
    line-height: 1.3;
    font-size: 11px;
  }

  .planet-chapter-panel .chapter-actions {
    bottom: calc(74px + env(safe-area-inset-bottom));
    width: calc(100vw - 48px);
    max-width: calc(100vw - 48px);
    gap: 24px;
    align-items: center;
    justify-content: center;
  }
  .planet-chapter-panel .chapter-actions button { min-height: 44px; font-size: 12px; }
  .view-controls {
    bottom: calc(74px + env(safe-area-inset-bottom));
    width: calc(100vw - 48px);
    max-width: 360px;
    justify-content: center;
    gap: 12px;
    white-space: normal;
    flex-wrap: wrap;
    text-align: center;
  }
  .view-controls .orbit-help { display: none; }
}

@media (max-width: 380px) {
  .site-header .brand { font-size: 14px; }
  .site-header .header-actions { gap: 12px; }
  .site-header .agency-nav,
  .site-header .header-actions .menu-link { font-size: 11px; }
  .chapter-work[data-mode="brands"] .brand-wall { gap: 10px; }
  .planet-chapter-panel .chapter-actions { gap: 18px; }
}

@media (max-width: 760px) and (max-height: 730px) {
  .chapter-copy:has(.curved-heading) { top: 82px; }
  .final-scene:has(.curved-heading) { padding-top: 82px; }
  .chapter-copy:has(.curved-heading) .chapter-line { font-size: 12px; margin-top: 1px; }
  .chapter-scroll-guide { margin-top: 15px; font-size: 10px; }
  .chapter-work,
  .chapter-work[data-mode="brands"],
  .chapter-work[data-mode="campaign"],
  .chapter-work[data-treatment="website-capture"] { top: 40svh; }
  .chapter-work[data-mode="brands"] .brand-wall { grid-auto-rows: 33px; gap: 8px 12px; }
  .chapter-work[data-mode="campaign"] .greggs-poster { max-height: 9.6svh; }
  .chapter-work .scene-explanation { font-size: 10px; }
  .chapter-work .scene-project-title { font-size: 17px; }
  .planet-chapter-panel .chapter-actions,
  .view-controls { bottom: calc(65px + env(safe-area-inset-bottom)); }
}
