/* ============================================================
   css/main.css — MyFinancePal design system
   THE single source of truth for tokens: color, type, spacing,
   radius, elevation, motion, focus. Every other stylesheet and
   inline <style> block consumes these variables — no raw hex
   outside this file.

   Type:   Lexend (display/headings — designed for reading
           proficiency, ideal for limited-English readers)
           + Inter (body/UI). Loaded per-page via Google Fonts.
   Color:  calm-blue brand. Primary action blue is #2563EB —
           white text on it passes WCAG AA (5.2:1); the legacy
           #3E7BFF failed (3.8:1) and now serves as accent only.
   ============================================================ */

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

/* ============================================
   DESIGN TOKENS — :root
   ============================================ */
:root {
  /* ── Font stacks ── */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Lexend', 'Inter', system-ui, -apple-system, sans-serif;

  /* ── Brand blue ramp ── */
  --blue-700: #1D4ED8;   /* pressed / active */
  --blue-600: #2563EB;   /* primary actions — AA on white */
  --blue-500: #3E7BFF;   /* brand accent: icons, rings, glows */
  --blue-300: #A9C7FF;   /* decorative accents on dark */
  --blue-200: #C9DCFF;   /* tint borders, hover fills */
  --blue-100: #D6E6FF;   /* icon tiles, soft fills */
  --blue-50:  #EAF2FF;   /* page background */

  /* ── Cyan ramp (Dashboard Accents) ── */
  --cyan-500: #06B6D4;
  --cyan-400: #22D3EE;
  --cyan-100: #CFFAFE;
  --cyan-50:  #ECFEFF;

  /* ── Ink ramp ── */
  --ink-900: #101E3C;    /* display headings */
  --ink-800: #1A2A4D;    /* headings, primary text (13.5:1) */
  --ink-600: #43536F;    /* strong body on tint */
  --ink-500: #5B6B87;    /* secondary text (5.3:1) */
  --ink-400: #64748B;    /* captions, timestamps (4.8:1) */

  /* ── Semantic status (text-safe ≥4.5:1 / accent / tint) ── */
  --success:        #047857;
  --success-accent: #1A9E5C;
  --success-tint:   #E5F5EC;
  --error:          #D93025;
  --error-tint:     #FDEDEB;
  --warning:        #B45309;
  --warning-accent: #E8A44A;
  --warning-tint:   #FDF3E4;

  /* ── Legacy palette aliases (inline styles + JS-injected CSS) ── */
  --primary-blue: var(--blue-600);
  --light-blue:   var(--blue-50);
  --soft-blue:    var(--blue-100);
  --accent-blue:  var(--blue-500);
  --navy:         var(--ink-800);
  --slate:        var(--ink-500);
  --white:        #FFFFFF;
  --border:       #DDE5F3;
  --cta-hover:    var(--blue-700);

  /* ── Semantic tokens ── */
  --color-primary:       var(--blue-600);
  --color-primary-hover: var(--blue-700);
  --color-primary-dark:  var(--blue-100);  /* structural surfaces — logo boxes, icon tiles */
  --color-cta-hover:     var(--blue-700);
  --color-accent:        var(--blue-500);
  --color-ring:          rgba(37, 99, 235, 0.45);

  /* Backgrounds */
  --color-bg:       var(--blue-50);   /* page background */
  --color-bg-soft:  #FFFFFF;          /* cards / surfaces */
  --color-bg-muted: #F7FAFF;          /* subtle fills, input wells */
  --color-bg-info:  var(--blue-100);  /* info fills */
  --color-bg-navy:  #FFFFFF;
  --color-bg-sky:   var(--blue-100);
  --color-bg-dark:  var(--ink-800);   /* footer */

  /* Text */
  --color-text:       var(--ink-800);
  --color-text-muted: var(--ink-500);
  --color-text-faint: var(--ink-400);
  --color-text-mid:   var(--ink-600);

  /* Borders */
  --color-border:       var(--border);
  --color-border-light: #E7EDF8;
  --color-border-mid:   var(--border);
  --color-border-info:  var(--blue-200);
  --color-border-hover: var(--blue-500);
  --color-border-dark:  var(--ink-800);

  /* ── Layout ── */
  --px-desktop: 48px;
  --px-mobile:  20px;
  --container:  1200px;

  /* ── Spacing scale (4px rhythm) ── */
  --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; --space-24: 96px;

  /* ── Radius scale ── */
  --radius-xs:   6px;    /* tags, tiny chips */
  --radius-sm:   8px;    /* small controls */
  --radius-md:   12px;   /* buttons, inputs */
  --radius-lg:   16px;   /* cards */
  --radius-xl:   24px;   /* hero panels, large cards */
  --radius-full: 9999px;

  /* ── Elevation (ink-tinted, one family) ── */
  --shadow-xs: 0 1px 2px rgba(16, 30, 60, 0.06);
  --shadow-sm: 0 1px 3px rgba(16, 30, 60, 0.08), 0 1px 2px rgba(16, 30, 60, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(16, 30, 60, 0.10), 0 2px 4px -2px rgba(16, 30, 60, 0.05);
  --shadow-lg: 0 16px 32px -8px rgba(16, 30, 60, 0.16), 0 4px 8px -4px rgba(16, 30, 60, 0.06);
  --shadow-xl: 0 24px 48px -12px rgba(16, 30, 60, 0.18), 0 8px 16px -8px rgba(16, 30, 60, 0.08);
  --shadow-hover: 0 12px 24px -6px rgba(16, 30, 60, 0.12), 0 4px 8px -4px rgba(16, 30, 60, 0.08);
  --shadow-primary: 0 4px 14px -2px rgba(37, 99, 235, 0.35);

  /* ── Motion ── */
  --transition-fast: 0.15s;
  --transition: 0.2s;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================
   BASE
   ============================================ */
html {
  font-size: 16px;
  overflow-x: hidden;
  background: var(--blue-50); /* match page bg — avoid flash on load */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-width: 0;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

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

button {
  cursor: pointer;
  font-family: var(--font-sans);
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

::selection {
  background: var(--blue-200);
  color: var(--ink-900);
}

/* Money and stat figures never shift width as digits change */
.tabular, .stat-num, .mfp-stat-value, .remit-amount, .remit-row-val,
.bc-row-val, .trust-stat-num {
  font-variant-numeric: tabular-nums;
}

/* ============================================
   FOCUS — single, consistent keyboard signal
   ============================================ */
:focus-visible {
  outline: 3px solid var(--color-ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; /* fields use their own border + ring treatment */
}

/* Skip link — first tab stop on every navbar page */
.skip-link {
  position: absolute;
  left: 16px; top: -48px;
  z-index: 100;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  transition: top var(--transition-fast) ease;
}
.skip-link:focus { top: 12px; }

/* ============================================
   REDUCED MOTION
   ============================================ */
@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;
  }
}

/* ============================================
   LAYOUT UTILITIES
   ============================================ */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--px-desktop);
}

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

.section-center {
  text-align: center;
  max-width: 640px;
  margin: 0 auto var(--space-10);
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: var(--space-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-h2 {
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.section-sub {
  font-size: 1.0625rem;
  color: var(--color-text-muted);
  line-height: 1.65;
}

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0 var(--px-desktop);
}

/* ============================================
   TEXT UTILITIES
   ============================================ */
.text-blue  { color: var(--color-primary); }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.text-white { color: #fff; }
.blue-val   { color: var(--color-primary); font-weight: 600; }

/* ============================================
   ACCESSIBILITY
   ============================================ */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ============================================
   RESPONSIVE BASE RULES
   ============================================ */
@media (max-width: 768px) {
  .nav-links         { display: none !important; }
  .hero,
  .ai-section,
  .remit-grid,
  .footer-top        { grid-template-columns: 1fr !important; }
  .section           { padding: var(--space-12) var(--px-mobile); }
  .hero              { padding: var(--space-12) var(--px-mobile) var(--space-10); }
  .hero-visual       { display: none; }
  .steps-row         { flex-direction: column; align-items: center; }
  .step-connector    { transform: rotate(90deg); }
  .btn-primary,
  .btn-secondary     { width: 100%; justify-content: center; box-sizing: border-box; }
  .footer            { padding: var(--space-10) var(--px-mobile) !important; }
  .footer-top        { gap: 28px !important; }
  .divider           { margin: 0 var(--px-mobile); }
  /* Prevent any fixed-width element from busting the viewport */
  * { max-width: 100%; }
  /* Re-allow elements that legitimately exceed parent (e.g. absolutely positioned) */
  .phone-wrapper,
  .phone-frame,
  .floating-card     { max-width: none; }
}
