/* CompoundSnowball — shared stylesheet
   Color tokens follow the dataviz reference palette so the site chrome
   and the charts read as one system. */

:root {
  color-scheme: light;
  --page-plane:     #f9f9f7;
  --surface-1:      #fcfcfb;
  --surface-2:      #ffffff;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --series-1: #2a78d6; /* blue   — contributions / scenario A */
  --series-2: #eb6834; /* orange — scenario B */
  --series-3: #1baf7a; /* aqua   — interest / scenario C */

  --success-text: #006300;
  --milestone: #a67300; /* achievement badges on the chart — decorative, not a data series */

  --radius: 14px;
  --max-width: 980px;
  --font-sans: 'Manrope', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --shadow-sm: 0 1px 2px rgba(11,11,11,0.04);
  --shadow-md: 0 1px 2px rgba(11,11,11,0.03), 0 10px 28px -8px rgba(11,11,11,0.10);
  --shadow-lg: 0 2px 4px rgba(11,11,11,0.04), 0 20px 44px -12px rgba(11,11,11,0.16);
  --accent-glow: 0 0 0 1px rgba(42,120,214,0.10), 0 12px 32px -10px rgba(42,120,214,0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page-plane:     #0d0d0d;
    --surface-1:      #1a1a19;
    --surface-2:      #222220;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;

    --success-text: #0ca30c;
    --milestone: #e0b400;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 1px 0 rgba(255,255,255,0.03) inset, 0 10px 28px -8px rgba(0,0,0,0.5);
    --shadow-lg: 0 1px 0 rgba(255,255,255,0.04) inset, 0 20px 44px -12px rgba(0,0,0,0.6);
    --accent-glow: 0 0 0 1px rgba(57,135,229,0.18), 0 12px 32px -8px rgba(57,135,229,0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-plane:     #0d0d0d;
  --surface-1:      #1a1a19;
  --surface-2:      #222220;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  --success-text: #0ca30c;
  --milestone: #e0b400;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 1px 0 rgba(255,255,255,0.03) inset, 0 10px 28px -8px rgba(0,0,0,0.5);
  --shadow-lg: 0 1px 0 rgba(255,255,255,0.04) inset, 0 20px 44px -12px rgba(0,0,0,0.6);
  --accent-glow: 0 0 0 1px rgba(57,135,229,0.18), 0 12px 32px -8px rgba(57,135,229,0.35);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.55;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Soft ambient color aura fixed behind the whole page — a subtle premium
   backdrop rather than a flat plane. Purely decorative, so it's excluded
   from reduced-motion/print concerns and never intercepts clicks. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(560px 420px at 12% -6%, color-mix(in srgb, var(--series-1) 16%, transparent), transparent 65%),
    radial-gradient(600px 460px at 108% 18%, color-mix(in srgb, var(--series-3) 13%, transparent), transparent 65%);
}

/* Smooth the light/dark switch and general hover/focus states across the
   surfaces most likely to be visible when the theme flips or a value changes. */
.site-header,
.panel,
.stat-tile,
.chart-card,
.ad-slot,
.viz-tooltip,
.scenario-chip,
.field input,
.field select,
.btn {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease,
    box-shadow 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

a { transition: opacity 0.15s ease, color 0.15s ease; }

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.tool-card:hover,
.scenario-chip:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }

:focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
  transition: outline-color 0.15s ease;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--series-1); }
a:hover { opacity: 0.85; }

/* Header */
.site-header {
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
  gap: 12px;
}
.logo {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-mark { display: inline-flex; }
.logo span { color: var(--series-1); }

.site-nav { display: flex; gap: 20px; align-items: center; }
.site-nav-links { display: flex; align-items: center; gap: 24px; }
.site-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
}
.site-nav a:hover { color: var(--text-primary); }

.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1rem;
  transition: background-color 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}
.theme-toggle:hover { transform: rotate(-12deg); }
.theme-toggle:active { transform: scale(0.9); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.2rem;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-primary);
}
@media (max-width: 760px) {
  .site-nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 20px 18px;
    gap: 14px;
  }
  .site-nav-links.is-open { display: flex; }
  .nav-toggle { display: inline-block; }
}

/* Hero */
.hero {
  padding: 44px 0 8px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  margin: 0 0 10px;
}
.hero p {
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto;
  font-size: 1.02rem;
}

/* Calculator layout */
.calc-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 24px;
  margin: 30px 0;
  align-items: start;
}
@media (max-width: 860px) {
  .calc-shell { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-md);
}
.panel h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.field-row.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  /* Reserve room for a 2-line label regardless of whether this particular
     one wraps, so two fields in the same row whose labels wrap differently
     (e.g. "Initial investment ($)" vs "Monthly contribution ($)") still
     line up their inputs instead of one sitting higher than the other. */
  min-height: 3.1em;
  display: flex;
  align-items: flex-end;
}
.field input, .field select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 0.98rem;
  width: 100%;
}
.field .hint { font-size: 0.76rem; color: var(--text-muted); }

.input-with-select { display: flex; gap: 6px; }
.input-with-select input { flex: 1 1 auto; min-width: 0; }
.input-with-select select {
  flex: 0 0 auto;
  width: auto;
  padding-left: 8px;
  padding-right: 4px;
}
@media (max-width: 400px) {
  .input-with-select { flex-wrap: wrap; }
  .input-with-select input { flex-basis: 100%; }
  .input-with-select select { flex: 1 1 auto; }
}

.slider-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.slider-field .slider-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.slider-field label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.slider-field .slider-value {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-weight: 800;
  color: var(--series-1);
  font-size: 0.98rem;
}
.slider-field .slider-value input[type="number"] {
  width: 3.2em;
  text-align: right;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--series-1);
  color: inherit;
  font: inherit;
  font-weight: inherit;
  padding: 0 0 1px;
}
.slider-field .slider-value input[type="number"]:focus {
  outline: none;
  border-bottom-style: solid;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--series-1);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 16px;
}
.toggle-row input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--series-1);
}
.toggle-row label { font-size: 0.88rem; color: var(--text-secondary); }

/* Results / hero figure */
.result-panel { display: flex; flex-direction: column; gap: 18px; }
.hero-figure {
  text-align: center;
  padding: 6px 0 2px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--accent-glow);
}
.hero-figure::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--series-1), var(--series-3));
}
.hero-figure .hf-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.hero-figure .hf-value {
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 4px 0 2px;
  font-variant-numeric: proportional-nums;
  background: linear-gradient(90deg, var(--series-1), var(--series-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-figure .hf-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-tile .st-label { font-size: 0.76rem; color: var(--text-secondary); font-weight: 600; }
.stat-tile .st-value { font-size: 1.15rem; font-weight: 800; margin-top: 4px; }
.stat-tile .st-value.series-1 { color: var(--series-1); }
.stat-tile .st-value.series-2 { color: var(--series-2); }
.stat-tile .st-value.series-3 { color: var(--series-3); }

/* Chart card */
.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 6px;
  box-shadow: var(--shadow-md);
}
.chart-card h2 { margin-top: 0; font-size: 1.05rem; }
.chart-card .chart-sub { font-size: 0.85rem; color: var(--text-muted); margin: -8px 0 12px; }

.viz-root { position: relative; }
.viz-root svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  opacity: 0;
  transition: opacity 0.1s ease;
  white-space: nowrap;
  z-index: 5;
}
.viz-tooltip.is-visible { opacity: 1; }
.viz-tooltip .tt-title { color: var(--text-muted); font-size: 0.72rem; margin-bottom: 4px; }
.viz-tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.viz-tooltip .tt-key { width: 10px; height: 2px; border-radius: 1px; display: inline-block; }
.viz-tooltip .tt-label { color: var(--text-secondary); }
.viz-tooltip .tt-value { color: var(--text-primary); font-weight: 700; margin-left: auto; padding-left: 10px; }

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  justify-content: center;
}
.viz-legend .lg-item { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-secondary); }
.viz-legend .lg-key { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }

.viz-table-toggle {
  background: none;
  border: none;
  color: var(--series-1);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  margin-top: 10px;
  text-decoration: underline;
}
.viz-table-wrap { margin-top: 14px; overflow-x: auto; }
.viz-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.viz-table th, .viz-table td {
  text-align: right;
  padding: 6px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
.viz-table th:first-child, .viz-table td:first-child { text-align: left; font-variant-numeric: normal; }
.viz-table th { color: var(--text-secondary); font-weight: 600; }

/* Scenario chips */
.scenario-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.scenario-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  font-size: 0.82rem;
  animation: chipIn 0.25s ease;
}
.scenario-chip .chip-key { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.scenario-chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}
.scenario-empty { font-size: 0.85rem; color: var(--text-muted); }

.share-row { display: flex; justify-content: center; }
.share-row .btn { width: 100%; justify-content: center; }

.field-note { font-size: 0.76rem; color: var(--text-muted); margin: 2px 0 0; }

.callout {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--series-3);
  border-radius: 8px;
  padding: 12px 14px;
}
.callout-headline { margin: 0 0 4px; font-weight: 700; font-size: 0.92rem; color: var(--success-text); }
.callout-sub { margin: 0; font-size: 0.8rem; color: var(--text-secondary); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--series-1), color-mix(in srgb, var(--series-1) 78%, var(--series-3)));
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11,11,11,0.08), 0 8px 20px -6px color-mix(in srgb, var(--series-1) 55%, transparent);
}
.btn:hover { opacity: 0.94; box-shadow: 0 2px 4px rgba(11,11,11,0.1), 0 12px 26px -6px color-mix(in srgb, var(--series-1) 60%, transparent); }
.btn.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Ad slots */
.ad-slot {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 0.76rem;
  text-align: center;
  padding: 10px;
  margin: 26px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-slot--incontent { min-height: 250px; max-width: 728px; margin-left: auto; margin-right: auto; }
.ad-slot__label { letter-spacing: 0.05em; text-transform: uppercase; }

/* Article / content */
.article { max-width: 760px; margin: 40px auto 50px; }
.article h2 { margin-top: 34px; font-size: 1.3rem; }
.article p { font-size: 1rem; color: var(--text-primary); }
.faq-item { margin-bottom: 18px; }
.faq-item h3 { margin: 0 0 6px; font-size: 1.02rem; }
.faq-item p { margin: 0; color: var(--text-secondary); }

.page-header { padding: 40px 0 8px; }
.page-header h1 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); margin: 0 0 10px; }
.page-header p.lede { color: var(--text-secondary); font-size: 1.02rem; max-width: 700px; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 26px 0 40px;
  margin-top: 20px;
}
.footer-inner { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.footer-inner p { color: var(--text-muted); font-size: 0.85rem; margin: 0; max-width: 640px; }
.footer-nav { display: flex; gap: 18px; }
.footer-nav a { font-size: 0.85rem; text-decoration: none; color: var(--text-secondary); }

.simple-page .article { margin-top: 30px; }
