/* =========================================================================
   calculator.us-zj.com — Shared brand theme
   Every calculator under this domain links this file (before its own
   styles.css) to inherit the "private banking" design language shared with
   about-me.us-zj.com and tfa-portal.us-zj.com: dark-first, champagne-gold
   accent, serif display headings + Outfit body, hairline glass cards, no
   icon fonts.

   What lives here: design tokens, base reset, app shell, header, footer,
   and generic reusable atoms (buttons, glass panels/cards, range sliders,
   stat cards, the segmented mode toggle, eyebrow labels, page/hero shell).

   What does NOT live here: anything specific to one calculator's features
   (e.g. Rule of 72's decade-color tokens, its stack visualizer, its chart
   or table layout). Those stay in that calculator's own styles.css, which
   loads after this file and can freely add to or override it.
   ========================================================================= */

/* ---------- 1. Theme tokens ------------------------------------------------ */

:root,
:root[data-theme="dark"] {
  --bg:              #0A0E14;
  --bg-accent:       #12161F;
  --surface:         #141922;
  --surface-2:       #181E29;
  --surface-glass:   rgba(20, 25, 34, 0.68);
  --ink:             #EDE4CE;
  --ink-soft:        rgba(237, 228, 206, 0.72);
  --ink-muted:       rgba(237, 228, 206, 0.46);
  --ink-faint:       rgba(237, 228, 206, 0.26);
  --divider:         rgba(237, 228, 206, 0.10);
  --accent:          #C9A876;
  --accent-soft:     rgba(201, 168, 118, 0.45);
  --accent-deep:     #E0C28A;
  --accent-dim-bg:   rgba(201, 168, 118, 0.10);
  --accent-dim-bd:   rgba(201, 168, 118, 0.28);
  --halo:            radial-gradient(ellipse at 50% 0%, rgba(201,168,118,0.10) 0%, transparent 55%);
  --shadow:          0 30px 80px -30px rgba(0, 0, 0, 0.7);
  --danger:          #CB8375;
  --danger-bg:       rgba(203, 131, 117, 0.12);
  --danger-bd:       rgba(203, 131, 117, 0.38);
  --footer-bg:       #070A0F;
  --footer-ink:      #EDE4CE;
  --footer-ink-soft: rgba(237, 228, 206, 0.55);
  --grain-blend:     screen;
  --grain-opacity:   0.035;
  --font-display:    'DM Serif Display', 'Cormorant Garamond', Georgia, serif;
  --font-body:       'Outfit', system-ui, sans-serif;
  --font-mono:       'JetBrains Mono', 'SFMono-Regular', monospace;
}

:root[data-theme="light"] {
  --bg:              #F1EAD9;
  --bg-accent:       #E7DBBF;
  --surface:         #FBF6E9;
  --surface-2:       #FFFFFF;
  --surface-glass:   rgba(251, 246, 233, 0.72);
  --ink:             #1E1812;
  --ink-soft:        rgba(30, 24, 18, 0.72);
  --ink-muted:       rgba(30, 24, 18, 0.48);
  --ink-faint:       rgba(30, 24, 18, 0.28);
  --divider:         rgba(30, 24, 18, 0.13);
  --accent:          #93712F;
  --accent-soft:     rgba(147, 113, 47, 0.4);
  --accent-deep:     #7A5E33;
  --accent-dim-bg:   rgba(147, 113, 47, 0.09);
  --accent-dim-bd:   rgba(147, 113, 47, 0.26);
  --halo:            radial-gradient(ellipse at 50% 0%, rgba(147,113,47,0.12) 0%, transparent 55%);
  --shadow:          0 30px 60px -28px rgba(30, 24, 18, 0.24);
  --danger:          #A24E3D;
  --danger-bg:       rgba(162, 78, 61, 0.09);
  --danger-bd:       rgba(162, 78, 61, 0.3);
  --footer-bg:       #1E1812;
  --footer-ink:      #F1E9D7;
  --footer-ink-soft: rgba(241, 233, 215, 0.62);
  --grain-blend:     multiply;
  --grain-opacity:   0.025;
  --font-display:    'DM Serif Display', 'Cormorant Garamond', Georgia, serif;
  --font-body:       'Outfit', system-ui, sans-serif;
  --font-mono:       'JetBrains Mono', 'SFMono-Regular', monospace;
}

/* ---------- 2. Base --------------------------------------------------------- */

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.4s ease, color 0.4s ease;
}

body { min-height: 100vh; overflow-x: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, ul { margin: 0; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-soft); }

/* ---------- 3. Shell + ambient background ----------------------------------- */

.app-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, currentColor 0.5px, transparent 0);
  background-size: 4px 4px;
  color: var(--ink);
  opacity: var(--grain-opacity);
  z-index: 1;
  mix-blend-mode: var(--grain-blend);
}

.bg-halo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: var(--halo);
  z-index: 0;
}

/* ---------- 4. Header -------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(20px, 4vw, 56px);
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--divider);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--accent-dim-bd);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 15px;
}

.brand-text { min-width: 0; }

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.brand-pill {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-dim-bg);
  color: var(--accent);
  border: 1px solid var(--accent-dim-bd);
  white-space: nowrap;
  flex: none;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  transition: all 0.25s ease;
  white-space: nowrap;
}
.header-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.header-btn svg { width: 14px; height: 14px; }
.header-btn.icon-only { padding: 9px; }
.header-btn.icon-only svg { width: 15px; height: 15px; }

/* ---------- 5. Page shell / eyebrow / hero / glass primitives --------------- */

.page {
  position: relative;
  z-index: 5;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(28px, 4vw, 48px) clamp(20px, 4vw, 56px) 0;
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 3vw, 36px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--accent); opacity: 0.8; }

.hero-block { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }

.hero-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.12;
  color: var(--ink);
}
.hero-title em { font-style: normal; color: var(--accent); }

.hero-sub {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.65;
  max-width: 620px;
}

.glass-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.glass-card {
  background: var(--surface-2);
  border: 1px solid var(--divider);
  border-radius: 14px;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.glass-card:hover { border-color: var(--accent-dim-bd); }

/* ---------- 6. Buttons ------------------------------------------------------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  border: 1px solid var(--accent);
  transition: all 0.25s ease;
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); transform: translateY(-1px); }
.btn-primary svg { width: 13px; height: 13px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--divider);
  color: var(--ink-muted);
  font-size: 12.5px;
  transition: all 0.25s ease;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost svg { width: 13px; height: 13px; }

/* ---------- 7. Inputs, stat cards, segmented toggle -------------------------- */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill, 50%), var(--divider) var(--fill, 50%), var(--divider) 100%);
  outline: none;
  cursor: pointer;
  margin: 6px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-deep);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 4px 10px rgba(0,0,0,0.4);
  transition: transform 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-deep);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent-soft);
  cursor: pointer;
}
input[type="range"]::-moz-range-track { background: transparent; }

.range-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
}

.stat-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.stat-card-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-card-label svg { width: 13px; height: 13px; color: var(--accent); }

.stat-card-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 24px;
  color: var(--accent-deep);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.stat-card-value span { font-family: var(--font-body); font-weight: 400; font-size: 12px; color: var(--ink-muted); }

.stat-card-foot { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint); }

.stat-card.is-highlight { background: var(--accent-dim-bg); border-color: var(--accent-dim-bd); }
.stat-card.is-highlight .stat-card-label { color: var(--accent); }

/* Segmented mode toggle (e.g. "Rule of 72 / Exact Math") */
.mode-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--divider);
  gap: 2px;
}
.mode-toggle button {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.25s ease;
  white-space: nowrap;
}
.mode-toggle button.is-active {
  background: var(--accent-dim-bg);
  color: var(--accent);
  border: 1px solid var(--accent-dim-bd);
}

/* ---------- 8. Footer -------------------------------------------------------- */

.site-footer {
  position: relative;
  z-index: 5;
  background: var(--footer-bg);
  color: var(--footer-ink);
  padding: 28px clamp(20px, 4vw, 56px);
  margin-top: clamp(32px, 5vw, 56px);
}
.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.footer-brand { font-family: var(--font-display); font-size: 14px; color: var(--footer-ink); }
.footer-disclaimer { font-size: 11px; color: var(--footer-ink-soft); max-width: 640px; line-height: 1.6; }

/* ---------- 9. Motion -------------------------------------------------------- */

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 10. Responsive ---------------------------------------------------- */

@media (max-width: 640px) {
  .brand-sub { display: none; }
  .site-header { flex-wrap: wrap; row-gap: 12px; padding: 14px 16px; }
  .brand { flex: 1 1 100%; }
  .brand-title { font-size: 15px; }
  .brand-pill { display: none; }
  .header-actions { flex: 1 1 100%; justify-content: space-between; }
  .mode-toggle { flex: 1; }
  .mode-toggle button { flex: 1; text-align: center; }
}
