/* =========================================================
   Coast FIRE Calculator — styles
   ========================================================= */

:root {
  --teal: #0fb3a3;
  --teal-600: #0e9c8e;
  --blue: #0e90ba;
  --indigo: #1f4ea8;
  --gold: #ffce3a;
  --gold-deep: #f4a922;

  --bg: #f4f7fb;
  --bg-soft: #eef3f9;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --border: #e3e9f2;
  --text: #142033;
  --text-soft: #51607a;
  --text-faint: #8794a8;
  --accent: var(--blue);
  --accent-grad: linear-gradient(135deg, var(--teal) 0%, var(--blue) 55%, var(--indigo) 100%);
  --good: #12a36b;
  --good-bg: #e6f7ef;
  --warn: #d98300;
  --warn-bg: #fdf3e2;

  --shadow-sm: 0 1px 2px rgba(20,32,51,.06), 0 1px 3px rgba(20,32,51,.05);
  --shadow-md: 0 6px 20px rgba(20,32,51,.08), 0 2px 6px rgba(20,32,51,.05);
  --shadow-lg: 0 18px 50px rgba(16,40,80,.14);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --maxw: 1120px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg-soft: #0e1626;
  --surface: #131c2e;
  --surface-2: #18233a;
  --border: #25324a;
  --text: #eaf1fb;
  --text-soft: #a9b7cd;
  --text-faint: #7787a0;
  --accent: #36b6e0;
  --good: #36d399;
  --good-bg: #103128;
  --warn: #ffc14d;
  --warn-bg: #332611;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; color: var(--text); }

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

.visually-hidden, .skip-link:not(:focus) {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: 12px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 10px 16px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-weight: 600;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { border-radius: 8px; box-shadow: var(--shadow-sm); }
.brand-text strong { color: var(--accent); font-weight: 800; }

.primary-nav { display: flex; gap: 6px; margin-left: 8px; }
@media (max-width: 720px) { .primary-nav { display: none; } }
.primary-nav a {
  color: var(--text-soft); font-weight: 600; font-size: .94rem;
  padding: 8px 12px; border-radius: 10px;
}
.primary-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.lang-picker {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 10px 6px 12px; color: var(--text-soft);
}
.lang-picker .globe { flex: none; }
.lang-picker select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  font: inherit; font-weight: 600; font-size: .9rem; color: var(--text);
  padding-right: 4px; cursor: pointer;
}
.lang-picker select:focus { outline: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft);
  border-radius: 12px; cursor: pointer; transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { color: var(--text); background: var(--bg-soft); }
.icon-btn:active { transform: scale(.94); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ---------- Hero ---------- */
.hero { padding: clamp(36px, 6vw, 72px) 0 8px; text-align: center; }
.eyebrow {
  display: inline-block; margin: 0 0 14px; font-weight: 700; font-size: .82rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--teal-600);
  background: color-mix(in srgb, var(--teal) 14%, transparent);
  padding: 6px 14px; border-radius: 999px;
}
[data-theme="dark"] .eyebrow { color: #4fd6c6; }
.hero h1 {
  margin: 0 0 14px; font-size: clamp(2.1rem, 5.5vw, 3.4rem); font-weight: 800;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { margin: 0 auto; max-width: 640px; font-size: clamp(1.02rem, 2.4vw, 1.2rem); color: var(--text-soft); }

/* ---------- Calculator layout ---------- */
.calculator { padding: clamp(20px, 4vw, 36px) 0 8px; }
.calc-grid { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: clamp(18px, 3vw, 28px); 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-lg); padding: clamp(18px, 3vw, 26px); box-shadow: var(--shadow-md);
}
.panel-title { margin: 0 0 16px; font-size: 1.15rem; font-weight: 700; }

.inputs { position: sticky; top: 80px; }
@media (max-width: 880px) { .inputs { position: static; } }

.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; font-size: .9rem; margin-bottom: 7px; color: var(--text); }
.field .hint { font-weight: 400; color: var(--text-faint); font-size: .8rem; }
.cur-tag::before { content: ""; }

.field input[type="text"],
.field select {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
.field select { cursor: pointer; }
.field input[type="text"]:focus,
.field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.money-input { position: relative; display: flex; align-items: center; }
.money-input .cur-sym {
  position: absolute; left: 13px; color: var(--text-faint); font-weight: 600; pointer-events: none;
}
.field .money-input input[type="text"] { padding-left: 30px; }

.slider-field .hint { margin: 8px 0 0; }
.slider-out {
  font-weight: 800; font-size: 1rem; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.slider-field.highlight .slider-out { color: var(--gold-deep); background: color-mix(in srgb, var(--gold) 26%, transparent); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 6px 0;
  border-radius: 999px; background: var(--border); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow-sm);
  transition: transform .1s;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--surface);
  border: 3px solid var(--accent); box-shadow: var(--shadow-sm);
}
.slider-field.highlight input[type="range"]::-webkit-slider-thumb { border-color: var(--gold-deep); }
.slider-field.highlight input[type="range"]::-moz-range-thumb { border-color: var(--gold-deep); }

.advanced { margin: 4px 0 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.advanced summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--text-soft); list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "▸"; display: inline-block; margin-right: 8px; transition: transform .15s; color: var(--text-faint); }
.advanced[open] summary::before { transform: rotate(90deg); }
.advanced .field { margin-top: 14px; margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer;
  border-radius: 12px; padding: 12px 18px; border: 1.5px solid transparent;
  transition: transform .1s, box-shadow .15s, background .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { box-shadow: var(--shadow-lg); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-soft); }
.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-reset { width: 100%; margin-top: 4px; }

/* ---------- Results ---------- */
.results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.status-banner {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--text-faint);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.status-banner.good { border-left-color: var(--good); background: var(--good-bg); }
.status-banner.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.status-icon { font-size: 1.7rem; line-height: 1; }
.status-title { margin: 0; font-weight: 800; font-size: 1.05rem; }
.status-detail { margin: 2px 0 0; color: var(--text-soft); font-size: .92rem; }

/* 2x2 grid: the results column is never wide enough for 4 comfortable cards */
.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 380px) { .stat-cards { grid-template-columns: 1fr; } }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
}
.stat-card.accent { background: var(--accent-grad); border: 0; color: #fff; }
.stat-card.accent .stat-label, .stat-card.accent .stat-foot { color: rgba(255,255,255,.85); }
.stat-label { margin: 0 0 6px; font-size: .78rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--text-faint); }
.stat-value { margin: 0; font-size: clamp(1.35rem, 3vw, 1.7rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-foot { margin: 6px 0 0; font-size: .78rem; color: var(--text-faint); }

.chart-panel { padding: clamp(16px, 2.5vw, 22px); }
.chart-head { margin-bottom: 8px; }
.chart-head .panel-title { margin-bottom: 2px; }
.chart-head .hint { margin: 0; color: var(--text-faint); font-size: .82rem; }
.chart-wrap { position: relative; width: 100%; }
#growthChart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-tooltip {
  position: absolute; transform: translate(-50%, -115%); pointer-events: none;
  background: var(--text); color: var(--surface); padding: 7px 10px; border-radius: 8px;
  font-size: .78rem; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-md); z-index: 5;
}
[data-theme="dark"] .chart-tooltip { background: #060b15; color: #eaf1fb; }
.chart-tooltip b { display: block; font-weight: 800; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; list-style: none; margin: 14px 0 0; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--text-soft); }
.swatch { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
.swatch-grow { background: var(--blue); height: 10px; border-radius: 3px; }
.swatch-coast { background: var(--teal); border-bottom: 2px dashed var(--teal); height: 0; }
.swatch-target { background: var(--gold-deep); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.actions .btn { flex: 1 1 auto; }
.actions-note { margin: -4px 0 0; font-size: .86rem; color: var(--good); font-weight: 600; }
.disclaimer-inline { margin: 0; font-size: .8rem; color: var(--text-faint); }

/* ---------- Content / SEO article ---------- */
.content { max-width: 760px; padding-top: clamp(36px, 6vw, 64px); padding-bottom: 24px; }
.content h2 { margin: 2em 0 .5em; font-size: clamp(1.4rem, 3.2vw, 1.85rem); font-weight: 800; }
.content h2:first-child { margin-top: 0; }
.content h3 { margin: 1.6em 0 .4em; font-size: clamp(1.1rem, 2.6vw, 1.3rem); font-weight: 700; color: var(--text); }
.content p { margin: 0 0 1.1em; color: var(--text-soft); font-size: 1.04rem; }
.content strong { color: var(--text); }
.content ol, .content ul { color: var(--text-soft); padding-left: 1.3em; margin: 0 0 1.2em; }
.content li { margin-bottom: .6em; }
.content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
}
.content .formula {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: 14px 18px; font-size: 1.05rem; color: var(--text);
  box-shadow: var(--shadow-sm); overflow-x: auto;
}

/* ---------- Related calculators (internal links) ---------- */
.related { padding: clamp(24px, 4vw, 40px) 0 8px; }
.related .container { max-width: 980px; }
.related h2 { margin: 0 0 16px; font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 800; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .related-grid { grid-template-columns: 1fr; } }
.related-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.related-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); text-decoration: none; }
.rc-title { font-weight: 700; color: var(--accent); font-size: 1.02rem; }
.related-card:hover .rc-title { text-decoration: underline; }
.rc-note { font-size: .86rem; color: var(--text-soft); }

/* ---------- Embed / backlink CTA ---------- */
.embed-cta { padding: clamp(24px, 4vw, 40px) 0 8px; }
.embed-cta .container { max-width: 760px; }
.embed-cta h2 { margin: 0 0 .4em; font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 800; }
.embed-cta p { margin: 0 0 16px; color: var(--text-soft); }
.embed-box {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
}
.embed-code {
  width: 100%; resize: vertical; min-height: 96px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; line-height: 1.5;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px;
}
.embed-code:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.embed-box .btn { align-self: flex-start; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; background: var(--surface); border-top: 1px solid var(--border); }
.footer-grid { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-block: 28px 18px; }
.footer-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { color: var(--text-soft); font-weight: 600; font-size: .92rem; }
.footer-legal { border-top: 1px solid var(--border); padding-block: 18px 28px; }
.footer-legal p { margin: 0 0 8px; font-size: .82rem; color: var(--text-faint); }
.footer-legal .copyright { margin: 0; }

/* ---------- Small print page (about/privacy) ---------- */
.doc { max-width: 760px; padding-block: clamp(28px, 5vw, 56px); }
.doc h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 .5em; }
.doc h2 { font-size: 1.3rem; margin: 1.6em 0 .4em; }
.doc p, .doc li { color: var(--text-soft); }
.doc a { font-weight: 600; }

/* number count-up animation helper */
.stat-value, .slider-out { transition: color .2s; }
