/* HomeCrunch — modern & friendly home buyer toolkit
   Shared styles across all pages. */

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --accent: #F59E0B;
  --accent-light: #FEF3C7;
  --success: #10B981;
  --success-light: #D1FAE5;
  --danger: #EF4444;
  --bg: #FAFAF9;
  --surface: #FFFFFF;
  --surface-alt: #F3F4F6;
  --text: #111827;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow: 0 4px 12px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.04);
  --shadow-lg: 0 20px 40px -12px rgba(79, 70, 229, 0.18);
  --max-width: 1100px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 2.5vw, 2rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
p  { margin: 0 0 1em; color: var(--text); }
.muted { color: var(--text-muted); }

/* ---------- Layout ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

main { padding: 2rem 0 4rem; }

/* ---------- Header / Nav ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  display: grid; place-items: center;
  color: white;
  box-shadow: var(--shadow-sm);
}
.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0; padding: 0;
  flex-wrap: wrap;
}
.nav-links a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  transition: all 0.15s ease;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--surface-alt);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--primary);
  background: var(--primary-light);
}
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    padding: 0.5rem 0;
  }
  .nav-links.open { display: flex; }
  .nav { flex-wrap: wrap; }
  .nav-toggle { display: inline-flex; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 3.5rem 0 2rem;
  text-align: center;
}
.hero .eyebrow {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}
.hero h1 { max-width: 18ch; margin: 0 auto 0.6rem; }
.hero p.lead {
  max-width: 60ch;
  margin: 0 auto 1.75rem;
  font-size: 1.15rem;
  color: var(--text-muted);
}

.cta-row {
  display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.97rem;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
  font-family: var(--font);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-lg);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); }
.btn-ghost {
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover { background: var(--primary-light); }

/* ---------- Cards / Grid ---------- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #C7D2FE;
  text-decoration: none;
}
.tool-card .icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
  display: grid; place-items: center;
  margin-bottom: 0.5rem;
}
.tool-card.amber .icon { background: var(--accent-light); color: var(--accent); }
.tool-card.green .icon { background: var(--success-light); color: var(--success); }
.tool-card.pink .icon { background: #FCE7F3; color: #DB2777; }
.tool-card h3 { margin: 0; }
.tool-card p { color: var(--text-muted); margin: 0; font-size: 0.95rem; }

/* ---------- Calculator pages ---------- */
.calc-header {
  margin-bottom: 1.75rem;
}
.calc-header h1 { margin-bottom: 0.5rem; }
.calc-header p { color: var(--text-muted); max-width: 65ch; font-size: 1.05rem; }

.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 880px) {
  .calc-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.panel h2 { font-size: 1.15rem; margin-bottom: 1.25rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.field label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
}
.field .hint { color: var(--text-muted); font-weight: 400; font-size: 0.82rem; }

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap .prefix,
.input-wrap .suffix {
  position: absolute;
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}
.input-wrap .prefix { left: 0.9rem; }
.input-wrap .suffix { right: 0.9rem; }

.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.input-wrap .prefix + input { padding-left: 1.7rem; }
.input-wrap input + .suffix ~ input,
.input-wrap input:has(+ .suffix) { padding-right: 2rem; }
.input-wrap.has-suffix input { padding-right: 2.2rem; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- Result panel ---------- */
.result-headline {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.result-headline .label {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin-bottom: 0.25rem;
}
.result-headline .value {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.result-headline .sub {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

.breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
}
.breakdown li {
  display: flex;
  justify-content: space-between;
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.97rem;
}
.breakdown li:last-child { border-bottom: 0; }
.breakdown li .k { color: var(--text-muted); }
.breakdown li .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.breakdown li.total { border-top: 2px solid var(--text); border-bottom: none; padding-top: 0.85rem; margin-top: 0.4rem; }
.breakdown li.total .k, .breakdown li.total .v { font-weight: 700; font-size: 1.05rem; }

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
  display: flex;
  margin: 1rem 0;
}
.bar > span { display: block; height: 100%; }

.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.legend .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 2rem 0;
  margin-top: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.disclaimer {
  background: var(--accent-light);
  border: 1px solid #FDE68A;
  color: #78350F;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  margin-top: 1.25rem;
}
.disclaimer strong { color: #92400E; }

/* ---------- Ad slots ----------
   Each slot is a wrapper that currently holds a cross-promo card.
   When you're approved for AdSense (or another network), replace the
   inner <a class="cross-promo"> with the network's ad code. The slot
   wrapper and its data-ad-slot attribute can stay.                   */
.ad-slot {
  margin: 1.75rem auto;
  width: 100%;
}
.ad-leaderboard { max-width: 728px; }
.ad-inline      { max-width: 100%; }

/* Cross-promo card (currently sits inside the ad slot) */
.cross-promo {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, #FAFAF9 100%);
  border: 1px solid #C7D2FE;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.15s ease;
}
.cross-promo:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
  text-decoration: none;
}
.cross-promo .cp-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--primary);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.cross-promo .cp-text { flex: 1; min-width: 0; }
.cross-promo .cp-title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 2px;
  line-height: 1.3;
}
.cross-promo .cp-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0;
}
.cross-promo .cp-arrow {
  flex: 0 0 auto;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.25rem;
}
@media (max-width: 480px) {
  .cross-promo { padding: 0.95rem 1rem; gap: 0.75rem; }
  .cross-promo .cp-title { font-size: 0.95rem; }
  .cross-promo .cp-desc { font-size: 0.82rem; }
}

/* ---------- Amortization table ---------- */
.amort-section { margin-top: 2rem; }
.amort-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toggle-group {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 4px;
}
.toggle-group button {
  border: none;
  background: transparent;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
}
.toggle-group button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.amort-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.amort-table thead th {
  text-align: right;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.7rem 0.85rem;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
}
.amort-table thead th:first-child { text-align: left; }
.amort-table tbody td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
.amort-table tbody td:first-child { text-align: left; font-weight: 600; }
.amort-table tbody tr:hover { background: var(--primary-light); }
.amort-table tbody tr:last-child td { border-bottom: none; }
.amort-scroll { max-height: 480px; overflow-y: auto; }

/* ---------- Affiliate disclosure (in footer) ---------- */
.site-disclosure {
  max-width: var(--max-width);
  margin: 1rem auto 0;
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
}
.site-disclosure p {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
  line-height: 1.55;
  max-width: 70ch;
  margin-left: auto;
  margin-right: auto;
}
.site-disclosure strong { color: var(--text); }

/* ---------- Cookie consent banner ---------- */
.hc-consent {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.18);
  z-index: 100;
  padding: 1.25rem;
  transform: translateY(150%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), opacity 0.25s ease;
}
.hc-consent.open {
  transform: translateY(0);
  opacity: 1;
}
.hc-consent-inner {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.hc-consent-text strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.hc-consent-text p {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.hc-consent-text a { color: var(--primary); }
.hc-consent-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.hc-consent-actions .btn {
  padding: 0.55rem 1.1rem;
  font-size: 0.92rem;
  box-shadow: none;
}
@media (max-width: 480px) {
  .hc-consent {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 1rem;
  }
  .hc-consent-actions { justify-content: stretch; }
  .hc-consent-actions .btn { flex: 1; }
}

/* ---------- Tips section ---------- */
.tips {
  margin-top: 2.5rem;
}
.tips h2 { margin-bottom: 1rem; }
.tip-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.tip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
}
.tip h4 { margin: 0 0 0.3rem; font-size: 1rem; }
.tip p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
