/* =========================================================================
   Dhan Matters — Glassmorphism design system
   ========================================================================= */

:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Light theme */
  --bg: #eef1f8;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-shadow: 0 18px 50px -20px rgba(31, 41, 84, 0.35);
  --menu-bg: #ffffff; /* solid for the mobile dropdown — no bleed-through */

  --field-bg: rgba(255, 255, 255, 0.55);
  --field-border: rgba(148, 163, 184, 0.4);
  --field-focus: rgba(255, 255, 255, 0.9);

  --hairline: rgba(148, 163, 184, 0.22);

  /* Default accent (overridden per-calculator by JS) */
  --accent-1: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-ink: #4f46e5;

  --good: #10b981;
  --info: #3b82f6;
  --warn: #f59e0b;
  --bad: #ef4444;

  --radius: 22px;
  --radius-sm: 14px;
}

[data-theme="dark"] {
  --bg: #070a18;
  --ink: #e8ecf8;
  --ink-soft: #aab4d4;
  --ink-faint: #6b7493;

  --glass-bg: rgba(22, 27, 51, 0.55);
  --glass-bg-strong: rgba(26, 32, 60, 0.72);
  --glass-border: rgba(148, 163, 220, 0.22);
  --glass-shadow: 0 24px 60px -22px rgba(0, 0, 0, 0.75);
  --menu-bg: #0b0f20;

  --field-bg: rgba(13, 18, 38, 0.55);
  --field-border: rgba(148, 163, 220, 0.22);
  --field-focus: rgba(20, 26, 52, 0.92);

  --hairline: rgba(148, 163, 220, 0.16);
  --accent-ink: #c7b9ff;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.4s ease, color 0.4s ease;
}

/* ---------- Decorative gradient backdrop ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  transition: background 0.6s ease;
  animation: float 18s ease-in-out infinite;
}
.blob-1 { width: 46vw; height: 46vw; top: -10vw; left: -8vw;
  background: radial-gradient(circle at 30% 30%, var(--accent-1), transparent 70%); }
.blob-2 { width: 40vw; height: 40vw; top: 8vw; right: -10vw;
  background: radial-gradient(circle at 70% 30%, #22d3ee, transparent 70%); animation-delay: -4s; }
.blob-3 { width: 38vw; height: 38vw; bottom: -12vw; left: 18vw;
  background: radial-gradient(circle at 40% 60%, var(--accent-2), transparent 70%); animation-delay: -8s; }
.blob-4 { width: 30vw; height: 30vw; bottom: 4vw; right: 6vw;
  background: radial-gradient(circle at 50% 50%, #f0abfc, transparent 70%); animation-delay: -12s; opacity: 0.4; }
[data-theme="dark"] .blob { opacity: 0.4; }
[data-theme="dark"] .blob-4 { opacity: 0.3; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(3vw, 4vw) scale(1.08); }
  66%      { transform: translate(-3vw, -2vw) scale(0.96); }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

/* ---------- Glass utilities ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.glass-soft {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--glass-border);
}

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  border-left: none;
  border-right: none;
  border-top: none;
  border-radius: 0;
}
.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.brand-logo {
  width: 42px;
  height: 42px;
  display: block;
  background: url("../assets/logo.svg") center/contain no-repeat;
  filter: drop-shadow(0 4px 10px rgba(13, 148, 136, 0.4));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.02rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-text small { font-size: 0.7rem; color: var(--ink-soft); margin-top: 2px; }

.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--ink);
  transition: transform 0.2s ease;
}
.theme-toggle:hover { transform: scale(1.08) rotate(-12deg); }

.tabs {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.tab {
  border: 1px solid var(--field-border);
  background: var(--glass-bg);
  color: var(--ink-soft);
  padding: 8px 15px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); transform: translateY(-1px); }
.tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 8px 20px -8px var(--accent-1);
}

.nav-menu-btn {
  display: none;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ink);
}

/* ---------- View / layout ---------- */
.view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 22px 10px;
}
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Card ---------- */
.card {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 26px;
}
.card-head {
  padding: 22px 26px;
  background: linear-gradient(120deg, var(--accent-soft), transparent 70%);
  border-bottom: 1px solid var(--hairline);
}
.card-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-head p { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.9rem; }
.card-body { padding: 24px 26px; }

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 4px 0 14px;
}
.subcard {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 18px;
  background: var(--glass-bg);
}

/* ---------- Forms ---------- */
.grid { display: grid; gap: 16px 20px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field > label .req { color: var(--bad); }
.field .hint { font-size: 0.72rem; color: var(--ink-faint); }

input, select {
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: 11px;
  padding: 11px 13px;
  width: 100%;
  min-width: 0; /* let grid tracks size equally instead of input intrinsic width */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
input::placeholder { color: var(--ink-faint); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-1);
  background: var(--field-focus);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.inline-field { display: flex; gap: 8px; }
.inline-field select { width: auto; flex-shrink: 0; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.check input { width: 17px; height: 17px; accent-color: var(--accent-1); cursor: pointer; }
.checks-row { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; }

.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 4px; }
.presets .preset-label { font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); }
.chip {
  border: 1px solid var(--field-border);
  background: var(--glass-bg);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.16s ease;
}
.chip:hover { color: var(--ink); }
.chip.active { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-1); }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  border-radius: 13px;
  padding: 13px 20px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 12px 26px -12px var(--accent-1);
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -14px var(--accent-1); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; margin-top: 26px; }

/* Smoothly revealed option panels (Step-up / Monte Carlo) — avoids layout jump */
.collapsible {
  display: grid;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.3s ease;
}
.collapsible.open { max-height: 260px; opacity: 1; margin-top: 16px; }

.btn-ghost {
  background: var(--glass-bg);
  color: var(--accent-ink);
  border: 1px solid var(--accent-1);
  box-shadow: none;
  font-size: 0.86rem;
  padding: 11px 16px;
}
.btn-ghost:hover { background: var(--accent-soft); transform: translateY(-1px); box-shadow: none; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn-ghost { flex: 1; min-width: 130px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-add {
  background: var(--glass-bg);
  color: var(--accent-ink);
  border: 1px dashed var(--accent-1);
  box-shadow: none;
  font-size: 0.8rem;
  padding: 7px 13px;
}
.btn-add:hover { background: var(--accent-soft); transform: none; box-shadow: none; }

/* ---------- Results ---------- */
.results { margin-top: 22px; display: grid; gap: 16px; }
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  background: linear-gradient(150deg, var(--stat-tint, var(--accent-soft)), transparent);
  position: relative;
  overflow: hidden;
}
.stat .label { font-size: 0.76rem; color: var(--ink-soft); font-weight: 600; }
.stat .value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 2px; color: var(--stat-color, var(--accent-ink)); }
.stat .sub { font-size: 0.72rem; color: var(--ink-faint); }

.tint-green  { --stat-tint: rgba(16,185,129,0.16);  --stat-color:#059669; }
.tint-blue   { --stat-tint: rgba(59,130,246,0.16);  --stat-color:#2563eb; }
.tint-purple { --stat-tint: rgba(139,92,246,0.16);  --stat-color:#7c3aed; }
.tint-pink   { --stat-tint: rgba(236,72,153,0.16);  --stat-color:#db2777; }
.tint-orange { --stat-tint: rgba(245,158,11,0.18);  --stat-color:#d97706; }
.tint-red    { --stat-tint: rgba(239,68,68,0.16);   --stat-color:#dc2626; }
.tint-teal   { --stat-tint: rgba(20,184,166,0.16);  --stat-color:#0d9488; }
[data-theme="dark"] .tint-green  { --stat-color:#34d399; }
[data-theme="dark"] .tint-blue   { --stat-color:#60a5fa; }
[data-theme="dark"] .tint-purple { --stat-color:#a78bfa; }
[data-theme="dark"] .tint-pink   { --stat-color:#f472b6; }
[data-theme="dark"] .tint-orange { --stat-color:#fbbf24; }
[data-theme="dark"] .tint-red    { --stat-color:#f87171; }
[data-theme="dark"] .tint-teal   { --stat-color:#2dd4bf; }

.banner {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 0.85rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.banner-warn { background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.4); color: #b45309; }
.banner-info { background: var(--accent-soft); border: 1px solid var(--accent-1); color: var(--accent-ink); }
[data-theme="dark"] .banner-warn { color: #fcd34d; }

.info-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 4px; }
.info-card { border-radius: var(--radius-sm); padding: 14px 16px; border: 1px solid var(--hairline); background: var(--glass-bg); font-size: 0.84rem; }
.info-card b { display: block; margin-bottom: 4px; }

/* ---------- Charts ---------- */
.charts { display: grid; gap: 22px; grid-template-columns: 1fr 1fr; }
.chart-card { border-radius: var(--radius); padding: 20px 22px; }
.chart-card h3 { margin: 0 0 14px; font-size: 1rem; font-weight: 700; }
.chart-wrap { position: relative; height: 300px; }

/* details table for goal / debt */
.kv { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.kv td:last-child { text-align: right; font-weight: 700; }
.kv tr:last-child td { border-bottom: none; }

.repeat-row {
  display: grid;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  margin-bottom: 12px;
  position: relative;
}
.repeat-row .remove {
  position: absolute; top: 8px; right: 10px;
  border: none; background: transparent; color: var(--ink-faint);
  cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.repeat-row .remove:hover { color: var(--bad); }
/* Reserve equal label height so every input in a row starts at the same y */
.repeat-row .field > label { min-height: 34px; align-items: flex-start; }
/* Goal row: 5 fields on one line so the Target Amount column aligns cleanly */
.row-goal { grid-template-columns: 1.3fr 1.5fr 0.85fr 0.85fr 1.3fr; padding-right: 30px; }
@media (max-width: 900px) { .row-goal { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .row-goal { grid-template-columns: 1fr; } }

/* ---------- Welcome page ---------- */
.hero { text-align: center; padding: 32px 12px 8px; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.2rem); font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.hero .grad {
  background: linear-gradient(120deg, var(--accent-1), #22d3ee 50%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap; /* keep "Dhan Matters" on one line; it wraps as a unit on mobile */
}
.hero p { font-size: 1.05rem; color: var(--ink-soft); margin: 14px 0 0; }

.story { padding: 28px 30px; margin: 26px 0; }
.story h2 { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; margin: 0 0 16px; }
.story p { color: var(--ink-soft); line-height: 1.75; font-size: 0.94rem; margin: 0 0 14px; max-width: none; }
.story .lede { font-weight: 700; color: var(--ink); }
.story blockquote {
  margin: 18px 0; padding: 12px 18px;
  border-left: 3px solid var(--accent-1);
  background: var(--accent-soft);
  border-radius: 0 12px 12px 0;
  font-style: italic; color: var(--ink);
}
.story .brandword {
  text-align: center; font-size: 1.6rem; font-weight: 800; margin: 22px 0;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.story .sign { text-align: right; font-weight: 700; color: var(--ink); }

.feature-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 8px; }
.feature {
  border-radius: var(--radius); padding: 24px;
  text-align: center;
}
.feature .ico {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; margin: 0 auto 14px;
  font-size: 1.5rem; color: #fff;
}
.feature h3 { margin: 0 0 6px; font-size: 1.05rem; }
.feature p { margin: 0; color: var(--ink-soft); font-size: 0.86rem; }

.cta { text-align: center; padding: 36px 12px 8px; }
.cta h2 { font-size: 1.6rem; margin: 0 0 8px; }
.cta p { color: var(--ink-soft); margin: 0 0 22px; }
.cta-tabs { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* Mobile home quick-nav (all 8 modules above the story); hidden on desktop */
.home-quicknav { display: none; }

.site-footer {
  max-width: 1180px; margin: 20px auto 0; padding: 26px 22px 40px;
  text-align: center; color: var(--ink-soft); font-size: 0.82rem;
}
.site-footer .disclaimer { color: var(--ink-faint); font-size: 0.74rem; margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .nav-menu-btn { display: grid; }
  /* Group the theme + menu icons at the right edge */
  .theme-toggle { margin-left: auto; }
  .tabs {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    padding: 14px 18px 20px;
    background: var(--menu-bg);
    -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 22px 44px -16px rgba(15, 23, 42, 0.35);
  }
  .tabs.open { display: flex; }
  .tab { text-align: center; padding: 11px 15px; }
  .cols-3, .cols-4 { grid-template-columns: repeat(2, 1fr); }

  /* Show the quick-nav of modules above the story; hide the bottom CTA */
  .home-quicknav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
  .home-quicknav .chip { width: 100%; padding: 13px 10px; font-size: 0.9rem; }
  .cta { display: none; }
}
@media (max-width: 560px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .card-body { padding: 16px; }
  .card-head { padding: 18px 16px; }
  .card-head h2 { font-size: 1.15rem; }
  .brand-text small { display: none; }
  .view { padding: 18px 12px 8px; }
  .nav-inner { padding: 10px 14px; gap: 10px; }
  .brand-logo { width: 36px; height: 36px; }
  .brand-text strong { font-size: 0.95rem; }
  .hero { padding: 18px 6px 4px; }
  .story { padding: 20px 16px; }
  .story h2 { font-size: 1.12rem; }
  .story p { font-size: 0.9rem; line-height: 1.7; }
  .stat .value { font-size: 1.3rem; }
  .stat-grid { gap: 12px; }
  .chart-card { padding: 16px 14px; }
  .chart-wrap { height: 240px; }
  .btn-block { margin-top: 20px; }
  .btn-row .btn-ghost { min-width: 0; }
  .presets { gap: 8px; }
  .repeat-row.cols-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .repeat-row.cols-4 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.9rem; }
}
