/* Car Repair vs Replace — styles. Pure static, no frameworks. */
:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #14263f;
  --muted: #5d6f88;
  --line: #e3e9f2;
  --repair: #0d9488;
  --repair-deep: #0b6e65;
  --repair-soft: #e0f2ef;
  --replace: #4f46e5;
  --replace-deep: #3c3799;
  --replace-soft: #e8e8fb;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --good-soft: #e7f7f0;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(20, 38, 63, 0.08);
  --shadow-sm: 0 4px 14px rgba(20, 38, 63, 0.07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: 0.6rem 1rem; z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--repair);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(120deg, #0c2342 0%, #123a5e 45%, #0d9488 130%);
  padding: 3.2rem 1.25rem 3.8rem;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 260px at 15% 20%, rgba(255,255,255,0.10), transparent 60%),
    radial-gradient(500px 240px at 85% 80%, rgba(13,148,136,0.35), transparent 60%);
  pointer-events: none;
  animation: heroGlow 9s ease-in-out infinite alternate;
}
@keyframes heroGlow {
  from { transform: translateX(-2%); opacity: 0.9; }
  to   { transform: translateX(2%);  opacity: 1; }
}
.hero-inner {
  position: relative;
  max-width: 1120px; margin: 0 auto;
}
.eyebrow {
  display: inline-block;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.35rem 0.8rem; border-radius: 999px;
  margin-bottom: 1rem;
}
.hero h1 {
  margin: 0 0 0.6rem; font-size: clamp(1.9rem, 4.5vw, 3rem);
  line-height: 1.12; letter-spacing: -0.02em; max-width: 20ch;
}
.hero p.lede {
  margin: 0; max-width: 62ch; font-size: 1.06rem; color: #dbe7f3;
}
.hero .currency-row {
  margin-top: 1.4rem; display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.92rem; color: #dbe7f3;
}
.currency-row select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.45rem 0.7rem; background: #fff; cursor: pointer;
}

/* ---------- Layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.layout {
  display: grid; gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-top: -2.2rem; position: relative; z-index: 2;
  padding-bottom: 2rem;
}
@media (min-width: 980px) {
  .layout { grid-template-columns: 380px 1fr; align-items: start; }
  .inputs-col { position: sticky; top: 1rem; }
}

/* ---------- Cards & entrance animation ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem;
  margin-bottom: 1.25rem;
}
.card h2 {
  margin: 0 0 0.9rem; font-size: 1.12rem; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 0.55rem;
}
.card h2 .step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 0.85rem; font-weight: 700;
  flex: none;
}
.entrance {
  opacity: 0;
  transform: translateY(22px);
  animation: riseIn 0.65s cubic-bezier(0.22, 0.9, 0.3, 1) forwards;
  animation-delay: calc(var(--i, 0) * 90ms);
}
@keyframes riseIn {
  to { opacity: 1; transform: none; }
}

/* ---------- Form controls ---------- */
.field { margin-bottom: 1.15rem; }
.field:last-child { margin-bottom: 0; }
.field-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 0.35rem; gap: 0.75rem;
}
.field-head label { font-weight: 650; font-size: 0.95rem; }
.field-head .hint { font-size: 0.8rem; color: var(--muted); }
.value-pill {
  font-variant-numeric: tabular-nums;
  font-weight: 750; font-size: 1rem;
  background: var(--bg); border: 1px solid var(--line);
  padding: 0.25rem 0.65rem; border-radius: 999px; white-space: nowrap;
}
input[type="range"] {
  width: 100%; appearance: none; -webkit-appearance: none;
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right, var(--repair) var(--fill, 50%), #dbe3ee var(--fill, 50%));
  outline-offset: 4px; cursor: pointer; margin: 0.55rem 0 0.3rem;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--repair);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--repair);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.15s ease;
}
input[type="range"]::-moz-range-thumb:hover { transform: scale(1.15); }
input[type="range"].indigo {
  background: linear-gradient(to right, var(--replace) var(--fill, 50%), #dbe3ee var(--fill, 50%));
}
input[type="range"].indigo::-webkit-slider-thumb { border-color: var(--replace); }
input[type="range"].indigo::-moz-range-thumb { border-color: var(--replace); }

.num-row { display: flex; gap: 0.6rem; align-items: center; }
.num-row input[type="number"], .adv-grid input[type="number"] {
  font: inherit; width: 100%;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.5rem 0.65rem; background: #fbfcfe; color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.num-row input[type="number"]:focus, .adv-grid input[type="number"]:focus {
  border-color: var(--repair); box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
  outline: none;
}
.or { color: var(--muted); font-size: 0.85rem; flex: none; }

/* Segmented age-band control */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.45rem; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span {
  display: block; text-align: center; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 0.5rem 0.2rem; font-size: 0.88rem; font-weight: 650;
  background: #fbfcfe; transition: all 0.18s ease;
}
.seg input:checked + span {
  background: var(--ink); color: #fff; border-color: var(--ink);
  transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
.seg input:focus-visible + span { outline: 3px solid var(--repair); outline-offset: 2px; }

/* Advanced toggles */
.adv-toggle {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: none; border: 1px dashed var(--line); border-radius: 12px;
  padding: 0.65rem 0.9rem; font: inherit; font-weight: 650; font-size: 0.92rem;
  color: var(--muted); cursor: pointer; margin-top: 0.4rem;
  transition: all 0.18s ease;
}
.adv-toggle:hover { border-color: var(--repair); color: var(--ink); }
.adv-toggle:active { transform: scale(0.985); }
.adv-toggle .chev {
  display: inline-block; transition: transform 0.25s ease; font-size: 0.8rem;
}
.adv-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.adv-toggle[aria-expanded="true"] { color: var(--ink); border-style: solid; }
.adv-region {
  display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease;
}
.adv-region.open { grid-template-rows: 1fr; }
.adv-region > div { overflow: hidden; }
.adv-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem;
  padding-top: 0.9rem;
}
.adv-grid .full { grid-column: 1 / -1; }
.adv-grid label { display: block; font-size: 0.83rem; font-weight: 600; color: var(--muted); margin-bottom: 0.25rem; }

/* ---------- Verdict ---------- */
.verdict {
  border: none; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #123a5e, #0d9488);
  transition: background 0.5s ease;
}
.verdict.v-replace { background: linear-gradient(135deg, #2b2a6e, #4f46e5); }
.verdict.v-close { background: linear-gradient(135deg, #7c4a03, #b45309); }
.verdict-badge {
  display: inline-block; font-size: 0.78rem; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.35);
  padding: 0.3rem 0.8rem; border-radius: 999px; margin-bottom: 0.7rem;
}
.verdict h2 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); margin: 0 0 0.3rem; letter-spacing: -0.02em; }
.verdict .verdict-sub { margin: 0 0 1rem; color: rgba(255,255,255,0.88); }
.savings-line {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  background: rgba(0,0,0,0.22); border-radius: 12px; padding: 0.9rem 1.1rem;
}
.savings-line .savings-num {
  font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.savings-line .savings-label { font-size: 0.92rem; color: rgba(255,255,255,0.85); }
/* The verdict card has its own entrance (not .entrance) because the verdict-
   change "pop" animation overrides the animation property — sharing .entrance
   would leave it stuck at opacity 0. */
.verdict {
  /* backwards fill: invisible only during the delay; natural opacity is 1,
     so the verdict-change "pop" can never leave the card stuck at 0. */
  animation: verdictIn 0.65s cubic-bezier(0.22, 0.9, 0.3, 1) 90ms backwards;
}
@keyframes verdictIn {
  from { opacity: 0; transform: translateY(22px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
.verdict.pop { animation: verdictPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes verdictPop {
  0% { opacity: 1; transform: scale(0.985); }
  60% { opacity: 1; transform: scale(1.008); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---------- Roads ---------- */
.roads { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .roads { grid-template-columns: 1fr 1fr; } }
.road {
  border-radius: var(--radius); padding: 1.15rem 1.2rem 1.3rem;
  border: 1px solid var(--line); background: var(--card);
  position: relative; overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.road:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.road.winner { border-width: 2px; }
.road.repair { --road: var(--repair); --road-deep: var(--repair-deep); --road-soft: var(--repair-soft); }
.road.replace { --road: var(--replace); --road-deep: var(--replace-deep); --road-soft: var(--replace-soft); }
.road.winner { border-color: var(--road); }
.road-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.2rem; }
.road-head svg { flex: none; }
.road-head h3 { margin: 0; font-size: 1.05rem; }
.winner-tag {
  margin-left: auto; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: #fff; background: var(--road);
  padding: 0.22rem 0.6rem; border-radius: 999px;
  opacity: 0; transform: scale(0.8); transition: all 0.3s ease;
}
.road.winner .winner-tag { opacity: 1; transform: scale(1); }
.road-total {
  font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; margin: 0.35rem 0 0.8rem;
  color: var(--road-deep);
}
.track {
  position: relative; height: 44px; border-radius: 12px;
  background: var(--road-soft); overflow: hidden;
}
.track::after {
  /* animated dashed lane line */
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 3px; transform: translateY(-50%);
  background-image: linear-gradient(to right, rgba(255,255,255,0.9) 55%, transparent 45%);
  background-size: 26px 3px; background-repeat: repeat-x;
  animation: laneMove 1.1s linear infinite;
  pointer-events: none;
}
@keyframes laneMove { to { background-position-x: 26px; } }
.bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  display: flex; border-radius: 12px 0 0 12px;
  transition: width 0.7s cubic-bezier(0.25, 0.9, 0.3, 1);
  overflow: hidden;
}
.bar-upfront { background: var(--road); height: 100%; transition: width 0.7s cubic-bezier(0.25, 0.9, 0.3, 1); }
.bar-running { background: var(--road-deep); opacity: 0.45; height: 100%; transition: width 0.7s cubic-bezier(0.25, 0.9, 0.3, 1); }
.road-legend { display: flex; gap: 1rem; margin-top: 0.6rem; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; }
.swatch { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 3px; margin-right: 0.3em; vertical-align: baseline; }

/* ---------- TCO table ---------- */
.tco-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tco-table caption { text-align: left; font-weight: 700; padding-bottom: 0.6rem; }
.tco-table th, .tco-table td { padding: 0.6rem 0.5rem; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tco-table th:first-child, .tco-table td:first-child { text-align: left; }
.tco-table thead th { font-size: 0.85rem; color: var(--muted); border-bottom: 2px solid var(--line); }
.tco-table tfoot td { font-weight: 800; font-size: 1.02rem; border-bottom: none; border-top: 2px solid var(--ink); }
.tco-table .col-repair { color: var(--repair-deep); }
.tco-table .col-replace { color: var(--replace-deep); }
.table-scroll { overflow-x: auto; }

/* ---------- Explainer / checks ---------- */
.check { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.7rem 0; border-bottom: 1px dashed var(--line); }
.check:last-child { border-bottom: none; }
.check .icon { flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; }
.check.ok .icon { background: var(--repair); }
.check.bad .icon { background: #b91c1c; }
.check.warn .icon { background: var(--warn); }
.check p { margin: 0.1rem 0 0; font-size: 0.94rem; }
.formula {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.9rem 1.1rem; font-size: 0.95rem; margin: 0.9rem 0;
  font-variant-numeric: tabular-nums;
}
.formula strong { color: var(--repair-deep); }
.swing { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.swing li {
  background: var(--warn-soft); border-left: 4px solid var(--warn);
  border-radius: 0 10px 10px 0; padding: 0.6rem 0.9rem; margin-bottom: 0.55rem;
  font-size: 0.92rem;
}
.no-swing { color: var(--muted); font-size: 0.92rem; }

/* ---------- Next 12 months ---------- */
.month12 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .month12 { grid-template-columns: 1fr 1fr; } }
.m12 {
  border-radius: 12px; padding: 1rem 1.1rem; border: 1px solid var(--line);
}
.m12.repair { background: var(--repair-soft); border-color: #bfe3de; }
.m12.replace { background: var(--replace-soft); border-color: #cfcff5; }
.m12 h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.m12 .amt { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.m12 p { margin: 0.35rem 0 0; font-size: 0.86rem; color: var(--muted); }

/* ---------- Sunk cost ---------- */
.sunk {
  background: linear-gradient(135deg, #fff8ec, #fef3e2);
  border: 1px solid #f3ddb8;
}
.sunk h2 { color: #7c4a03; }

/* ---------- Actions ---------- */
.actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin: 0.2rem 0 1.25rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer;
  border-radius: 12px; padding: 0.7rem 1.2rem; border: 2px solid var(--ink);
  background: var(--ink); color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: #fff; color: var(--ink); }
.btn .ok-msg { font-weight: 600; }

/* ---------- FAQ ---------- */
.faq details {
  border-bottom: 1px solid var(--line); padding: 0.85rem 0;
}
.faq summary {
  cursor: pointer; font-weight: 700; font-size: 1rem; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; font-size: 1.4rem; font-weight: 400; color: var(--repair);
  transition: transform 0.25s ease; flex: none;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--muted); margin: 0.6rem 0 0.2rem; max-width: 70ch; }

/* ---------- Footer ---------- */
footer.site {
  border-top: 1px solid var(--line); margin-top: 1rem;
  padding: 1.6rem 0 2.5rem; color: var(--muted); font-size: 0.86rem;
}
.disclaimer {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.2rem; margin-bottom: 1.2rem; font-size: 0.88rem;
}

/* ---------- Print: summary only ---------- */
@media print {
  .hero .currency-row, .inputs-col, .actions, .faq, .adv-toggle, footer.site nav { display: none !important; }
  .hero { padding: 1rem; background: none; color: var(--ink); }
  .hero::before { display: none; }
  .hero p.lede, .eyebrow { color: var(--muted); }
  .layout { display: block; margin-top: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .entrance { opacity: 1; transform: none; animation: none; }
  .verdict { color: var(--ink); background: none; border: 2px solid var(--ink); }
  .verdict .verdict-sub, .savings-line .savings-label { color: var(--muted); }
  .savings-line { background: none; border: 1px solid var(--line); }
  .verdict-badge { color: var(--ink); border-color: var(--ink); background: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .entrance { opacity: 1; transform: none; }
  .verdict { opacity: 1; animation: none; }
  .hero::before { animation: none; }
  .track::after { animation: none; }
}
