/* SF Live Board — design tokens and layout, per the handoff.
   Colours are authored in oklch at hue 274 (dusk indigo) with accents at
   55 / 145 / 25 / 200. Two hue families only; do not add more. */

:root{
  --bg:oklch(0.155 0.028 274);
  --surface:oklch(0.205 0.030 274);
  --surface2:oklch(0.245 0.032 274);
  --line:oklch(0.315 0.030 274);
  --text:oklch(0.945 0.010 274);
  --dim:oklch(0.665 0.020 274);
  --dimmer:oklch(0.505 0.022 274);
  --amber:oklch(0.790 0.140 55);
  --green:oklch(0.790 0.140 145);
  --red:oklch(0.680 0.160 25);
  --cyan:oklch(0.800 0.090 200);
  --sans:"Space Grotesk",Helvetica,Arial,sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,monospace;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  background:oklch(0.10 0.02 274);
  color:var(--text);
  font-family:var(--sans);
  -webkit-font-smoothing:antialiased;
  display:flex;justify-content:center;
}
a{color:var(--amber);text-decoration:none}
a:hover{color:var(--text)}
button:focus-visible,.chip:focus-visible{outline:1px solid var(--text);outline-offset:1px}
#app{
  width:100%;max-width:480px;height:100dvh;background:var(--bg);
  display:flex;flex-direction:column;overflow:hidden;position:relative;
  box-shadow:0 0 0 1px oklch(0.28 0.03 274), 0 40px 120px -40px oklch(0.05 0.02 274);
}

/* ---------- header ---------- */
header{
  padding:14px 16px 12px;display:flex;flex-direction:column;gap:10px;
  border-bottom:1px solid var(--line);flex:none;
}
.brandrow{display:flex;align-items:flex-start;gap:12px}
.brand{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}
.brand h1{margin:0;font-size:19px;font-weight:600;letter-spacing:0.14em;line-height:1}
.brand .sub{
  font-family:var(--mono);font-size:9.5px;letter-spacing:0.20em;color:var(--dim);
  text-transform:uppercase;
}
.clockbox{text-align:right;display:flex;flex-direction:column;gap:3px;align-items:flex-end}
.clock{font-family:var(--mono);font-size:17px;font-weight:500;letter-spacing:0.04em;line-height:1;font-variant-numeric:tabular-nums}
.clock .sec{color:var(--dimmer)}
.tzline{font-family:var(--mono);font-size:9px;letter-spacing:0.14em;color:var(--dimmer)}

.readout{display:flex;gap:0;border:1px solid var(--line);border-radius:3px;overflow:hidden}
.readout div{
  flex:1;padding:7px 9px;display:flex;flex-direction:column;gap:3px;
  border-right:1px solid var(--line);min-width:0;
}
.readout div:last-child{border-right:0}
.readout .k{font-family:var(--mono);font-size:8.5px;letter-spacing:0.16em;color:var(--dimmer);text-transform:uppercase}
.readout .v{font-family:var(--mono);font-size:13px;font-weight:500;letter-spacing:0.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}

.langrow{display:flex;gap:6px;align-items:center}
.lang{
  font-family:var(--mono);font-size:10px;letter-spacing:0.08em;padding:4px 8px;
  border:1px solid var(--line);border-radius:2px;background:transparent;color:var(--dim);
  cursor:pointer;font-weight:500;
}
.lang[aria-pressed="true"]{background:var(--text);color:var(--bg);border-color:var(--text)}

/* Replaces the prototype's DEMO FEED pill: real provenance, not a placeholder.
   Reads "n/14 live" and colours by the worst state on the board. */
/* Scanner audio toggle.
   This is a feature, not a preference, so it is styled to be found: a filled
   control with a play affordance rather than another hairline label. Until it
   has been used once it breathes gently to invite the tap, then stops for good
   — an ambient board should ask once, not nag. */
.audio{
  margin-left:auto;display:flex;align-items:center;gap:7px;cursor:pointer;
  font-family:var(--mono);font-size:10px;font-weight:500;letter-spacing:0.14em;
  padding:6px 11px;border:1px solid var(--green);border-radius:2px;
  background:var(--surface2);color:var(--text);white-space:nowrap;
  transition:border-color .2s ease, background .2s ease;
}
/* display:flex would otherwise defeat the hidden attribute. */
.audio[hidden]{display:none}
/* With the audio control gone, provenance takes over pushing itself right. */
.audio[hidden] ~ .prov{margin-left:auto}
.audio:hover{background:var(--line)}
.audio:not([data-used]){animation:invite 2.6s ease-in-out infinite}
@keyframes invite{
  0%,100%{box-shadow:0 0 0 0 oklch(0.790 0.140 145 / 0)}
  50%{box-shadow:0 0 0 3px oklch(0.790 0.140 145 / 0.16)}
}

.aicon{display:flex;align-items:center;justify-content:center;width:11px;height:10px;flex:none}
/* Play triangle when idle; level meter when live. */
.aplay{
  width:0;height:0;display:block;
  border-left:8px solid var(--green);
  border-top:5px solid transparent;border-bottom:5px solid transparent;
}
.abars{display:none;align-items:flex-end;gap:2px;height:10px}
.abars i{width:2px;height:3px;background:var(--green);display:block;border-radius:1px}
.audio[aria-pressed="true"]{border-color:var(--green);background:oklch(0.790 0.140 145 / 0.14)}
.audio[aria-pressed="true"] .aplay{display:none}
.audio[aria-pressed="true"] .abars{display:flex}
.audio[aria-pressed="true"] .abars i{animation:vu 900ms ease-in-out infinite}
.audio[aria-pressed="true"] .abars i:nth-child(2){animation-delay:150ms}
.audio[aria-pressed="true"] .abars i:nth-child(3){animation-delay:300ms}
.audio[data-state="loading"]{border-color:var(--dim);color:var(--dim)}
.audio[data-state="blocked"]{border-color:var(--amber);color:var(--amber)}
.audio[data-state="blocked"] .aplay{border-left-color:var(--amber)}
@keyframes vu{0%,100%{height:3px}50%{height:10px}}

.prov{display:flex;align-items:center;gap:5px;font-family:var(--mono);
  font-size:8.5px;letter-spacing:0.14em;color:var(--dimmer);
  border:1px solid var(--line);padding:4px 7px;border-radius:2px;white-space:nowrap;
}
.prov .pdot{width:5px;height:5px;border-radius:50%;background:var(--dimmer);flex:none}
.prov.live .pdot{background:var(--green);animation:breathe 2s ease-in-out infinite}
.prov.lag .pdot{background:var(--amber)}
.prov.stale .pdot{background:var(--red)}

/* ---------- map ---------- */
.mapwrap{position:relative;flex:1 1 auto;min-height:120px;overflow:hidden;background:oklch(0.13 0.025 274)}
#map{position:absolute;inset:0;background:oklch(0.13 0.025 274)}
.leaflet-tile-pane{filter:invert(1) hue-rotate(185deg) saturate(0.35) brightness(0.92) contrast(0.88)}
.leaflet-container{background:oklch(0.13 0.025 274);font-family:var(--mono)}
.leaflet-control-attribution{
  background:oklch(0.155 0.028 274 / 0.85)!important;color:var(--dimmer)!important;
  font-family:var(--mono)!important;font-size:8px!important;padding:2px 5px!important;
}
.leaflet-control-attribution a{color:var(--dim)!important}

.veh{width:12px;height:12px;border-radius:50%;border:2px solid oklch(0.13 0.025 274)}
.veh.metro{background:var(--green)}
.veh.bus{background:var(--cyan)}
.veh.historic{background:var(--amber)}
.plane{
  font-family:var(--mono);font-size:11px;color:var(--dim);line-height:1;
  text-shadow:0 0 6px oklch(0.13 0.025 274);
}
.apt{
  display:flex;align-items:center;justify-content:center;height:19px;
  border:1px solid var(--green);border-radius:2px;background:oklch(0.155 0.028 274 / 0.88);
  font-family:var(--mono);font-size:10.5px;font-weight:600;letter-spacing:0.08em;
}
.inc{width:12px;height:12px;position:relative}
.inc i{position:absolute;inset:3px;border-radius:50%;display:block}
.inc b{
  position:absolute;inset:0;border-radius:50%;border:1px solid currentColor;
  animation:ping 2.4s cubic-bezier(0,.4,.6,1) infinite;display:block;
}
@keyframes ping{0%{transform:scale(.5);opacity:.9}100%{transform:scale(2.6);opacity:0}}
.ship{width:10px;height:10px;background:var(--cyan);border:1.5px solid oklch(0.13 0.025 274);
  border-radius:1px;transform:rotate(45deg)}
.fog{
  position:absolute;inset:0;z-index:450;pointer-events:none;
  background:radial-gradient(120% 90% at 8% 60%, oklch(0.80 0.02 274 / 0.30) 0%, oklch(0.80 0.02 274 / 0.14) 38%, transparent 66%);
  animation:drift 26s ease-in-out infinite alternate;
  opacity:0;transition:opacity 4s ease;
}
@keyframes drift{0%{transform:translateX(-4%) scale(1.02)}100%{transform:translateX(8%) scale(1.10)}}
.c311{width:10px;height:10px;border-radius:1px;border:1.5px dashed var(--dim);background:oklch(0.66 0.02 274 / 0.22)}

/* SVG icon markers. The glyph sits above an optional ping ring; both take
   their colour from the layer so one rule serves every icon layer. */
.mk{position:relative;display:flex;align-items:center;justify-content:center}
.mk .mi{display:block;position:relative;z-index:2;overflow:visible}
.mk b{
  position:absolute;inset:18%;border-radius:50%;border:1px solid currentColor;
  animation:ping 2.4s cubic-bezier(0,.4,.6,1) infinite;display:block;z-index:1;
}

.cam{
  width:11px;height:11px;border:1.5px solid oklch(0.945 0.010 274);border-radius:2px;
  background:oklch(0.13 0.025 274 / 0.65);box-shadow:0 0 0 1px oklch(0.13 0.025 274);
}
.pip{
  position:absolute;right:10px;top:10px;z-index:520;width:132px;padding:0;cursor:pointer;
  background:oklch(0.155 0.028 274 / 0.9);border:1px solid var(--line);border-radius:3px;
  display:flex;flex-direction:column;overflow:hidden;backdrop-filter:blur(6px);
}
.pipframe{
  position:relative;display:flex;align-items:center;justify-content:center;
  aspect-ratio:16/9;width:100%;overflow:hidden;
  background:repeating-linear-gradient(135deg,oklch(0.235 0.030 274) 0 5px,oklch(0.200 0.028 274) 5px 10px);
}
.pipframe img,.camview img,.pipframe video,.camview video{
  position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block;
}
.pipnote{font-family:var(--mono);font-size:7.5px;letter-spacing:0.12em;color:var(--dim);text-transform:uppercase}
.pipscan{
  position:absolute;left:0;right:0;top:0;height:22%;pointer-events:none;z-index:2;
  background:linear-gradient(oklch(0.95 0.01 274 / 0.10),transparent);
  animation:scan 4.2s linear infinite;
}
@keyframes scan{0%{transform:translateY(-100%)}100%{transform:translateY(460%)}}
.piplbl{
  display:flex;align-items:center;gap:5px;padding:5px 7px;border-top:1px solid var(--line);
  font-family:var(--mono);font-size:8px;letter-spacing:0.10em;color:var(--dim);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.pipdot{width:4px;height:4px;border-radius:50%;background:var(--red);flex:none;animation:breathe 1.6s ease-in-out infinite}
.camview{
  display:none;position:relative;align-items:flex-end;justify-content:space-between;
  aspect-ratio:16/9;width:100%;overflow:hidden;border:1px solid var(--line);border-radius:3px;padding:8px;
  background:repeating-linear-gradient(135deg,oklch(0.235 0.030 274) 0 6px,oklch(0.200 0.028 274) 6px 12px);
  /* Hold the 16:9 frame instead of being squeezed by the flex column. */
  flex:none;
  /* The design sized this frame inside a 480px column. On a wide screen the
     map column is ~1200px, and an unconstrained 16:9 frame becomes 670px tall
     — big enough to push everything else, including the way out, off the
     bottom of the panel. Cap it at roughly the width it was drawn for. */
  max-width:520px;
}
.camtag,.camnote{position:relative;z-index:3}
.camtag{font-family:var(--mono);font-size:9.5px;letter-spacing:0.12em;color:var(--text);text-shadow:0 1px 4px oklch(0.10 0.02 274)}
.camnote{font-family:var(--mono);font-size:8.5px;letter-spacing:0.10em;color:var(--dimmer);text-align:right;text-shadow:0 1px 4px oklch(0.10 0.02 274)}
.maplabel{
  position:absolute;left:10px;top:10px;z-index:500;display:flex;gap:6px;align-items:center;
  font-family:var(--mono);font-size:9px;letter-spacing:0.14em;color:var(--dim);
  background:oklch(0.155 0.028 274 / 0.82);padding:5px 8px;border:1px solid var(--line);border-radius:2px;
  backdrop-filter:blur(6px);
}
.pulse{width:5px;height:5px;border-radius:50%;background:var(--green);animation:breathe 2s ease-in-out infinite}
@keyframes breathe{0%,100%{opacity:1}50%{opacity:.25}}

/* ---------- layer rail ---------- */
.rail{
  flex:none;display:flex;gap:6px;padding:10px 12px;overflow-x:auto;
  border-top:1px solid var(--line);border-bottom:1px solid var(--line);
  scrollbar-width:none;background:var(--bg);
}
.rail::-webkit-scrollbar{display:none}
.chip{
  flex:none;display:flex;flex-direction:column;gap:5px;padding:7px 10px;min-width:74px;
  border:1px solid var(--line);border-radius:3px;background:transparent;cursor:pointer;
  text-align:left;font-family:var(--mono);
}
.chip[aria-pressed="false"]{opacity:0.42}
.chip[data-state="unconfigured"]{border-style:dashed;cursor:not-allowed}
.chip .top{display:flex;align-items:center;gap:5px}
.chip .dot{width:6px;height:6px;border-radius:50%;flex:none}
.chip .nm{font-size:10.5px;font-weight:500;letter-spacing:0.06em;color:var(--text);white-space:nowrap}
.chip .age{font-size:9px;letter-spacing:0.10em;color:var(--dimmer);white-space:nowrap;font-variant-numeric:tabular-nums}

/* ---------- ticker ---------- */
.ticker{
  flex:none;padding:12px 16px 16px;display:flex;gap:12px;align-items:flex-start;min-height:78px;
}
.tstamp{
  font-family:var(--mono);font-size:9.5px;letter-spacing:0.08em;color:var(--dimmer);
  padding-top:2px;flex:none;font-variant-numeric:tabular-nums;
}
.tbody{flex:1;min-width:0;display:flex;flex-direction:column;gap:5px;transition:opacity .35s ease}
.tkind{font-family:var(--mono);font-size:9px;letter-spacing:0.18em;text-transform:uppercase}
.ttext{font-size:14.5px;line-height:1.32;text-wrap:pretty}
.ttext .tlink{color:inherit;text-decoration:none;border-bottom:1px solid var(--line)}
.ttext .tlink:hover{border-bottom-color:var(--amber);color:var(--amber)}
.tmeta{font-family:var(--mono);font-size:9.5px;letter-spacing:0.08em;color:var(--dimmer)}
.tdots{display:flex;flex-direction:column;gap:4px;padding-top:4px;flex:none}
.tdots span{width:4px;height:4px;border-radius:50%;background:var(--line)}
.tdots span.on{background:var(--dim)}

@media (max-height:640px){
  header{padding:10px 14px 9px;gap:7px}
  .readout div{padding:5px 8px}
  .ticker{min-height:0;padding:9px 14px}
  .ttext{font-size:13px}
}

/* ---------- landscape / TV ---------- */
@media (min-width:820px) and (min-aspect-ratio:6/5){
  #app{
    max-width:none;display:grid;
    grid-template-columns:1fr minmax(340px,400px);
    grid-template-rows:auto auto 1fr;
  }
  /* The handoff pins .langrow to top/right:16px, which lands it on top of the
     clock at this width. Same intent — controls out of the reading path — but
     resolved with layout, so it holds at any header width. */
  header{
    grid-column:1 / -1;position:relative;
    display:grid;grid-template-columns:1fr auto;
    grid-template-areas:"brand brand" "readout lang";
    align-items:center;column-gap:16px;
  }
  .brandrow{grid-area:brand}
  .readout{grid-area:readout}
  .langrow{grid-area:lang;position:static;justify-content:flex-end}
  .mapwrap{grid-column:1;grid-row:2 / 4;border-right:1px solid var(--line)}
  .rail{grid-column:2;grid-row:2;flex-wrap:wrap;overflow:visible;border-top:0;align-content:flex-start}
  .chip{flex:1 1 90px}
  .ticker{grid-column:2;grid-row:3;border-bottom:0;align-items:center}
  /* No sponsor module: the ticker takes the column's remaining height. */
  .rail{align-content:flex-start}
  .ttext{font-size:17px}
  .brand h1{font-size:24px}
  .readout{max-width:520px}
  /* Keep the sheet reading as a panel rather than a full-bleed wall, and keep
     the note text at a sane measure instead of stretching to 1200px. */
  .sheetscroll{max-width:680px}
}

/* ---------- sheet ---------- */
.sheet{
  position:absolute;left:0;right:0;bottom:0;z-index:900;background:var(--surface);
  border-top:1px solid var(--line);padding:14px 16px 18px;
  transform:translateY(101%);transition:transform .28s cubic-bezier(.2,.7,.2,1);
  display:flex;flex-direction:column;gap:10px;
  /* The map clips this sheet on purpose. Without a ceiling, a tall sheet — a
     camera frame is the usual culprit — grows past the top of the map and the
     CLOSE button gets clipped away, leaving no visible way out. */
  max-height:100%;
}
.sheet.open{transform:translateY(0)}
.sheet .hd{display:flex;align-items:baseline;gap:10px;flex:none}
.sheetscroll{
  display:flex;flex-direction:column;gap:10px;
  overflow-y:auto;min-height:0;overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}
.sheet .kd{font-family:var(--mono);font-size:9px;letter-spacing:0.18em;text-transform:uppercase}
.sheet .x{
  margin-left:auto;background:var(--surface);border:1px solid var(--line);color:var(--text);
  font-family:var(--mono);font-size:10px;padding:6px 12px;border-radius:2px;cursor:pointer;
  letter-spacing:0.10em;
}
.sheet .x:hover{border-color:var(--text)}
.sheet h2{margin:0;font-size:18px;font-weight:500;letter-spacing:-0.01em;line-height:1.2}
.sheet .grid{display:grid;grid-template-columns:1fr 1fr;gap:1px;background:var(--line);border:1px solid var(--line);border-radius:3px}
.sheet .grid div{background:var(--surface);padding:8px 10px;display:flex;flex-direction:column;gap:3px}
.sheet .grid .k{font-family:var(--mono);font-size:8.5px;letter-spacing:0.14em;color:var(--dimmer);text-transform:uppercase}
.sheet .grid .v{font-family:var(--mono);font-size:12.5px}
.stale{font-family:var(--mono);font-size:9.5px;letter-spacing:0.06em;color:var(--dimmer);line-height:1.5}

/* Ambient displays run for days in rooms with people in them. Every looping
   animation degrades to a static state; nothing here needs motion to be read. */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important}
  .inc b{display:none}
  .mk b{display:none}
  .audio:not([data-used]){animation:none}
  .pipscan{display:none}
  .fog{opacity:var(--fog-static,0.5)}
}
