/* Theme tokens — light is the default. ThemeManager toggles
 * `data-theme="light"` or `data-theme="dark"` on <html> to override.
 * When no override is set we fall back to prefers-color-scheme via the
 * @media block below.
 *
 * CANONICAL SOURCE: src/ui/tokens.ts owns the palette values.
 * The hex values below MUST stay in sync with LIGHT_TOKENS/DARK_TOKENS —
 * constants.ts derives Pixi COLORS from the same file via hexToNumber(). */

:root {
  --bg: #fff6ea;
  --surface: #ffffff;
  --surface-muted: #fbefe1;
  --surface-sunken: #f3e7d4;
  --border: #ecdcc3;
  --border-strong: #dcc7a6;

  --text: #3e322b;
  --text-secondary: #7c6a58;
  --text-tertiary: #a68f7b;

  --primary: #ff6b4a;
  --primary-hover: #f0563b;
  --primary-pressed: #d8442b;
  --primary-soft: #ffe3d6;
  --primary-on: #ffffff;
  /* Tinted focus ring. Per-theme alpha so dark mode can brighten it. */
  --primary-focus: rgba(255, 107, 74, 0.28);

  /* Secondary accent (teal) — 1v1 / informational affordances. */
  --secondary: #12a594;
  --secondary-hover: #0d8f7c;
  --secondary-pressed: #0a7668;
  --secondary-soft: #d9f1ed;
  --secondary-on: #ffffff;

  --success: #2e9e5b;
  --success-bg: #e0f3e7;
  --warning: #c07a00;
  --warning-bg: #fdf0d5;
  --error: #e5484d;
  --error-bg: #fde3e0;

  --scrim: rgba(40, 28, 20, 0.55);
  /* Warm-tinted soft shadows (flat illustration). */
  --shadow-1: 0 1px 2px rgba(90, 60, 40, 0.06), 0 2px 8px rgba(90, 60, 40, 0.06);
  --shadow-2: 0 4px 14px rgba(90, 60, 40, 0.1), 0 1px 3px rgba(90, 60, 40, 0.06);

  --gold: #f2a93b;
  --disabled: #e4d5c2;
  --disabled-text: #a68f7b;

  /* Radii — flat cards/buttons use generous rounding. */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Debug console inverts the app theme so it always stands out from the
   * canvas. Light app → dark panel, dark app → light panel. */
  --debug-bg: rgba(30, 22, 16, 0.92);
  --debug-text: #f3e7d4;
  --debug-border: rgba(255, 255, 255, 0.12);
  --debug-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #251f1b;
  --surface: #2f2823;
  --surface-muted: #38312b;
  --surface-sunken: #1d1915;
  --border: #4b4036;
  --border-strong: #6e6152;

  --text: #f6ede1;
  --text-secondary: #cbbaa6;
  --text-tertiary: #9c8b77;

  --primary: #ff9e7e;
  --primary-hover: #ffb89b;
  --primary-pressed: #ff8a66;
  --primary-soft: #4a2b1f;
  --primary-on: #3b1d12;
  --primary-focus: rgba(255, 158, 126, 0.32);

  --secondary: #4fd1c5;
  --secondary-hover: #6fe0d6;
  --secondary-pressed: #3cbfb4;
  --secondary-soft: #17403c;
  --secondary-on: #0b2b27;

  --success: #63ce97;
  --success-bg: #1e3a2c;
  --warning: #f2b04c;
  --warning-bg: #46330f;
  --error: #f4837b;
  --error-bg: #47211e;

  --scrim: rgba(0, 0, 0, 0.6);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px 1px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 2px 6px 2px rgba(0, 0, 0, 0.45), 0 1px 2px 0 rgba(0, 0, 0, 0.3);

  --gold: #f5b73f;
  --disabled: #4b4036;
  --disabled-text: #9c8b77;

  --debug-bg: rgba(246, 237, 225, 0.94);
  --debug-text: #251f1b;
  --debug-border: rgba(0, 0, 0, 0.12);
  --debug-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* Shared animation keyframes for DOM UI (spinner, waiting pulses). */
@keyframes differSpin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes differPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

body {
  margin: 0;
  padding: 0;
  color: var(--text);
  background-color: var(--bg);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* React-driven DOM UI overlay. Absolute over the canvas. By default the
 * container does not swallow clicks — individual modals/buttons opt in
 * via pointer-events: auto. */
#react-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
