/* The two banks flank a dedicated model stage. The center button has its own
   space, so an aircraft wing or the board can never pass underneath it. */
.tunnel.scene {
  --stage-lift: clamp(26px, 4.5vh, 44px);
  display: grid;
  grid-template-columns: clamp(156px, 15vw, 212px) minmax(0, 1fr) clamp(156px, 15vw, 212px);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "random . toggle" "left visual right" "left project right" "foot foot foot";
  column-gap: clamp(12px, 1.4vw, 24px);
  padding: clamp(15px, 1.7vw, 28px);
  color: var(--control-text);
}
.visual-bay {
  grid-area: visual; position: relative; min-width: 0; min-height: 0;
  width: 100%; height: 100%; overflow: hidden;
  translate: 0 calc(-1 * var(--stage-lift));
}
.project-slot {
  grid-area: project; display: grid; justify-items: center; align-items: center;
  padding: 4px 0 clamp(15px, 3vh, 30px); min-width: 0;
}
.project-slot .project-cta {
  justify-self: center;
  width: min(100%, 465px);
  min-height: clamp(86px, 11vh, 110px);
  padding: 16px clamp(20px, 3vw, 48px);
  gap: clamp(14px, 2.1vw, 32px);
  font-size: clamp(27px, 2.65vw, 38px);
}
.project-slot .link-arrow { width: 1.15em; height: 1.15em; }
#random, .scene-toolbar { position: relative; z-index: 1; }
.console-rail { min-width: 0; display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: clamp(21px, 4vh, 42px); }
.rail-left { grid-area: left; }
.rail-right { grid-area: right; }
.console-rail .control-heading { align-items: start; flex-wrap: wrap; gap: 3px 6px; }
.console-rail .control-heading output { text-align: left; }
#random { grid-area: random; justify-self: start; align-self: center; }
.scene-toolbar {
  grid-area: toggle; justify-self: end; align-self: center;
  display: flex; align-items: center; gap: 8px; width: max-content;
}
#controls-toggle, .scene-toolbar #limits-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 9px 15px; border: 1px solid #697d92; border-radius: 999px;
  background: #202831; color: var(--control-text); font-size: 14px; font-weight: 650;
  line-height: 1.15; white-space: nowrap;
}
.scene-toolbar #limits-button { width: auto; height: auto; min-width: 44px; color: #c7e2ff; }
#controls-toggle:hover, #controls-toggle[aria-expanded=true], .scene-toolbar #limits-button:hover { background: #2b3745; border-color: #9bc7f3; }
#controls-toggle .ui-icon { width: 18px; height: 18px; }
#tunnel-details:not([hidden]) { display: contents; }
.rail-right .scene-actions { display: flex; align-items: center; flex-wrap: wrap; }
.flow-tools { min-width: 0; display: grid; gap: 15px; }
.flow-tools:has(#flow-modes[hidden]):has(#color-key[hidden]) { display: none; }
.flow-tools .surface-modes { flex-direction: column; align-items: start; }
.flow-tools .surface-modes button { padding-inline: 15px; }
.flow-tools .color-key { position: static; margin: 0; padding: 0; background: transparent; }
.flow-tools .spectrum { width: clamp(38px, 5vw, 70px); }
.rail-right .readouts { flex-direction: column; align-items: start; gap: 16px; }
.scene-foot {
  grid-area: foot; display: flex; justify-content: space-between; align-items: end;
  gap: 12px; align-self: end; min-width: 0;
}
.scene-foot #skate-credit { margin: 0; text-align: right; }
.tunnel.scene.expanded { width: 100%; height: 100%; border: 0; border-radius: 0; }

/* On a phone both banks become two short rows, retaining a full-width model. */
@media (max-width: 820px) and (min-height: 481px) {
  .tunnel.scene {
    --stage-lift: clamp(15px, 3vh, 22px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto minmax(0, 1fr) repeat(6, auto);
    grid-template-areas: "random toggle" "visual visual" "project project" "case camera" "modes modes" "metrics metrics" "utilities utilities" "foot foot";
    padding: 12px clamp(11px, 2.8vw, 20px) 10px;
    gap: 5px 15px;
  }
  .console-rail { display: contents; }
  .rail-right .scene-actions { grid-area: utilities; justify-self: center; align-self: center; gap: 6px; }
  .rail-left .control { grid-area: case; }
  #flip-speed-control { grid-area: modes; }
  .rail-right .control { grid-area: camera; }
  .rail-right .readouts { grid-area: metrics; flex-direction: row; gap: 18px; justify-content: center; }
  .project-slot { padding: 3px 0 12px; }
  .project-slot .project-cta {
    width: min(91%, 390px); min-height: clamp(68px, 9vh, 84px);
    font-size: clamp(22px, 5.7vw, 30px); padding: 12px 18px;
  }
  .flow-tools { grid-area: modes; display: flex; gap: 8px; align-items: center; }
  .flow-tools .surface-modes { flex: 1; flex-direction: row; align-items: center; gap: 4px; }
  .flow-tools .surface-modes button { padding: 5px; min-height: 34px; }
  .flow-tools .color-key { gap: 3px; font-size: 8px; }
  .flow-tools .spectrum { width: 32px; }
  .tunnel .scene-foot { align-items: end; }
  .scene-foot .scene-status { gap: 2px; }
  .scene-foot #skate-credit { max-width: 45%; font-size: 10px; }
}
@media (max-width: 480px) and (min-height: 481px) {
  #random { min-height: 44px; font-size: 15px; padding: 8px 15px; }
  .flow-tools { flex-wrap: wrap; }
  .flow-tools .color-key { margin-left: auto; }
  .console-rail .control-heading { min-height: 25px; }
}
@media (max-height: 480px) {
  .tunnel.scene {
    --stage-lift: clamp(8px, 3.5vh, 16px);
    grid-template-columns: minmax(110px, 17%) minmax(0, 1fr) minmax(110px, 17%);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    padding: 9px 12px; gap: 3px 8px;
  }
  .console-rail { gap: 9px; }
  #random { width: auto; min-height: 36px; gap: 6px; padding: 5px 12px; font-size: 14px; }
  .flow-tools, .flow-tools .surface-modes { gap: 4px; }
  .flow-tools .surface-modes button { min-height: 25px; padding: 3px 9px; font-size: 11px; }
  .rail-right .scene-actions { gap: 4px; }
  .rail-right .scene-actions .round-button { width: 32px; height: 32px; }
  .rail-right .readouts { display: flex; gap: 4px; }
  .rail-right .measurement { display: flex; flex-direction: row; align-items: baseline; gap: 4px; }
  .rail-right .measurement small { display: none; }
  .rail-right .measurement strong { font-size: 15px; }
  .project-slot { padding: 0 0 4px; }
  .project-slot .project-cta { width: min(100%, 310px); min-height: 52px; padding: 7px 14px; font-size: 22px; }
  .scene-foot .scene-status { flex-direction: row; align-items: center; }
  .scene-foot #skate-credit { font-size: 10px; }
}

/* The closed view gives the model all the space between the two action rows. */
.tunnel.scene:has(> #tunnel-details[hidden]) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "random toggle" "visual visual" "project project";
}
@media (max-width: 480px), (max-height: 480px) {
  .scene-toolbar { gap: 5px; }
  #controls-toggle, .scene-toolbar #limits-button { font-size: 13px; padding: 8px 11px; gap: 6px; }
}
@media (max-width: 360px) {
  #random { width: auto; min-width: 72px; padding-inline: 10px; gap: 0; }
  #random .ui-icon, #controls-toggle .ui-icon { display: none; }
}
