/* =====================================================================
   DESIGN TOKENS — single source of truth for color, type, space,
   radius, shadow, motion, z-index. Loaded BEFORE design-system-v3.css.

   Brand: Valley West Mortgage (red brand across VA/FHA/Conv).
   Inspired by: Stripe (typography, restraint), Rocket (warmth + scale),
   Veterans United (trust), Bankrate (information density).

   Audit baseline (2026-04-25 across 48 pages):
     - 66 unique colors -> consolidating to 18 tokens
     - 35 font sizes   -> consolidating to 11 tokens
     - 24 radii        -> consolidating to 6 tokens
     - 10+ durations   -> consolidating to 3 tier tokens
   ===================================================================== */

:root {
  /* ============== COLOR PALETTE ============== */
  /* Brand (red — primary across all 3 sites) */
  --color-brand-50:  #FFF5F5;
  --color-brand-100: #FEF2F2;
  --color-brand-200: #FEE2E2;
  --color-brand-300: #FCA5A5;
  --color-brand-400: #EF4444;
  --color-brand-500: #DC2626;   /* primary brand */
  --color-brand-600: #B91C1C;
  --color-brand-700: #991B1B;
  --color-brand:     var(--color-brand-500);

  /* Ink (text + icon) */
  --color-ink-900: #0A0A0A;     /* primary heading */
  --color-ink-800: #1A1A1A;     /* secondary heading */
  --color-ink-700: #374151;     /* emphasized body */
  --color-ink-600: #4B5563;     /* body */
  --color-ink-500: #6B7280;     /* muted body */
  --color-ink-400: #9CA3AF;     /* muted UI */
  --color-ink-300: #D1D5DB;     /* disabled / very muted */
  --color-ink-200: #E5E7EB;     /* hairlines / borders */

  /* Surface (background) */
  --color-surface-pure: #FFFFFF;
  --color-surface-1:    #FAFAFA;
  --color-surface-2:    #F5F5F5;
  --color-surface-3:    #F0F0F0;
  --color-surface-dark: #0A0A0A; /* for dark sections */

  /* State (system colors) */
  --color-success-50:  #F0FDF4;
  --color-success-100: #DCFCE7;
  --color-success-500: #22C55E;
  --color-warning-500: #F59E0B;
  --color-error-500:   #DC2626; /* same as brand intentionally */

  /* Semantic aliases (use these in component CSS, not raw colors) */
  --bg-page:        var(--color-surface-pure);
  --bg-section-alt: var(--color-surface-1);
  --bg-card:        var(--color-surface-pure);
  --bg-card-soft:   var(--color-surface-2);
  --bg-banner-red:  var(--color-brand-100);
  --bg-banner-gray: var(--color-surface-2);
  --text-heading:   var(--color-ink-900);
  --text-body:      var(--color-ink-700);
  --text-muted:     var(--color-ink-500);
  --text-faint:     var(--color-ink-400);
  --border-subtle:  var(--color-ink-200);
  --accent:         var(--color-brand-500);
  --accent-hover:   var(--color-brand-600);
  --accent-soft:    var(--color-brand-100);

  /* ============== TYPOGRAPHY SCALE ============== */
  --font-display: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:    'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'Consolas', monospace;

  /* Modular type scale (1.20 ratio, 16px base) — 11 steps */
  --fs-2xs: 11px;     /* eyebrows, micro-labels */
  --fs-xs:  12px;     /* badges, tiny meta */
  --fs-sm:  13px;     /* small body, captions */
  --fs-base: 14px;    /* primary body */
  --fs-md:  15px;     /* lead paragraph */
  --fs-lg:  16px;     /* card titles */
  --fs-xl:  18px;     /* section subtitle */
  --fs-2xl: 22px;     /* h3 */
  --fs-3xl: 28px;     /* h2 small */
  --fs-4xl: 40px;     /* h2 large */
  --fs-5xl: clamp(42px, 7vw, 72px);   /* hero h1 */

  /* Font weights */
  --fw-light:    300;
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* Line heights — Stripe-style: 1.55 body for readability */
  --lh-tight:   1.05;   /* hero displays (Stripe uses 1.05) */
  --lh-snug:    1.15;   /* h2/h3 (Stripe uses 1.1-1.15) */
  --lh-normal:  1.55;   /* body text (Stripe uses 1.55) */
  --lh-relaxed: 1.7;    /* long-form body */

  /* Letter spacing */
  --tracking-tight:  -0.02em;
  --tracking-normal: 0;
  --tracking-wide:   0.05em;
  --tracking-wider:  0.1em;     /* eyebrows */

  /* ============== SPACING SCALE (8px base) ============== */
  --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;
  --space-24: 96px;

  /* ============== RADIUS SCALE ============== */
  --radius-xs:    4px;
  --radius-sm:    8px;          /* small chips, badges */
  --radius-md:    12px;         /* inputs, small cards */
  --radius-lg:    16px;
  --radius-xl:    18px;         /* primary cards */
  --radius-2xl:   24px;         /* large feature cards */
  --radius-pill:  100px;        /* buttons, pills */
  --radius-circle: 50%;

  /* ============== SHADOW SCALE ============== */
  --shadow-xs:   0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(15,25,35,.06), 0 2px 4px rgba(15,25,35,.04); /* Stripe blue-tinted */
  --shadow-lg:   0 12px 32px rgba(0,0,0,.06), 0 4px 8px rgba(0,0,0,.04);
  --shadow-xl:   0 24px 64px rgba(0,0,0,.07), 0 8px 16px rgba(0,0,0,.04);
  --shadow-button-hover: 0 8px 24px rgba(220,38,38,.18);

  /* ============== MOTION (3 tiers) ============== */
  --duration-fast: 150ms;       /* hover state changes */
  --duration-base: 250ms;       /* card lifts, button presses */
  --duration-slow: 400ms;       /* page-level transitions, modal */
  --duration-page: 800ms;       /* hero rotations, big reveals */

  --ease-out:    cubic-bezier(0.215, 0.61, 0.355, 1);  /* Stripe standard easeOutCubic */
  --ease-in-out: cubic-bezier(0.83, 0, 0.17, 1);       /* Stripe modal/page easeInOutQuart */
  --ease-emphasized: cubic-bezier(0.34, 1.56, 0.64, 1); /* slight overshoot */

  /* ============== Z-INDEX SCALE (organized stacking) ============== */
  --z-below: -1;
  --z-base: 0;
  --z-rise: 10;        /* hover lifts */
  --z-sticky: 30;      /* sticky CTAs */
  --z-nav: 50;         /* header */
  --z-dropdown: 60;
  --z-modal: 100;
  --z-toast: 120;
  --z-tooltip: 130;

  /* ============== ICON SYSTEM ============== */
  --icon-xs: 12px;
  --icon-sm: 16px;
  --icon-md: 20px;     /* default UI icon */
  --icon-lg: 22px;
  --icon-xl: 28px;
  --icon-stroke: 1.5;  /* default stroke for outline icons */
  --icon-stroke-bold: 2;

  /* ============== CONTAINER WIDTHS ============== */
  --container-narrow: 720px;   /* article, single-column content */
  --container-base:   980px;   /* rate tables, focused content */
  --container-wide:   1180px;  /* primary shell (matches v3) */
  --container-max:    1400px;  /* hero overflow only */

  /* ============== FOCUS RING (a11y) ============== */
  --focus-ring: 0 0 0 3px var(--color-brand-200), 0 0 0 4px var(--color-brand-500);
}

/* =====================================================================
   GLOBAL TYPOGRAPHY APPLY
   Uses the tokens above. Scoped tight so legacy inline styles still win.
   ===================================================================== */

html {
  font-family: var(--font-body);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body {
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  background: var(--bg-page);
  color: var(--text-body);
}

/* Heading defaults — fall back to tokens; inline styles override */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-heading);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
  margin: 0 0 var(--space-3);
}
h1 { font-size: var(--fs-5xl); font-weight: var(--fw-light); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-4xl); font-weight: var(--fw-light); }
h3 { font-size: var(--fs-2xl); font-weight: var(--fw-medium); }
h4 { font-size: var(--fs-xl);  font-weight: var(--fw-medium); }
h5 { font-size: var(--fs-lg);  font-weight: var(--fw-semibold); }
h6 { font-size: var(--fs-base); font-weight: var(--fw-semibold); }

p { margin: 0 0 var(--space-4); }

/* Eyebrow / label class — used everywhere */
.lbl, .eyebrow {
  font-family: var(--font-display);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

/* Standard hairline */
hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
}

/* =====================================================================
   FOCUS-VISIBLE — accessibility token
   ===================================================================== */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* =====================================================================
   PRIMARY BUTTON — canonical .btn-p
   Matches what's in inline styles, but enforces consistent height,
   radius, transition, and focus-visible.
   ===================================================================== */
.btn-p, a.btn-p, button.btn-p {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-normal);
  background: var(--accent);
  color: var(--color-surface-pure);
  border: 0;
  border-radius: var(--radius-pill);
  padding: 14px 28px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn-p:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-button-hover);
}
.btn-p:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Ghost / secondary button */
.btn-g, a.btn-g, button.btn-g {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  background: transparent;
  color: var(--text-heading);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 13px 27px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-base) var(--ease-out),
              border-color var(--duration-base) var(--ease-out),
              color var(--duration-base) var(--ease-out);
}
.btn-g:hover {
  background: var(--accent-soft);
  border-color: var(--color-brand-300);
  color: var(--accent);
}

/* =====================================================================
   ICON BOX — canonical icon container
   ===================================================================== */
.icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  flex-shrink: 0;
  transition: transform var(--duration-base) var(--ease-out),
              background var(--duration-base) var(--ease-out);
}
.icon-box svg {
  width: var(--icon-md);
  height: var(--icon-md);
  stroke-width: var(--icon-stroke);
  stroke: var(--accent);
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-hover]:hover .icon-box,
.glow-card:hover .icon-box {
  transform: scale(1.08);
}

/* =====================================================================
   CARD STYLES — unified
   ===================================================================== */
.glow-card,
.liquid-glass,
[class*="glow-card"],
[class*="liquid-glass"] {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  transition: transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out),
              border-color var(--duration-base) var(--ease-out);
  position: relative;
  overflow: hidden;
}
[data-hover].glow-card:hover,
[data-hover].liquid-glass:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-brand-200);
}

/* Liquid-glass card (frosted) */
.liquid-glass {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* Flip card */
.flip-card {
  perspective: 1000px;
  border-radius: var(--radius-xl);
}
.flip-card-inner {
  border-radius: var(--radius-xl);
  transition: transform var(--duration-slow) var(--ease-out);
}

/* =====================================================================
   FORM INPUTS — canonical
   ===================================================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input:not([type]),
select,
textarea {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--text-heading);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  min-height: 48px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Range slider — use brand red */
input[type="range"] {
  accent-color: var(--accent);
  min-height: 24px;
}

/* =====================================================================
   ANIMATIONS — micro-interactions
   ===================================================================== */
@keyframes float-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 var(--accent-soft); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes subtle-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

/* .rv = revealed (intersection observer triggers .vis) */
.rv {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--duration-page) var(--ease-out),
              transform var(--duration-page) var(--ease-out);
}
.rv.vis {
  opacity: 1;
  transform: translateY(0);
}

/* 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;
  }
  .rv { opacity: 1; transform: none; }
}

/* =====================================================================
   COMPONENT PATTERNS — replicated from reference sites
   ===================================================================== */

/* ---- Loan officer profile module (Veterans United pattern) ---- */
.lo-profile {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: var(--space-5);
  align-items: start;
  max-width: 520px;
}
.lo-profile__avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-circle);
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xl);
  color: var(--accent);
  overflow: hidden;
}
.lo-profile__avatar img { width: 100%; height: 100%; object-fit: cover; }
.lo-profile__name { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--text-heading); margin: 0 0 2px; }
.lo-profile__credentials { font-size: var(--fs-sm); color: var(--text-muted); margin: 0 0 var(--space-3); line-height: var(--lh-snug); }
.lo-profile__quote { font-size: var(--fs-sm); color: var(--text-body); line-height: var(--lh-normal); margin: 0 0 var(--space-3); font-style: italic; }
.lo-profile__contacts { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--fs-sm); }
.lo-profile__contacts a { color: var(--accent); text-decoration: none; }
.lo-profile__contacts a:hover { text-decoration: underline; }
.lo-profile__cta { margin-top: var(--space-3); }
@media (max-width: 480px) {
  .lo-profile { grid-template-columns: 1fr; text-align: center; }
  .lo-profile__avatar { margin: 0 auto; }
}

/* ---- Scenario block (Veterans United pattern) ---- */
.scenario-block {
  background: var(--bg-banner-red);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-8) auto;
  max-width: var(--container-narrow);
}
.scenario-block__tag {
  display: inline-block;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--accent);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.scenario-block h2,
.scenario-block h3 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-medium);
  color: var(--text-heading);
  margin: 0 0 var(--space-2);
  line-height: var(--lh-snug);
}
.scenario-block p {
  font-size: var(--fs-md);
  color: var(--text-body);
  line-height: var(--lh-normal);
  margin: 0;
}

/* ---- Updated-today timestamp (Bankrate pattern) ---- */
.updated-stamp {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}
.updated-stamp strong { color: var(--text-heading); font-weight: var(--fw-semibold); }
.updated-stamp::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success-500);
  animation: pulse-dot 2s var(--ease-out) infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(1.15); }
}

/* ---- Author byline E-E-A-T (Bankrate pattern) ---- */
.author-byline {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4);
  background: var(--bg-section-alt);
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
}
.author-byline__avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-circle);
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-semibold);
  color: var(--accent);
  overflow: hidden;
}
.author-byline__name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-heading); margin: 0; }
.author-byline__meta { font-size: var(--fs-xs); color: var(--text-muted); margin: 2px 0 0; line-height: var(--lh-snug); }

/* ---- Trust strip logo grid (Stripe pattern) ---- */
.trust-strip {
  text-align: center;
  padding: var(--space-12) 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.trust-strip__title {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin: 0 0 var(--space-6);
}
.trust-strip__logos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-8);
  align-items: center;
  justify-items: center;
}
.trust-strip__logos img,
.trust-strip__logos svg {
  height: 32px;
  width: auto;
  max-width: 140px;
  filter: grayscale(100%);
  opacity: 0.5;
  transition: filter var(--duration-base) var(--ease-out), opacity var(--duration-base) var(--ease-out);
}
.trust-strip__logos img:hover,
.trust-strip__logos svg:hover {
  filter: grayscale(0%);
  opacity: 1;
}

/* ---- "Why trust Valley West" expandable (Bankrate pattern) ---- */
.why-trust {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin: var(--space-6) 0;
  overflow: hidden;
}
.why-trust > summary {
  padding: var(--space-4) var(--space-5);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-heading);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.why-trust > summary::after {
  content: '+';
  font-size: var(--fs-lg);
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-out);
}
.why-trust[open] > summary::after { transform: rotate(45deg); }
.why-trust__body {
  padding: 0 var(--space-5) var(--space-5);
  font-size: var(--fs-sm);
  color: var(--text-body);
  line-height: var(--lh-normal);
}

/* ---- Inline jargon tooltip (Bankrate pattern) ---- */
.tooltip {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  position: relative;
}
.tooltip:hover::after,
.tooltip:focus::after {
  content: attr(data-def);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--color-ink-900);
  color: var(--color-surface-pure);
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  font-style: normal;
  white-space: normal;
  width: 240px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-tooltip);
  line-height: var(--lh-normal);
}

/* =====================================================================
   END DESIGN TOKENS
   ===================================================================== */
