/* Shared styles for all calculator pages */

@font-face {
  font-family: 'MADE Tommy Soft';
  src: url('../fonts/MadeTommySoftBold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Maax';
  src: url('../fonts/Maax-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Maax';
  src: url('../fonts/Maax-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --brand-mauve: #AFA2A6;
  --brand-cream: #EFE6E3;
  --brand-teal: #008486;
  --brand-teal-dark: #006e70;
  --brand-ink: #231F20;
  --max-width: 1140px;
  --font-header: 'MADE Tommy Soft', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Maax', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--brand-ink);
  background: #fff;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-header);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--brand-ink);
}

a { color: var(--brand-teal); text-decoration: none; }
a:hover { color: var(--brand-teal-dark); }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== HEADER (shared with home) ===== */
.calc-header {
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #f0eceb;
  z-index: 100;
}

.calc-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  gap: 1rem;
}

.calc-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--brand-ink);
}

.calc-logo .mark { width: 32px; height: 32px; }

.calc-back {
  font-size: 0.92rem;
  color: var(--brand-ink);
  font-weight: 500;
}

.calc-back:hover { color: var(--brand-teal); }

.btn {
  display: inline-block;
  background: var(--brand-teal);
  color: #fff;
  padding: 0.7rem 1.4rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease;
}
.btn:hover { background: var(--brand-teal-dark); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--brand-teal);
  border: 1.5px solid var(--brand-teal);
}
.btn-outline:hover { background: var(--brand-teal); color: #fff; }

/* ===== TITLE BLOCK ===== */
.calc-title {
  padding: 3.5rem 0 2rem;
  background: linear-gradient(180deg, #fff 0%, var(--brand-cream) 100%);
}

.calc-eyebrow {
  color: var(--brand-teal);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.calc-title h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin-bottom: 0.6rem;
}

.calc-title p {
  color: #555;
  max-width: 660px;
  font-size: 1.05rem;
}

/* ===== TWO-COLUMN LAYOUT ===== */
.calc-shell {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 2.5rem;
  padding: 3rem 0 5rem;
  align-items: start;
}

@media (max-width: 880px) {
  .calc-shell { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 2rem; }
}

/* ===== INPUT PANEL ===== */
.calc-inputs {
  background: var(--brand-cream);
  padding: 2rem;
  border-radius: 8px;
  position: sticky;
  top: 96px;
}

@media (max-width: 880px) {
  .calc-inputs { position: static; }
}

.calc-inputs h2 {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--brand-ink);
}

.input-row {
  margin-bottom: 1.25rem;
}

.input-row label {
  display: block;
  font-size: 0.88rem;
  color: var(--brand-ink);
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.input-row .hint {
  font-size: 0.78rem;
  color: #777;
  font-weight: 400;
  margin-left: 0.4rem;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input[type="number"] {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #d8d2d0;
  background: #fff;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--brand-ink);
  transition: border-color 0.2s ease;
}

.input-wrap input[type="number"]:focus {
  outline: none;
  border-color: var(--brand-teal);
}

.input-wrap.with-prefix input { padding-left: 2rem; }
.input-wrap.with-suffix input { padding-right: 2.4rem; }

.input-wrap .prefix,
.input-wrap .suffix {
  position: absolute;
  color: #777;
  font-size: 0.95rem;
  pointer-events: none;
}
.input-wrap .prefix { left: 0.9rem; }
.input-wrap .suffix { right: 0.9rem; }

.input-row select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #d8d2d0;
  background: #fff;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--brand-ink);
  cursor: pointer;
}

.input-row select:focus {
  outline: none;
  border-color: var(--brand-teal);
}

/* Toggle for $/% on down payment */
.toggle-pair {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: stretch;
}

.toggle-pair .switch {
  display: inline-flex;
  border: 1px solid #d8d2d0;
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
}

.toggle-pair .switch button {
  padding: 0 0.85rem;
  background: transparent;
  border: 0;
  color: #555;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.toggle-pair .switch button.active {
  background: var(--brand-teal);
  color: #fff;
}

/* ===== RESULTS PANEL ===== */
.calc-results {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.result-headline {
  background: var(--brand-ink);
  color: #fff;
  padding: 2rem 2rem 1.75rem;
  border-radius: 8px;
}

.result-headline .label {
  color: rgba(255,255,255,0.65);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.result-headline .number {
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.result-headline .number .currency {
  font-size: 0.6em;
  color: rgba(255,255,255,0.6);
  margin-right: 0.1em;
  font-weight: 500;
}

.result-headline .freq {
  color: rgba(255,255,255,0.55);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.result-tile {
  background: #fff;
  border: 1px solid #ece7e6;
  padding: 1.25rem;
  border-radius: 6px;
}

.result-tile .label {
  font-size: 0.78rem;
  color: #777;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.result-tile .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand-ink);
  line-height: 1.1;
}

.result-tile .sub {
  font-size: 0.82rem;
  color: #777;
  margin-top: 0.2rem;
}

/* ===== CHART CARD ===== */
.chart-card {
  background: #fff;
  border: 1px solid #ece7e6;
  padding: 1.5rem;
  border-radius: 6px;
}

.chart-card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.chart-canvas-wrap {
  position: relative;
  height: 280px;
}

/* ===== "What this means" card ===== */
.explainer {
  background: var(--brand-cream);
  border-left: 4px solid var(--brand-teal);
  padding: 1.5rem 1.75rem;
  border-radius: 4px;
}

.explainer h3 {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
  color: var(--brand-ink);
}

.explainer p {
  color: #444;
  font-size: 0.95rem;
  line-height: 1.65;
}

.explainer p + p { margin-top: 0.75rem; }

/* ===== AMORTIZATION TABLE ===== */
.amort-card {
  background: #fff;
  border: 1px solid #ece7e6;
  border-radius: 6px;
  overflow: hidden;
}

.amort-card header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #ece7e6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.amort-card header h3 {
  font-size: 1rem;
}

.amort-card .scroll {
  max-height: 360px;
  overflow-y: auto;
}

.amort-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.amort-card th,
.amort-card td {
  padding: 0.7rem 1.5rem;
  text-align: right;
  border-bottom: 1px solid #f3efee;
}

.amort-card th:first-child,
.amort-card td:first-child {
  text-align: left;
}

.amort-card thead th {
  background: var(--brand-cream);
  color: #555;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}

.amort-card tbody tr.term-row {
  background: #fdf7ec;
}

.amort-card tbody tr.term-row td {
  font-weight: 600;
}

/* ===== Checkbox row ===== */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.88rem;
  color: var(--brand-ink);
  margin-bottom: 1rem;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: var(--brand-teal);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.checkbox-row .desc {
  color: #666;
  font-size: 0.8rem;
  display: block;
  margin-top: 0.1rem;
}

/* ===== Subsection divider in input panel ===== */
.input-section-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #888;
  text-transform: uppercase;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e2dad7;
}

.input-section-label:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

/* ===== Rate-ladder mini info ===== */
.rate-ladder-info {
  background: #fff;
  border: 1px solid #e8e0dd;
  border-radius: 4px;
  padding: 0.65rem 0.85rem;
  font-size: 0.78rem;
  color: #555;
  line-height: 1.45;
  margin-top: 0.5rem;
}

.rate-ladder-info strong { color: var(--brand-ink); }

/* ===== Eligibility warnings ===== */
.eligibility-warn {
  background: #fdf3ec;
  border-left: 4px solid #d97a3b;
  padding: 1rem 1.25rem;
  border-radius: 4px;
}

.eligibility-warn h3 {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #b04e10;
  margin-bottom: 0.5rem;
}

.eligibility-warn ul {
  list-style: disc;
  padding-left: 1.25rem;
  font-size: 0.92rem;
  color: #5a3618;
}

.eligibility-warn li { margin-bottom: 0.25rem; }

/* ===== GDS / TDS bars ===== */
.ratio-card {
  background: #fff;
  border: 1px solid #ece7e6;
  padding: 1.5rem 1.75rem;
  border-radius: 6px;
}

.ratio-card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.ratio-block {
  margin-bottom: 1.5rem;
}

.ratio-block:last-child { margin-bottom: 0; }

.ratio-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}

.ratio-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--brand-ink);
}

.ratio-name .small {
  font-weight: 400;
  font-size: 0.8rem;
  color: #777;
  margin-left: 0.4rem;
}

.ratio-value {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--brand-ink);
}

.ratio-value.over { color: #b04e10; }

.ratio-bar {
  position: relative;
  background: #f0eceb;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
}

.ratio-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--brand-teal);
  border-radius: 6px;
  transition: width 0.25s ease;
}

.ratio-bar-fill.over { background: #d97a3b; }

.ratio-bar-limit {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--brand-ink);
  border-radius: 1px;
}

.ratio-bar-limit::after {
  content: attr(data-limit);
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: #555;
  white-space: nowrap;
  font-weight: 600;
}

.ratio-detail {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: #666;
}

/* ===== Closing-cost breakdown ===== */
.cc-breakdown {
  background: #fff;
  border: 1px solid #ece7e6;
  border-radius: 6px;
  overflow: hidden;
}
.cc-breakdown header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #ece7e6;
}
.cc-breakdown header h3 {
  font-size: 1rem;
}
.cc-breakdown .cc-section {
  padding: 0.5rem 0 0.6rem;
  border-bottom: 1px solid #f3efee;
}
.cc-breakdown .cc-section:last-of-type { border-bottom: 0; }
.cc-breakdown .cc-section-label {
  padding: 0.65rem 1.5rem 0.4rem;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  color: #888;
  text-transform: uppercase;
  font-weight: 600;
}
.cc-line {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 1.5rem;
  font-size: 0.94rem;
}
.cc-line .name { color: var(--brand-ink); }
.cc-line .amount { color: var(--brand-ink); font-weight: 500; min-width: 100px; text-align: right; }
.cc-line.negative .amount { color: var(--brand-teal); }
.cc-line.subtotal {
  background: #faf6f4;
  font-weight: 600;
  font-size: 0.92rem;
  color: #555;
}
.cc-total {
  padding: 1rem 1.5rem;
  background: var(--brand-cream);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 2px solid var(--brand-ink);
}
.cc-total .name {
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--brand-ink);
}
.cc-total .amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-ink);
}

/* Cash-to-close highlight tile */
.cash-tile {
  background: var(--brand-ink);
  color: #fff;
  padding: 1.5rem 1.75rem;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.cash-tile .label {
  color: rgba(255,255,255,0.65);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cash-tile .value {
  font-size: 1.8rem;
  font-weight: 700;
}
.cash-tile .sub {
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  flex-basis: 100%;
  margin-top: 0.4rem;
}

/* ===== Renewal/switch comparison cards ===== */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 720px) {
  .compare-grid { grid-template-columns: 1fr; }
}
.compare-card {
  background: #fff;
  border: 1px solid #ece7e6;
  border-radius: 6px;
  padding: 1.5rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.compare-card.winner {
  border: 2px solid var(--brand-teal);
  background: #f0fafa;
}
.compare-card .badge {
  align-self: flex-start;
  background: var(--brand-teal);
  color: #fff;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
}
.compare-card h3 {
  font-size: 1.1rem;
}
.compare-card .rate {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brand-ink);
  line-height: 1;
}
.compare-card .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  color: #555;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f3efee;
}
.compare-card .stat-row:last-child { border-bottom: 0; }
.compare-card .stat-row strong { color: var(--brand-ink); font-weight: 600; }
.compare-card .stat-row.total {
  border-top: 1px solid var(--brand-ink);
  border-bottom: 0;
  padding-top: 0.6rem;
  margin-top: 0.4rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--brand-ink);
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  background: #fff;
  border: 1px solid #d8d2d0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.mode-toggle button {
  flex: 1;
  padding: 0.75rem 0.6rem;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  color: #555;
  font-weight: 500;
}
.mode-toggle button.active {
  background: var(--brand-teal);
  color: #fff;
  font-weight: 600;
}

/* Penalty breakdown */
.penalty-card {
  background: var(--brand-cream);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
}
.penalty-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
.penalty-card .penalty-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.92rem;
}
.penalty-card .penalty-row.winner strong { color: var(--brand-ink); }
.penalty-card .penalty-row.dim { color: #888; }
.penalty-card .penalty-row.dim strong { color: #888; }
.penalty-card .penalty-row.total {
  border-top: 1px solid var(--brand-ink);
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--brand-ink);
}

/* ===== APPLY STRIP ===== */
.apply-strip {
  background: var(--brand-ink);
  color: #fff;
  padding: 3.5rem 0;
  text-align: center;
  margin-top: 4rem;
}

.apply-strip h2 {
  color: #fff;
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 0.75rem;
}

.apply-strip p {
  color: rgba(255,255,255,0.7);
  max-width: 540px;
  margin: 0 auto 1.75rem;
}

/* ===== FOOTER ===== */
footer.calc-footer {
  background: var(--brand-ink);
  color: rgba(255,255,255,0.7);
  padding: 2.5rem 0 1.5rem;
  font-size: 0.86rem;
}

.calc-footer-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
}
