/* ===================================================================
   Temperance · Hackathon Stopwatch
   Every value below traces to Temperance_Content/DESIGN.md (web template v1.21.0):
   colors (OKLCH 12-step), typography roles, soft radii (pill buttons / xl cards),
   spacious density, flat/surface-tone elevation, expressive-but-restrained motion.
   Mode: light (DESIGN mode.primary). Background = neutral.1 (lightest neutral).
   =================================================================== */

:root {
  /* ── Neutral scale (hue 85, near-gray) ── */
  --neutral-1:  oklch(0.99 0.003 85);   /* app background — lightest neutral */
  --neutral-2:  oklch(0.97 0.004 85);
  --neutral-3:  oklch(0.95 0.004 85);   /* raised surface (cards) */
  --neutral-4:  oklch(0.92 0.004 85);   /* hovered surface */
  --neutral-5:  oklch(0.88 0.004 85);
  --neutral-6:  oklch(0.83 0.004 85);   /* subtle border */
  --neutral-7:  oklch(0.75 0.004 85);   /* interactive border */
  --neutral-8:  oklch(0.66 0.003 85);   /* strong border / disabled text */
  --neutral-9:  oklch(0.55 0.003 85);
  --neutral-11: oklch(0.38 0.002 85);   /* secondary text */
  --neutral-12: oklch(0.22 0.002 85);   /* primary text */

  /* ── Primary (brand green, hue 162) ── */
  --primary-3:  oklch(0.95 0.022 162);
  --primary-8:  oklch(0.66 0.108 162);  /* focus ring */
  --primary-9:  oklch(0.49 0.108 162);  /* solid CTA */
  --primary-10: oklch(0.43 0.094 162);  /* hovered solid */
  --primary-11: oklch(0.38 0.066 162);  /* low-contrast brand text */

  /* ── Accents ── */
  --amber-9:   oklch(0.72 0.130 75);    /* paused */
  --danger-3:  oklch(0.95 0.028 25);
  --danger-11: oklch(0.45 0.150 25);    /* error text */
  --twitch-9:  oklch(0.52 0.210 295);   /* Twitch purple */
  --twitch-10: oklch(0.46 0.200 295);

  /* ── Role tokens ── */
  --surface-canvas: var(--neutral-1);
  --surface-raised: var(--neutral-3);
  --border-subtle:  var(--neutral-6);
  --border-default: var(--neutral-7);
  --border-strong:  var(--neutral-8);
  --text-primary:   var(--neutral-12);
  --text-secondary: var(--neutral-11);
  --text-disabled:  var(--neutral-8);
  --text-inverse:   var(--neutral-1);

  /* ── Radius (soft profile) ── */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;    /* cards (soft) */
  --r-full: 9999px;

  /* ── Spacing (4px base) ── */
  --s-1: 4px;  --s-1_5: 6px; --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px;  --s-8: 32px; --s-10: 40px; --s-12: 48px;
  --s-16: 64px; --s-20: 80px;

  /* ── Motion ── */
  --dur-instant: 100ms;
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --dur-slow: 300ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0, 1);

  /* ── Type families ── */
  --font-display: "Fraunces", ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  color-scheme: light;
}

/* ── Reset / base ── */
*, *::before, *::after { box-sizing: border-box; }
/* `hidden` must win over class-level `display` rules (flex/block) below */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--surface-canvas);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  font-feature-settings: "kern" 1, "liga" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fraunces on every display role — Soft cut (SOFT 50), opsz set per role */
.title, .stopwatch__time, .admin-title, .admin-readout__time {
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 50;
  font-weight: 600;
}

/* ── Page layout ──────────────────────────────────────────────────
   The clock is the page: one centered column, nothing competing with the numerals.
   Sized to stay legible when the site is a source in a stream overlay. */
.page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(20px, 3.5vh, 44px) clamp(20px, 5vw, 56px);
}

.page--solo {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(28px, 5vh, 52px);
  text-align: left;
}

.page--admin {
  max-width: 520px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s-5);
}

/* ── Masthead ── */
.masthead { text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-4); }
.lockup {
  height: clamp(30px, 1.5rem + 2.2vw, 42px);
  width: auto;
  display: block;
  margin-bottom: var(--s-1);
}
.title {
  /* display-xl role: clamp(2.25rem, 1.5rem + 3.2vw, 3.125rem), tuned tracking */
  margin: 0;
  font-size: clamp(2.25rem, 1.5rem + 3.2vw, 3.125rem);
  line-height: 1.08;
  letter-spacing: -0.014em;
  font-variation-settings: "SOFT" 50, "opsz" 50;
  text-wrap: balance;
}
.subtitle {
  margin: 0;
  font-size: 1.125rem;           /* body-lg */
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 34ch;
}

/* ── Overline (label) ── */
.overline {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ── Stopwatch (public — read-only) ── */
.stopwatch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-5);
  text-align: left;
}
.stopwatch__head { display: flex; align-items: center; gap: var(--s-4); }
.stopwatch__time {
  /* display-mega — the largest text style defined: clamp(3.5rem, 1.5rem + 6vw, 5.5rem) */
  font-size: clamp(3.5rem, 1.5rem + 6vw, 5.5rem);
  line-height: 1.02;
  letter-spacing: -0.022em;
  font-variation-settings: "SOFT" 50, "opsz" 88;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  color: var(--text-primary);
  transition: color var(--dur-base) var(--ease-standard);
}
.stopwatch.is-running .stopwatch__time { color: var(--primary-11); }
.stopwatch.is-paused  .stopwatch__time { color: var(--text-secondary); }
.stopwatch__note { margin: 0; font-size: 0.9375rem; color: var(--danger-11); }

/* ── Status pill ── */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1_5) var(--s-3);
  border-radius: var(--r-full);
  background: var(--neutral-3);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
}
.status__dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: var(--neutral-8);
  flex: 0 0 auto;
}
.status[data-state="running"] { background: var(--primary-3); color: var(--primary-11); }
.status[data-state="running"] .status__dot { background: var(--primary-9); animation: pulse 2s var(--ease-standard) infinite; }
.status[data-state="paused"] .status__dot { background: var(--amber-9); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.82); }
}

/* ── Buttons (pill, per DESIGN button component) ── */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text-primary);
  --btn-bd: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-body);
  font-weight: 500;
  border-radius: var(--r-full);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-instant) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible {
  outline: 2px solid var(--primary-8);
  outline-offset: 2px;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}
.btn--lg { height: 48px; padding: 0 20px; font-size: 1rem; gap: var(--s-3); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 0.875rem; }
.btn--block { width: 100%; }

.btn--primary { --btn-bg: var(--primary-9); --btn-fg: #fff; --btn-bd: transparent; }
.btn--primary:hover:not(:disabled) { --btn-bg: var(--primary-10); }
.btn--primary:active:not(:disabled) { --btn-bg: var(--primary-11); }

.btn--outline { --btn-bg: transparent; --btn-fg: var(--text-primary); --btn-bd: var(--border-default); }
.btn--outline:hover:not(:disabled) { --btn-bg: var(--neutral-3); }
.btn--outline:active:not(:disabled) { --btn-bg: var(--neutral-4); }

.btn--ghost { --btn-bg: transparent; --btn-fg: var(--text-secondary); --btn-bd: transparent; }
.btn--ghost:hover:not(:disabled) { --btn-bg: var(--neutral-3); --btn-fg: var(--text-primary); }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; display: block; }
[data-action="start"] .icon { fill: currentColor; stroke: none; }

/* ── Card (flat, surface-tone separation — raised fill vs canvas, no border/shadow) ── */
.card {
  background: var(--surface-raised);
  border-radius: var(--r-xl);
  padding: clamp(20px, 4vw, 32px);
}

/* ── Footer / Twitch ── */
.footer { display: flex; }
.twitch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-full);
  background: var(--twitch-9);
  color: #fff;
  font-weight: 500;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-standard),
              transform var(--dur-instant) var(--ease-standard);
}
.twitch:hover { background: var(--twitch-10); }
.twitch:active { transform: scale(0.97); }
.twitch:focus-visible { outline: 2px solid var(--twitch-9); outline-offset: 3px; }
.twitch__glyph { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* ── Admin ────────────────────────────────────────────────────── */
.admin-card { display: flex; flex-direction: column; gap: var(--s-6); }
.admin-title {
  margin: 0;
  font-size: 1.75rem;            /* heading-md */
  line-height: 1.2;
  letter-spacing: -0.008em;
  font-variation-settings: "SOFT" 50, "opsz" 28;
}
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); }
.admin-head .overline { margin-bottom: var(--s-2); }

.admin-form { display: flex; flex-direction: column; gap: var(--s-4); }
.field { display: flex; flex-direction: column; gap: var(--s-2); }

.input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 18px;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--surface-canvas);
  border: 1px solid var(--border-default);
  border-radius: var(--r-full);
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.input::placeholder { color: var(--text-secondary); }
.input:hover { border-color: var(--border-strong); }
.input:focus {
  outline: none;
  border-color: var(--primary-8);
  box-shadow: 0 0 0 2px oklch(from var(--primary-8) l c h / 0.40);
}

.alert {
  margin: 0;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  background: var(--danger-3);
  color: var(--danger-11);
  font-size: 0.9375rem;
}

.admin-readout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-5);
  border-radius: var(--r-lg);
  background: var(--surface-canvas);
}
.admin-readout__time {
  font-size: 2.75rem;            /* display-md */
  line-height: 1.05;
  letter-spacing: -0.018em;
  font-variation-settings: "SOFT" 50, "opsz" 44;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.admin-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.admin-hint { margin: 0; font-size: 0.875rem; color: var(--text-secondary); }

.admin-back { margin: 0; text-align: center; font-size: 0.875rem; }
.admin-back a { color: var(--text-secondary); text-decoration: none; }
.admin-back a:hover { color: var(--text-primary); text-decoration: underline; }
.admin-back a:focus-visible { outline: 2px solid var(--primary-8); outline-offset: 2px; border-radius: var(--r-sm); }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
