/* =====================================================================
   DESIGN SYSTEM V3 — single source of truth for layout, alignment,
   responsive scale, and Rocket-Mortgage / Stripe-style centered content.

   Every page should ship with /design-system-v3.css linked AFTER
   /design-system.css. This file overrides legacy inline styles ONLY
   where required to enforce the global system. Run
   `python scripts/sync_v3_css.py` to mirror to all 3 sites.

   Author intent (per ownerand reference: rocketmortgage.com,
   veteransunited.com, stripe.com, bankrate.com):
     - Content max ~1180px, never full-bleed except hero/footer
     - Generous side gutters that scale: 16px mobile → 48px desktop
     - Title container EDGE-ALIGNED with the cards/table beneath it
     - No 3+1 / 4+2 grid orphans — 4 cards = 4 cols, 6 = 3+3
     - No inner section scrolling. Page scrolls. Sections never do.
     - Calculators always render fully (overflow visible, height auto)
     - Live rates table same width as its title
     - Video section under hero compact (clamp 220px – 420px)
     - Header content vertically centered
   ===================================================================== */

/* ---- Design tokens (v3) ---- */
:root {
  --v3-shell-max: 1180px;             /* primary content container */
  --v3-shell-pad: clamp(16px, 4vw, 48px);
  --v3-shell-gap: 24px;
  --v3-section-py: clamp(72px, 9vw, 128px);  /* Stripe-tier breathing room */
  --v3-rates-max: 980px;              /* live rates table is narrower */
  --v3-card-radius: 18px;
  --v3-card-gap: 18px;
  --v3-grid-min-tablet: 720px;
  --v3-video-min: clamp(220px, 38vw, 420px);
  --v3-header-h: 64px;
}

/* =====================================================================
   PHASE 2: SECTION SHELL — Rocket-style centered container
   Every section content container is constrained to 1180px max,
   centered, with generous gutters that scale with viewport.
   ===================================================================== */

/* Sections themselves: own the side padding (clamp scales it) */
section {
  padding-left: var(--v3-shell-pad) !important;
  padding-right: var(--v3-shell-pad) !important;
  padding-top: var(--v3-section-py) !important;
  padding-bottom: var(--v3-section-py) !important;
}
/* Full-bleed sections (hero, dark band) keep edge-to-edge bg */
section.fullBleed {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* The inner content container — every legacy width gets normalized.
   .mx (1200px), .mx14 (1400px), and inline max-width:1200/1100/1400px
   all collapse to the same shell. */
section > .mx,
section > .mx14,
section.fullBleed > .mx,
section.fullBleed > .mx14,
section > .section-shell,
section > [style*="max-width:1200px"],
section > [style*="max-width: 1200px"],
section > [style*="max-width:1400px"],
section > [style*="max-width: 1400px"],
section > [style*="max-width:1100px"],
section > [style*="max-width: 1100px"] {
  max-width: var(--v3-shell-max) !important;
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  box-sizing: border-box !important;
}

/* Full-bleed sections: still constrain inner content to shell width
   (hero text doesn't span 1920px, dark-band text doesn't span 1920px) */
section.fullBleed > .mx14,
section.fullBleed > .mx {
  padding-left: var(--v3-shell-pad) !important;
  padding-right: var(--v3-shell-pad) !important;
}

/* =====================================================================
   PHASE 2: TITLE WIDTH = CONTENT WIDTH (banner edge-aligned)
   The .banner (rounded title block) lives inside the same shell as
   the cards/table beneath it. Banner spans 100% of shell, cards span
   100% of shell -> visual edges line up.
   ===================================================================== */
.banner {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  border-radius: var(--v3-card-radius) !important;
  padding: clamp(20px, 3vw, 32px) clamp(20px, 4vw, 40px) !important;
  margin-bottom: clamp(28px, 4vw, 40px) !important;
  text-align: center !important;
  box-sizing: border-box !important;
  display: block !important;
}
/* Banner background colors (preserve red/gray brand variants) */
.banner.banner-red { background: #FEF2F2 !important; }
.banner.banner-gray { background: #F5F5F5 !important; }
/* Banner without color modifier: transparent (default) */
.banner:not(.banner-red):not(.banner-gray) { background: transparent !important; }
/* Title typography inside banner */
.banner .h2s,
.banner h2 {
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: 100% !important;
  line-height: 1.15 !important;
}
.banner p {
  max-width: 640px;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* =====================================================================
   PHASE 3: CARD GRID SYSTEM — even rows only, never orphans
   Use [data-count="N"] (set via scripts/tag_grids.py) for explicit
   column control. Falls back to legacy .g2/.g3/.g4 column counts.
   ===================================================================== */

/* Base grid behavior — equal heights, equal widths, consistent gap */
.g2, .g3, .g4, .cards-grid {
  display: grid !important;
  gap: var(--v3-card-gap) !important;
  align-items: stretch !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
/* Children stretch to fill row height + flex-column for footer-aligned CTAs */
.g2 > *, .g3 > *, .g4 > *, .cards-grid > * {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

/* DESKTOP — explicit column counts driven by data-count first, class second */
@media (min-width: 1025px) {
  .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }

  /* data-count overrides for proper N->cols mapping (no orphans) */
  [data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  [data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  [data-count="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
  [data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }  /* 3+3 not 4+2 */
  [data-count="7"] { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }  /* 4+3 acceptable */
  [data-count="8"] { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }  /* 4+4 */
  [data-count="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }  /* 3+3+3 */
}

/* TABLET (768–1024px) — 2 columns where class permits, no orphans */
@media (min-width: 768px) and (max-width: 1024px) {
  .g2, .g3, .g4, .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  [data-count="6"], [data-count="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* MOBILE — single column, full-width, vertical stack */
@media (max-width: 767px) {
  .g2, .g3, .g4, .cards-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  [data-count] { grid-template-columns: 1fr !important; }
}

/* =====================================================================
   PHASE 5/6: NO INNER SCROLL + CALCULATOR FULL VISIBILITY
   ===================================================================== */
section,
section > *,
.calculator-wrapper,
.calculator-section,
.calculator-container,
.calcW,
.calc-card,
.hero-calc-card,
[class*="calc-"],
[id*="calculator"] {
  overflow: visible !important;
  max-height: none !important;
}
.calculator-wrapper,
.calculator-section,
.calculator-container,
.calcW,
.calc-card,
.hero-calc-card {
  height: auto !important;
  min-height: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
/* Iframe-based calculators */
iframe[src*="calc"], iframe.calc, iframe.calculator {
  width: 100% !important;
  min-height: 720px !important;
  border: 0 !important;
  display: block !important;
}
/* Allow legitimate modal scrolls */
.vw-mobile-nav,
.sh-mob,
[class*="modal"],
[role="dialog"] {
  overflow: auto !important;
}

/* =====================================================================
   PHASE 7: LIVE RATES — title and table share the SAME width (980px)
   ===================================================================== */
.rates-shell,
section:has(#liveRateTable) > .mx,
section:has(#liveRateTable) > .mx14 {
  max-width: var(--v3-rates-max) !important;
}
#liveRateTable,
table.rates-table,
table#liveRateTable {
  width: 100% !important;
  max-width: 100% !important;
  table-layout: auto !important;
  margin-left: auto !important;
  margin-right: auto !important;
  border-collapse: collapse !important;
}
/* Rates table cells: tighter padding, no horizontal scroll on desktop */
@media (min-width: 768px) {
  #liveRateTable th, #liveRateTable td { white-space: nowrap; padding: 14px 16px !important; }
}
/* Mobile: cells can wrap */
@media (max-width: 767px) {
  #liveRateTable th, #liveRateTable td { white-space: normal; padding: 10px 8px !important; font-size: 12px !important; }
}

/* =====================================================================
   PHASE 8: VIDEO SECTION COMPACT
   ===================================================================== */
.video-section,
section[data-role="video"],
section:has(> .video-frame) {
  padding-top: clamp(28px, 4vw, 56px) !important;
  padding-bottom: clamp(28px, 4vw, 56px) !important;
}
.video-frame, .video-wrap, .vwm-cinematic {
  max-height: var(--v3-video-min) !important;
  aspect-ratio: 16 / 9;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* =====================================================================
   PHASE 9: HEADER VERTICAL CENTERING + GLOBAL CONSISTENCY
   ===================================================================== */
.vw-header,
.vw-header-inner,
.header-inner,
header > .container,
header > .mx,
header > .mx14 {
  display: flex !important;
  align-items: center !important;
}
.vw-header-inner {
  min-height: var(--v3-header-h) !important;
  gap: 16px !important;
}
.vw-nav, .vw-header-actions, .header-actions {
  display: flex !important;
  align-items: center !important;
}
/* Sticky header: ensure backdrop + z-index */
.vw-header { z-index: 50 !important; }

/* =====================================================================
   PHASE 10: RESPONSIVE GUARDS
   Prevent horizontal overflow at any viewport.
   ===================================================================== */
html, body {
  overflow-x: clip !important;
  max-width: 100vw;
}
img, video, canvas, iframe, svg {
  max-width: 100% !important;
  height: auto;
}
table {
  max-width: 100% !important;
}

/* =====================================================================
   PHASE 11: VISUAL POLISH (Rocket / Stripe-style premium feel)
   ===================================================================== */

/* Section line dividers: subtle, never aggressive */
.section-line {
  max-width: var(--v3-shell-max) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
/* Card visual consistency */
.glow-card, .liquid-glass, .flip-card,
[class*="glow-card"], [class*="scenario"] {
  border-radius: var(--v3-card-radius) !important;
  box-sizing: border-box !important;
}
/* Reduce excessive shadow on desktop (Rocket style is restrained) */
@media (min-width: 1025px) {
  .glow-card, .liquid-glass {
    transition: transform .22s ease, box-shadow .22s ease;
  }
}

/* =====================================================================
   PHASE 12 (added 2026-04-25): SLIMMER SLIDERS + CALC OVERFLOW + HEADER
   Refinements addressing visible UI bugs in the live preview.
   ===================================================================== */

/* ---- Sliders: thinner, more refined (was 6px, now 4px) ---- */
input[type="range"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 100% !important;
  height: 4px !important;
  border-radius: 2px !important;
  background: #FEE2E2 !important;
  outline: none !important;
  cursor: pointer;
  margin: 8px 0 !important;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #DC2626;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(220,38,38,0.32), 0 0 0 1px rgba(220,38,38,0.2);
  transition: transform 150ms cubic-bezier(0.215, 0.61, 0.355, 1),
              box-shadow 150ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(220,38,38,0.42), 0 0 0 4px rgba(220,38,38,0.12);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #DC2626;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(220,38,38,0.32);
}

/* ---- Calculator overflow guards (sitewide) ---- */
.cc2col, .p2col, .ftb2col, .afford-2col,
[class*="calc-card"], [class*="hero-calc-card"] {
  overflow: visible !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
/* Calc card padding scales fluidly */
section[id="calculator"] > .mx > .rv > div,
section[id="calculator"] .rv > div[style*="background:rgba(255,255,255"] {
  padding: clamp(20px, 3vw, 40px) clamp(18px, 2.5vw, 36px) !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}
/* Calc 2-col internal grid: ensure children don't overflow at narrow widths */
.cc2col > *, .p2col > *, .ftb2col > *, .afford-2col > * {
  min-width: 0 !important;
}

/* ---- Header: 4 simple direct links, no dropdowns + hamburger ---- */
/* Per user requirement 2026-04-25:
   - 4 important pages aligned next to the logo on the left
   - NO dropdowns
   - Hamburger is the secondary "everything else" nav
   The simplify_header_nav.py script replaces the legacy .sh-tab dropdowns
   with simple <a class="sh-link"> elements. */
.sh-nav.sh-nav-simple {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  flex: 1 1 auto !important;
}
.sh-nav.sh-nav-simple .sh-link {
  display: inline-flex !important;
  align-items: center !important;
  padding: 10px 16px !important;
  font-family: 'Sora', system-ui, sans-serif !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: #374151 !important;
  text-decoration: none !important;
  border-radius: 100px !important;
  transition: background 150ms cubic-bezier(0.215, 0.61, 0.355, 1),
              color 150ms cubic-bezier(0.215, 0.61, 0.355, 1) !important;
  white-space: nowrap !important;
}
.sh-nav.sh-nav-simple .sh-link:hover {
  background: #FEF2F2 !important;
  color: #DC2626 !important;
}
.sh-nav.sh-nav-simple .sh-link.is-active {
  color: #DC2626 !important;
  background: #FEF2F2 !important;
}
/* Mobile: hide the inline links, hamburger handles it all */
@media (max-width: 768px) {
  .sh-nav.sh-nav-simple { display: none !important; }
}
/* Hamburger always visible at all viewports */
.sh-ham {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 44px !important;
  height: 44px !important;
  border: 1px solid #E5E7EB !important;
  border-radius: 100px !important;
  background: transparent !important;
  cursor: pointer !important;
  margin-left: 12px !important;
  transition: background 150ms cubic-bezier(0.215, 0.61, 0.355, 1) !important;
}
.sh-ham:hover { background: #FEF2F2 !important; }

/* Hide any legacy .sh-tab dropdowns that linger if simplify script not run */
.sh-tab .sh-drop { display: none !important; }

/* ---- Hero / section scroll elimination ---- */
/* User requirement: no scrollbar should EVER appear inside a section.
   The page scrolls. Sections never do.
   We allow overflow:hidden (for orb containment) but block auto/scroll. */
section[style*="overflow:auto"],
section[style*="overflow:scroll"],
section[style*="overflow-y:auto"],
section[style*="overflow-y:scroll"],
section[style*="overflow-x:auto"] section[style*="overflow-x:scroll"],
section [style*="overflow:auto"]:not(.sh-mob):not(.vw-mobile-nav):not([role="dialog"]),
section [style*="overflow:scroll"]:not(.sh-mob):not(.vw-mobile-nav):not([role="dialog"]),
section [style*="overflow-y:auto"]:not(.sh-mob):not(.vw-mobile-nav):not([role="dialog"]),
section [style*="overflow-y:scroll"]:not(.sh-mob):not(.vw-mobile-nav):not([role="dialog"]) {
  overflow: visible !important;
  overflow-y: visible !important;
  max-height: none !important;
}
/* Hero blocks: no fixed height that would force scroll */
[class*="hero"][style*="height:"],
[class*="hero"][style*="max-height:"] {
  height: auto !important;
  max-height: none !important;
}
/* Market dashboard, video sections: no inner scroll */
#marketDash, #marketDash > *, [class*="vwm-cinematic"] {
  overflow: visible !important;
  max-height: none !important;
}
/* Legitimate scroll containers stay as-is */
.sh-mob, .vw-mobile-nav, [role="dialog"], [class*="modal"] {
  overflow-y: auto !important;
}

/* ---- Mobile menu (sh-mob) styling refinements ---- */
.sh-mob {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: #fff !important;
  z-index: 100 !important;
  padding: 80px 24px 24px !important;
  overflow-y: auto !important;
  flex-direction: column !important;
  gap: 12px !important;
}
.sh-mob-g {
  padding: 14px 0 !important;
  border-bottom: 1px solid #E5E7EB !important;
}
.sh-mob-g:last-of-type { border-bottom: none !important; }
.sh-mob-t {
  background: transparent !important;
  border: none !important;
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 12px 0 !important;
  font-family: 'Sora', system-ui, sans-serif !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  color: #0a0a0a !important;
  cursor: pointer !important;
  gap: 12px !important;
}
.sh-mob-l {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  padding-left: 32px !important;
  transition: max-height 300ms cubic-bezier(0.215, 0.61, 0.355, 1),
              opacity 300ms cubic-bezier(0.215, 0.61, 0.355, 1) !important;
  overflow: hidden !important;
}
.sh-mob-l a {
  padding: 10px 0 !important;
  font-size: 14px !important;
  color: #6B7280 !important;
  text-decoration: none !important;
  transition: color 150ms;
}
.sh-mob-l a:hover { color: #DC2626 !important; }
.sh-mob-ico {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-right: 12px;
}

/* ---- Hero h1 line-height refinement (1.05 was too tight in some viewports) ---- */
.ht, h1.ht {
  line-height: 1.02 !important;     /* tighter for hero impact */
  letter-spacing: -0.04em !important;
}

/* ---- Visually hidden content (used for screen readers / AI crawlers) ---- */
[style*="position:absolute"][style*="width:1px"][style*="height:1px"][style*="clip:"],
[style*="position: absolute"][style*="width: 1px"][style*="height: 1px"][style*="clip:"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* =====================================================================
   PHASE 13 (added 2026-04-26): TYPOGRAPHY BREATHING + VIDEO SECTION SHRINK
   User feedback: titles too cramped (line-height too tight), Quick Answer
   subpage section eyebrow→h2 spacing too tight, video/cinematic section
   below hero takes up way too much vertical space.
   ===================================================================== */

/* ---- Loosen tight title typography sitewide ---- */
/* Inline letter-spacing of -2px / -4px on big H1/H2 was too aggressive.
   Override to a relative unit that scales properly across viewports. */
h1.ht, h2.h2s,
.ht[style*="font-size:clamp"],
.h2s[style*="font-size:clamp"],
[class*="ht "][style*="letter-spacing:-"],
h2[style*="font-size:48px"],
h2[style*="font-size:68px"],
h2[style*="letter-spacing:-2px"],
h2[style*="letter-spacing:-1.8px"] {
  letter-spacing: -0.018em !important;  /* much less aggressive than -2px on 48px */
  line-height: 1.12 !important;          /* was 1.05, gives breathing room */
}
h1.ht, h1[style*="letter-spacing:-4px"] {
  letter-spacing: -0.025em !important;
  line-height: 1.05 !important;          /* hero gets to be tight */
}

/* ---- Quick Answer subpage section: spacing + h2 size ---- */
/* Pattern: <div ... font-size:11px; color:#DC2626; text-transform:uppercase>Quick Answer</div>
            <h2 ...>The actual question</h2>
   Fix: increase eyebrow margin-bottom + bump h2 size + add line-height. */
div[style*="font-size:11px"][style*="color:#DC2626"][style*="text-transform:uppercase"][style*="letter-spacing:1.5px"] {
  margin-bottom: 14px !important;
  font-size: 12px !important;
  letter-spacing: 0.12em !important;
}
div[style*="font-size:11px"][style*="color:#DC2626"][style*="text-transform:uppercase"][style*="letter-spacing:1.5px"] + h2 {
  font-size: 22px !important;
  line-height: 1.5 !important;
  letter-spacing: -0.012em !important;
  font-weight: 500 !important;
  margin: 0 0 14px 0 !important;
}
div[style*="font-size:11px"][style*="color:#DC2626"][style*="text-transform:uppercase"][style*="letter-spacing:1.5px"] + h2 + p {
  font-size: 16px !important;
  line-height: 1.65 !important;
  color: var(--text-body, #374151) !important;
}

/* ---- Cinematic video section (below hero): kill the 140vh giant ---- */
.vwm-cinematic {
  min-height: auto !important;
  padding: clamp(40px, 5vw, 72px) 0 !important;
}
.vwm-cinematic .vwm-cin-sticky {
  position: relative !important;     /* was sticky, now flows naturally */
  height: auto !important;
  min-height: clamp(280px, 36vw, 460px) !important;
  padding: clamp(24px, 4vw, 56px) 0 !important;
}
.vwm-cinematic .vwm-cin-stage {
  padding: 0 var(--v3-shell-pad, 32px) !important;
  max-width: var(--v3-shell-max, 1180px) !important;
}
/* Frame stack: only show the FIRST frame as static (since we removed scroll mechanic) */
.vwm-cinematic .vwm-cin-frame {
  position: relative !important;
  opacity: 1 !important;
  transform: none !important;
  display: block !important;
}
.vwm-cinematic .vwm-cin-frame:not([data-frame="1"]) {
  display: none !important;
}

/* ---- General section padding sanity (no section taller than its content) ---- */
section { min-height: auto !important; }

/* ---- Pixel-perfect title-to-content alignment ---- */
/* Banner (rounded title block) and the grid below it should share the same
   horizontal edges. Banner uses padding-x = 0, grid uses padding-x = 0,
   both inside the same .mx / .mx14 / .section-shell. */
section > .mx > .banner,
section > .mx14 > .banner,
section > .mx > .rv > .banner,
section > .mx14 > .rv > .banner {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100% !important;
}
/* Grid containers below banners: same width as banner */
section > .mx > .g2,
section > .mx > .g3,
section > .mx > .g4,
section > .mx14 > .g2,
section > .mx14 > .g3,
section > .mx14 > .g4 {
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* =====================================================================
   END DESIGN SYSTEM V3
   ===================================================================== */
