/*
 * Waves of Africa — design tokens.
 *
 * Implements the zer0paper Design Constitution (_design/00-constitution.md)
 * with the Waves accent from _design/prompts/waves-of-africa.md.
 *
 * Token names follow §3 verbatim (`ink`, `ink-secondary`, `paper`, `surface`,
 * `hairline`) because §10.4 asks every product to speak the same names.
 *
 * ─── the one accent, split three ways ──────────────────────────────────────
 * The prompt gives Waves `#0891B2` / pressed `#0E7490`. Used naively that
 * breaks the §8 accessibility floor, which is non-negotiable:
 *
 *     white on #0891B2  = 3.68:1   ← FAILS the 4.5:1 text minimum
 *     white on #0E7490  = 5.36:1   ← passes
 *
 * So the hue is kept and its *roles* are separated. `--accent` stays the
 * identity colour and is only used where WCAG asks 3:1 (focus ring, selected
 * border, the bloom). Anything carrying text at body size uses `--accent-text`
 * / `--accent-fill`. Same hue family, no compromise on either doc.
 *
 * Measured (see git history for the checker):
 *   light  ink/paper 18.23  ink-secondary/paper 6.18  accent/paper 3.56
 *          white on accent-fill 5.36   accent-text on paper 5.17
 *   dark   ink/paper 17.97  ink-secondary/paper 7.94  accent/surface 4.82
 *          paper-ink on accent-fill 5.28
 */

:root {
  /* ── structural palette · shared across all 8 zer0paper products ───────── */
  --ink: #101114;
  --ink-secondary: #5a5f6a;
  --paper: #fbfbfa;              /* warm off-white, not clinical white */
  --surface: #ffffff;            /* bento cells */
  --hairline: #ececea;

  /* ── accent · Waves' one hue (ocean cyan) ──────────────────────────────── */
  --accent: #0891b2;             /* identity: focus ring, selected, bloom  (3:1 UI) */
  --accent-text: #0e7490;        /* accent carrying text at body size      (4.5:1)  */
  --accent-fill: #0e7490;        /* filled primary button background                */
  --accent-fill-ink: #ffffff;    /* its label                              (5.36:1) */
  --accent-pressed: #0c6480;     /* pressed state of the filled button     (6.67:1) */
  --accent-wash: rgba(8, 145, 178, 0.10);

  /* ── semantic · status, not brand. Fixed everywhere. ───────────────────── */
  --success: #1f9d57;
  --warning: #e8a317;
  --danger: #e5484d;

  /* ── spacing · base unit 8; 4 only for icon nudges and hairline gaps ───── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --gutter: 16px;                /* 24 on wide viewports, see @media below */

  /* ── shape · soft, Japanese — never bubbly, never sharp ────────────────── */
  --radius-cell: 20px;
  --radius-control: 12px;
  --radius-pill: 999px;
  --radius-sheet: 24px;

  /* ── elevation · exactly two levels, never three ───────────────────────── */
  --elevation-flat: none;
  --elevation-raised: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.08);

  /* ── type · Inter; the face is swappable, the ramp is not ──────────────── */
  --font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --type-display: 700 34px/40px var(--font);
  --type-title: 600 28px/34px var(--font);
  --type-h1: 600 22px/28px var(--font);
  --type-h2: 600 18px/24px var(--font);
  --type-body: 400 16px/24px var(--font);
  --type-callout: 500 15px/20px var(--font);
  --type-footnote: 400 13px/18px var(--font);
  --type-caption: 500 11px/14px var(--font);

  /* ── motion · quick and quiet; never bouncy in ordinary use ────────────── */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration: 200ms;
  --duration-fast: 150ms;
}

/* Dark is first-class, not an afterthought. Elevation comes from surface
   lightness + hairline rather than heavier shadow (§3). */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f5f6f7;
    --ink-secondary: #a0a6b0;
    --paper: #0c0d0f;
    --surface: #17181b;
    --hairline: #26282d;

    /* On dark the identity hue already clears 4.5:1, so it carries text
       directly and the fill flips to a near-black label. */
    --accent-text: #0891b2;
    --accent-fill: #0891b2;
    --accent-fill-ink: #0c0d0f;
    --accent-pressed: #22b8cf;
    --accent-wash: rgba(8, 145, 178, 0.16);

    --elevation-raised: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

@media (min-width: 900px) {
  :root { --gutter: 24px; }
}

/* ── reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--type-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── bento ─────────────────────────────────────────────────────────────── */
.cell {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-cell);
  padding: var(--space-4);
  box-shadow: var(--elevation-flat);
}

/* One hero per screen — the thing the user came for.
   Keeps its hairline: paper (#FBFBFA) and surface (#FFFFFF) are deliberately
   close, so a shadow alone leaves the hero's edge indistinct. Hierarchy comes
   from elevation plus a slightly wider gutter, not from removing the border. */
.cell--hero {
  box-shadow: var(--elevation-raised);
  padding: var(--space-6);
}

.cell__label {
  font: var(--type-caption);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  margin: 0 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── type helpers ──────────────────────────────────────────────────────── */
.t-title   { font: var(--type-title); letter-spacing: -0.02em; margin: 0; }
.t-h1      { font: var(--type-h1); letter-spacing: -0.01em; margin: 0; }
.t-h2      { font: var(--type-h2); margin: 0; }
.t-callout { font: var(--type-callout); margin: 0; }
.t-foot    { font: var(--type-footnote); color: var(--ink-secondary); margin: 0; }
.t-quiet   { color: var(--ink-secondary); }

/* ── controls ──────────────────────────────────────────────────────────── */
label {
  display: block;
  font: var(--type-footnote);
  color: var(--ink-secondary);
  margin: 0 0 var(--space-1);
}

input, select {
  width: 100%;
  min-height: 44px;                       /* §8 touch floor */
  padding: 0 var(--space-3);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-control);
  font: var(--type-body);
  transition: border-color var(--duration-fast) var(--ease);
}
input::placeholder { color: var(--ink-secondary); opacity: 0.7; }
input:hover, select:hover { border-color: var(--ink-secondary); }

/* One focus treatment everywhere, and it is the accent. */
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

button {
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-control);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font: var(--type-callout);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease);
}
button:hover:not(:disabled) { border-color: var(--ink-secondary); }
button:active:not(:disabled) { transform: translateY(1px); }
/* A disabled control should read as "not yet", not as a faded version of the
   accent — a washed-out primary looks like a rendering fault. Strip it back to
   neutral so only genuinely available actions carry colour. */
button:disabled {
  cursor: not-allowed;
  background: var(--paper);
  color: var(--ink-secondary);
  border-color: var(--hairline);
  box-shadow: none;
  opacity: 1;
}
button.primary:disabled,
button.danger:disabled {
  background: var(--paper);
  color: var(--ink-secondary);
  border-color: var(--hairline);
}

/* Exactly one primary action per screen (§2.5). */
button.primary {
  background: var(--accent-fill);
  color: var(--accent-fill-ink);
  border-color: transparent;
  font-weight: 600;
  box-shadow: var(--elevation-raised);
}
button.primary:hover:not(:disabled) { background: var(--accent-pressed); border-color: transparent; }

button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

/* ── status · never colour alone (§8): every pill carries a glyph + text ─── */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--hairline);
  background: var(--surface);
  font: var(--type-caption);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  white-space: nowrap;
}
.status__dot { width: 8px; height: 8px; border-radius: var(--radius-pill); background: currentColor; flex: none; }
.status--ok   { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.status--live { color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.status--on   { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* A live broadcast is the one thing allowed to pulse — it is genuinely
   urgent state, not decoration. */
.status--live .status__dot { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── layout ────────────────────────────────────────────────────────────── */
.stack > * + * { margin-top: var(--space-3); }
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 180px; min-width: 0; }
.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ── the moment of truth ───────────────────────────────────────────────── */
/* Waves declares one sacred moment: the call connects (§6 + prompt).
   Hero scales 0.92 → 1 on an overshoot, the accent washes in, and the Thump
   fires at the visual peak. Nothing else on either page is allowed to bloom. */
@keyframes bloom {
  0%   { transform: scale(0.92); box-shadow: 0 0 0 0 var(--accent-wash); }
  60%  { transform: scale(1.01); box-shadow: 0 0 0 18px var(--accent-wash); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}
.bloom { animation: bloom 600ms var(--ease); }

/* §4 + §8: honour reduce-motion — but the haptic still fires, because a user
   who disabled animation still deserves the confirmation in their hand. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bloom { animation: fade-in 200ms var(--ease); }
  @keyframes fade-in { from { opacity: 0.6; } to { opacity: 1; } }
}

/* Screen-reader-only, for status changes that must be announced. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
