/* ==========================================================================
   AXIOMA Design System & Multi-Theme Tokens (FOX · DIVINE · FELINE)
   Compact RPG-Materiality · Glassmorphism with Fallback · Safe Areas
   ========================================================================== */

:root {
  /* Strict Compactness Scale (Spec §4) */
  --sp-1: 2px;
  --sp-2: 4px;
  --sp-3: 6px;
  --sp-4: 8px;
  --sp-5: 12px;
  --sp-6: 16px;

  /* Geometry: crisp angular & chamfered RPG silhouettes */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --cut-sm: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);

  /* Typography */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* Motion */
  --dur-fast: 110ms;
  --dur-med: 180ms;
  --ease-snappy: cubic-bezier(0.2, 0.9, 0.2, 1);

  /* Safe Areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 56px;
}

/* ---------------- THEME 1: FOX (Default) ----------------
   Warm Orange, Amber, Copper · Dark Obsidian RPG Surfaces */
:root,
[data-theme="fox"] {
  --bg-canvas: #120f0d;
  --bg-canvas-grad: radial-gradient(circle at 15% 0%, rgba(245, 130, 32, 0.14), transparent 52%),
                    radial-gradient(circle at 90% 100%, rgba(186, 82, 24, 0.12), transparent 50%),
                    #120f0d;
  --surface-1: rgba(28, 22, 19, 0.86);
  --surface-2: rgba(39, 31, 26, 0.92);
  --surface-solid: #1e1815;
  --glass-bg: rgba(32, 25, 21, 0.72);
  --glass-edge: rgba(255, 180, 96, 0.24);
  --glass-sheen: linear-gradient(135deg, rgba(255, 196, 128, 0.11) 0%, transparent 45%);
  --border-subtle: rgba(245, 130, 32, 0.22);
  --border-strong: rgba(255, 166, 77, 0.55);

  --text-primary: #f7efe6;
  --text-secondary: #cbb8a6;
  --text-muted: #9b8876;

  --accent: #f58220;
  --accent-bright: #ffb347;
  --accent-dim: rgba(245, 130, 32, 0.16);
  --accent-contrast: #160e08;

  --xp-color: #ffb347;
  --coin-color: #f4c430;
  --success: #52c47b;
  --warning: #f0a830;
  --danger: #e8584a;
  --focus-ring: 0 0 0 2px #ffb347;
  --shadow-elev: 0 6px 18px rgba(0, 0, 0, 0.45);
  --particle-1: #ffb347;
  --particle-2: #f58220;
}

/* ---------------- THEME 2: DIVINE ----------------
   White, Ivory, Gold · Monumental Crisp Geometry (Non-denominational) */
[data-theme="divine"] {
  --bg-canvas: #f4f0e6;
  --bg-canvas-grad: linear-gradient(160deg, rgba(212, 168, 67, 0.13) 0%, transparent 40%),
                    radial-gradient(circle at 85% 10%, rgba(255, 248, 224, 0.8), transparent 45%),
                    #f4f0e6;
  --surface-1: rgba(255, 253, 247, 0.88);
  --surface-2: rgba(248, 243, 232, 0.95);
  --surface-solid: #fffdf8;
  --glass-bg: rgba(255, 253, 248, 0.78);
  --glass-edge: rgba(184, 137, 40, 0.34);
  --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.7) 0%, rgba(212, 168, 67, 0.06) 50%, transparent 100%);
  --border-subtle: rgba(164, 124, 42, 0.26);
  --border-strong: rgba(164, 124, 42, 0.65);

  --text-primary: #1c1811;
  --text-secondary: #4e4535;
  --text-muted: #766a54;

  --accent: #a6781e;
  --accent-bright: #c9972e;
  --accent-dim: rgba(166, 120, 30, 0.13);
  --accent-contrast: #fffdf8;

  --xp-color: #b5841d;
  --coin-color: #9c6e14;
  --success: #227a46;
  --warning: #b36b00;
  --danger: #b83227;
  --focus-ring: 0 0 0 2px #a6781e;
  --shadow-elev: 0 6px 20px rgba(84, 62, 18, 0.12);
  --particle-1: #d4a843;
  --particle-2: #f7e4a1;
}

/* ---------------- THEME 3: FELINE ----------------
   Deep Violet, Midnight Blue, Silver · Sleek Contours */
[data-theme="feline"] {
  --bg-canvas: #0c0c16;
  --bg-canvas-grad: radial-gradient(circle at 20% 5%, rgba(154, 124, 255, 0.16), transparent 48%),
                    radial-gradient(circle at 80% 95%, rgba(92, 138, 224, 0.14), transparent 50%),
                    #0c0c16;
  --surface-1: rgba(20, 20, 36, 0.88);
  --surface-2: rgba(29, 28, 50, 0.94);
  --surface-solid: #151526;
  --glass-bg: rgba(22, 22, 40, 0.74);
  --glass-edge: rgba(208, 214, 240, 0.24);
  --glass-sheen: linear-gradient(135deg, rgba(214, 202, 255, 0.12) 0%, transparent 48%);
  --border-subtle: rgba(168, 146, 255, 0.24);
  --border-strong: rgba(208, 214, 240, 0.56);

  --text-primary: #eef0fa;
  --text-secondary: #bcc0da;
  --text-muted: #8a8fae;

  --accent: #9b82ff;
  --accent-bright: #c2b2ff;
  --accent-dim: rgba(155, 130, 255, 0.18);
  --accent-contrast: #0e0c1a;

  --xp-color: #b49cff;
  --coin-color: #d7deee;
  --success: #4dd4a0;
  --warning: #eab64d;
  --danger: #f0657d;
  --focus-ring: 0 0 0 2px #c2b2ff;
  --shadow-elev: 0 6px 20px rgba(4, 4, 14, 0.55);
  --particle-1: #c2b2ff;
  --particle-2: #d7deee;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-canvas-grad);
  background-color: var(--bg-canvas);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Glass Material System with Performance Fallback */
.glass-panel {
  background: var(--glass-bg);
  background-image: var(--glass-sheen);
  border: 1px solid var(--border-subtle);
  box-shadow: inset 0 1px 0 var(--glass-edge), var(--shadow-elev);
  border-radius: var(--radius-sm);
}

@supports (backdrop-filter: blur(10px)) {
  .glass-panel {
    backdrop-filter: blur(10px) saturate(1.15);
    -webkit-backdrop-filter: blur(10px) saturate(1.15);
  }
}

/* Explicit no-blur performance fallback mode */
[data-blur="off"] .glass-panel {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: var(--surface-solid);
}

/* Accessibility & Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-med: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Desktop: slightly calmer motion */
@media (min-width: 960px) {
  :root {
    --dur-fast: 90ms;
    --dur-med: 140ms;
  }
}

/* Focus visibility */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
