/* ============================================================
   DESIGN TOKENS — Single Source of Truth
   Bautagebuch.org Design System v2

   This file replaces tokens.css, app/tokens.css, and
   dashboard-theme.css variable definitions.
   ============================================================ */

:root {
  /* ─── Color System ──────────────────────────────────────── */

  /* Backgrounds (darkest → lightest) */
  --bg-base: #0B1220;
  --bg-surface-1: #141720;
  --bg-surface-2: #1a1e28;
  --bg-surface-3: #222633;
  --bg-elevated: #262b38;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  /* Glass */
  --glass-bg: rgba(20, 23, 32, 0.85);
  --glass-blur: 20px;

  /* Text */
  --text-primary: #f1f3f7;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-disabled: #475569;

  /* Accent — Orange (Primary) */
  --accent: #EA6A0E;
  --accent-soft: rgba(234, 106, 14, 0.12);
  --accent-softer: rgba(234, 106, 14, 0.06);
  --accent-hover: #f57c22;
  --accent-pressed: #d45e0c;
  --accent-text: #ffa654;

  /* Semantic Colors */
  --color-success: #10b981;
  --color-success-soft: rgba(16, 185, 129, 0.12);
  --color-warning: #f59e0b;
  --color-warning-soft: rgba(245, 158, 11, 0.12);
  --color-danger: #ef4444;
  --color-danger-soft: rgba(239, 68, 68, 0.12);
  --color-info: #3b82f6;
  --color-info-soft: rgba(59, 130, 246, 0.12);

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-accent: rgba(234, 106, 14, 0.3);
  --border-hover: rgba(255, 255, 255, 0.2);

  /* ─── Spacing (4px base) ────────────────────────────────── */
  --sp-0: 0;
  --sp-px: 1px;
  --sp-0-5: 2px;
  --sp-1: 4px;
  --sp-1-5: 6px;
  --sp-2: 8px;
  --sp-2-5: 10px;
  --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;

  /* ─── Border Radius ─────────────────────────────────────── */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* ─── Shadows (3 levels only) ───────────────────────────── */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.25);

  /* Focus Ring */
  --focus-ring: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent);

  /* ─── Typography ────────────────────────────────────────── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Size Scale */
  --text-xs: 0.6875rem;    /* 11px */
  --text-sm: 0.8125rem;    /* 13px */
  --text-base: 0.9375rem;  /* 15px */
  --text-lg: 1.0625rem;    /* 17px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */

  /* Line Heights */
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* Font Weights */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ─── Layout ────────────────────────────────────────────── */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 60px;
  --topbar-h: 56px;
  --contextbar-h: 48px;
  --bottom-nav-h: 56px;
  --content-max: 1600px;
  --content-wide: 1800px;
  --content-narrow: 800px;
  --content-padding: var(--sp-6);

  /* ─── Transitions ───────────────────────────────────────── */
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;

  /* ─── Z-Index Scale ─────────────────────────────────────── */
  --z-base: 1;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-contextbar: 30;
  --z-sidebar: 40;
  --z-topbar: 50;
  --z-modal-backdrop: 60;
  --z-modal: 70;
  --z-toast: 80;
  --z-tooltip: 90;

  /* ─── Breakpoints (reference, used in media queries) ───── */
  /* Mobile: 0 - 767px */
  /* Tablet: 768px - 1023px */
  /* Desktop: 1024px+ */
  /* Wide: 1440px+ */
}

/* ─── Backward Compatibility Aliases ──────────────────────── */
/* These map old variable names to new tokens so existing CSS
   continues to work during the migration. Remove once done. */
:root {
  --bg: var(--bg-base);
  --surface-1: var(--bg-surface-1);
  --surface-2: var(--bg-surface-2);
  --surface-3: var(--bg-surface-3);
  --text-strong: var(--text-primary);
  --text-muted: var(--text-secondary);
  --text-faint: var(--text-tertiary);
  --accent-warm: var(--accent);
  --accent-warm-soft: var(--accent-soft);
  --accent-cool: var(--color-info);
  --accent-green: var(--color-success);
  --accent-amber: var(--color-warning);
  --accent-red: var(--color-danger);
  --text-default: var(--text-primary);
  --border-soft: var(--border);
  --hover-overlay: rgba(255, 255, 255, 0.04);
  --shadow-card: var(--shadow-sm);
  --shadow-elevated: var(--shadow-md);

  /* Additional old aliases */
  --accent-warm-hover: var(--accent-hover);
  --accent-warm-dark: var(--accent-pressed);
  --accent-cool-soft: var(--color-info-soft);
  --accent-green-dark: var(--color-success);
  --glass-bg-strong: rgba(20, 23, 32, 0.95);
  --backdrop-overlay: var(--bg-overlay);
  --color-navy: #0F172A;
  --color-navy-light: #1E293B;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
  --content-max-w: var(--content-max);
  --content-narrow-w: var(--content-narrow);
  --media-max-w: var(--content-max);
  --mobile-nav-h: var(--bottom-nav-h);

  /* Old sidebar/topbar aliases */
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 60px;
  --topbar-h: 56px;
  --contextbar-h: 48px;

  /* Icon sizes */
  --icon-xs: 14px;
  --icon-sm: 16px;
  --icon-md: 18px;
  --icon-lg: 20px;
  --icon-xl: 24px;
}

/* ─── Light Mode ─────────────────────────────────────── */
html[data-theme='light'] {
  --bg-base: #F5F7FA;
  --bg-surface-1: #FFFFFF;
  --bg-surface-2: #EEF1F6;
  --bg-surface-3: #E3E8EF;
  --bg-elevated: #FFFFFF;
  --bg-overlay: rgba(0, 0, 0, 0.3);

  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-bg-strong: rgba(255, 255, 255, 0.95);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  --text-disabled: #CBD5E1;

  --accent: #EA6A0E;
  --accent-soft: rgba(234, 106, 14, 0.10);
  --accent-softer: rgba(234, 106, 14, 0.05);
  --accent-hover: #D45E0A;
  --accent-pressed: #C85000;
  --accent-text: #C85000;

  --color-success: #16A34A;
  --color-success-soft: rgba(22, 163, 74, 0.10);
  --color-warning: #D97706;
  --color-warning-soft: rgba(217, 119, 6, 0.10);
  --color-danger: #DC2626;
  --color-danger-soft: rgba(220, 38, 38, 0.10);
  --color-info: #3B7AE8;
  --color-info-soft: rgba(59, 122, 232, 0.10);

  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.18);
  --border-hover: rgba(15, 23, 42, 0.22);

  --hover-overlay: rgba(0, 0, 0, 0.04);
  --backdrop-overlay: rgba(255, 255, 255, 0.85);

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.10), 0 0 0 1px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);

  --focus-ring: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--accent);
}
