/* EvenSums - design system v7: financial editorial. Warm paper, ink bands,
   Fraunces display headings, amber brand. All class contracts preserved. */
:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #211d16;
  --ink-2: #2c2720;
  --ink-text: #f5efe4;
  --ink-muted: #b3a996;
  --text: #23201a;
  --muted: #6b6357;
  --border: #e7e0d2;
  --accent: #b45309;
  --accent-hover: #8f4207;
  --accent-soft: #f6ead8;
  --warn-soft: #fdf3e3;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(48, 35, 15, 0.06), 0 8px 24px -18px rgba(48, 35, 15, 0.25);
  --shadow-lift: 0 2px 6px rgba(48, 35, 15, 0.08), 0 16px 32px -16px rgba(48, 35, 15, 0.3);
  --max-width: 960px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --surface: #1d1a15;
    --ink: #0f0d0a;
    --ink-2: #181510;
    --ink-text: #f0e9dc;
    --ink-muted: #8d8371;
    --text: #ece6da;
    --muted: #a39a8a;
    --border: #332d23;
    --accent: #e5a04e;
    --accent-hover: #efb267;
    --accent-soft: #2e2415;
    --warn-soft: #2e2617;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-lift: 0 4px 16px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, .logo { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }

/* Header: ink band */
.site-header {
  background: var(--ink);
  border-bottom: 3px solid var(--accent);
}
.site-header .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.logo {
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink-text);
  text-decoration: none;
}
.logo span { color: var(--accent); }
@media (prefers-color-scheme: light) {
  .logo span { color: #e5a04e; }
}
.site-nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-nav a {
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink-text); }
select.currency-switch {
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--ink-2);
  border-radius: 8px;
  background: var(--ink-2);
  color: var(--ink-muted);
  cursor: pointer;
}
select.currency-switch:hover, select.currency-switch:focus {
  color: var(--ink-text);
  border-color: var(--accent);
}

/* Homepage hero */
.hero {
  background: var(--ink);
  background-image: radial-gradient(ellipse 90% 130% at 85% -20%, rgba(180, 83, 9, 0.35), transparent 55%);
  color: var(--ink-text);
}
.hero .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3.2rem 1rem 2.6rem;
}
.hero .page-title {
  color: var(--ink-text);
  font-size: 2.7rem;
  margin: 0 0 0.5rem;
}
.hero .page-title em {
  font-style: italic;
  color: #e5a04e;
}
.hero .page-subtitle {
  color: var(--ink-muted);
  font-size: 1.08rem;
  margin: 0 0 1.6rem;
  max-width: 42rem;
}
.hero #tool-search {
  background: var(--ink-2);
  border: 1px solid #4a4234;
  color: var(--ink-text);
}
.hero #tool-search::placeholder { color: var(--ink-muted); }
.hero .no-results { color: var(--ink-muted); }
.hero-stats {
  display: flex;
  gap: 2.2rem;
  flex-wrap: wrap;
  margin-top: 1.8rem;
}
.hero-stats div { font-size: 0.85rem; color: var(--ink-muted); }
.hero-stats strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--ink-text);
  font-weight: 600;
}

/* Layout */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}
.page-title { margin: 0.7rem 0 0.3rem; font-size: 2rem; line-height: 1.2; }
.page-subtitle { margin: 0 0 1.5rem; color: var(--muted); max-width: 46rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

/* Calculator form */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}
.field .hint { font-weight: 400; color: var(--muted); }
.field input, .field select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.calc-actions { margin-top: 1.4rem; }
button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 2px 8px -2px rgba(180, 83, 9, 0.5);
  transition: transform 0.12s ease, background 0.12s ease;
}
button.primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
button.primary:active { transform: translateY(0); }

/* Results */
.results { margin-top: 1.6rem; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.stat {
  background: linear-gradient(150deg, var(--accent-soft), var(--surface) 130%);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 0.95rem 1.05rem;
}
.stat .label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat .value {
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.result-note { color: var(--muted); font-size: 0.92rem; margin-top: 0.85rem; }
.chart-wrap { margin-top: 1.4rem; }
canvas.chart { width: 100%; height: auto; }

/* Tables */
.table-wrap { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--border); border-radius: 10px; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  text-align: right;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.data tr:last-child td { border-bottom: none; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent-soft);
}
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--accent-soft) 30%, transparent); }

/* Content sections */
.content h2 {
  font-size: 1.45rem;
  margin-top: 2.2rem;
  padding-top: 0.4rem;
}
.content h2::before {
  content: "";
  display: block;
  width: 2.2rem;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin-bottom: 0.7rem;
}
.content h3 { font-size: 1.1rem; }
.content p, .content li { color: var(--text); max-width: 46rem; }
.formula {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  overflow-x: auto;
}

/* Ad slots - replace the inner comment with your ad network tag (see README) */
.ad-slot {
  min-height: 90px;
  margin: 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8rem;
  background: var(--surface);
}
.ad-slot:empty { display: none; }

/* Affiliate / CTA box. Hidden until affiliate links are live; remove the
   display:none override to restore all boxes site-wide. */
.cta-box { display: none; }
.cta-box {
  background: var(--warn-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}
.cta-box h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.cta-box p { margin: 0 0 0.6rem; font-size: 0.92rem; color: var(--muted); }
.cta-box a.cta-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
}
.cta-box a.cta-link:hover { background: var(--accent-hover); }
.cta-box .disclosure { font-size: 0.75rem; color: var(--muted); margin-top: 0.5rem; }

/* Calculator search */
.search-wrap { margin: 0 0 1.5rem; }
#tool-search {
  width: 100%;
  max-width: 500px;
  padding: 0.75rem 1.05rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#tool-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.no-results { color: var(--muted); }

/* Homepage sections */
body.home main section > h2 {
  font-size: 1.6rem;
  margin: 2.4rem 0 0;
}
body.home main section > h2::after {
  content: "";
  display: block;
  width: 2.6rem;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin-top: 0.45rem;
}

/* Tool cards */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.05rem;
  margin-top: 1.4rem;
}
.tool-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.tool-card:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}
.tool-card h2 { margin: 0 0 0.3rem; font-size: 1.12rem; color: var(--text); }
.tool-card:hover h2 { color: var(--accent); }
.tool-card p { margin: 0; font-size: 0.9rem; color: var(--muted); }
.tool-card .tool-icon {
  width: 40px;
  height: 40px;
  padding: 9px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 11px;
  display: block;
  margin-bottom: 0.7rem;
}
@media (prefers-reduced-motion: reduce) { .tool-card:hover { transform: none; } }

/* FAQ */
details.faq {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.55rem;
  background: var(--surface);
}
details.faq[open] { border-color: var(--accent); }
details.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.98rem;
}
details.faq p { color: var(--muted); }

/* Footer: ink band */
.site-footer {
  border-top: 3px solid var(--accent);
  background: var(--ink);
  margin-top: 3rem;
}
.site-footer .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.8rem 1rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.site-footer nav { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.site-footer a { color: var(--ink-muted); }
.site-footer a:hover { color: var(--ink-text); }
.site-footer .disclaimer { max-width: 46rem; }

/* Cross-promotion banner */
.cross-promo {
  background: linear-gradient(150deg, var(--accent-soft), var(--surface) 140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin: 1.5rem 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.cross-promo p { margin: 0; font-size: 0.95rem; }
.cross-promo a.promo-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.55rem 1.2rem;
  border-radius: 9px;
  white-space: nowrap;
}
.cross-promo a.promo-btn:hover { background: var(--accent-hover); }

/* Share-result button */
.share-link {
  margin-top: 1rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.share-link:hover { color: var(--accent); border-color: var(--accent); }

/* Related tools pills */
.related { margin: 1.75rem 0; }
.related h2 { font-size: 1.15rem; margin: 0 0 0.65rem; }
.related-links { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.related-links a {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.related-links a:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Debt payoff planner rows */
.debt-head, .debt-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.debt-head {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.debt-row input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.debt-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
@media (max-width: 640px) {
  .debt-head { display: none; }
  .debt-row { grid-template-columns: 1fr 1fr; }
}

/* Homepage splash */
.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--ink);
  background-image: radial-gradient(ellipse 90% 130% at 85% -20%, rgba(180, 83, 9, 0.4), transparent 55%);
  animation: splash-out 0.5s ease 1.1s forwards;
}
.splash svg { width: 72px; height: 72px; color: #e5a04e; animation: splash-pop 0.6s cubic-bezier(0.2, 0.8, 0.3, 1.15); }
.splash .splash-word {
  color: var(--ink-text);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.7rem;
  animation: splash-rise 0.6s ease;
}
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }
@keyframes splash-pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes splash-rise { from { transform: translateY(10px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .splash { display: none; } }

@media (max-width: 600px) {
  .page-title { font-size: 1.55rem; }
  .hero .page-title { font-size: 2rem; }
}

/* Print: just the tool and its results */
@media print {
  .site-header, .hero, .ad-slot, .cross-promo, .search-wrap, .share-link, .related,
  .splash, .site-footer nav, button.primary, select.currency-switch { display: none !important; }
  body { background: #fff; }
  .card, .stat { box-shadow: none; border: 1px solid #ddd; }
}
