/* Display layouts for the current encounter. Keep this sheet after arcade.css.
   No device names or assumed future hardware. Unsupported segment queries use
   the normal responsive layout; manual modes never require fullscreen or lock
   orientation. All scenes retain their authored 16:9 composition. */
:root {
  --ath-safe-top:env(safe-area-inset-top,0px);
  --ath-safe-right:env(safe-area-inset-right,0px);
  --ath-safe-bottom:env(safe-area-inset-bottom,0px);
  --ath-safe-left:env(safe-area-inset-left,0px);
}
.mast {
  padding-top:max(16px,var(--ath-safe-top));
  padding-right:max(24px,var(--ath-safe-right));
  padding-left:max(24px,var(--ath-safe-left));
}
main {
  padding-left:max(24px,var(--ath-safe-left));
  padding-right:max(24px,var(--ath-safe-right));
  padding-bottom:max(28px,var(--ath-safe-bottom));
}
.stage,.film-frame { aspect-ratio:16/9; }
.stage canvas,.continuity-frame,.film-frame img,.film-frame video { object-fit:contain; }
.play-layout,.encounter,.companion,.companion-body,.film-copy,.controls { min-width:0; }
.controls button,.controls .onward { overflow-wrap:anywhere; }

/* Tablet portrait and smaller unfolded screens get the entire game width.
   The companion follows below; a narrow side column never shrinks the cue. */
@media (min-width:761px) and (max-width:1100px) {
  .play-layout { grid-template-columns:minmax(0,1fr); }
  .companion { display:block;margin-top:0; }
  .portrait { height:280px;min-height:0; }
  .companion-body { padding:16px 24px 24px; }
  .narrative p:last-child,.film-copy>p:not(.eyebrow),.chapter-ending p { font-size:17px; }
}

/* Shared touch ergonomics on tablets and landscape tabletop displays. */
@media (min-width:768px) {
  button,select { min-height:56px; }
  .controls button,.controls .onward,.film-controls button,#storyBridgeNext { min-height:60px; }
  .controls .block { min-width:220px;font-size:25px; }
  .controls .block small { font-size:11px; }
  .options label,details label { font-size:14px; }
  .setting-buttons button,details button,.film-link { font-size:14px; }
  .options select,details select { font-size:16px; }
  .mast nav a { min-height:44px;display:inline-flex;align-items:center; }
  summary { min-height:44px;display:list-item;padding-top:9px; }
}
@media (orientation:landscape) and (min-width:768px) {
  .controls { gap:14px; }
  .controls button,.controls .onward { min-height:60px; }
}

/* Tabletop: optional wider presentation with reachable, generous controls.
   Below 1101px it still stacks, including on a folded/narrow display. */
body[data-display-layout=tabletop] main,
body[data-display-layout=tabletop] .mast { max-width:1800px; }
body[data-display-layout=tabletop] .controls button,
body[data-display-layout=tabletop] .controls .onward,
body[data-display-layout=tabletop] .film-controls button,
body[data-display-layout=tabletop] #storyBridgeNext { min-height:64px;font-size:19px; }
body[data-display-layout=tabletop] .controls .block { font-size:28px; }
@media (min-width:1101px) {
  body[data-display-layout=tabletop] .play-layout { grid-template-columns:minmax(0,1fr) minmax(280px,340px);gap:28px; }
  body[data-display-layout=tabletop] .portrait { height:300px; }
}

/* Cabinet: one centered encounter with larger type and a deliberate primary
   action. Settings remain below the scene; ordinary scrolling stays available. */
body[data-display-layout=cabinet] main,
body[data-display-layout=cabinet] .mast { max-width:1060px; }
body[data-display-layout=cabinet] .play-layout { display:grid;grid-template-columns:minmax(0,1fr);gap:28px; }
body[data-display-layout=cabinet] h1 { font-size:clamp(34px,4.5vw,64px); }
body[data-display-layout=cabinet] h2 { font-size:clamp(27px,3vw,42px); }
body[data-display-layout=cabinet] .narrative { padding:28px;min-height:0; }
body[data-display-layout=cabinet] .narrative p:last-child,
body[data-display-layout=cabinet] .film-copy>p:not(.eyebrow),
body[data-display-layout=cabinet] .chapter-ending p { font-size:clamp(17px,1.8vw,21px);max-width:58ch; }
body[data-display-layout=cabinet] .controls button,
body[data-display-layout=cabinet] .controls .onward,
body[data-display-layout=cabinet] .film-controls button,
body[data-display-layout=cabinet] #storyBridgeNext { min-height:68px;font-size:20px; }
body[data-display-layout=cabinet] .controls .block { font-size:30px;flex:1; }
body[data-display-layout=cabinet] .stage-top,
body[data-display-layout=cabinet] .stage-bottom { font-size:12px; }
body[data-display-layout=cabinet] .input-notice { font-size:15px; }
body[data-display-layout=cabinet] .companion { display:block; }
body[data-display-layout=cabinet] .portrait { height:320px;min-height:0; }
body[data-display-layout=cabinet] .companion-body { padding:18px 24px 26px; }

@media (max-width:760px) {
  .mast { padding-left:max(16px,var(--ath-safe-left));padding-right:max(16px,var(--ath-safe-right)); }
  main { padding-left:max(14px,var(--ath-safe-left));padding-right:max(14px,var(--ath-safe-right)); }
}
@media (max-width:600px) {
  body[data-display-layout=cabinet] .companion { display:block; }
  body[data-display-layout=cabinet] .portrait { height:220px;min-height:0; }
  body[data-display-layout=cabinet] .narrative { padding:20px 16px 8px; }
  body[data-display-layout=cabinet] .stage-top,
  body[data-display-layout=cabinet] .stage-bottom { font-size:8px; }
}

/* Progressive enhancement for a known physical gap. Never bridge the hinge
   with the scene or controls. Put the complete surface in the first segment;
   do not try to split companions, change DOM order or guess a fold posture. */
@media (horizontal-viewport-segments:2) {
  body[data-display-layout] > .mast,
  body[data-display-layout] > main {
    inline-size:env(viewport-segment-width 0 0,100vw);
    max-inline-size:env(viewport-segment-width 0 0,100vw);
    margin-inline-start:env(viewport-segment-left 0 0,0px);
    margin-inline-end:0;
  }
  body[data-display-layout] .play-layout { display:grid;grid-template-columns:minmax(0,1fr); }
  body[data-display-layout] .companion { display:block; }
  body[data-display-layout] .portrait { height:220px;min-height:0; }
  body[data-display-layout] .mast { flex-wrap:wrap;gap:12px; }
  body[data-display-layout] .mast nav { flex-wrap:wrap;margin-left:0; }
  body[data-display-layout] .controls .block { min-width:0; }
}

/* A horizontal hinge creates vertically stacked segments. Keep the header
   and a scrollable main surface inside the first segment so interaction never
   crosses the gap. The scene stays 16:9; smaller panels scroll instead of crop. */
@media (vertical-viewport-segments:2) {
  body[data-display-layout] {
    display:grid;grid-template-rows:auto minmax(0,1fr);
    block-size:env(viewport-segment-height 0 0,100vh);
    min-block-size:0;max-block-size:env(viewport-segment-height 0 0,100vh);
    inline-size:env(viewport-segment-width 0 0,100vw);
    margin-top:env(viewport-segment-top 0 0,0px);
    overflow:hidden;
  }
  body[data-display-layout] > .mast { grid-row:1;inline-size:100%;max-inline-size:100%;margin:0;flex-wrap:wrap; }
  body[data-display-layout] > main {
    grid-row:2;inline-size:100%;max-inline-size:100%;min-block-size:0;
    overflow-y:auto;overscroll-behavior-y:contain;margin:0;
  }
  body[data-display-layout] .play-layout { display:grid;grid-template-columns:minmax(0,1fr); }
  body[data-display-layout] .companion { display:block; }
  body[data-display-layout] .portrait { height:220px;min-height:0; }
  body[data-display-layout] .controls .block { min-width:0; }
}
