/* ──────────────────────────────────────────────────────────
   Compound Interest Calculator — Premium Styles
   Mobile-first, accessible, fast
   ────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-2: #1a2236;
  --surface-3: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #22c55e;
  --accent-soft: #16a34a;
  --accent-glow: rgba(34, 197, 94, 0.25);
  --border: rgba(148, 163, 184, 0.15);
  --error: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0,0,0,0.4);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.2);
  --transition: 0.2s ease;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 20px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11,15,25,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.logo:hover { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
}
.nav-link:hover { color: var(--text); }

/* Hero */
.hero {
  padding: 72px 0 48px;
  text-align: center;
  background:
    radial-gradient(ellipse 60% 60% at 50% 0%, rgba(34,197,94,0.08), transparent 70%),
    radial-gradient(ellipse 40% 40% at 60% 60%, rgba(59,130,246,0.04), transparent 70%);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -1.5px;
  margin: 0 0 16px;
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 540px;
  margin: 0 auto;
}

/* Calculator layout */
.calculator-grid {
  display: grid;
  gap: 32px;
  padding-bottom: 48px;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .calculator-grid {
    grid-template-columns: 340px 1fr;
    padding-bottom: 72px;
  }
}

/* Input panel */
.input-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: max-content;
}

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input, .select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
  width: 100%;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Range input */
.range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  border: 3px solid var(--surface-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}
.range::-webkit-slider-thumb:hover { transform: scale(1.1); }
.range::-moz-range-thumb {
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 50%;
  border: 3px solid var(--surface-2);
  cursor: pointer;
}
.range-value {
  text-align: center;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.92rem;
  margin-top: 4px;
}

.field-hint {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: -2px;
}

/* Output panel */
.output-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 800;
  word-break: break-word;
}
.stat-value.accent { color: var(--accent); }
.stat-value.muted  { color: var(--text-muted); }

/* Chart */
.chart-wrap { position: relative; }
#growth-chart {
  width: 100%;
  max-height: 320px;
  display: block;
}
.chart-caption {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 8px 0 0;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity 0.15s ease;
  min-width: 140px;
}
.chart-tooltip.visible { opacity: 1; }

/* Breakdown table */
.breakdown-details {
  margin-top: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 16px;
}
.breakdown-details summary {
  cursor: pointer;
  padding: 16px 8px;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}
.breakdown-details summary:hover { color: var(--text); }
.breakdown-details summary::before {
  content: '▶';
  font-size: 0.7rem;
  display: inline-block;
  transition: transform 0.2s ease;
}
.breakdown-details[open] summary::before { transform: rotate(90deg); }

.table-wrap { padding: 8px 8px 16px; }
#breakdown-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
#breakdown-table th, #breakdown-table td {
  padding: 10px 8px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
#breakdown-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; text-align: right; }
#breakdown-table td:first-child, #breakdown-table th:first-child { text-align: left; }
#breakdown-table tbody tr:hover { background: rgba(255,255,255,0.03); }
#breakdown-table tbody tr:last-child td { border-bottom: none; color: var(--accent); font-weight: 700; }

/* SEO Article */
.seo-article {
  max-width: 780px;
  padding: 48px 20px 64px;
}
.seo-article h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 16px;
}
.seo-article h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--accent);
}
.seo-article p {
  color: var(--text-muted);
  margin: 0 0 16px;
}

.formula-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 16px 0;
  text-align: center;
  overflow-x: auto;
}
.formula-box code {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  color: var(--accent);
  background: none;
  padding: 0;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  padding: 16px 20px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}
.faq-item summary:hover { background: var(--surface-2); }
.faq-item summary::before {
  content: '+';
  font-size: 1.2rem;
  color: var(--accent);
  width: 20px;
  display: inline-block;
}
.faq-item[open] summary::before { content: '−'; }
.faq-item p {
  padding: 0 20px 16px;
  margin: 0;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 36px 0;
}
.footer-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-links {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.footer-links a:hover { color: var(--accent); }
.small { font-size: 0.85rem; color: var(--text-dim); }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .range::-webkit-slider-thumb { transition: none; }
}

/* Print */
@media print {
  .site-header, .site-footer, .chart-wrap, .breakdown-details, .cookie-banner { display: none; }
  body { background: #fff; color: #000; }
  .input-panel { border: 1px solid #ccc; }
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  z-index: 200;
  transition: transform 0.3s ease;
}
.cookie-banner.hidden { transform: translateY(110%); }
.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.cookie-content span { font-size: 0.85rem; color: var(--text-muted); }
.cookie-content a { color: var(--accent); }
.btn-cookie {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-cookie:hover { background: var(--accent-soft); }
