/* Traffic Desk pages (traffic.html, traffic-surnadal.html). Loaded after watch.css, whose panel, top bar,
   bulletin, chip and about styles it shares; this file only lays out the board (.board.tr) and the desk.
   Same unit (--u) and the same three layouts: stacked (phones), landscape wall, portrait wall (?wall only).
   Red stays for alarms: a closed road, a cancelled ferry, the live dot. */

.board.tr { grid-template-areas: "top" "map" "desk" "bulletin" "about"; }

/* ── the chart ── */
.map { grid-area: map; aspect-ratio: 4 / 3; background: var(--cream); }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(1.4 * var(--u)); font-weight: 700; letter-spacing: 0.14em; color: var(--stone); }
.map .legend { position: absolute; z-index: 2; left: calc(0.8 * var(--u)); top: calc(0.8 * var(--u)); display: flex; flex-wrap: wrap; gap: calc(0.5 * var(--u));
  max-width: calc(100% - 1.6 * var(--u)); }
.map .legend span { background: var(--bg); border: calc(0.15 * var(--u)) solid var(--ink); font-size: calc(1.15 * var(--u)); font-weight: 700;
  padding: calc(0.15 * var(--u)) calc(0.55 * var(--u)); display: inline-flex; align-items: center; gap: calc(0.4 * var(--u)); white-space: nowrap; }
.map .legend svg { position: static; width: calc(1.3 * var(--u)); height: calc(1.3 * var(--u)); }
.map .wxchip { right: calc(0.8 * var(--u)); top: calc(0.8 * var(--u)); font-size: calc(1.3 * var(--u)); }
.map .wxchip svg { position: static; width: calc(1.8 * var(--u)); height: calc(1.8 * var(--u)); }

/* chart marks, in the chart image's own pixels (a 1920-wide frame); --s scales them to the frame */
#chart .xing { fill: none; stroke: var(--ink); stroke-width: calc(2.2px * var(--s, 1)); stroke-dasharray: calc(9px * var(--s, 1)) calc(7px * var(--s, 1)); opacity: 0.55; }
#chart .quay { fill: var(--bg); stroke: var(--ink); stroke-width: calc(2px * var(--s, 1)); }
#chart text { font-family: 'Space Grotesk', sans-serif; font-weight: 700; paint-order: stroke; stroke: var(--bg); stroke-linejoin: round; fill: var(--ink); }
#chart .qlabel { font-size: calc(17px * var(--s, 1)); stroke-width: calc(5px * var(--s, 1)); fill: #4A453D; }
#chart .vlabel { font-size: calc(19px * var(--s, 1)); stroke-width: calc(5px * var(--s, 1)); }
#chart .vlabel tspan.sub { font-weight: 500; fill: #4A453D; }
#chart .ferry path { fill: var(--yellow); stroke: var(--ink); stroke-width: calc(2.4px * var(--s, 1)); stroke-linejoin: round; }
#chart .bus rect { fill: var(--bg); stroke: var(--ink); stroke-width: calc(2.4px * var(--s, 1)); }
#chart .plane path { fill: var(--ink); stroke: var(--bg); stroke-width: calc(1.6px * var(--s, 1)); stroke-linejoin: round; }
#chart .plane.mil path { fill: #6B6458; }
#chart .road circle { fill: var(--red); stroke: var(--ink); stroke-width: calc(2.4px * var(--s, 1)); }
#chart .road path { stroke: var(--bg); stroke-width: calc(3.2px * var(--s, 1)); stroke-linecap: round; }
#chart .road.works circle, #chart .road.soon circle { fill: var(--bg); }
#chart .road.works path, #chart .road.soon path { stroke: var(--ink); }
#chart .credit { font-size: calc(13px * var(--s, 1)); font-weight: 500; stroke-width: calc(4px * var(--s, 1)); fill: #4A453D; }

/* ── the desk ── */
.desk { grid-area: desk; display: grid; gap: var(--gap); grid-template-columns: 1fr; min-height: 0; }
.box { padding: calc(0.8 * var(--u)) calc(1.1 * var(--u)); display: flex; flex-direction: column; gap: calc(0.5 * var(--u)); }
.box .k { display: flex; gap: calc(0.8 * var(--u)); align-items: baseline; white-space: nowrap; }
.box .k > span:first-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.box .k .n { margin-left: auto; letter-spacing: 0.06em; }
.rows { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
/* the next ferry, large, then the rest in a list (two columns on a wall) */
.next { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 calc(1 * var(--u)); padding-bottom: calc(0.4 * var(--u)); border-bottom: var(--line); min-width: 0; }
.next .t { font-size: calc(3.6 * var(--u)); font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.next .w { font-size: calc(2 * var(--u)); font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next .r { margin-left: auto; font-size: calc(1.5 * var(--u)); color: var(--stone); font-weight: 500; white-space: nowrap; }
.next.gone .t, .next.gone .w { text-decoration: line-through; color: var(--stone); }
.row { display: grid; grid-template-columns: calc(6.2 * var(--u)) 1fr auto; gap: calc(0.8 * var(--u)); align-items: baseline;
  padding: calc(0.3 * var(--u)) 0; border-top: calc(0.12 * var(--u)) solid #D9D1BC; font-size: calc(1.5 * var(--u)); min-width: 0; }
.row:first-child { border-top: 0; }
.row .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.row .w { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row .w small { color: var(--stone); font-size: 0.82em; }
.row .r { color: var(--stone); font-size: 0.86em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.gone .t, .row.gone .w { text-decoration: line-through; color: var(--stone); }
.row .late { color: var(--ink); font-weight: 700; }
.row .ontime, .next .ontime { color: var(--stone); font-weight: 500; }
/* wind on the crossings (2026-11-25): one line under the next departure */
.wind { margin: calc(0.3 * var(--u)) 0 calc(0.3 * var(--u)); font-size: calc(1.35 * var(--u)); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wind .k2 { font-weight: 700; margin-right: calc(0.5 * var(--u)); }
.wind b.warn { background: var(--yellow); color: #111; padding: 0 0.2em; }
.wind b.bad { background: var(--red); color: #111; padding: 0 0.2em; }
html.wall .tag.yel { color: #111; }   /* dark text on the yellow tag on a wall (it was the light ink: unreadable) */
.tag { display: inline-block; font-size: calc(1.0 * var(--u)); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; line-height: 1;
  padding: calc(0.25 * var(--u)) calc(0.45 * var(--u)); border: calc(0.15 * var(--u)) solid var(--ink); background: var(--bg); white-space: nowrap; vertical-align: 0.1em; }
.tag.red { background: var(--red); color: var(--bg); border-color: var(--ink); }
.tag.ink { background: var(--ink); color: var(--bg); }
.tag.yel { background: var(--yellow); }
.notice { font-size: calc(1.35 * var(--u)); font-weight: 500; line-height: 1.3; padding: calc(0.4 * var(--u)) calc(0.6 * var(--u)); background: var(--yellow);
  border: calc(0.15 * var(--u)) solid var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notice.severe { background: var(--red); color: var(--bg); }
.pol { padding: calc(0.4 * var(--u)) 0; border-top: calc(0.12 * var(--u)) solid #D9D1BC; font-size: calc(1.4 * var(--u)); }
.pol:first-child { border-top: 0; }
.pol .h { display: flex; gap: calc(0.6 * var(--u)); align-items: baseline; font-weight: 700; min-width: 0; }
.pol .h .where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pol .h .ago { margin-left: auto; color: var(--stone); font-weight: 500; font-size: 0.86em; white-space: nowrap; }
.pol p { font-weight: 500; line-height: 1.3; margin-top: calc(0.15 * var(--u)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.none { font-size: calc(1.4 * var(--u)); }
.roads .pol p { -webkit-line-clamp: 3; }   /* a road notice ran to "detour ·…" in two lines on the wall (2026-11-25) */


/* Landscape wall: any window ≥ 1000 px wide and wider than 13:10 (as watch.css). */
@media (min-width: 1000px) and (min-aspect-ratio: 13/10) {
  .board.tr {
    grid-template-columns: minmax(0, 1fr) calc(38 * var(--u));   /* the chart takes the extra width, the desk keeps a readable one (2026-11-25; was 60u + 1fr) */
    grid-template-rows: auto minmax(0, 1fr) calc(3.6 * var(--u));
    grid-template-areas: "top top" "map desk" "bulletin bulletin";
  }
  .map { aspect-ratio: auto; }
  /* row by row (left, right, then the next line): a hidden row then never reflows a column (2026-11-25) */
  .ferries .rows.cols { display: grid; grid-auto-flow: row; grid-template-columns: 1fr 1fr; column-gap: calc(1.6 * var(--u)); align-content: start; }
  .ferries .rows.cols .row:nth-child(-n + 2) { border-top: 0; }
  /* two columns are narrow: the time takes only its own width, an empty status cell takes none ("Kanestraum" was cut at 1920x1080) */
  .ferries .rows.cols .row { display: flex; gap: calc(1 * var(--u)); }
  .ferries .rows.cols .row .w { flex: 1 1 auto; }
  .ferries .rows.cols .row .r:empty { display: none; }   /* in a flex row a hidden cell costs no gap (a grid track still did) */
}

/* Portrait wall (?wall only): chart on top, the desk as a 2 x 2 grid under it. */
@media (max-aspect-ratio: 3/4) {
  .wall .board.tr {
    grid-template-rows: auto minmax(0, 1fr) calc(46 * var(--u)) calc(3.6 * var(--u));
    grid-template-areas: "top" "map" "desk" "bulletin";
  }
  .wall .map { aspect-ratio: auto; }
}

/* hidden means gone: a class that sets display (flex/grid rows) would otherwise beat the browser's [hidden] rule and keep a fitted-out row on screen */
.board [hidden] { display: none !important; }

/* ── one desk (2026-11-25, /frontend-design traffic pages): a single panel read top to bottom like a duty sheet --
   departures, roads, aircraft, police log -- with a heavy rule between sections, instead of four boxed cards. The chart
   stays the one bold thing. A section with nothing to report ("quiet", set by traffic.js) shrinks to its one line, and
   on the walls the rest share the height: departures most. Headings in sentence case (only here). ── */
.tr .desk { display: flex; flex-direction: column; gap: 0; background: var(--bg); border: var(--line); box-shadow: var(--drop); min-width: 0; }
.tr .desk > .panel { border: 0; box-shadow: none; background: none; }
.tr .desk > .panel + .panel { border-top: calc(0.25 * var(--u)) solid var(--ink); }
.tr .k { font-size: calc(1.3 * var(--u)); font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink); }
.tr .box .k .n { letter-spacing: 0; font-weight: 500; color: var(--stone); }
.tr .box.quiet .none { color: var(--stone); font-size: calc(1.3 * var(--u)); }
.tr .map .ph { letter-spacing: 0; font-weight: 500; }
/* the walls: roads, police and aircraft take what their entries need and give way when the desk is full (fit() hides
   whole entries), in this order of priority: departures take the rest but never less than the next ferry and two rows;
   roads and the police log always keep one whole entry; aircraft give way first (the chart shows them anyway) */
@media (min-width: 1000px) and (min-aspect-ratio: 13/10) {
  .tr .desk > .panel { flex: 0 1 auto; min-height: 0; }
  .tr .desk > .ferries { flex: 1 0 calc(14 * var(--u)); }
  .tr .desk > .roads:not(.quiet) { min-height: calc(11.5 * var(--u)); }
  .tr .desk > .police:not(.quiet) { min-height: calc(10 * var(--u)); }
}
@media (max-aspect-ratio: 3/4) {
  .wall .tr .desk > .panel { flex: 0 1 auto; min-height: 0; }
  .wall .tr .desk > .ferries { flex: 1 0 calc(14 * var(--u)); }
  .wall .tr .desk > .roads:not(.quiet) { min-height: calc(11.5 * var(--u)); }
  .wall .tr .desk > .police:not(.quiet) { min-height: calc(10 * var(--u)); }
}

/* zoom and pan (2026-11-25; traffic.js): buttons bottom-left on the chart, not on a wall. A finger scrolls the page
   until the chart is zoomed (then it pans); two fingers always pinch. */
.map .zoom { position: absolute; z-index: 2; left: calc(0.8 * var(--u)); bottom: calc(0.8 * var(--u)); display: flex; gap: calc(0.3 * var(--u)); }
.map .zoom button { font: 700 calc(1.5 * var(--u))/1 'Space Grotesk', sans-serif; width: calc(3 * var(--u)); height: calc(3 * var(--u)); min-width: 32px; min-height: 32px;
  background: var(--bg); color: var(--ink); border: calc(0.15 * var(--u)) solid var(--ink); cursor: pointer; padding: 0; }
.map .zoom button:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.map .zoom button:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.wall .map .zoom { opacity: 0; transition: opacity .3s; }   /* on a wall the buttons show only while a mouse is over the chart */
.wall .map.user .zoom, .wall .map .zoom:focus-within { opacity: 1; }   /* .user: set once a mouse has really moved (traffic.js) */
#chart { touch-action: pan-x pan-y; cursor: zoom-in; }
#chart.zoomed { touch-action: none; cursor: grab; }
#chart.zoomed:active { cursor: grabbing; }

/* a denser desk where the height is fixed (owner 2026-11-25: "the right column can be denser with info"): smaller list
   text, so the ferries fill both columns (up to eight) and more road and police entries fit */
@media (min-width: 1000px) and (min-aspect-ratio: 13/10) {
  .tr .desk .row { font-size: calc(1.3 * var(--u)); padding: calc(0.2 * var(--u)) 0; }
  .tr .desk .next .t { font-size: calc(3 * var(--u)); }
  .tr .desk .next .w { font-size: calc(1.7 * var(--u)); }
  .tr .desk .pol { font-size: calc(1.2 * var(--u)); padding: calc(0.3 * var(--u)) 0; }
  .tr .desk .box { padding: calc(0.6 * var(--u)) calc(1.1 * var(--u)); gap: calc(0.35 * var(--u)); }
  .tr .desk > .roads:not(.quiet) { min-height: calc(9 * var(--u)); }
  .tr .desk > .police:not(.quiet) { min-height: calc(8.5 * var(--u)); }
  .tr .desk > .air:not([hidden]) { min-height: calc(6.4 * var(--u)); }   /* an aircraft on the chart always gets its line */
  .air .row .t { font-weight: 700; }
}
/* the portrait wall: the same two-column departures and denser desk */
@media (max-aspect-ratio: 3/4) {
  .wall .tr .ferries .rows.cols { display: grid; grid-auto-flow: row; grid-template-columns: 1fr 1fr; column-gap: calc(1.6 * var(--u)); align-content: start; }
  .wall .tr .ferries .rows.cols .row { display: flex; gap: calc(1 * var(--u)); }
  .wall .tr .ferries .rows.cols .row .w { flex: 1 1 auto; }
  .wall .tr .ferries .rows.cols .row .r:empty { display: none; }
  .wall .tr .ferries .rows.cols .row:nth-child(-n + 2) { border-top: 0; }
  .wall .tr .desk .row { font-size: calc(1.3 * var(--u)); padding: calc(0.2 * var(--u)) 0; }
  .wall .tr .desk .pol { font-size: calc(1.2 * var(--u)); padding: calc(0.3 * var(--u)) 0; }
  .wall .tr .desk > .air:not([hidden]) { min-height: calc(6.4 * var(--u)); }
}

/* the bus board (2026-11-25): the line number in bold; on a full wall desk it gives way first (fit() hides it whole) */
.buses .row .ln { font-weight: 700; margin-right: 0.3em; }
.tr .desk > .buses { flex: 0 1 auto; }

.tr .rmore { font-size: calc(1.1 * var(--u)); color: var(--stone); font-weight: 600; padding-top: calc(0.2 * var(--u)); }

/* the chart's own magenta boxes explained (2026-11-25, a review: "the box near Rindal is unexplained"): they are printed on
   Kartverket's sea chart and mark where a more detailed chart takes over */
.map .chartnote { position: absolute; z-index: 2; right: calc(0.8 * var(--u)); bottom: calc(0.8 * var(--u)); margin: 0; max-width: 60%;
  background: var(--bg); border: calc(0.15 * var(--u)) solid var(--ink); font-size: calc(1.05 * var(--u)); font-weight: 600;
  padding: calc(0.25 * var(--u)) calc(0.6 * var(--u)); display: flex; align-items: center; gap: calc(0.5 * var(--u)); }
.map .chartnote .sw { flex: 0 0 auto; width: calc(1.1 * var(--u)); height: calc(0.8 * var(--u)); border: 2px solid #C7239B; }

/* ── TV floor (?wall, landscape): no text under 20 px at 1920x1080 (1.05u); a TV review 2026-11-25, owner "go" ── */
@media (min-width: 1000px) and (min-aspect-ratio: 13/10) {
  html.wall .tr .tag { font-size: calc(1.05 * var(--u)); }
  html.wall #chart .credit { font-size: calc(17.5px * var(--s, 1)); }   /* Kartverket's credit stays on the chart (its licence) */
}

/* the TV's camera tour names each stop in the chart's bottom-left corner (where the zoom buttons show only under a mouse,
   which pauses the tour and hides this) */
.map .tourcap { position: absolute; z-index: 2; left: calc(0.8 * var(--u)); bottom: calc(0.8 * var(--u)); margin: 0; max-width: 55%;
  background: var(--bg); border: calc(0.15 * var(--u)) solid var(--ink); font-size: calc(1.3 * var(--u)); font-weight: 700;
  padding: calc(0.3 * var(--u)) calc(0.7 * var(--u)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.wall .map .chartnote { max-width: 38%; }   /* shares the bottom edge with the tour's caption */

/* phones: a taller chart, and the chips and buttons smaller, so they cover less of it (a review, 2026-11-25: 353 x 265 px) */
@media (max-width: 699px) {
  .map { aspect-ratio: 1 / 1; }
  .map .legend span { font-size: 11px; padding: 1px 5px; }
  .map .legend svg { width: 12px; height: 12px; }
  .map .zoom button { min-width: 30px; min-height: 30px; width: 30px; height: 30px; font-size: 16px; }
  .map .wxchip { font-size: 12px; }
}
.tr .none.warn { color: #A85A00; font-weight: 700; }   /* a source that did not answer (traffic.js down()) */
html.wall .tr .none.warn { color: #E8B04A; }

/* the chart's credit as the legend's last chip (traffic.js), quieter than the counts */
.map .legend .cr { font-weight: 500; color: var(--stone); }
/* no line under 2 px on the TV (tests/layout_wall.py): the marks' and quays' outlines keep 2 px whatever the zoom */
html.wall #chart .ferry path, html.wall #chart .bus rect, html.wall #chart .quay, html.wall #chart .road circle, html.wall #chart .plane path { stroke-width: 2px; vector-effect: non-scaling-stroke; }
html.wall .map .legend svg [stroke], html.wall .map .legend svg path, html.wall .map .legend svg circle { vector-effect: non-scaling-stroke; }
