/* ===================================================================
   ThasmaiSuite Meditator — Design System v2 "Serene Modern"
   Token-first approach. All visual values via CSS custom properties.
   No hardcoded hex outside this file.
   =================================================================== */

/* ===================================================================
   Color Tokens — Light (default)
   =================================================================== */
:root {
  /* --- Surface / Background --- */
  --surface-primary: #ffffff;
  --surface-secondary: #f8f8f7;
  --surface-tertiary: #f0eeeb;
  --surface-elevated: #ffffff;
  --surface-inset: #f5f3f0;

  /* --- Text --- */
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-tertiary: #a8a29e;
  --text-inverse: #ffffff;
  --text-on-accent: #ffffff;

  /* --- Accent: Warm Indigo --- */
  --accent-primary: #6366f1;
  --accent-hover: #4f46e5;
  --accent-pressed: #4338ca;
  --accent-subtle: #eef2ff;
  --accent-muted: #c7d2fe;

  /* --- Saffron (spiritual actions) --- */
  --saffron-primary: #f59e0b;
  --saffron-hover: #d97706;
  --saffron-subtle: #fffbeb;
  --saffron-muted: #fde68a;

  /* --- Semantic --- */
  --success-primary: #16a34a;
  --success-subtle: #f0fdf4;
  --warning-primary: #ea580c;
  --warning-subtle: #fff7ed;
  --error-primary: #dc2626;
  --error-subtle: #fef2f2;
  --info-primary: #2563eb;
  --info-subtle: #eff6ff;

  /* --- Borders --- */
  --border-default: #e7e5e4;
  --border-subtle: #ececea;
  --border-strong: #d6d3d1;
  --border-accent: var(--accent-primary);

  /* --- Shadows (premium-grade: 2× stronger than v2.0) --- */
  --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.08);
  --shadow-sm: 0 2px 12px rgba(28, 25, 23, 0.06), 0 1px 2px rgba(28, 25, 23, 0.03);
  --shadow-md: 0 4px 20px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.05);
  --shadow-lg: 0 10px 32px rgba(28, 25, 23, 0.12), 0 4px 8px rgba(28, 25, 23, 0.06);
  --shadow-xl: 0 20px 30px rgba(28, 25, 23, 0.16), 0 8px 12px rgba(28, 25, 23, 0.08);
  --shadow-accent: 0 4px 14px rgba(99, 102, 241, 0.3);

  /* --- Hero Gradient (saturated for visibility) --- */
  --hero-gradient: linear-gradient(135deg, #dde6ff 0%, #f0e4ff 50%, #ffe4cc 100%);
  --hero-gradient-dark: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1c1917 100%);
}

/* ===================================================================
   Color Tokens — Dark (body.dark)
   =================================================================== */
body.dark {
  --surface-primary: #1c1917;
  --surface-secondary: #292524;
  --surface-tertiary: #44403c;
  --surface-elevated: #292524;
  --surface-inset: #1c1917;

  --text-primary: #fafaf9;
  --text-secondary: #a8a29e;
  --text-tertiary: #78716c;
  --text-inverse: #1c1917;

  --accent-primary: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-pressed: #6366f1;
  --accent-subtle: #1e1b4b;
  --accent-muted: #312e81;

  --saffron-primary: #fbbf24;
  --saffron-hover: #f59e0b;
  --saffron-subtle: #451a03;
  --saffron-muted: #78350f;

  --success-primary: #4ade80;
  --success-subtle: #052e16;
  --warning-primary: #fb923c;
  --warning-subtle: #431407;
  --error-primary: #f87171;
  --error-subtle: #450a0a;
  --info-primary: #60a5fa;
  --info-subtle: #172554;

  --border-default: #44403c;
  --border-subtle: #292524;
  --border-strong: #57534e;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.20), 0 1px 2px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.30), 0 2px 6px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 10px 32px rgba(0, 0, 0, 0.36), 0 4px 8px rgba(0, 0, 0, 0.20);
  --shadow-xl: 0 20px 30px rgba(0, 0, 0, 0.42), 0 8px 12px rgba(0, 0, 0, 0.22);
  --shadow-accent: 0 4px 14px rgba(129, 140, 248, 0.3);

  --header-bg: linear-gradient(135deg, rgba(28,25,23,0.95) 0%, rgba(30,27,75,0.92) 100%);
  --header-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 2px 10px rgba(0,0,0,0.35);
}

/* ===================================================================
   Typography Tokens
   =================================================================== */
:root {
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;

  /* Size scale (explicit px — Stitch-grade) */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 28px;
  --text-3xl: 34px;
  --text-4xl: 40px;

  /* Weight */
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Line height */
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;
}

/* ===================================================================
   Spacing Grid (4px base unit)
   =================================================================== */
:root {
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
}

/* ===================================================================
   Component Tokens
   =================================================================== */
:root {
  /* Card */
  --card-radius: 20px;
  --card-padding: 20px;
  --card-shadow: var(--shadow-sm);
  --card-border: none;

  /* Button */
  --btn-height: 44px;
  --btn-height-sm: 34px;
  --btn-height-lg: 52px;
  --btn-radius: 12px;
  --btn-padding-x: 24px;

  /* Input */
  --input-height: 48px;
  --input-radius: 12px;
  --input-padding-x: 16px;

  /* Bottom Nav */
  --nav-height: 64px;
  --nav-icon-size: 24px;
  --nav-label-size: 11px;
  --bottom-nav-height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));

  /* Header */
  --header-height: 56px;
  --header-bg: linear-gradient(135deg, rgba(255,255,255,0.94) 0%, rgba(238,242,255,0.90) 100%);
  --header-shadow: 0 1px 0 rgba(0,0,0,0.06), 0 2px 8px rgba(99,102,241,0.06);

  /* Page */
  --page-padding-x: 20px;
  --page-padding-top: 16px;
  --page-max-width: 640px;

  /* Avatar */
  --avatar-sm: 32px;
  --avatar-md: 48px;
  --avatar-lg: 80px;
  --avatar-xl: 120px;

  /* Badge */
  --badge-height: 22px;
  --badge-radius: 6px;
  --badge-font-size: 11px;
}

/* ===================================================================
   Transition & Animation Tokens
   =================================================================== */
:root {
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --duration-slow: 300ms;
  --duration-entrance: 350ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===================================================================
   Keyframe Animations
   =================================================================== */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes confettiBurst {
  0%   { opacity: 1; transform: scale(0) rotate(0deg); }
  50%  { opacity: 1; transform: scale(1.2) rotate(180deg); }
  100% { opacity: 0; transform: scale(0.8) rotate(360deg) translateY(-40px); }
}

@keyframes streakFlame {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1) rotate(3deg); }
}

@keyframes checkmarkDraw {
  0%   { stroke-dashoffset: 24; }
  100% { stroke-dashoffset: 0; }
}

@keyframes gentlePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* Stagger delays for card grids */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }

/* ===================================================================
   Reduced Motion — Respect user preference
   =================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===================================================================
   Legacy compat — map old variable names so existing pages don't break
   during migration (remove after full rewrite)
   =================================================================== */
:root {
  --bg-primary: var(--surface-primary);
  --bg-secondary: var(--surface-secondary);
  --bg-tertiary: var(--surface-tertiary);
  --accent-light: var(--accent-hover);
  --border-color: var(--border-default);
}

body.dark {
  --bg-primary: var(--surface-primary);
  --bg-secondary: var(--surface-secondary);
  --bg-tertiary: var(--surface-tertiary);
  --accent-light: var(--accent-hover);
  --border-color: var(--border-default);
}
