/* Design tokens, ported verbatim from mobile/src/theme/theme.ts.
 *
 * Light is the source palette and dark is derived from it. Both are warm --
 * paper and charcoal rather than white and blue-black -- because this is a
 * reference tool read for minutes at a time, not a terminal.
 *
 * The typeface is Inter, which the mobile app bundles. It is NOT available
 * here: this app works fully offline, so there is no webfont to fetch and no
 * CDN to fetch it from. The stack below falls through to whatever the system
 * has, which on every target platform is a humanist sans close enough that
 * the metrics in `--font-*` still hold.
 *
 * React Native cannot map fontWeight onto a custom family on Android, so the
 * mobile tokens name four weight-families. On the web that problem does not
 * exist, so those become numeric weights against one stack.
 *
 * Nothing on screen is smaller than --font-tiny, and tiny is 13px.
 *
 * Three theme states, and all three must be handled: an explicit choice
 * stamps data-theme on <html>, and the default "system" setting stamps
 * nothing, leaving prefers-color-scheme to decide. So the dark palette is
 * declared twice -- once under the media query guarded against an explicit
 * light choice, once under the explicit dark attribute -- and every colour
 * has its base definition on bare :root.
 */

:root {
  color-scheme: light;

  /* --- light palette (the source) --- */
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-alt: #F1EEE9;
  --border: #E6E1DA;
  --border-strong: #CFC8BF;
  --text: #1C1B19;
  --text-dim: #5F5B55;
  --text-faint: #8A857D;
  --accent: #0F766E;
  --accent-bg: rgba(15, 118, 110, 0.10);
  --accent-border: rgba(15, 118, 110, 0.32);
  --accent-solid: #0F766E;
  --accent-text: #FFFFFF;
  --user-bubble: #0F766E;
  --user-text: #FFFFFF;
  --danger: #B42318;
  --danger-bg: rgba(180, 35, 24, 0.10);
  --warn: #B54708;
  --warn-bg: rgba(181, 71, 8, 0.12);
  --success: #027A48;
  --code-bg: #F1EEE9;
  --overlay: rgba(28, 27, 25, 0.45);

  /* --- space --- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-xxl: 32px;

  /* --- radius --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* --- font sizes --- */
  --font-display: 34px;
  --font-h1: 28px;
  --font-h2: 22px;
  --font-h3: 18px;
  --font-body: 16px;
  --font-small: 14px;
  --font-tiny: 13px;
  --line-height: 24px;

  /* --- families --- */
  --family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --family-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Minimum tap target, both axes. Carried over from HIT_TARGET: a pointer
     is more precise than a thumb, but this app is used at phone width on a
     touchscreen as often as not. */
  --hit-target: 44px;

  --shadow-pill: 0 2px 6px rgba(0, 0, 0, 0.12);
  --shadow-sheet: 0 14px 40px rgba(0, 0, 0, 0.18);
}

/* System setting: no data-theme is stamped, so this is the only signal.
   Guarded so an explicit light choice still wins on a dark-set OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151412;
    --surface: #1E1C19;
    --surface-alt: #282521;
    --border: #332F2A;
    --border-strong: #45403A;
    --text: #F2EFEA;
    --text-dim: #A8A198;
    --text-faint: #7C766E;
    --accent: #3FBFB2;
    --accent-bg: rgba(63, 191, 178, 0.14);
    --accent-border: rgba(63, 191, 178, 0.40);
    --accent-solid: #14867C;
    --accent-text: #FFFFFF;
    --user-bubble: #14867C;
    --user-text: #F0FDFA;
    --danger: #F97066;
    --danger-bg: rgba(249, 112, 102, 0.14);
    --warn: #F5A524;
    --warn-bg: rgba(245, 165, 36, 0.16);
    --success: #4ADE80;
    --code-bg: #282521;
    --overlay: rgba(0, 0, 0, 0.55);
    --shadow-pill: 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-sheet: 0 14px 40px rgba(0, 0, 0, 0.5);
  }
}

/* Explicit dark, so the toggle wins in both directions. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151412;
  --surface: #1E1C19;
  --surface-alt: #282521;
  --border: #332F2A;
  --border-strong: #45403A;
  --text: #F2EFEA;
  --text-dim: #A8A198;
  --text-faint: #7C766E;
  --accent: #3FBFB2;
  --accent-bg: rgba(63, 191, 178, 0.14);
  --accent-border: rgba(63, 191, 178, 0.40);
  --accent-solid: #14867C;
  --accent-text: #FFFFFF;
  --user-bubble: #14867C;
  --user-text: #F0FDFA;
  --danger: #F97066;
  --danger-bg: rgba(249, 112, 102, 0.14);
  --warn: #F5A524;
  --warn-bg: rgba(245, 165, 36, 0.16);
  --success: #4ADE80;
  --code-bg: #282521;
  --overlay: rgba(0, 0, 0, 0.55);
  --shadow-pill: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-sheet: 0 14px 40px rgba(0, 0, 0, 0.5);
}
