/* Marconi control room: the tablet and desktop view. The same room, the same screens, the same parts and the same words as the
   phone; this file only gives them more room. Take its link out of index.html and the phone app is exactly as it was.
   The rules it keeps (the first four are Mission Control's, docs/design-system.md there):
   1. Wider screens get more columns, not new layouts. Nothing is added, moved to another screen or hidden.
   2. Every icon in the tab carries its word when there is room for it.
   3. A chart never grows past its card, and a card stays near its phone width. A wider window shows more cards.
   4. Nothing scrolls sideways: a row of chips wraps.
   5. No new token, colour, curve or type size: everything here is the phone's own.
   Tablet is 700px and up; desktop is 1100px and up. Below 700px this file does nothing.
   From 1100px (section 8.2) the desktop also holds what a phone has no room for: an item's detail beside its list, and small
   figures from what the API returns. wide.js draws them, only while the window is that wide; the rules for them are the last
   block of the desktop query below, and they too are the phone's own parts. */

@media (min-width: 700px) {
  /* the room fills the window; the dark field beside a phone column is gone */
  body { background: var(--room); }
  .phone { max-width: none; box-shadow: none; }

  /* the page: the left gutter widens, and the right one clears the Chief's capsule as well as the tab,
     so the capsule stays where it is when the page scrolls and the head needs no space kept for it */
  .scr { padding-left: max(40px, env(safe-area-inset-left, 0px)); padding-right: calc(var(--sr) + 72px); }
  .phone.scrolled .capsule { transform: none; opacity: 1; pointer-events: auto; }
  .head, .sub { padding-right: 0; }

  /* reading screens (the Loop, the Journal and every detail screen) hold one 760px column, centred */
  #scr-loop, #scr-journal, #scr-detail { padding-left: max(40px, env(safe-area-inset-left, 0px), calc(50% - 380px)); padding-right: max(calc(var(--sr) + 72px), calc(50% - 380px)); }

  /* more columns: cards and tiles */
  .grid2 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .grid2.score-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

  /* more columns: the long lists read across in two */
  #scr-plans .rows, #scr-cast .cast-list, #scr-scores .score-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  #scr-plans .rows > .row:nth-child(2), #scr-cast .cast-list > .row:nth-child(2), #scr-scores .score-list > .row:nth-child(2) { border-top: 0; }
  #scr-plans .card:has(> .air-row) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  #scr-plans .card > .air-row:nth-child(2) { margin-top: 0; padding-top: 0; border-top: 0; }

  /* nothing scrolls sideways */
  .chips, .filter-row, .castrow { flex-wrap: wrap; overflow: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .chips .sep { display: none; }

  /* Pulse: today's Loop and the alerts sit side by side when there are alerts; the parts and their order are the phone's */
  #scr-pulse.on:has(> .kick + .stack) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; grid-auto-flow: dense; grid-auto-rows: max-content; align-content: start; }
  #scr-pulse.on:has(> .kick + .stack) > * { grid-column: 1 / -1; }
  #scr-pulse.on:has(> .kick + .stack) > .kick:has(+ .card), #scr-pulse.on:has(> .kick + .stack) > .card { grid-column: 1; }
  #scr-pulse.on:has(> .kick + .stack) > .kick:has(+ .stack), #scr-pulse.on:has(> .kick + .stack) > .stack { grid-column: 2; align-self: start; }
  #scr-pulse.on:has(> .kick + .stack) > .kick { align-self: end; }
  #scr-pulse > .card { max-width: 760px; }
  #scr-pulse.on:has(> .kick + .stack) > .card { max-width: none; }

  /* a chart keeps the size it was drawn at: a wider window shows more cards, never a bigger chart */
  .line svg, .strip svg, .score-strip { max-width: 360px; }
  .gauge svg { max-width: 180px; }

  /* control surfaces keep their phone size */
  .btn.wide { max-width: 360px; }
  .pref-row .btn { width: auto; min-width: 200px; }
  .bar { left: max(var(--sl), calc(50% - 280px)); right: max(var(--sr), calc(50% - 280px)); }
  .sheet { left: max(0px, calc(50% - 380px)); right: max(0px, calc(50% - 380px)); }

  /* the Chief Director's room is the phone's room, docked on the right where its capsule is */
  .room { left: auto; width: 430px; max-width: calc(100% - 24px); }

  /* a score's panel still opens over the whole room; its words hold the reading column */
  .score-panel .inner, .morph .inner { padding-left: max(var(--sl), calc(50% - 380px)); padding-right: max(var(--sr), calc(50% - 380px)); }
  .score-close, .morph .x { right: max(var(--sr), calc(50% - 380px)); }
}

@media (min-width: 1100px) {
  /* the page holds 1120px, centred */
  .scr { padding-left: max(128px, calc(50% - 560px)); padding-right: max(128px, calc(50% - 560px)); }
  #scr-loop, #scr-journal, #scr-detail { padding-left: max(128px, calc(50% - 380px)); padding-right: max(128px, calc(50% - 380px)); }

  /* the long lists: the cast reads across in three */
  #scr-cast .cast-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #scr-cast .cast-list > .row:nth-child(3) { border-top: 0; }

  /* section 8.2, wide.js: a list screen keeps its list, and the column beside it holds its figures or the detail of an item
     opened from it. The column stays in view while the list scrolls, and ends above the heartbeat bar. */
  .scr.wd-split.on { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); column-gap: 28px; align-items: start; }
  #scr-loop.wd-split, #scr-journal.wd-split { padding-left: max(128px, calc(50% - 560px)); padding-right: max(128px, calc(50% - 560px)); }
  .wd-main, .wd-side { min-width: 0; }
  .wd-side { position: sticky; top: 0; max-height: calc(100vh - var(--st) - var(--sb) - 160px); overflow-y: auto; overflow-x: hidden; scrollbar-width: none; padding-bottom: 8px; }
  .wd-side::-webkit-scrollbar { display: none; }
  .wd-side .grid2, .wd-side .grid2.score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wd-side .tbar { margin-top: 4px; }
  #scr-cast .wd-main .cast-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #scr-cast .wd-main .cast-list > .row:nth-child(3) { border-top: 1px solid var(--line-d); }

  /* the figures: rows of small numbers, and a chart that keeps to its card */
  .wd-list { padding: 0 14px; }
  .wd-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .wd-two > .row:nth-child(2) { border-top: 0; }
  .wd-spark { width: 96px; flex: 0 0 96px; }
  .wd-pulse-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .wd-pulse .wd-list { margin-top: 10px; }
  .wd-pulse .cols svg, .wd-side .cols svg, .wd-panel .cols svg, .wd-agent .cols svg { max-width: 360px; }
  .wd-panel { margin: 18px 0 4px; }
  .wd-bars .row .t { flex: 0 0 38%; }
  .wd-bars .row .bar-h { flex: 1; }
}

/* every icon in the tab carries its word: the tab is the phone's tab, wider by the width of a word */
@media (min-width: 700px) and (min-height: 640px) {
  .rail { width: 112px; height: 392px; margin-top: -196px; gap: 14px; padding: 0 40px 0 8px; }
  .rail.long { height: 448px; margin-top: -224px; }
  .rr, .way-out { width: 62px; height: 38px; grid-template-rows: 16px auto; row-gap: 7px; justify-items: center; align-content: center; }
  .rr::before, .way-out::before { content: attr(aria-label); position: static; inset: auto; order: 2; font: 7.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }
  .way-out::before { content: "Listener"; }
  .way-out::after { top: -11px; left: 14px; right: 14px; }
  .rr[aria-current="page"]::after { left: 16px; top: 8px; }
}

/* a pointer shows what it is over, with the phone's own pressed fill and its own outline */
@media (min-width: 700px) and (hover: hover) and (pointer: fine) {
  .disc:not(.gold):hover, .tile:not(.on):hover, .voice:hover { background: var(--fill-3); }
  .chip:hover, .pill:not(.gold):not(.ink):hover, .btn.ghost:hover { border-color: rgba(255,255,255,0.45); }
  .card.press:hover, a.card:hover, button.card:hover { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22); }
  .tlc:hover { box-shadow: inset 0 0 0 1px currentColor; }
  .rr:hover, .way-out:hover { opacity: 1; }
  a.row:hover .t, button.row:hover .t { color: var(--gold-l); }
}
