/* Phit stylesheet, part 1 of 8. Tokens (colours, type scale, radii), the light and dark themes, the logo, and the base look of text, buttons, fields and panels.
   The parts are one stylesheet cut into files: they must load in this order (index.html and the plain pages list them), because a later rule can override an earlier one. */

:root {
  /* type scale (body and interface text; headings and the text inside charts and pictures keep their own sizes) and corner radii */
  --fs-xs: 0.72rem;
  --fs-sm: 0.8rem;
  --fs-md: 0.85rem;
  --fs-base: 0.9rem;
  --fs-lg: 0.95rem;
  --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px; --r-2xl: 14px; --r-pill: 999px;
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2e38;
  --text: #e8eaed;
  --muted: #8b93a1;
  --accent: #4da3ff;
  --accent-ink: #4da3ff;       /* accent-coloured text on a tint of the accent (the selected nav item, the Sample chip) */
  --good: #3ecf8e;
  --good-ink: #3ecf8e;
  --bad: #ff6b6b;
  /* categorical slots 1 and 2, validated on this dark surface */
  --series-1: #3987e5; /* earlier run */
  --series-2: #d95926; /* later run */
  --series-3: #199e70; /* runs 3-5 (Paid): validated as a set on this surface */
  --series-4: #c98500;
  --series-5: #d55181;
  --ink-rgb: 255 255 255;      /* the "ink" colour at low opacity: hovers, selections */
  --accent-rgb: 77 163 255;
  --warn: #eda100;             /* amber: decoupling, reference lines, Paid badges */
  --warn-ink: #eda100;
  --warn-rgb: 237 161 0;
  --on-accent: #06121f;        /* text on an accent-coloured button */
}

/* Light theme: every colour that matters is a token, so this block is the whole difference.
   Text/graphics contrast on the panel surface is at least 4.5:1 for each colour below. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f8;
  --panel: #ffffff;
  --border: #d5d9e2;
  --text: #1b1f27;
  --muted: #5a6372;
  --accent: #0b62c4;
  --accent-ink: #0a56ab;       /* a step darker than the accent: 5.4 to 1 on its own tint, where the accent itself is 4.4 */
  --good: #12804f;
  --good-ink: #0e6f43;      /* green text on a tint: 5.4 to 1 on a selected card, where --good itself is 4.3 */
  --bad: #c42b2b;
  --series-1: #1f6fd1;
  --series-2: #c4480c;
  --series-3: #0e7f58;
  --series-4: #9a6700;
  --series-5: #b8285f;
  --ink-rgb: 15 23 42;
  --accent-rgb: 11 98 196;
  --warn: #8f5b00;
  --warn-ink: #7a4f00;      /* amber text on a tinted chip: 6 to 1 on a selected card */
  --warn-rgb: 143 91 0;
  --on-accent: #ffffff;
}

* { box-sizing: border-box; }

/* An element marked [hidden] stays hidden whatever display value its class sets (e.g. the wide-screen grid layout). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;     /* the system's own UI font: nothing is fetched from anywhere */
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: calc(0.75rem + env(safe-area-inset-top)) 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

h1 { font-size: 1.25rem; margin: 0; }
/* the logo: "phit" with the top half of the p's circle and the h's hump in the five heart-rate zone colours, fading into the text colour (index.html holds the outlines;
   backend/tools/build_logo.py writes them). It follows the theme through the same variables as everything else. */
.phit-defs { position: absolute; }
.phit-ink { fill: var(--text); }
.phit-s-z5 { stop-color: var(--z5); } .phit-s-z4 { stop-color: var(--z4); } .phit-s-z3 { stop-color: var(--z3); } .phit-s-z2 { stop-color: var(--z2); } .phit-s-z1 { stop-color: var(--z1); }
.phit-s-ink { stop-color: var(--text); }
.brand { line-height: 0; }
.phit-logo { display: block; height: 1.7rem; aspect-ratio: 1793 / 1005; width: auto; }
h2, :where(.content) h1 { font-size: 1.05rem; margin: 0 0 0.75rem; }      /* a view's title (its one h1) is drawn like any other panel heading unless a rule below says more */

.header-right { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }

.status { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.connected { color: var(--good); }

.panel {
  max-width: 760px;
  margin: 1rem auto;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: 0 1px 2px rgb(var(--ink-rgb) / 0.04), 0 10px 28px -12px rgb(var(--ink-rgb) / 0.10);
}

@media (max-width: 800px) {
  .panel { margin: 0.75rem; }
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.panel-header :is(h1, h2) { margin: 0; }

.hint { color: var(--muted); font-size: var(--fs-md); }
.error { color: var(--bad); font-size: var(--fs-base); }

form { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }

input[type=email], input[type=password], input[type=text] {
  flex: 1;
  min-width: 180px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* prevents iOS zoom-on-focus */
}

button, input, select, textarea { font-family: inherit; }     /* controls use the page's font, not the browser's own (which is Arial on Windows) */
button {
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border-radius: var(--r-md);
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.link { background: none; color: var(--accent); min-height: 0; padding: 0; font-weight: 500; font-size: var(--fs-md); }

