/* ETHRX HQ theme. One stylesheet for / and /approve, driven by the custom properties below.

   Where the values come from:
   - Brand (logo, type families, tracking, accent): website/src/styles/theme.css (.ml-* tokens)
   - App surfaces (panels, hairlines, radii, shadow, status colours): chaos/frontend/src/index.css
   Sizes are scaled up from both sources: this is read at a glance on a car screen. */

/* ---------- fonts: self-hosted copies of the website's families ---------- */
@font-face { font-family: "Bebas Neue"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/bebas-neue-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bebas Neue"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/bebas-neue-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "DM Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/dm-mono-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "DM Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/dm-mono-400-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "DM Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/dm-mono-500-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "DM Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/dm-mono-500-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/dm-sans-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 300 700; font-display: swap; src: url(/fonts/dm-sans-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;

  /* palette: the ETHRX warm grey ramp */
  --bg: #080808;                             /* website --ml-bg, CHAOS neutral-950 */
  --surface: #111110;                        /* CHAOS --color-panel */
  --surface-2: #191917;                      /* CHAOS --color-panel-2 */
  --well: #0c0c0b;                           /* CHAOS --color-well (inputs) */
  --border: rgba(244, 242, 238, 0.07);       /* CHAOS --color-line */
  --border-2: rgba(244, 242, 238, 0.11);     /* CHAOS --color-line-2 */
  --border-3: rgba(244, 242, 238, 0.2);      /* CHAOS --color-line-3 */
  --border-hi: rgba(244, 242, 238, 0.28);    /* website --ml-border-hi (buttons) */
  --text: #f4f2ee;                           /* website --ml-white */
  --text-2: #d6d3cc;                         /* website --ml-gray-1 */
  --muted: #9e9b94;                          /* website --ml-gray-2 */
  --accent: #f4f2ee;                         /* off-white ink is the accent on both */
  --accent-ink: #080808;
  --ok: #d6d3cc;                             /* CHAOS --color-ok */
  --warning: #e8a33d;                        /* CHAOS --color-warn */
  --danger: #ef4444;                         /* CHAOS --color-bad */

  /* type */
  --font-display: "Bebas Neue", "Arial Narrow", sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --track-label: 0.25em;                     /* website .ml-label */
  --track-button: 0.22em;                    /* website .ml-btn */
  --track-display: 0.02em;                   /* website .ml-title-sm */
  --track-figure: -0.04em;                   /* CHAOS .display figures */

  /* shape */
  --radius-card: 12px;                       /* CHAOS .glass */
  --radius-control: 8px;                     /* CHAOS .field-input */
  --radius-pill: 999px;
  --shadow-card: inset 0 1px 0 rgba(244, 242, 238, 0.03), 0 1px 2px rgba(0, 0, 0, 0.4);
  --sheen: linear-gradient(180deg, rgba(244, 242, 238, 0.025), rgba(244, 242, 238, 0.01));
  --focus-ring: 0 0 0 3px rgba(244, 242, 238, 0.06);

  /* car-screen rules */
  --tap: 60px;                               /* minimum tap target height */
  --fs-base: clamp(16px, min(1.5vw, 2.5vh), 28px);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--bg); -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base)/1.35 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
/* The room: the website's 80px grid and CHAOS's faint light from above. Static, no animation. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 40% at 50% -8%, rgba(244, 242, 238, 0.05), transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px) 0 0 / 80px 80px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px) 0 0 / 80px 80px;
}
button, input { font: inherit; color: inherit; }
button, a.tile { cursor: pointer; }
:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
::selection { background: var(--text); color: var(--bg); }
.hidden { display: none !important; }

/* ---------- brand: logo | rule | product ---------- */
.brand { display: flex; align-items: center; gap: 0.6em; margin: 0; font-size: 1em; font-weight: 400; }
.brand__logo { height: clamp(40px, 2.6em, 72px); width: auto; display: block; }
.brand__rule { width: 1px; height: 1.5em; background: var(--border-3); }
.brand__product { font-family: var(--font-display); font-size: 1.9em; line-height: 1; letter-spacing: 0.06em; padding-top: 0.08em; }
.brand__tag { font-family: var(--font-mono); font-weight: 500; font-size: 0.72em; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); }

/* ---------- shared pieces ---------- */
.label { font-family: var(--font-mono); font-weight: 500; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); }
.pill {
  font-family: var(--font-mono); font-weight: 500; font-size: 0.8em; letter-spacing: 0.2em; white-space: nowrap;
  border: 1px solid var(--warning); color: var(--warning); border-radius: var(--radius-pill); padding: 0.3em 0.9em 0.3em 1.1em;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 1.4em;
  font-family: var(--font-mono); font-weight: 500; font-size: 0.8em; letter-spacing: var(--track-button); text-transform: uppercase;
  text-decoration: none; white-space: nowrap;
  color: var(--text); background: transparent; border: 1px solid var(--border-hi); border-radius: var(--radius-control);
}
.btn:active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:active { background: var(--text-2); border-color: var(--text-2); }
.btn:disabled { opacity: 0.5; }

/* ---------- pairing screen (truck, signed out) ---------- */
#pair { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4vh 4vw; gap: 3vh; }
#pair .brand { font-size: 1.3em; }
#pair #code { font: 500 clamp(72px, min(13vw, 24vh), 200px)/1 var(--font-mono); letter-spacing: 0.1em; padding-left: 0.1em; font-variant-numeric: tabular-nums; }
#pair p { margin: 0; color: var(--text-2); max-width: 34em; font-size: 1.1em; }
#pair b { color: var(--text); font-weight: 600; white-space: nowrap; }
#pair #pairState { font-family: var(--font-mono); font-weight: 500; font-size: 0.85em; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); min-height: 1.4em; }

/* ---------- dashboard ---------- */
#dash { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 1.8vh; padding: 2vh 2vw; }
#dash > header { display: flex; align-items: center; justify-content: space-between; gap: 2vw; }
.meta { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0.6em 1.5em; color: var(--muted); font-size: 0.8em; font-variant-numeric: tabular-nums; }
.meta .btn { font-size: 0.95em; }

main { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.2vw; min-height: 0; }
.card {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding: 1.1em 1.2em; container-type: inline-size;
  background: var(--sheen), var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
}
.card h2 { margin: 0; font-family: var(--font-mono); font-weight: 500; font-size: 0.72em; letter-spacing: var(--track-label); text-transform: uppercase; color: var(--muted); }
.big { font-family: var(--font-mono); font-weight: 400; font-size: 3.2em; line-height: 1; letter-spacing: var(--track-figure); margin: 0.22em 0 0.12em; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Cash can run to 10 characters: size it to the card so it never clips. Plain em is the fallback. */
#cash { font-size: 2.4em; font-size: min(3.2em, 17cqi); margin-top: 0.3em; }
.big small { font-family: var(--font-body); font-weight: 400; font-size: 0.3em; letter-spacing: 0; color: var(--muted); margin-left: 0.6em; }

.card ul { list-style: none; margin: 0.6em 0 0; padding: 0; overflow: hidden; }
.card li { padding: 0.55em 0; border-top: 1px solid var(--border-2); }
li .top { display: flex; justify-content: space-between; gap: 1em; color: var(--muted); font-size: 0.8em; }
li .top span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
li .top span:last-child { font-family: var(--font-mono); }
li .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card ul.agenda { margin-top: 0.9em; font-size: 1.1em; }
.agenda li { display: flex; align-items: baseline; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.time { font-family: var(--font-mono); font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; margin-right: 0.9em; }
.agenda li { color: var(--text-2); }

.rows { margin-top: 0.6em; }
.row { display: flex; justify-content: space-between; gap: 1em; padding: 0.5em 0; border-top: 1px solid var(--border-2); }
.row span:first-child { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row span:last-child { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.bad { color: var(--danger); }

#dash > footer { display: flex; gap: 1vw; align-items: stretch; }
a.tile {
  flex: 1; display: flex; align-items: center; justify-content: center; min-height: max(var(--tap), 3.2em); padding: 0 0.5em;
  font-family: var(--font-mono); font-weight: 500; font-size: 0.8em; letter-spacing: var(--track-button); text-transform: uppercase; text-decoration: none; text-align: center;
  color: var(--text); background: var(--sheen), var(--surface); border: 1px solid var(--border-hi); border-radius: var(--radius-control);
}
a.tile:active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
footer .note { flex: 1.4; align-self: center; padding-left: 0.8em; color: var(--muted); font-size: 0.8em; }

/* Two columns only when the screen is narrow AND not a short landscape (short landscape keeps one row of four). */
@media (max-width: 1100px) and (max-aspect-ratio: 4/3) {
  main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  html, body { height: auto; min-height: 100%; }
  #dash { height: auto; padding: 16px; gap: 16px; }
  #dash > header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .meta { justify-content: flex-start; }
  main { grid-template-columns: 1fr; gap: 12px; }
  #dash > footer { flex-wrap: wrap; gap: 12px; }
  a.tile { flex: 1 1 40%; }
  footer .note { flex: 1 1 100%; padding-left: 0; }
  #pair { min-height: 100vh; }
}

/* ---------- /approve (phone) ---------- */
body.approve { font-size: 18px; line-height: 1.4; }
.approve .box { max-width: 24em; margin: 0 auto; padding: 9vh 1.4em 2em; display: flex; flex-direction: column; gap: 1.2em; }
.approve form, .approve section { display: flex; flex-direction: column; gap: 1.2em; }
.approve p { margin: 0; color: var(--text-2); }
.approve .who { color: var(--muted); font-size: 0.9em; overflow-wrap: anywhere; }
.approve .who b { color: var(--text); font-weight: 500; }
.approve .brand { font-size: 1em; }
.approve h1 { margin: 0.6em 0 0; font-family: var(--font-display); font-weight: 400; font-size: 2.6em; line-height: 0.95; letter-spacing: var(--track-display); text-transform: uppercase; }
.approve label { display: flex; flex-direction: column; gap: 0.6em; font-family: var(--font-mono); font-weight: 500; font-size: 0.7em; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.approve input {
  width: 100%; min-height: var(--tap); padding: 0.45em 0.6em;
  font: 500 2.2em var(--font-mono); letter-spacing: 0.15em; text-transform: none;
  color: var(--text); background: var(--well); border: 1px solid var(--border-3); border-radius: var(--radius-control); outline: none;
}
.approve input:focus { border-color: var(--text); box-shadow: var(--focus-ring); }
.approve input::placeholder { color: #5a5855; }
.approve .btn { width: 100%; min-height: 64px; font-size: 0.85em; margin-top: 0.4em; text-align: center; }
.approve .btn + .btn { margin-top: 0; }
#msg { min-height: 1.5em; color: var(--text-2); }
#msg.ok { color: var(--text); }
#msg.err { color: var(--danger); }
