/* =============================================================
   Vitarix Landing — base.css
   Theme tokens, reset, base typography, RTL support.
   Single source of truth for design tokens.
   Syncs with: src/theme/colors.ts, src/theme/tokens/*, theme.json
   ============================================================= */

/* ─── Design Tokens (CSS custom properties) ────────────────── */
/* Phase 5: "Vitarix Pulse" palette.
   Identity preservation: lime is kept (matches app's SCAN button #C4FF00).
   Purple is removed (the app never used it — was the AI-default secondary).
   New warm-earth secondaries pulled from the actual app screenshots:
   - ember orange #FF7A00 (app's Home dashboard CTA)
   - olive green  #6B7A2F (app's Hydration active elements)
   - gold         #FFD700 (app's settings/active icons)
   To avoid touching every reference to --purple across the codebase,
   --purple is now aliased to ember. Existing code reads as ember.
*/
:root {
  /* Surfaces — slightly bluer ink, less zinc, matches app's #121212 */
  --bg:                 #0F1115;
  --surface:            #0F1115;
  --surface-dim:        #0F1115;
  --surface-bright:     #363A40;
  --surface-container:        #1A1D22;
  --surface-container-low:    #16191E;
  --surface-container-high:   #252830;
  --surface-container-highest:#2F323A;
  --surface-container-lowest: #080A0D;
  --surface-variant:    #2F323A;

  /* On-surface text — warm white, not cold */
  --on-background:      #F5F4F0;
  --on-surface:         #F5F4F0;
  --on-surface-variant: #B8B6B0;
  --on-primary:         #2A3500;
  --on-primary-container: #586C00;

  /* Primary (lime) — kept; matches app's #C4FF00 SCAN button exactly */
  --primary:            #FFFFFF;
  --primary-container:  #CBF231;
  --neon-lime:          #C4FF00;  /* Phase 5: was #C4FF00, now exact app match */
  --secondary:          #CBF231;
  --secondary-container:#AFD500;
  --accent-active:      #BBD073;

  /* Phase 5: warm-earth secondaries from the actual app.
     --purple is aliased to ember so existing refs auto-migrate. */
  --ember:              #FF7A00;  /* app's Home CTA + workout energy */
  --olive:              #8B9A2F;  /* app's Hydration active + warmth */
  --gold:               #FFD700;  /* app's settings/active icons */
  --purple:             var(--ember);  /* ALIAS — backward compat for existing refs */
  --primary-neon:       var(--ember);  /* ALIAS */

  /* Outline / borders */
  --outline:            #8E9192;
  --outline-variant:    #444748;

  /* Inverse */
  --inverse-surface:    #F5F4F0;
  --inverse-on-surface: #2D3136;

  /* Brand gradients — Phase 5: lime→ember (was lime→purple) */
  --gradient-brand:     linear-gradient(135deg, var(--ember) 0%, var(--neon-lime) 100%);
  --gradient-brand-soft:linear-gradient(135deg, rgba(255,122,0,0.10) 0%, rgba(196,255,0,0.10) 100%);
  --gradient-hero-bg:   radial-gradient(circle at 50% 0%, rgba(196,255,0,0.05) 0%, transparent 60%);

  /* Glows — Phase 5: ember replaces purple */
  --glow-lime:          0 0 20px rgba(196,255,0,0.20);
  --glow-lime-strong:   0 0 40px rgba(196,255,0,0.35);
  --glow-ember:         0 0 20px rgba(255,122,0,0.20);
  --glow-purple:        var(--glow-ember);  /* ALIAS — backward compat */

  /* Shape / radii */
  --radius-sm:          0.125rem;
  --radius-md:          0.25rem;
  --radius-lg:          0.5rem;
  --radius-xl:          0.75rem;
  --radius-2xl:         1rem;
  --radius-3xl:         1.5rem;
  --radius-4xl:         2rem;
  --radius-full:        9999px;

  /* Spacing tokens */
  --space-vertical-sm:  16px;
  --space-vertical-md:  24px;
  --space-container:    24px;
  --space-editorial:    48px;
  --space-section:      80px;
  --space-section-lg:   128px;

  /* Responsive overrides for mobile */
  --phone-w: 320px;
  --phone-h: 640px;

  /* Typography — Phase 5: Bricolage Grotesque (display) + Inter Tight (body).
     Both off the Impeccable reflex-reject list. Inter Tight is the condensed
     Inter variant — same workhorse DNA, slightly compressed, pairs cleanly
     with the app's existing Inter-based UI. Bricolage adds athletic warmth
     to display headings without being cartoonish. Tajawal stays for Arabic. */
  --font-sans: "Inter Tight", "Tajawal", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Inter Tight", "Tajawal", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --fs-display-lg: 3.5rem;   /* 56 — overridden on mobile below */
  --fs-headline-lg: 2rem;    /* 32 */
  --fs-headline-md: 1.5rem;  /* 24 */
  --fs-body-lg:     1.125rem;/* 18 */
  --fs-body-md:     0.875rem;/* 14 */
  --fs-label-md:    0.75rem; /* 12 */
  --fs-eyebrow:     0.75rem; /* 12 */

  --lh-tight:  1.1;
  --lh-snug:   1.2;
  --lh-normal: 1.5;
  --lh-loose:  1.7;

  --tracking-tight:  -0.04em;
  --tracking-snug:   -0.02em;
  --tracking-wide:    0.05em;
  --tracking-wider:   0.1em;

  /* Easing curves (mirror src/theme/tokens/motion.ts) */
  --ease-standard:     cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized:   cubic-bezier(0.2, 0, 0, 1);
  --ease-out-expo:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart:    cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-cubic:    cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-spring:       cubic-bezier(0.16, 1, 0.3, 1);  /* was bounce 0.34,1.56,0.64,1 — Impeccable ban on bounce easing; alias to ease-out-expo */

  /* Duration scale */
  --dur-instant: 100ms;
  --dur-fast:    200ms;
  --dur-base:    300ms;
  --dur-slow:    500ms;
  --dur-slower:  800ms;
  --dur-slowest: 1200ms;

  /* Z-index scale */
  --z-base:    1;
  --z-raised:  10;
  --z-sticky:  40;
  --z-overlay: 50;
  --z-modal:   100;
  --z-preloader: 200;
  --z-cursor:  9999;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Dark base lives on <html> so the body can be transparent and
     let the animated aurora + particles show through. */
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
  color: var(--on-surface);
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  line-height: var(--lh-normal);
  letter-spacing: 0em;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* Promote body to its own stacking context so background
     layers (z-index: 0) sit cleanly behind content. */
  isolation: isolate;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  overflow-wrap: break-word;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  background: var(--neon-lime);
  color: var(--surface);
}

/* ─── Base typography ──────────────────────────────────────── */
.font-display-lg {
  font-family: var(--font-display);
  font-size: var(--fs-display-lg);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: 800;
}

.font-headline-lg {
  font-family: var(--font-display);
  font-size: var(--fs-headline-lg);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-snug);
  font-weight: 700;
}

.font-headline-md {
  font-family: var(--font-display);
  font-size: var(--fs-headline-md);
  line-height: var(--lh-snug);
  font-weight: 700;
}

.font-body-md {
  font-family: var(--font-sans);
  font-size: var(--fs-body-md);
  line-height: var(--lh-normal);
  font-weight: 400;
}

.font-label-md {
  font-family: var(--font-sans);
  font-size: var(--fs-label-md);
  line-height: 1.2;
  letter-spacing: var(--tracking-wide);
  font-weight: 600;
}

/* ─── RTL / Arabic ─────────────────────────────────────────── */
html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] .ar { display: block !important; }
html[dir="rtl"] .en { display: none !important; }

.ar { display: none !important; }
.en { display: block; }

/* Logical properties for RTL-safe spacing */
html[dir="rtl"] .items-start { align-items: flex-end; }
html[dir="rtl"] .flex-col.items-start { align-items: flex-start; }

/* Tajawal for Arabic script */
html[dir="rtl"] body,
html[dir="rtl"] .font-display-lg,
html[dir="rtl"] .font-headline-lg,
html[dir="rtl"] .font-headline-md,
html[dir="rtl"] .font-body-md,
html[dir="rtl"] .font-label-md {
  font-family: "Tajawal", "Inter Tight", system-ui, sans-serif;
  letter-spacing: 0;
  line-height: 1.6;
}

html[dir="rtl"] .font-display-lg,
html[dir="rtl"] .font-headline-lg {
  font-weight: 800;
  line-height: 1.3;
}

/* ─── Mobile responsive overrides ─────────────────────────── */
@media (max-width: 768px) {
  :root {
    --space-container: 16px;
    --space-editorial: 28px;
    --space-section: 48px;
    --space-section-lg: 72px;
    --fs-display-lg: 2.5rem;
    --fs-headline-lg: 1.5rem;
    --fs-headline-md: 1.25rem;
    --phone-w: 260px;
    --phone-h: 520px;
    --phone-radius: 36px;
    --phone-bezel: 10px;
  }
}

@media (max-width: 375px) {
  :root {
    --fs-display-lg: 2.1rem;
    --phone-w: 240px;
    --phone-h: 480px;
  }
}

/* ─── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Focus visibility (a11y) ──────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--neon-lime);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Hide content visually but keep it for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
