/* CycleHUD — styled for the Meta Ray-Ban Display (600×600, additive light).
   SPDX-License-Identifier: AGPL-3.0-or-later
   Black (#000) is transparent to the wearer, so the page is pure black and
   only the information you need is lit. UI surfaces use dark greys so they
   still read as panels. */

:root {
  --bg: #000000;
  --surface: #14141f;
  --surface-2: #1c2328;
  --line: #2a333a;
  --text: #FFFFFF;
  --text-2: #E4E6EB;
  --dim: #B0B3B8;
  --accent: #4fe3c1;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --ok: #4cd97b;
  --dash-dim: 0.45;      /* brightness of the speed / media / clock row in the Glance View (Glance View: Dimmed) */
  --ride-val: #D8DBE0;   /* ride time digits: brighter than --dim, not as bright as the clock */
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; width: 600px; height: 600px; overflow: hidden; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;          /* safe margin */
  gap: 8px;
}
.screen[hidden] { display: none; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- map screen ---------- */
.map-screen { padding: 0; }
.map-focus {
  position: absolute; inset: 0;
  opacity: 0; z-index: 0;
}
.map-focus:focus-visible { outline: none; }
/* The map uses the top 400 px only: the lower part of the display is hard to
   see while riding, so the media bar sits directly under the map instead. */
#map { position: absolute; top: 0; left: 0; width: 600px; height: 400px; pointer-events: none; z-index: 1; }

.pill {
  position: absolute;
  z-index: 2;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0 18px;
  height: 64px;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
}
/* speed dial: a 100 px disc with a 270-degree gauge arc round its edge (7:30
   clockwise over the top to 4:30, the bottom open), full and red at
   SPEED_GAUGE_FULL_MPS. The SVG is drawn in a 120 unit box (circle r = 54,
   circumference 339.3, three quarters = 254.5) and scaled down. The 12 px top
   padding sets the number level with the clock's digits (y = 56), unit beneath. */
.pill.speed {
  top: 10px; left: 24px;
  width: 100px; height: 100px; padding: 12px 0 0;
  border-radius: 50%;
  flex-direction: column; justify-content: center; gap: 0;
}
.speed-gauge { position: absolute; inset: 0; width: 100%; height: 100%; }
.gauge-track { fill: none; stroke: var(--line); stroke-width: 4; stroke-linecap: butt; stroke-dasharray: 254.5 339.3; }
/* the arc itself: 27 short segments (app.js buildGauge), each its own colour on
   the white -> yellow -> orange -> red run, revealed in turn as the speed rises */
.gauge-seg { fill: none; stroke-width: 4; stroke-linecap: butt; transition: stroke-dasharray 700ms ease-out; }
.speed-val { position: relative; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.speed-unit { position: relative; font-size: 13px; color: var(--dim); margin-top: 2px; }
.pill.dim .speed-val { color: var(--dim); }
.pill.dim .gauge-seg { stroke: var(--dim) !important; }

.pill.clock { top: 24px; right: 24px; font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ride time: moving time only (app.js RideTime). Map view: a small right-aligned
   block beside the clock (right edge at x 440, 31 px clear of the clock pill); each .ride-row
   is label + value so a second row (time to destination) can join later.
   Glance View: the value alone sits under the time inside the clock pill. */
.ride {
  position: absolute; z-index: 2;
  top: 24px; height: 64px; right: 160px;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 2px;
  pointer-events: none;
}
.ride-row { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; line-height: 1.3; }
.ride-label { text-transform: uppercase; letter-spacing: 0.06em; }
.ride-row .ride-val { font-size: 20px; font-weight: 600; color: var(--ride-val); }
.clock-ride { display: none; font-size: 18px; font-weight: 600; color: var(--ride-val); font-variant-numeric: tabular-nums; line-height: 1.2; }
.ride-val.paused { animation: ridepulse 1.6s ease-in-out infinite; }   /* stopped mid-ride: the count waits, pulsing */
@keyframes ridepulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.pill.notice {
  height: 44px; padding: 0 16px;
  font-size: 16px; font-weight: 600;
  left: 50%; transform: translateX(-50%);
  background: var(--surface-2);
}
.pill.notice.gps { top: 100px; color: var(--warn); }
.pill.notice.mapmsg { top: 150px; color: var(--text-2); }

/* on-map debug readout (Status -> Debug, off by default): bottom band, under the media bar */
.pill.debug {
  top: 504px; left: 50%; transform: translateX(-50%);
  height: 64px; padding: 0 12px;
  flex-direction: column; justify-content: center; gap: 3px;
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--text-2); background: var(--surface-2); white-space: nowrap;
}
.pill[hidden] { display: none; }

/* media bar: one node, moved by app.js between the map screen (absolute, flush
   under the 400 px map) and the pause screen (in flow) */
.media-bar {
  position: relative; z-index: 2;
  width: 100%; height: 88px;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  pointer-events: none;
  overflow: hidden;      /* clips the progress line into the rounded bottom corners */
  transition: opacity 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
}
.media-bar[hidden] { display: none; }
.map-screen .media-bar { position: absolute; width: auto; left: 8px; right: 8px; top: 408px; }
/* track progress: a thin line along the bottom edge, the bar's full width = the whole track */
.media-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.media-prog[hidden] { display: none; }
.media-prog-fill { height: 100%; width: 0; background: var(--dim); transition: width 1s linear; }
.media-prog-fill.snap { transition: none; }   /* a jump backwards (new track, seek) must not animate */
.media-bar.dim { color: var(--dim); }
.media-glyph {
  flex: 0 0 44px; height: 44px;
  border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
/* the glyph is the play state, never a button: bouncing bars while playing,
   pause bars for a paused track, a note when nothing is on */
.media-glyph .eq { display: flex; align-items: flex-end; gap: 3px; height: 18px; }
.media-glyph .eq i { display: block; width: 4px; height: 8px; border-radius: 1px; background: currentColor; animation: eq 1s ease-in-out infinite; }
.media-glyph .eq i:nth-child(2) { animation-delay: -0.35s; }
.media-glyph .eq i:nth-child(3) { animation-delay: -0.7s; }
@keyframes eq {
  0%, 100% { height: 6px; }
  50% { height: 18px; }
}
.media-text { flex: 1 1 auto; min-width: 0; }
.mq-box { overflow: hidden; white-space: nowrap; }
.mq-text { display: inline-block; font-size: 20px; font-weight: 700; will-change: transform; }
.mq-text.marquee { animation: mq var(--mq-t, 6s) ease-in-out infinite alternate; }
.mq-text.paused { animation-play-state: paused; }
@keyframes mq {
  from { transform: translateX(0); }
  to { transform: translateX(var(--mq-x, 0px)); }
}
.media-artist { font-size: 16px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-ctl { flex: 0 0 auto; display: flex; gap: 14px; font-size: 22px; color: var(--text-2); }

/* Glance View (Enter on the main screen): no map; the media bar stays where it is
   and the speed dial and clock drop down beside it, all dimmed to --dash-dim.
   The row is centred on y = 452 (the bar's middle); notices stay full brightness. */
.map-screen.dash #map { display: none; }
.map-screen.dash .media-bar { left: 140px; right: 152px; }
.map-screen.dash .pill.speed { top: 402px; }
.map-screen.dash .pill.clock { top: 420px; flex-direction: column; justify-content: center; gap: 0; line-height: 1; }
.map-screen.dash .clock-ride { display: block; margin-top: 2px; }   /* ride time under the time, like mph under the speed */
.map-screen.dash .ride { display: none; }
.map-screen.dash .pill.speed, .map-screen.dash .pill.clock, .map-screen.dash .media-bar { opacity: var(--dash-dim); }
.map-screen.dash.bright .pill.speed, .map-screen.dash.bright .pill.clock, .map-screen.dash.bright .media-bar { opacity: 1; }   /* Glance View: Bright */

/* ---------- menu ---------- */
.rows { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.row {
  height: 72px;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 22px; font-weight: 600;
  text-align: left;
  padding: 0 28px;
  opacity: 0.85;
  transition: transform 475ms cubic-bezier(0.6, 0, 0.4, 1), opacity 300ms cubic-bezier(0.4, 0.04, 0.5, 1);
}
.row[hidden] { display: none; }
.row.center { text-align: center; }
/* two settings side by side */
.row2 { display: flex; gap: 8px; width: 100%; }
.row2 .row { flex: 1 1 0; width: auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* menu player row: previous | now playing (press = play/pause) | next */
.transport { display: flex; gap: 8px; width: 100%; }
.transport[hidden] { display: none; }
.transport .row { width: auto; text-align: center; }
.transport .tbtn { flex: 0 0 104px; padding: 0; display: flex; align-items: center; justify-content: center; }
.transport .tbtn svg { width: 32px; height: 32px; fill: currentColor; }
.transport .tmain { flex: 1 1 auto; }
.transport .player { position: relative; overflow: hidden; display: flex; align-items: center; gap: 14px; padding: 0 20px; text-align: left; min-width: 0; }
.pp-glyph { flex: 0 0 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; }
.row:focus-visible .pp-glyph { background: var(--line); }
.pp-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.pp-title { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-artist { font-size: 14px; font-weight: 400; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-artist:empty { display: none; }
.pp-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.pp-prog[hidden] { display: none; }
.pp-prog-fill { display: block; height: 100%; width: 0; background: var(--dim); }
.row:focus-visible { opacity: 1; background: var(--surface-2); transform: scale(0.97); outline: 3px solid var(--accent); outline-offset: -3px; }

/* ---------- top bar, buttons ---------- */
.topbar { display: flex; align-items: center; gap: 12px; height: 64px; margin-top: 16px; }
.back {
  flex: 0 0 64px; height: 64px;
  border-radius: 50%; background: var(--surface);
  font-size: 34px; line-height: 1;
}
.title { font-size: 28px; font-weight: 700; }
.actions { display: flex; gap: 16px; margin-top: auto; }
.btn {
  flex: 1 1 0; height: 88px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 20px; font-weight: 600;
}
.btn[hidden] { display: none; }
.hint { color: var(--dim); font-size: 16px; }

/* ---------- pair ---------- */
.pair-body { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 24px; text-align: center; }
.pair-url { font-size: 18px; font-weight: 600; word-break: break-all; color: var(--text-2); }
.pair-code { font-size: 44px; font-weight: 700; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.pair-status { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 16px; }
.pair-status .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--dim); }
.pair-status.on .dot { background: var(--ok); }
.pair-status.on { color: var(--text-2); }
.pair-status.paired { color: var(--ok); font-weight: 600; }

/* ---------- status ---------- */
.scroll { flex: 1 1 auto; overflow-y: auto; position: relative; padding: 4px 8px 32px; }
.scroll:focus-visible { outline: 2px solid var(--line); outline-offset: 0; }
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; font-size: 16px; }
.kv-row dt { color: var(--dim); }
.kv-row dd { color: var(--text-2); word-break: break-word; }

/* ---------- toast ---------- */
.toast {
  position: absolute; z-index: 5;
  top: 160px; left: 50%; transform: translateX(-50%);
  max-width: 536px;
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 18px; font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.toast[hidden] { display: none; }

/* ---------- wordmark (splash, pause, quit) ---------- */
.wordmark { font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; }
.wordmark span { color: var(--warn); }

/* ---------- pause ride ---------- */
.pause-screen { padding: 16px 16px 8px; gap: 10px; }
.pause-top { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.pause-clock { height: 56px; padding: 0 18px; display: flex; align-items: center; background: var(--surface); border-radius: var(--radius); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pause-label { font-size: 14px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--warn); }
.stats { display: flex; gap: 8px; width: 100%; }
.stat { flex: 1 1 0; height: 96px; background: var(--surface); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.stat-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }
.stat-val { font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.stat-unit { font-size: 14px; color: var(--dim); }
.media-host { width: 100%; }
.pause-actions, .quit-actions { display: flex; width: 100%; }
.btn.resume { font-size: 24px; }
.pause-hint { text-align: center; }

/* ---------- quit? ---------- */
.quit-screen { align-items: center; justify-content: center; gap: 18px; padding-bottom: 120px; }
.quit-q { font-size: 32px; font-weight: 700; }
.quit-hint { text-align: center; max-width: 440px; }
.quit-actions { max-width: 440px; }

/* ---------- splash ---------- */
.splash {
  position: absolute; inset: 0; z-index: 20;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding-bottom: 60px;
  opacity: 0; transition: opacity 400ms ease-out;
  pointer-events: none;
}
.splash.in { opacity: 1; }
.splash.out { opacity: 0; transition: opacity 500ms ease-in; }
.splash-mark { font-size: 76px; }
.splash-tag { font-size: 22px; letter-spacing: 0.08em; color: var(--text-2); }
.splash-safe { margin-top: 26px; max-width: 520px; text-align: center; font-size: 30px; font-weight: 600; color: var(--warn); opacity: 0; transition: opacity 600ms ease-out; }
.splash-safe.show { opacity: 1; }
