/* ============================================================
   StatsMatters — Full Combined Stylesheet
   (Base + index + all sub-page components)
   ============================================================ */

/* ---------- Color palette ---------- */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #5b6b7a;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --radius: 12px;
  --shadow: 0 6px 18px rgba(16, 32, 54, 0.08);
  --shadow-sm: 0 1px 3px rgba(16, 32, 54, 0.06);
  --ok: #15803d;
  --ok-bg: #e6f4ec;
  --warn: #b45309;
  --warn-bg: #fdf3e3;
  --bad: #b91c1c;
  --bad-bg: #fdecec;
  --soft: #f8fafc;
  --font: "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --radius-lg: 14px;
}

/* ---------- Dark mode (root variables) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1f2e;
    --card: #252b3a;
    --ink: #e2e8f0;
    --muted: #94a3b8;
    --line: #374151;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --soft: #2d3348;
    --ok-bg: #14532d;
    --warn-bg: #451a03;
    --bad-bg: #450a0a;
  }
  .site-nav,
  .card,
  .intro,
  .hero {
    background: var(--card);
  }
  .content,
  .site-nav,
  .stat-card,
  .step {
    border-color: var(--line);
  }
  .content th {
    background: #1e2536;
  }
  .content tr:nth-child(even) {
    background: #232a3c;
  }
  .note,
  .notice {
    background: #2d3348;
    border-color: #4a5568;
    color: #cbd5e1;
  }
  code {
    background: #1e2536;
    border-color: #374151;
    color: #e2e8f0;
  }
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---------- Layout ---------- */
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus {
  top: 8px;
}

/* ---------- Navigation ---------- */
.site-nav {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-nav .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  max-width: 960px;
}
.site-nav a.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
}
.site-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Hero (index page) ---------- */
.hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #3b82f6 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 40px 36px;
  margin-bottom: 32px;
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.25);
}
.hero h1 {
  font-size: 2.1rem;
  margin: 0 0 8px;
  line-height: 1.2;
}
.hero .tagline {
  font-size: 1.15rem;
  opacity: 0.92;
  margin: 0 0 14px;
  font-weight: 400;
}
.hero p {
  font-size: 0.95rem;
  opacity: 0.88;
  margin: 0 0 20px;
  line-height: 1.6;
}
.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.hero-actions a {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.hero-actions .btn-primary {
  background: #fff;
  color: var(--accent-dark);
}
.hero-actions .btn-primary:hover {
  background: #f0f4ff;
  text-decoration: none;
}
.hero-actions .btn-ghost {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.hero-actions .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.25);
  text-decoration: none;
}

/* ---------- Page hero (sub-pages) ---------- */
.page-hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #3b82f6 100%);
  color: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  margin-bottom: 28px;
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.25);
}
.page-hero h1 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 1.8rem;
}
.page-hero .tagline {
  font-size: 1.05rem;
  opacity: 0.92;
  margin: 0 0 10px;
}
.page-hero p {
  font-size: 0.92rem;
  opacity: 0.85;
  margin: 0;
}

/* ---------- Banner (informational strip) ---------- */
.banner {
  background: #f8fafc;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: 0.9rem;
  color: #5b6b7a;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card h2 {
  font-size: 1.05rem;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Card grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
a.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
a.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(16, 32, 54, 0.12);
  text-decoration: none;
}
a.card .cat {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}
a.card h3 {
  font-size: 1.02rem;
  margin: 0 0 6px;
}
a.card p {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}
a.card .arrow {
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 6px;
  display: block;
}

/* ---------- Typography ---------- */
h1 {
  font-size: 1.75rem;
  line-height: 1.25;
  margin: 0 0 8px;
}
h2 {
  font-size: 1.25rem;
  margin: 0 0 4px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
h3 {
  font-size: 1.05rem;
  margin: 0 0 6px;
}
p {
  margin: 0 0 10px;
}

/* ---------- Subtitle ---------- */
.sub {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 16px;
}

/* ---------- Form fields ---------- */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--muted);
}
.field .hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
}
input[type="number"],
input[type="text"],
input[type="date"],
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--card);
  color: var(--ink);
}
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* ---------- Hint (works outside .field too) ---------- */
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Checkbox rows ---------- */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.check input {
  width: auto;
}

/* ---------- Fieldset / legend ---------- */
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 18px 0;
}
legend {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 8px;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
}
.btn-ghost {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  background: var(--line);
}

/* ---------- Actions (button row) ---------- */
.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.actions .err {
  color: var(--bad);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---------- Result cards (show/hide) — fixed for BOTH classes ---------- */
.card.result,
.card.results {
  display: none;
}
.card.result.show,
.card.results.show {
  display: block;
}

/* ---------- Legacy generic results toggling ---------- */
.results {
  display: none;
}
.results.show {
  display: block;
}

/* ---------- KPI row ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.kpi .k {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 6px;
}
.kpi .v {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}
.kpi .s {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Range & metric (wedding calculator) ---------- */
.range {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.metric {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.metric .k {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 4px;
}
.metric .v {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

/* ---------- Budget bars (wedding) ---------- */
.bar-wrap {
  margin: 10px 0;
}
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: var(--ink);
}
.bar {
  background: var(--line);
  border-radius: 6px;
  height: 18px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  border-radius: 6px;
  transition: width 0.3s;
}

/* ---------- Key/value rows ---------- */
.kv {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.kv:last-child {
  border-bottom: none;
}
.kv .k {
  color: var(--muted);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

/* ---------- Notes / notices / callouts ---------- */
.note,
.notice {
  background: var(--soft);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.84rem;
  color: var(--muted);
  margin: 14px 0;
  line-height: 1.5;
}
.callout {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--ink);
  margin: 14px 0;
  font-size: 0.95rem;
}
.callout.good {
  border-left: 5px solid var(--ok);
}
.callout.warn {
  border-left: 5px solid var(--warn);
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 10px 0;
}
th,
td {
  padding: 7px 9px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
th {
  background: var(--soft);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr:nth-child(even) {
  background: var(--soft);
}

/* ---------- Small print / table notes / disclaimers ---------- */
.table-note,
.disclaimer,
.smallprint {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 10px 0;
}

/* ---------- Lock note (state-credit law) ---------- */
.lock {
  background: #fdf3e3;
  border: 1px solid #f0d9a8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #b45309;
  margin: 12px 0;
}

/* ---------- Footer ---------- */
footer {
  margin-top: 36px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
footer a {
  color: var(--accent);
}
footer a:hover {
  text-decoration: underline;
}

/* ---------- Misc section headers ---------- */
.section-header {
  margin: 30px 0 14px;
}
.section-header h2 {
  font-size: 1.25rem;
  margin: 0 0 4px;
}
.section-header p {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

/* ---------- Category chips / tags ---------- */
.cat-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cat-list li {
  background: #eef2ff;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ---------- Intro block (index page) ---------- */
.intro {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 28px;
}
.intro h2 {
  font-size: 1.3rem;
  margin: 0 0 12px;
  color: var(--accent);
}

/* ---------- Statistics strip ---------- */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: center;
}
.stat-card .num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-card .label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}
.stat-card .src {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
  opacity: 0.7;
}

/* ---------- How it works (steps) ---------- */
.how-it-works {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.step {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}
.step .num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.step h3 {
  font-size: 1rem;
  margin: 8px 0 6px;
}
.step p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  .hero {
    padding: 28px 22px;
  }
  .hero h1 {
    font-size: 1.6rem;
  }
  .page-hero {
    padding: 28px 22px;
  }
  .page-hero h1 {
    font-size: 1.4rem;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .stats-strip {
    grid-template-columns: 1fr 1fr;
  }
  .how-it-works {
    grid-template-columns: 1fr;
  }
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
  .range {
    grid-template-columns: 1fr 1fr;
  }
  .wrap {
    padding: 18px 14px 60px;
  }
}

/* ============================================================
   Dark mode (component overrides)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  .page-hero {
    background: linear-gradient(135deg, #172554 0%, #1e3a8a 60%, #1d4ed8 100%);
  }
  .banner,
  .callout,
  .kpi,
  .smallprint,
  .lock,
  .metric,
  .table-note,
  .disclaimer {
    background: #252b3a;
    border-color: #374151;
    color: #e2e8f0;
  }
  .kpi {
    background: #2d3348;
  }
  .sub,
  .hint {
    color: #94a3b8;
  }
  fieldset {
    border-color: #374151;
  }
  legend {
    color: #94a3b8;
  }
}