/* Desktop composition of Station 04 · Route bench (after base.css and shared/workspace.css).
   One station head, then the map plate as the largest field with its replay deck under it, beside a comparison rack:
   A = route channels (identity, visibility, focus, three quantities with relative bars, details),
   B = trade-off scope. The rack docks at the side (default) or below the map (data-dock="bottom") for wide, short
   windows; the choice is saved with the other presentation settings. Provenance stays in the Run details sheet. */
.shell {
  --bench-w: clamp(24rem, 29vw, 28.5rem);
  display: grid; height: 100dvh;
  grid-template-columns: minmax(0, 1fr) var(--bench-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "bar bar" "work bench";
}
body { container: bench-viewport / inline-size; }
.bar { grid-area: bar; height: auto; min-height: var(--ws-head); }
.pick-project { width: 13rem; flex: 0 1 auto; min-width: 9rem; }
.pick-run { width: 28rem; min-width: 12rem; flex: 0 1 auto; }
.pick select { font-size: .875rem; }
.ws .ib { min-width: var(--ws-hit); min-height: var(--ws-hit); }
.gap { flex: 1; }

/* ---------- work: tool strip, plate, replay deck ---------- */
.work { grid-area: work; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.plate-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; min-height: 3.25rem; padding: .25rem .375rem .25rem .75rem; border-bottom: 1px solid var(--rule-2); background: var(--paper); }
.plate-bar .seg > button { min-height: 2.375rem; padding: 0 .875rem; font-size: .875rem; }
.plate-bar .overlay-note { margin-left: .5rem; flex: 0 1 auto; font-size: .8125rem; }
.tool-group { display: flex; align-items: center; gap: 2px; padding-left: .375rem; border-left: 1px solid var(--rule); }
:root[data-view="cube"] .plan-only { visibility: hidden; }
.stage { border: 0; }

.deck {
  position: relative; grid-template-columns: var(--ws-hit) var(--ws-hit) auto minmax(0, 1fr) auto; column-gap: .75rem;
  min-height: 4.75rem; padding: .5rem 1rem .5rem .75rem; border-top: 1px solid var(--ink); background: var(--paper);
}
.deck::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; pointer-events: none; background: var(--ws-tick); background-size: 100% 5px, 100% 3px; background-repeat: no-repeat; }
.deck .play { width: var(--ws-hit); height: var(--ws-hit); }
.deck .clock { min-width: 7.5rem; padding: 0 .75rem; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }
.deck .clock b { font-size: 1.375rem; line-height: 1.1; }
.deck .clock span, .deck .clock em { font-size: .75rem; }
.deck .speed { min-width: 3.25rem; min-height: var(--ws-hit); }
.deck .axis { padding-top: 1.125rem; }
.deck .marks { height: 1.125rem; }
.deck .mk { width: 1.5rem; height: 1.5rem; margin-left: -.75rem; top: -.125rem; }
.deck .ticks { height: 1rem; }
.deck .ticks span { font-size: .75rem; }
:root[data-playing="yes"] .deck .clock b { color: var(--ink); text-shadow: 0 0 .75rem color-mix(in oklab, var(--signal) 70%, transparent); }

/* ---------- comparison rack ---------- */
.bench.ws-surface { background-color: var(--paper); }
/* The table card takes the height its channels need (scrolling beyond the rack), the trade-off card the rest: its plot
   is drawn to the card's proportions (--plot-fill, app.js), so spare height becomes value axis, not blank paper. */
.bench {
  grid-area: bench; display: grid; grid-template-rows: minmax(0, max-content) minmax(16rem, 1fr); gap: .75rem; min-height: 0; min-width: 0;
  padding: .75rem; border-left: 1px solid var(--ink);
}
.card { min-height: 0; min-width: 0; background: var(--plate); border: 1px solid var(--rule-2); border-radius: 4px; box-shadow: 0 1px 0 var(--rule); }
.rcard { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.bench-head { padding: .25rem .25rem 0 1rem; }
.bench-head h2 { font-size: 1rem; }
.bench-head .btn { min-height: 2.25rem; font-size: .8125rem; }
.rtab { --sw: 2.25rem; --act: var(--ws-hit); min-height: 0; overflow: auto; overscroll-behavior: contain; padding: .125rem 0 0; }
.bench-foot { margin: 0; padding: .625rem 1rem .75rem; border-top: 1px solid var(--rule); font-size: .75rem; line-height: 1.45; }
.trade { display: grid; grid-template-rows: auto minmax(0, 1fr); padding: .25rem 1rem .75rem; }
.trade-head { margin-bottom: .25rem; }
.trade-head h3 { font-size: 1rem; }
.seg-sm > button { min-height: 2.25rem; padding: 0 .875rem; font-size: .8125rem; }
.plot { --plot-fill: 1; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.plot .tp { height: 100%; min-height: 0; }
.plot .tp-note { font-size: .75rem; line-height: 1.45; }

/* route channels, two lines: the full cost name with its algorithm over three quantities, each column under its head
   label (unit included); eye and details at the edge. Names never shrink to fit the numbers. */
.rt-head { grid-template-columns: var(--sw) repeat(3, minmax(0, 1fr)) calc(var(--act) * 2 - .5rem); column-gap: 1rem; padding: .5rem 0 .5rem 1rem; font-size: .75rem; }
.rt-head span:nth-child(2) { display: none; }
.rt-head small { font-size: .6875rem; }
.rt { min-height: 4.5rem; }
.rt-main {
  grid-template-columns: var(--sw) repeat(3, minmax(0, 1fr)); grid-template-areas: "sw name name name" "sw a b c";
  column-gap: 1rem; row-gap: .375rem; align-items: start; min-height: 4.5rem; padding: .625rem .5rem .625rem 1rem;
}
.rt-sw { grid-area: sw; padding-top: .1875rem; }
.rt-name { grid-area: name; display: flex; align-items: baseline; gap: .5rem; min-width: 0; }
.rt-name b { flex: 0 1 auto; min-width: 0; font-size: 1rem; }
.rt-name small { flex: none; font-size: .75rem; color: var(--ink-3); }
.rt-vals { display: contents; }
.rt-vals > .v:nth-child(1) { grid-area: a; }
.rt-vals > .v:nth-child(2) { grid-area: b; }
.rt-vals > .v:nth-child(3) { grid-area: c; }
.rt .v { display: grid; justify-items: end; row-gap: .3125rem; font-size: 1.0625rem; }
.rt .v-k { display: none; }
.rt.is-peek .rt-main { background: color-mix(in oklab, var(--rc) 12%, transparent); }
.rt.is-peek::before { transform: scaleY(1); opacity: .55; }
.rt.is-focus.is-peek::before { opacity: 1; }

/* ---------- dock below: map keeps the full width, the rack becomes a band of two cards side by side ---------- */
:root[data-dock="bottom"] .shell {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) clamp(15rem, 36vh, 22rem);
  grid-template-areas: "bar" "work" "bench";
}
:root[data-dock="bottom"] .bench { grid-template-columns: minmax(0, 1.35fr) minmax(22rem, 1fr); grid-template-rows: minmax(0, 1fr); border-left: 0; border-top: 1px solid var(--ink); }
:root[data-dock="bottom"] .trade { display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: auto; }
:root[data-dock="bottom"] .trade .tp { max-height: 100%; }
:root[data-dock="bottom"] [data-act="dock"] .i { transform: rotate(90deg); }

/* sheet = right drawer over the rack, never over the map */
.sheet { position: fixed; inset: 0 0 0 auto; width: min(30rem, 100vw); height: 100dvh; margin: 0; box-shadow: -18px 0 44px rgb(0 0 0 / .18); border-left: 1px solid var(--ink); }
.sheet[open] { animation: drawer 320ms var(--spring); }
.sheet[data-kind="matrix"] { width: min(55rem, 100vw); }
.sheet-bar .ib { min-width: var(--ws-hit); min-height: var(--ws-hit); }
@keyframes drawer { from { transform: translateX(36px); opacity: 0; } }

@media (max-width: 1280px) {
  .ws-title small { display: none; }
  .pick-run { width: 22rem; }
}
@media (max-width: 1180px) {
  .pick-project { width: 10.5rem; }
  .pick-run { width: 18rem; }
  .plate-bar .overlay-note { display: none; }
  .plate-bar .overlay-note.is-warn { display: flex; }
  .ws-classic span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 980px) {
  .shell { --bench-w: 22.5rem; }
  .ws-id { display: none; }
  .rt-main, .rt-head { column-gap: .75rem; }
  .rt-head { grid-template-columns: var(--sw) repeat(3, minmax(0, 1fr)) calc(var(--act) * 2 - .25rem); }
  .seg[data-i18n-label="view"] > button > span { display: none; }
  :root[data-dock="bottom"] .bench { grid-template-columns: minmax(0, 1fr); overflow: auto; }
}
@media (max-width: 760px) {
  html, body { overflow: auto; }
  .shell, :root[data-dock="bottom"] .shell { height: auto; grid-template-columns: 1fr; grid-template-rows: auto 72vh auto; grid-template-areas: "bar" "work" "bench"; }
  .bar { flex-wrap: wrap; height: auto; padding: .5rem .625rem; row-gap: .5rem; }
  .pick-project, .pick-run { width: 100%; flex: 1 1 100%; }
  .bench { grid-template-rows: auto auto; border-left: 0; border-top: 1px solid var(--ink); }
  .plot { --plot-fill: 0; display: block; }
  .plot .tp { height: auto; }
  [data-act="dock"] { display: none; }
  .deck { grid-template-columns: var(--ws-hit) minmax(0, 1fr) auto; }
  .deck [data-act="restart"], .deck .clock { display: none; }
}

/* Text enlargement uses the existing lower dock composition with a scrollable document. */
@container bench-viewport (max-width: 60rem) {
  .shell, :root[data-dock="bottom"] .shell {
    height: auto; min-height: 100dvh; overflow: auto; grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(28rem, max-content) auto;
    grid-template-areas: "bar" "work" "bench";
  }
  .bar { flex-wrap: wrap; height: max-content; min-height: var(--ws-head); padding-block: .5rem; }
  .work { grid-template-rows: auto minmax(240px, 1fr) auto; }
  .plate-bar { flex-wrap: wrap; }
  .deck { grid-template-columns: var(--ws-hit) var(--ws-hit) minmax(0, 1fr) auto; }
  .deck .axis { grid-column: 1 / -1; grid-row: 2; margin-inline: .75rem; }
  .bench, :root[data-dock="bottom"] .bench { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; border-left: 0; border-top: 1px solid var(--ink); }
  .rtab { max-height: 20rem; }
  .rcard { grid-template-rows: auto minmax(0, 20rem) auto; }
  .plot .tp { height: 16rem; }
}
