/* =============================================================
   Financial Calculator Hub — Shared Base Stylesheet
   All pages link this file. Page-specific overrides go inline.
   ============================================================= */

/* ── Variables ── */
:root {
  --navy:       #0b2545;
  --navy-mid:   #163c6e;
  --gold:       #c9973a;
  --gold-light: #e8b95a;
  --cream:      #f8f4ee;
  --cream-dark: #ede7dc;
  --text:       #1a2640;
  --text-muted: #5a6a82;
  --positive:   #1d7a4e;
  --negative:   #b03030;
  --card-bg:    #ffffff;
  --border:     #d8cfc4;
  --shadow:     0 4px 24px rgba(11,37,69,0.10);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

/* ── Navigation ── */
header {
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 200;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-logo {
  font-family: 'Playfair Display', serif;
  color: #fff;
  font-size: 1.1rem;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo img { height: 32px; width: 32px; }
.nav-logo span { color: var(--gold-light); }

/* Desktop dropdown nav */
.nav-groups {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
}
.nav-group {
  position: relative;
}
.nav-group-btn {
  background: none;
  border: none;
  color: #9bb2cc;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.nav-group-btn::after {
  content: '▾';
  font-size: 0.65rem;
  opacity: 0.7;
  transition: transform 0.2s;
}
.nav-group:hover .nav-group-btn,
.nav-group-btn.active {
  color: #fff;
  background: rgba(255,255,255,0.08);
}
.nav-group-btn.active { color: var(--gold-light); background: rgba(201,151,58,0.15); }
.nav-group:hover .nav-group-btn::after { transform: rotate(180deg); }

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  /* padding-top bridges the gap so mouse can travel from button to dropdown
     without leaving the hover zone and triggering a close */
  padding-top: 8px;
  min-width: 210px;
  z-index: 300;
}
.nav-dropdown-inner {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(11,37,69,0.18);
  padding: 0.5rem 0;
}
.nav-group:hover .nav-dropdown { display: block; }
.nav-dropdown-inner a {
  display: block;
  padding: 0.55rem 1.1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.nav-dropdown-inner a:hover { background: var(--cream); color: var(--navy); }
.nav-dropdown-inner a.active { color: var(--gold); font-weight: 600; background: #fffdf5; }
.nav-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0;
}

/* "All Calculators" home link */
.nav-home {
  color: #9bb2cc;
  text-decoration: none;
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.nav-home:hover { color: #fff; border-color: rgba(255,255,255,0.35); }

/* Hamburger (mobile only) */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  flex-direction: column;
  gap: 5px;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #9bb2cc;
  border-radius: 2px;
  transition: all 0.25s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav drawer */
.nav-mobile-drawer {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--navy);
  overflow-y: auto;
  z-index: 199;
  padding: 0.5rem 0 2rem;
}
.nav-mobile-drawer.open { display: block; }

.nav-mobile-section {}
.nav-mobile-section-btn {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  color: #c5d8eb;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.9rem 1.5rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.nav-mobile-section-btn .arrow {
  font-size: 0.7rem;
  transition: transform 0.2s;
  opacity: 0.6;
}
.nav-mobile-section-btn.expanded .arrow { transform: rotate(180deg); }
.nav-mobile-section-links {
  display: none;
  background: rgba(0,0,0,0.2);
}
.nav-mobile-section-links.open { display: block; }
.nav-mobile-section-links a {
  display: block;
  padding: 0.7rem 2rem;
  color: #9bb2cc;
  text-decoration: none;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: color 0.12s, background 0.12s;
}
.nav-mobile-section-links a:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-mobile-section-links a.active { color: var(--gold-light); }

/* ── Footer ── */
footer {
  background: var(--navy);
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
  margin-top: auto;
}
.footer-inner {
  max-width: 900px;
  margin: 0 auto;
}
.footer-legal-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-bottom: 1.25rem;
}
.footer-legal-links a {
  color: #9bb2cc;
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.15s;
}
.footer-legal-links a:hover { color: var(--gold-light); }
footer p {
  color: #6a85a0;
  font-size: 0.8rem;
  line-height: 1.7;
}
footer a { color: var(--gold-light); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.footer-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin: 1rem auto;
  max-width: 400px;
}

/* ── Page wrapper ── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  width: 100%;
}
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  color: var(--navy);
  margin-bottom: 0.4rem;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 0.97rem;
  margin-bottom: 2rem;
  font-weight: 400;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.card-header {
  background: var(--navy);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.card-header h2 {
  font-family: 'Playfair Display', serif;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 400;
}
.step-badge {
  background: var(--gold);
  color: var(--navy);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.card-body { padding: 1.5rem; }

/* ── Form elements ── */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
}
.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1rem;
}
.field { margin-bottom: 0; }
.field + .field { margin-top: 1rem; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy-mid);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
label .req { color: var(--gold); margin-left: 2px; }

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-weight: 400;
  line-height: 1.4;
}

/* Input wrapper — flex row so prefix/suffix are real siblings, not overlays */
.input-wrap {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--cream);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}
.input-wrap:focus-within {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(22,60,110,0.1);
  background: #fff;
}
.input-prefix,
.input-suffix {
  display: flex;
  align-items: center;
  padding: 0 0.4rem 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
  flex-shrink: 0;
  background: transparent;
  white-space: nowrap;
  line-height: 1;
}
.input-suffix {
  padding: 0 0.75rem 0 0.25rem;
}

/* All inputs/selects — base styles shared */
input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.97rem;
  color: var(--text);
  background: var(--cream);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}
input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(22,60,110,0.1);
  background: #fff;
}

/* Inputs inside .input-wrap — wrapper owns the border/bg/focus ring */
.input-wrap input[type="number"],
.input-wrap input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.5rem;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transition: none;
}
.input-wrap input[type="number"]:focus,
.input-wrap input[type="text"]:focus {
  border: none;
  box-shadow: none;
  background: transparent;
}
/* has-prefix / has-suffix no longer needed but kept for compatibility */
.has-prefix input, .has-suffix input { padding-left: 0.5rem; padding-right: 0.5rem; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(22,60,110,0.1);
  background: #fff;
}
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6a82' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 2.5rem;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Buttons ── */
.btn-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.btn-calc {
  flex: 1;
  padding: 1rem;
  background: var(--gold);
  color: var(--navy);
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(201,151,58,0.3);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}
.btn-calc:hover  { background: var(--gold-light); box-shadow: 0 6px 20px rgba(201,151,58,0.45); }
.btn-calc:active { transform: translateY(1px); }
.btn-reset {
  padding: 0.7rem 1.5rem;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-reset:hover { border-color: var(--navy-mid); color: var(--navy); }

/* ── Results section ── */
.results { display: none; }
.results.visible { display: block; }

.results-header {
  background: var(--navy);
  color: #fff;
  padding: 1.2rem 1.5rem;
  border-radius: 14px 14px 0 0;
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
}
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.results-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.results-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.result-cell {
  padding: 1.1rem 1.4rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
/* Remove right border on last column */
.results-grid.cols-2 .result-cell:nth-child(2n),
.results-grid.cols-3 .result-cell:nth-child(3n),
.results-grid       .result-cell:nth-child(3n),
.results-grid.cols-4 .result-cell:nth-child(4n) { border-right: none; }
/* Remove bottom border on last row — handled via .no-bottom or JS */
.result-cell.no-bottom { border-bottom: none; }
.result-cell.full-row {
  grid-column: 1 / -1;
  border-right: none;
  background: #f9f6f1;
}

.result-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.result-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.55rem;
  color: var(--navy);
  white-space: nowrap;
}
.result-value.gold     { color: var(--gold); }
.result-value.positive { color: var(--positive); }
.result-value.negative { color: var(--negative); }
.result-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Standalone results grid (no header bar above it) */
.results-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.results-card .results-grid {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 0;
}

/* ── Chart card ── */
.chart-card {
  margin-top: 1.5rem;
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.chart-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--navy);
  margin-bottom: 1.1rem;
}
.chart-wrap { width: 100%; overflow: hidden; }
canvas { width: 100% !important; }

/* ── Legend ── */
.legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--text-muted); }
.legend-dot   { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Table card ── */
.table-card {
  margin-top: 1.25rem;
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-title {
  padding: 1rem 1.5rem;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--navy);
  border-bottom: 1px solid var(--border);
  background: #faf7f2;
}
.table-wrap { overflow-x: auto; max-height: 400px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  background: var(--navy);
  color: #fff;
  padding: 0.65rem 1rem;
  text-align: right;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 1;
}
th:first-child { text-align: left; }
td {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #f0ebe4;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
td:first-child { text-align: left; color: var(--text-muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: #faf8f5; }
.td-pos  { color: var(--positive); font-weight: 500; }
.td-neg  { color: var(--negative); font-weight: 500; }
.td-gold { color: #8a6010; font-weight: 600; }

/* ── Misc ── */
.note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1rem;
  font-style: italic;
  line-height: 1.5;
}
.placeholder-card {
  text-align: center;
  color: var(--text-muted);
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 4vw, 2rem);
  margin-top: 1.5rem;
}
.placeholder-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.placeholder-title { font-family: 'Playfair Display', serif; font-size: 1.1rem; color: var(--navy); margin-bottom: 0.5rem; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Switch to hamburger nav below 900px */
@media (max-width: 900px) {
  .nav-groups  { display: none; }
  .nav-home    { display: none; }
  .nav-hamburger { display: flex; }
  .nav-mobile-drawer { top: 64px; }
}

@media (max-width: 768px) {
  .results-grid,
  .results-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results-grid       .result-cell:nth-child(3n)  { border-right: 1px solid var(--border); }
  .results-grid.cols-4 .result-cell:nth-child(4n) { border-right: 1px solid var(--border); }
  .results-grid       .result-cell:nth-child(2n)  { border-right: none; }
}

@media (max-width: 600px) {
  .nav-inner  { padding: 0 0.75rem; height: 52px; }
  .nav-logo   { font-size: 0.9rem; }
  .nav-logo img { height: 24px; width: 24px; }
  .nav-mobile-drawer { top: 52px; }

  .page { padding: 0.75rem 0.75rem 2rem; }
  .page-subtitle { font-size: 0.86rem; margin-bottom: 1rem; }

  .form-grid-4,
  .form-row { grid-template-columns: 1fr; gap: 0.85rem; }
  .two-col  { grid-template-columns: 1fr; }

  .card-header { padding: 0.75rem 1rem; }
  .card-header h2 { font-size: 0.92rem; }
  .card-body { padding: 1rem; }

  .btn-row { flex-direction: column; }
  .btn-reset { width: 100%; }

  .results-grid,
  .results-grid.cols-2,
  .results-grid.cols-4 { grid-template-columns: 1fr 1fr; }

  .result-cell  { padding: 0.75rem 0.85rem; }
  .result-value { font-size: 1.15rem; }

  .chart-card  { padding: 1rem; margin-top: 1rem; }
  .chart-title { font-size: 0.9rem; }
  .table-title { padding: 0.75rem 1rem; font-size: 0.9rem; }
  th { padding: 0.5rem 0.6rem; font-size: 0.68rem; }
  td { padding: 0.4rem 0.6rem; font-size: 0.8rem; }
}
