/* =============================================
   COMPOUNDLY — Compound Interest Calculator
   ============================================= */

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

:root {
  --color-bg: #0D0F0E;
  --color-bg2: #131614;
  --color-bg3: #1A1D1B;
  --color-surface: #1F2220;
  --color-border: rgba(255,255,255,0.08);
  --color-border-strong: rgba(255,255,255,0.14);
  --color-text: #E8EAE8;
  --color-text-muted: #8A9088;
  --color-text-faint: #4A5048;
  --color-accent: #4AE087;
  --color-accent-dim: rgba(74,224,135,0.12);
  --color-accent-dim2: rgba(74,224,135,0.06);
  --color-blue: #2A5EBF;
  --color-green: #1A7A4A;
  --color-card-highlight-bg: rgba(74,224,135,0.08);
  --color-card-highlight-border: rgba(74,224,135,0.25);
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Noise texture overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

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

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--color-accent);
  color: #0D0F0E;
  font-weight: 600;
  font-size: 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

nav {
  display: flex;
  gap: 32px;
}

nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: color 0.2s;
}

nav a:hover {
  color: var(--color-text);
}

/* =============================================
   HERO
   ============================================= */
.hero {
  position: relative;
  padding: 100px 0 80px;
  overflow: hidden;
}

.hero-inner {
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  background: var(--color-accent-dim);
  border: 1px solid var(--color-accent-dim2);
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  margin-bottom: 24px;
  animation: fadeUp 0.6s ease both;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 5rem);
  font-weight: 400;
  line-height: 1.1;
  color: var(--color-text);
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  animation: fadeUp 0.6s ease 0.1s both;
}

h1 em {
  color: var(--color-accent);
  font-style: italic;
}

.hero-sub {
  font-size: 18px;
  color: var(--color-text-muted);
  font-weight: 300;
  max-width: 480px;
  margin: 0 auto 36px;
  line-height: 1.6;
  animation: fadeUp 0.6s ease 0.2s both;
}

.btn-primary {
  display: inline-block;
  background: var(--color-accent);
  color: #0D0F0E;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 32px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  animation: fadeUp 0.6s ease 0.3s both;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(74,224,135,0.25);
  opacity: 0.92;
}

.hero-bg-circle {
  position: absolute;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,224,135,0.06) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
}

/* =============================================
   CALCULATOR
   ============================================= */
.calculator-section {
  padding: 60px 0 80px;
  background: linear-gradient(to bottom, transparent, var(--color-bg2) 10%, var(--color-bg2) 90%, transparent);
}

.calc-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 32px;
  align-items: start;
}

/* --- Inputs Panel --- */
.inputs-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  position: sticky;
  top: 88px;
}

.inputs-panel h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: 28px;
  letter-spacing: -0.01em;
}

.field-group {
  margin-bottom: 22px;
}

.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.input-prefix-wrap,
.input-suffix-wrap {
  display: flex;
  align-items: center;
  background: var(--color-bg3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-prefix-wrap:focus-within,
.input-suffix-wrap:focus-within {
  border-color: var(--color-accent);
}

.prefix, .suffix {
  padding: 0 12px;
  font-size: 14px;
  color: var(--color-text-muted);
  font-weight: 500;
  background: transparent;
  flex-shrink: 0;
}

.inputs-panel input[type="number"],
.inputs-panel select {
  width: 100%;
  background: var(--color-bg3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

.input-prefix-wrap input[type="number"],
.input-suffix-wrap input[type="number"] {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
}

.inputs-panel input[type="number"]::-webkit-inner-spin-button,
.inputs-panel input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.inputs-panel select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A9088' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.inputs-panel input[type="number"]:focus,
.inputs-panel select:focus {
  border-color: var(--color-accent);
  outline: none;
}

/* Range sliders */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--color-border-strong);
  border-radius: 99px;
  margin-top: 12px;
  cursor: pointer;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-bg);
  box-shadow: 0 0 0 1px var(--color-accent);
  transition: transform 0.15s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 3px solid var(--color-bg);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.field-hint {
  font-size: 11px;
  color: var(--color-text-faint);
  margin-top: 6px;
}

/* --- Results Panel --- */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--color-border-strong);
}

.card--highlight {
  background: var(--color-card-highlight-bg);
  border-color: var(--color-card-highlight-border);
}

.card-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.card-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
  font-family: var(--font-body);
}

.card--highlight .card-value {
  color: var(--color-accent);
}

/* Chart */
.chart-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
}

.chart-legend {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

/* Table */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.table-header h3 {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
}

.btn-export {
  background: transparent;
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.btn-export:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr {
  border-bottom: 1px solid var(--color-border);
}

th {
  text-align: right;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 10px 10px;
}

th:first-child {
  text-align: left;
  padding-left: 0;
}

td {
  text-align: right;
  padding: 9px 10px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

td:first-child {
  text-align: left;
  padding-left: 0;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: rgba(255,255,255,0.02);
}

td.growth-pos {
  color: #4AE087;
  font-weight: 500;
}

td.total-col {
  font-weight: 600;
}

/* =============================================
   EXPLAINER
   ============================================= */
.explainer {
  padding: 80px 0;
}

.explainer h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  font-weight: 400;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 48px;
  letter-spacing: -0.02em;
}

.explainer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.explainer-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: border-color 0.2s, transform 0.2s;
}

.explainer-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-3px);
}

.explainer-icon {
  font-size: 24px;
  margin-bottom: 16px;
  color: var(--color-accent);
  font-weight: 600;
}

.explainer-card h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.explainer-card p {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.formula-box {
  background: var(--color-bg3);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 28px 32px;
  text-align: center;
}

.formula-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
  font-weight: 500;
  margin-bottom: 12px;
}

.formula {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(14px, 2.5vw, 20px);
  color: var(--color-text);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
  line-height: 1.8;
}

.formula sup {
  font-size: 0.65em;
}

.formula-note {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.formula-note strong {
  color: var(--color-text);
  font-weight: 600;
}

/* =============================================
   FOOTER
   ============================================= */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 28px 0;
  text-align: center;
}

.site-footer p {
  color: var(--color-text-faint);
  font-size: 13px;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 860px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }

  .inputs-panel {
    position: static;
  }

  nav {
    display: none;
  }

  h1 {
    font-size: 2.8rem;
  }

  .hero {
    padding: 60px 0 50px;
  }
}

@media (max-width: 560px) {
  .summary-cards {
    grid-template-columns: 1fr 1fr;
  }

  .chart-wrap,
  .table-wrap,
  .inputs-panel {
    padding: 20px 18px;
  }

  .formula {
    font-size: 13px;
  }

  h1 {
    font-size: 2.2rem;
  }
}
