/* ==========================================================================
   base.css — Reset, Design Tokens, Typography, Layout Primitives
   ========================================================================== */

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--color-primary-hover);
}

ul,
ol {
  list-style: none;
}

/* --- Design Tokens (from Figma Design System v2.0) --- */
:root {
  /* ── Primitive Color Scales ── */

  /* Green — Brand Primary (brand step: 700) */
  --green-25: #F2FAF7;  --green-50: #E5F5EE;
  --green-100: #C2E8D5; --green-200: #8BCFB2;
  --green-300: #52B48E;  --green-400: #2A9B70;
  --green-500: #1B7B58;  --green-600: #156044;
  --green-700: #124734;  --green-800: #0C3425;
  --green-900: #081F17;  --green-950: #011F17;

  /* Gold — Premium Accent (brand step: 300) */
  --gold-50: #FEFAED;   --gold-100: #FBF0CA;
  --gold-200: #F6DC98;   --gold-300: #E8C97A;
  --gold-400: #D9AE4E;   --gold-500: #BA9030;
  --gold-600: #98731F;   --gold-700: #755814;
  --gold-800: #533E0E;   --gold-900: #342608;

  /* Cream — Warm Background (brand step: 300) */
  --cream-50: #FDFCFA;   --cream-100: #F9F7F3;
  --cream-200: #F2EDE6;  --cream-300: #EAE5DB;
  --cream-400: #DDD4C5;  --cream-500: #C8BCAA;
  --cream-600: #ACA090;  --cream-700: #857870;
  --cream-800: #5B524B;  --cream-900: #393028;

  /* Neutral — Warm Gray */
  --neutral-50: #FAFAF9;  --neutral-100: #F4F3F0;
  --neutral-200: #EBE6E0; --neutral-300: #D2CEC6;
  --neutral-400: #A9A49B;  --neutral-500: #807C73;
  --neutral-600: #5B5750;  --neutral-700: #3C3834;
  --neutral-800: #252220;  --neutral-900: #14120F;
  --neutral-950: #0B0907;

  /* Red — Error / Loss */
  --red-50: #FFF1F2;  --red-100: #FFE4E6;
  --red-200: #FECDD3; --red-300: #FDA4AF;
  --red-400: #FB7185; --red-500: #F43F5E;
  --red-600: #E11D48; --red-700: #BE123C;
  --red-800: #9F1239; --red-900: #881337;

  /* Amber — Warning */
  --amber-50: #FFFBEB;  --amber-100: #FEF3C7;
  --amber-200: #FDE68A;  --amber-300: #FCD34D;
  --amber-400: #FBBF24;  --amber-500: #F59E0B;
  --amber-600: #D97706;  --amber-700: #B45309;
  --amber-800: #92400E;  --amber-900: #78350F;

  /* Blue — Info / Links */
  --blue-50: #EFF6FF;  --blue-100: #DBEAFE;
  --blue-200: #BFDBFE; --blue-300: #93C5FD;
  --blue-400: #60A5FA; --blue-500: #3B82F6;
  --blue-600: #2563EB; --blue-700: #1D4ED8;
  --blue-800: #1E40AF; --blue-900: #1E3A8A;

  /* Lime — Financial Gain (brand step: 400) */
  --lime-50: #F4FDEF;  --lime-100: #E5FACA;
  --lime-200: #CBF59A;  --lime-300: #9FEB6A;
  --lime-400: #6FCF57;  --lime-500: #4DB33E;
  --lime-600: #38952B;  --lime-700: #29741E;
  --lime-800: #1C5214;  --lime-900: #10320C;
  --lime-950: #071A06;

  /* Mint — Feature Highlight (brand step: 400) */
  --mint-50: #EDFDF8;  --mint-100: #D1F9EE;
  --mint-200: #A0F2DC;  --mint-300: #60E9C2;
  --mint-400: #26E4A3;  --mint-500: #14C588;
  --mint-600: #0E9E6C;  --mint-700: #0B7A53;
  --mint-800: #075739;  --mint-900: #043522;
  --mint-950: #021A11;

  /* ── Semantic Color Tokens (Light Mode) ── */

  /* Background */
  --color-bg: var(--cream-300);
  --color-bg-alt: var(--cream-200);
  --color-surface: #FFFFFF;
  --color-surface-raised: var(--cream-50);
  --color-bg-dark: var(--green-950);
  --color-bg-brand: var(--green-700);
  --color-bg-chat: var(--green-25);

  /* Brand */
  --color-primary: var(--green-700);
  --color-primary-hover: var(--green-600);
  --color-primary-subtle: var(--green-50);
  --color-primary-dark: var(--green-950);
  --color-secondary: var(--cream-300);
  --color-accent: var(--gold-300);
  --color-accent-dark: var(--gold-400);
  --color-accent-light: var(--gold-200);

  /* Text */
  --color-text: var(--neutral-800);
  --color-text-secondary: var(--neutral-700);
  --color-text-tertiary: var(--neutral-500);
  --color-text-light: #FFFFFF;
  --color-text-placeholder: var(--neutral-400);
  --color-text-disabled: var(--neutral-400);
  --color-text-on-brand: #FFFFFF;
  --color-text-on-brand-secondary: var(--green-200);
  --color-muted: var(--neutral-500);

  /* Border */
  --color-border: var(--neutral-300);
  --color-border-subtle: #E8E6E0;
  --color-border-strong: var(--neutral-500);
  --color-border-brand: var(--green-700);

  /* Status */
  --color-success: var(--green-500);
  --color-success-bg: var(--green-50);
  --color-warning: var(--amber-600);
  --color-warning-bg: var(--amber-50);
  --color-error: var(--red-600);
  --color-error-bg: var(--red-50);

  /* Finance */
  --color-gain: var(--lime-400);
  --color-gain-text: var(--lime-800);
  --color-gain-bg: var(--lime-50);
  --color-loss: var(--red-600);

  /* Feature Highlight (Mint) */
  --color-highlight: var(--mint-400);
  --color-highlight-bg: var(--mint-50);
  --color-highlight-border: var(--mint-300);
  --color-highlight-text: var(--mint-800);

  /* Premium (Gold) */
  --color-premium: var(--gold-700);
  --color-premium-bg: var(--gold-50);
  --color-premium-border: var(--gold-400);
  --color-premium-emphasis: var(--gold-500);

  /* ── Typography ── */
  --font-serif: "Merriweather", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", Calibri, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "Courier New", monospace;

  /* Type Scale */
  --text-display-xl: 4rem;
  --text-display-lg: 3rem;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;

  /* Line Heights */
  --leading-tight: 1.10;
  --leading-snug: 1.20;
  --leading-heading: 1.30;
  --leading-normal: 1.60;
  --leading-relaxed: 1.50;

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

  /* ── Spacing ── */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* ── Borders & Shadows ── */

  /* Radii — Buttons */
  --radius-btn-sm: 4px;
  --radius-btn-md: 8px;
  --radius-btn-lg: 12px;

  /* Radii — Cards */
  --radius-card-sm: 8px;
  --radius-card-md: 12px;
  --radius-card-lg: 16px;
  --radius-panel: 12px;

  /* Radii — Inputs */
  --radius-input: 4px;
  --radius-input-lg: 8px;

  /* Radii — Overlays */
  --radius-modal: 16px;
  --radius-dropdown: 8px;
  --radius-tooltip: 2px;

  /* Radii — Badge / Pill */
  --radius-badge: 2px;
  --radius-tag: 4px;
  --radius-pill: 9999px;

  /* Radii — Legacy aliases */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

  /* ── Layout ── */
  --container-max: 1280px;
  --container-narrow: 800px;
  --layout-page-margin: 2.5rem;
  --layout-section-gap: 5rem;
  --layout-content-gap: 3rem;
  --layout-grid-gap: 1.5rem;

  /* Breakpoints: sm 640, md 768, lg 1024, xl 1280, 2xl 1536 */

  /* ── Transitions ── */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* --- Typography --- */
h1, h2 {
  font-family: var(--font-serif);
  font-weight: var(--weight-bold);
  color: var(--color-text);
}

h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

h1 { font-size: var(--text-4xl); line-height: var(--leading-snug); letter-spacing: -0.02em; }
h2 { font-size: var(--text-3xl); line-height: var(--leading-snug); letter-spacing: -0.015em; }
h3 { font-size: var(--text-2xl); line-height: var(--leading-heading); }
h4 { font-size: var(--text-xl);  line-height: var(--leading-heading); }
h5 { font-size: var(--text-base); line-height: 1.40; }

p {
  margin-bottom: var(--space-4);
}

.text-muted { color: var(--color-muted); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }

.eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-3);
}

/* --- Layout Primitives --- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--narrow {
  max-width: var(--container-narrow);
}

.section {
  padding-block: var(--space-24);
}

.section--alt {
  background-color: var(--color-bg-alt);
}

.section--dark {
  background-color: var(--color-bg-dark);
  color: var(--color-text-light);
}

.section--dark h2,
.section--dark h3,
.section--dark h4 {
  color: var(--color-text-light);
}

.section__header {
  text-align: center;
  max-width: 680px;
  margin-inline: auto;
  margin-bottom: var(--space-16);
}

.section__header .eyebrow {
  margin-bottom: var(--space-4);
}

.section__header p {
  font-size: var(--text-lg);
  color: var(--color-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
  h3 { font-size: var(--text-xl); }

  .section {
    padding-block: var(--space-16);
  }

  .container {
    padding-inline: var(--space-4);
  }
}
