/* ===================================================================
   StellarMe Design Tokens
   Zentrale Definition aller Design-Werte für Konsistenz
   =================================================================== */

:root {
  /* ============================================================
     SPACING SYSTEM (4px Grid)
     ============================================================ */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* ============================================================
     LAYOUT CONSTRAINTS (iPhone SE baseline: 375px)
     ============================================================ */
  --app-max-width: 520px;       /* Unified card/page max — all pages same width */
  --app-container-max: 520px;   /* Shell container max — matches --app-max-width */
  --page-max-width: 520px;      /* Page container max width — matches --app-max-width */

  /* Semantic Spacing
     NOTE: These fixed values are OVERRIDDEN by responsive-shell.css
     with fluid clamp() values. The numeric grid (--space-1 through
     --space-20) above remains the reference. These aliases exist
     for fallback only — responsive-shell.css is authoritative. */
  --space-xs: var(--space-1);   /* 4px → overridden by clamp() */
  --space-sm: var(--space-2);   /* 8px → overridden by clamp() */
  --space-md: var(--space-4);   /* 16px → overridden by clamp() */
  --space-lg: var(--space-6);   /* 24px → overridden by clamp() */
  --space-xl: var(--space-8);   /* 32px → overridden by clamp() */
  --space-2xl: var(--space-12); /* 48px → overridden by clamp() */
  --space-3xl: var(--space-16); /* 64px → overridden by clamp() */

  /* ============================================================
     TYPOGRAPHY SCALE (Major Third: 1.25)
     ============================================================ */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-md: 1.125rem;   /* 18px */
  --font-size-lg: 1.25rem;    /* 20px */
  --font-size-xl: 1.5rem;     /* 24px */
  --font-size-2xl: 1.875rem;  /* 30px */
  --font-size-3xl: 2.25rem;   /* 36px */
  --font-size-4xl: 3rem;      /* 48px */

  /* Line Heights */
  --line-height-tight: 1.15;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

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

  /* Letter Spacing */
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;

  /* ============================================================
     COLORS - BRAND
     ============================================================ */
  /* Primary Brand Colors */
  --color-brand-primary: #3dffcf;      /* Cosmic Turquoise */
  --color-brand-secondary: #b77bff;    /* Cosmic Violet */
  --color-brand-tertiary: #ffd166;     /* Cosmic Gold */

  /* Brand with Opacity Variants */
  --color-brand-primary-10: rgba(61, 255, 207, 0.1);
  --color-brand-primary-20: rgba(61, 255, 207, 0.2);
  --color-brand-primary-30: rgba(61, 255, 207, 0.3);
  --color-brand-primary-40: rgba(61, 255, 207, 0.4);
  --color-brand-primary-60: rgba(61, 255, 207, 0.6);

  --color-brand-secondary-10: rgba(183, 123, 255, 0.1);
  --color-brand-secondary-20: rgba(183, 123, 255, 0.2);
  --color-brand-secondary-30: rgba(183, 123, 255, 0.3);
  --color-brand-secondary-40: rgba(183, 123, 255, 0.4);
  --color-brand-secondary-60: rgba(183, 123, 255, 0.6);

  --color-brand-tertiary-40: rgba(255, 209, 102, 0.4);
  --color-brand-tertiary-60: rgba(255, 209, 102, 0.6);

  /* ============================================================
     COLORS - BACKGROUNDS
     ============================================================ */
   --color-bg-page: #101322;           /* Deep space background */
   --color-bg-card: rgba(30, 25, 55, 0.9);  /* Card/Panel background */
   --color-bg-card-alt: rgba(30, 28, 62, 0.72); /* Alternative card bg */
   --color-bg-input: #17112e;          /* Input field background */
  --color-bg-overlay: rgba(0, 0, 0, 0.75); /* Modal overlay */

  /* ============================================================
     COLORS - TEXT
     ============================================================ */
  --color-text-primary: #f4f1ff;      /* Primary text — brightened S#449 */
  --color-text-secondary: #e0dcf6;    /* Secondary text — brightened S#449 */
  --color-text-muted: #c8bbe0;        /* Muted/disabled text — brightened */
  --color-text-inverse: #061018;      /* Text on light bg */

  /* Text with Opacity (brightened) */
  --color-text-primary-80: rgba(244, 241, 255, 0.92);
  --color-text-secondary-80: rgba(224, 220, 246, 0.88);

  /* ============================================================
     COLORS - UI ELEMENTS
     ============================================================ */
   --color-border: rgba(255, 255, 255, 0.14);
   --color-border-strong: rgba(255, 255, 255, 0.24);
  --color-border-focus: var(--color-brand-secondary);

  /* Success/Error/Warning */
  --color-success: #34d399;
  --color-error: #ff4d67;
  --color-warning: #fbbf24;
  --color-info: #60a5fa;

  --color-success-bg: rgba(52, 211, 153, 0.15);
  --color-error-bg: rgba(255, 77, 103, 0.15);
  --color-warning-bg: rgba(251, 191, 36, 0.15);

  /* ============================================================
     BORDER RADIUS
     ============================================================ */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;

  /* ============================================================
     SHADOWS (Unified across all pages)
     ============================================================ */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
  --shadow-md: 0 6px 16px 0 rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 12px 32px 0 rgba(0, 0, 0, 0.32);
  --shadow-xl: 0 16px 44px 0 rgba(0, 0, 0, 0.42);
  --shadow-2xl: 0 24px 56px 0 rgba(0, 0, 0, 0.52);

  /* Cosmic Glow Shadows — brightened S#449 */
  --shadow-glow-primary: 0 0 26px var(--color-brand-primary-60), 0 0 12px var(--color-brand-primary-40);
  --shadow-glow-secondary: 0 0 26px var(--color-brand-secondary-60), 0 0 12px var(--color-brand-secondary-40);
  --shadow-glow-combined:
    0 0 36px var(--color-brand-primary-40),
    0 0 64px var(--color-brand-secondary-30);

  /* Inset Shadows */
  --shadow-inset-sm: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-inset-md: inset 0 2px 4px rgba(0, 0, 0, 0.15);

  /* ============================================================
     COSMIC SYSTEM (Unified cosmic styling variables)
     Used by: palm.css, radar.css, and other cosmic pages
     ============================================================ */
   --cosmic-border: rgba(61, 255, 207, 0.45);
   --cosmic-border-strong: rgba(61, 255, 207, 0.70);
   --cosmic-panel: rgba(26, 22, 50, 0.74);
   --cosmic-glow: 0 0 44px rgba(61, 255, 207, 0.32), 0 0 90px rgba(183, 123, 255, 0.26), 0 0 130px rgba(255, 209, 102, 0.14);

  /* ============================================================
     CARD SYSTEM (Unified card styling across all pages)
     ============================================================ */
  /* Main Page Card (Glass effect — transparent to let star bg through) */
   --card-bg: rgba(26, 22, 52, 0.76);
   --card-bg-elevated: rgba(34, 29, 66, 0.86);
   --card-border: rgba(61, 255, 207, 0.32);      /* Türkis cosmic border for all cards */
   --card-border-accent: rgba(61, 255, 207, 0.55); /* Stronger türkis for accent/hover */
  --card-radius: var(--radius-xl);        /* 24px */
  --card-radius-sm: var(--radius-lg);     /* 16px */
  --card-padding: var(--space-4);         /* 16px */
  --card-padding-lg: var(--space-5);      /* 20px */
  --card-shadow: var(--shadow-lg);
  --card-shadow-hover: var(--shadow-xl);

  /* Cosmic card shadow — soft nebula glow for page cards
     Use this instead of hardcoding the same 3-layer shadow everywhere.
     Applied to: profile card, premium tiers, radar card, palm card, star-map */
  --card-shadow-cosmic:
   0 12px 44px rgba(0, 0, 0, 0.34),
   0 0 0 1px rgba(61, 255, 207, 0.26),
   0 0 38px rgba(61, 255, 207, 0.28),
   0 0 92px rgba(183, 123, 255, 0.22),
   0 0 120px rgba(255, 209, 102, 0.08);

  /* Item Card (within lists) */
  --item-bg: rgba(10, 12, 24, 0.75);
  --item-border: rgba(255, 255, 255, 0.08);
  --item-radius: var(--radius-lg);        /* 16px */
  --item-padding: var(--space-3);         /* 12px */
  --item-shadow: var(--shadow-md);

  /* ============================================================
     TYPOGRAPHY UNIFIED (Consistent text sizes)
     ============================================================ */
  --text-page-title: clamp(1.25rem, 3vw, 1.5rem);    /* Page headers */
  --text-card-title: 1.125rem;                       /* Card headings */
  --text-item-name: 1rem;                            /* List item names */
  --text-body: 0.95rem;                              /* Body text */
  --text-small: 0.875rem;                            /* Secondary text */
  --text-tiny: 0.8rem;                               /* Meta info */

  /* ============================================================
     BUTTON UNIFIED
     ============================================================ */
  --btn-radius: var(--radius-md);         /* 12px */
  --btn-radius-pill: var(--radius-full);  /* 9999px */
  --btn-padding: 10px 16px;
  --btn-padding-sm: 8px 12px;
  --btn-font-weight: 700;
  --btn-shadow: var(--shadow-md);

  /* ============================================================
     Z-INDEX SCALE (Layering System)
     Use these tokens consistently to avoid z-index conflicts
     ============================================================ */
  --z-base: 0;              /* Base layer - default content */
  --z-below: -1;            /* Behind base (decorative backgrounds) */
  --z-content: 1;           /* Normal content layer */
  --z-dropdown: 100;        /* Dropdowns and menus */
  --z-sticky: 200;          /* Sticky headers */
  --z-overlay: 300;         /* Overlays and backdrops */
  --z-modal: 400;           /* Modal dialogs */
  --z-popover: 500;         /* Popovers and tooltips */
  --z-toast: 600;           /* Toast notifications */
  --z-navbar: 800;          /* Bottom navigation bar */
  --z-max: 9999;            /* Maximum z-index for critical overlays only */

  /* ============================================================
     TRANSITIONS
     ============================================================ */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slower: 500ms ease;

  --transition-timing-default: ease;
  --transition-timing-in: ease-in;
  --transition-timing-out: ease-out;
  --transition-timing-in-out: ease-in-out;

  /* ============================================================
     BREAKPOINTS (for JS usage)
     ============================================================ */
  --bp-xs: 360px;
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
  --bp-2xl: 1536px;

  /* ============================================================
     COMPONENT SPECIFIC
     ============================================================ */
  /* Buttons */
  --button-height-sm: 36px;
  --button-height-md: 44px;
  --button-height-lg: 52px;
  --button-padding-x: var(--space-4);
  --button-padding-y: var(--space-2);

  /* Inputs */
  --input-height: 48px;
  --input-padding-x: var(--space-3);
  --input-padding-y: var(--space-2);
  --input-border-width: 1px;

  /* Cards - see CARD SYSTEM section above (L175) for full card tokens */
  /* --card-padding, --card-radius already defined above */

  /* Navigation — canonical height is --bottom-nav-h (navbar.css/base.css) */
  --nav-height: var(--bottom-nav-h, 60px);
  --nav-padding: var(--space-2);

  /* ============================================================
     SAFE AREA INSETS (iOS Notch Support)
     ============================================================ */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);

  /* ============================================================
     GLASSMORPHISM
     ============================================================ */
  --glass-bg: rgba(16, 14, 28, 0.55);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur: blur(10px);
  --glass-saturate: saturate(110%);

  /* ============================================================
     SCROLLBAR (Dating-App-Grade Scroll UX)
     ============================================================ */
  --scroll-thumb: rgba(61, 255, 207, 0.18);
  --scroll-thumb-hover: rgba(61, 255, 207, 0.35);
  --scroll-track: transparent;
  --scroll-width: 3px;

  /* ============================================================
     PAGE-HEADER SIZING (Icon + Title bars)
     ============================================================ */
  --header-height: 48px;
  --header-icon-size: 40px;
  --header-avatar-size: 44px;

  /* ============================================================
     DATING UI KERNEL (true aliases to brand tokens — Session redesign)
     Previously these were hardcoded to a second, drifted palette
     (#18d7d0 cyan, #8b5cf6 violet, #070919 bg) which caused visible
     color/surface mismatches between pages using --ui-* vs --color-*.
     Now every --ui-* alias resolves to the exact same value as the
     legacy token, so both naming systems render identically.
     ============================================================ */
  --ui-page-max: 960px;
  --ui-page-max-wide: 1600px;
  --ui-page-gutter: clamp(16px, 4vw, 24px);
  --ui-content-padding: var(--ui-page-gutter);
  --ui-page-top: clamp(12px, 3vw, 24px);
  --ui-page-bottom: calc(var(--bottom-nav-h, 78px) + var(--safe-area-bottom) + 24px);
  --ui-section-gap: clamp(14px, 1.8vw, 22px);
  --ui-panel-padding: clamp(16px, 2.2vw, 28px);
  --ui-space-1: var(--space-1);
  --ui-space-2: var(--space-2);
  --ui-space-3: var(--space-3);
  --ui-space-4: var(--space-4);
  --ui-space-5: var(--space-5);
  --ui-space-6: var(--space-6);
  --ui-space-8: var(--space-8);
  --ui-radius-sm: var(--radius-sm);
  --ui-radius-md: var(--radius-md);
  --ui-radius-lg: 20px;
  --ui-radius-pill: var(--radius-full);
  --ui-surface-0: rgba(18, 15, 34, .72);
  --ui-surface-1: rgba(26, 22, 52, .76);
  --ui-surface-2: rgba(34, 29, 66, .86);
  --ui-surface-3: rgba(44, 37, 84, .92);
  --ui-surface-elevated: var(--ui-surface-2);
  --ui-border-subtle: rgba(61, 255, 207, .16);
  --ui-border-strong: rgba(61, 255, 207, .55);
  --ui-border-highlight: rgba(255, 255, 255, .13);
  --ui-text: #f4f1ff;
  --ui-text-soft: #e0dcf6;
  --ui-text-muted: #c8bbe0;
  --ui-accent: #3dffcf;
  --ui-accent-2: #b77bff;
  --ui-stellar-cyan: #3dffcf;
  --ui-stellar-blue: #5793ff;
  --ui-stellar-violet: #b77bff;
  --ui-stellar-pink: #f15aa7;
  --ui-stellar-gold: #ffd166;
  --ui-accent-gradient: linear-gradient(100deg, #3dffcf 0%, #5793ff 38%, #b77bff 70%, #f15aa7 100%);
  --ui-accent-gradient-hover: linear-gradient(100deg, #7dffe0 0%, #78a9ff 38%, #c79bff 70%, #f578b8 100%);
  --ui-page-background: #101322;
  --ui-sidebar-width: 216px;
  --ui-shell-gap: clamp(14px, 2vw, 24px);
  --ui-mobile-nav-height: 66px;
  --ui-font-xs: var(--font-size-xs);
  --ui-font-sm: var(--font-size-sm);
  --ui-font-md: var(--font-size-base);
  --ui-font-lg: var(--font-size-lg);
  --ui-font-xl: var(--font-size-2xl);
  --ui-font-display: var(--font-size-3xl);
  --ui-glow-soft: 0 16px 42px rgba(2, 4, 18, .34);
  --ui-glow-active: 0 0 0 1px var(--color-brand-primary-20), 0 18px 50px var(--color-brand-secondary-20);
  --ui-glow: var(--ui-glow-active);
  --ui-focus-color: var(--color-brand-primary);
  --ui-focus-ring: 0 0 0 3px var(--color-brand-primary-30);
}

/* ============================================================
   BACKWARDS-COMPATIBLE ALIASES (Dezember 2025 CSS Variablen)
   Ensure old variable names work alongside new token system
   ============================================================ */
:root {
   /* Map NEW token names to old ones used in base.css (Dec 2025) */
   --color-text: var(--color-text-primary, #e6e0ff);
   --color-text-light: var(--color-text-primary, #e6e0ff);
   --color-text-muted: var(--color-text-secondary, #cfcdf1);
   --color-bg: var(--color-bg-page, #0b0b14);
   --color-panel: var(--color-bg-card, rgba(18,14,34,0.92));
   --color-input-bg: var(--color-bg-input, #0f0720);
   --color-input-bg-light: #ffffff;
   --color-accent: var(--color-brand-primary, #3dffcf);
   --color-primary: var(--color-brand-secondary, #b77bff);
   --color-gold: var(--color-brand-tertiary, #ffd166);

   /* OLD variable names from Dec 2025 base.css - mapped to new tokens */
   --text-light: #eae8ff;
   --bg-dark: #0b0b14;
   --text-dim: #cfcdf1cc;
   --brand: #b77bff;
   --brand-2: #3dffcf;
   --cosmic-turquoise: #3dffcf;
   --cosmic-turquoise-soft: #3dffcf33;
   --cosmic-violet: #bc8af8;
   --border-soft: #ffffff22;
   --shadow-lg: 0 10px 40px rgba(0,0,0,.35), 0 0 60px rgba(139,92,246,.25);
   --glow: 0 0 30px #b77bff44, 0 0 50px #3dffcf22;
   --bg-panel: #0f0d1f;
   --transition: .2s ease;
   --transition-slow: .3s ease;
   --color-border: rgba(255,255,255,0.08);

   /* Additional aliases used by newer pages (visitors, free_coins) */
   --color-surface-elevated: var(--color-bg-card, rgba(18,14,34,0.92));
   --color-surface-primary: var(--color-bg-page, #0b0b14);
   --color-border-subtle: var(--color-border, rgba(255,255,255,0.08));
   --color-text-tertiary: var(--color-text-muted, #b7aad8);
   --color-primary-light: rgba(183, 123, 255, 0.15);
   --color-primary-glow: 0 0 20px var(--color-brand-secondary-40);
   --input-bg: var(--color-bg-input, #0f0720);
}

/* ============================================================
   DARK MODE SUPPORT (Future-proof)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    /* StellarME is dark by default - no overrides needed */
    color-scheme: dark;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0.01ms;
    --transition-base: 0.01ms;
    --transition-slow: 0.01ms;
    --transition-slower: 0.01ms;
  }
}

/* ============================================================
   HIGH CONTRAST MODE
   ============================================================ */
@media (prefers-contrast: high) {
  :root {
    --color-border: rgba(255, 255, 255, 0.3);
    --color-border-strong: rgba(255, 255, 255, 0.5);
  }
}
