/* ============================================================
   when can i retire — premium neo-brutalism
   ============================================================ */

:root {
  --bg:        #E9E8EE;
  --surface:   #FCFCFD;
  --ink:       #101014;
  --ink-soft:  #2A2A31;
  --muted:     #6B6B75;
  --line:      #101014;

  --lime:      #C7F94E;
  --lime-deep: #A8E028;
  --coral:     #FF5C39;

  --radius:    22px;
  --radius-sm: 14px;
  --shadow:    6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --border:    2.5px solid var(--ink);

  --font: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 40px);
}

/* ============ HEADER ============ */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: clamp(20px, 3vw, 36px);
}
.brand-mark {
  font-weight: 700;
  font-size: clamp(20px, 3.2vw, 30px);
  letter-spacing: -0.02em;
}
.brand-mark .dot { color: var(--coral); }
.tagline {
  color: var(--muted);
  font-size: clamp(13px, 1.6vw, 16px);
  font-weight: 500;
}

/* ============ LAYOUT ============ */
.app {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: clamp(16px, 2vw, 24px);
  align-items: start;
}

/* ============ PANELS ============ */
.panel, .chart-card, .hero-result, .stat {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
}

.form-panel { padding: clamp(18px, 2.2vw, 28px); }

.panel-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ============ FORM ============ */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 14px;
}
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

.field > label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hint {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  outline: none;
}
.hint-bubble {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  background: var(--ink);
  color: var(--surface);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  letter-spacing: 0;
  text-transform: none;
  padding: 9px 11px;
  border-radius: 10px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 20;
}
.hint-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}
.hint:hover .hint-bubble,
.hint:focus-visible .hint-bubble,
.hint:focus .hint-bubble {
  opacity: 1;
  visibility: visible;
}
/* évite que la bulle sorte à gauche pour le 1er champ */
.field:first-child .hint-bubble { left: 0; transform: none; }
.field:first-child .hint-bubble::after { left: 8px; transform: none; }

.input-shell {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 48px;
  transition: box-shadow .12s ease, transform .12s ease;
}
.input-shell:focus-within {
  box-shadow: var(--shadow-sm);
  transform: translate(-1px, -1px);
}
.input-shell input,
.input-shell select {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}
.input-shell input::-webkit-outer-spin-button,
.input-shell input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-shell input[type=number] { -moz-appearance: textfield; }

.unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  padding-left: 6px;
}

.select-shell { position: relative; padding-right: 34px; }
.select-shell::after {
  content: "";
  position: absolute;
  right: 14px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-shell select { appearance: none; cursor: pointer; }

/* monthly / annual toggle */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.seg {
  display: inline-flex;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  flex: none;
}
.seg input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.seg label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 11px;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
  transition: background .12s ease, color .12s ease;
}
.seg input:checked + label { background: var(--ink); color: var(--surface); }
.seg input:focus-visible + label { outline: 2px solid var(--coral); outline-offset: -2px; }

.conv {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding-left: 4px;
  min-height: 15px;
}
.conv .pos { color: var(--lime-deep); }
.conv .neg { color: var(--coral); }

/* checkbox indexation */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  cursor: pointer;
  user-select: none;
}
.check-row input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.check-box {
  flex: none;
  width: 20px; height: 20px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  position: relative;
  transition: background .12s ease;
}
.check-box::after {
  content: "";
  position: absolute;
  left: 5px; top: 1px;
  width: 6px; height: 11px;
  border: solid var(--ink);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .12s ease;
}
.check-row input:checked + .check-box { background: var(--lime); }
.check-row input:checked + .check-box::after { transform: rotate(45deg) scale(1); }
.check-row input:focus-visible + .check-box { box-shadow: var(--shadow-sm); }
.check-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.fineprint {
  margin-top: 18px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  border-top: 2px dashed var(--ink);
  padding-top: 14px;
}

/* ============ RESULTS ============ */
.results { display: flex; flex-direction: column; gap: clamp(16px, 2vw, 24px); min-width: 0; }

/* hero */
.hero-result {
  background: var(--lime);
  box-shadow: var(--shadow);
  padding: clamp(22px, 3.5vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.hero-result.unreachable { background: var(--surface); }
.hero-result.warning { background: var(--coral); }
.hero-result.warning .hero-age,
.hero-result.warning .hero-label,
.hero-result.warning .hero-sub { color: var(--surface); }
.hero-label {
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.hero-age {
  font-size: clamp(56px, 12vw, 120px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.04em;
}
.hero-age .yr { font-size: 0.42em; letter-spacing: -0.02em; }
.hero-sub {
  font-size: clamp(14px, 1.9vw, 18px);
  font-weight: 500;
  margin-top: 6px;
}

/* stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: clamp(12px, 1.5vw, 16px);
}
.stat {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat-value {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* chart */
.chart-card { padding: clamp(16px, 2vw, 24px); }
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chart-head .panel-title { margin-bottom: 0; }
.legend { display: flex; gap: 14px; }
.lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.sw {
  width: 14px; height: 14px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  display: inline-block;
}
.sw-ink { background: var(--ink); }
.sw-lime { background: var(--lime); }

.chart-container { position: relative; width: 100%; }
#chart { width: 100%; height: auto; display: block; overflow: visible; }

/* chart svg elements */
.bar { transition: opacity .1s ease; }
.bar.dim { opacity: 0.35; }
.axis-line { stroke: var(--ink); stroke-width: 2; }
.grid-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.25; }
.axis-label { fill: var(--muted); font-size: 15px; font-weight: 600; font-family: var(--font); }
.fire-line { stroke: var(--coral); stroke-width: 2.5; stroke-dasharray: 6 5; }
.fire-flag {
  fill: var(--coral);
}
.fire-flag-text { fill: #fff; font-size: 15px; font-weight: 700; font-family: var(--font); }

/* tooltip */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--surface);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, -115%);
  z-index: 5;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.25);
}
.tooltip .tt-age { color: var(--lime); }
.tooltip .tt-cap { display: block; margin-top: 2px; font-weight: 700; }
.tooltip .tt-cap { margin-bottom: 4px; }
.tooltip .tt-flow {
  display: block;
  margin-top: 3px;
  font-weight: 500;
  font-size: 12px;
  opacity: 0.75;
}

/* ============ FOOTER ============ */
.site-footer {
  margin-top: clamp(24px, 4vw, 48px);
  text-align: center;
}
.site-footer p {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
  .dual { grid-template-columns: 1fr; gap: 8px; }
  .dual-link { justify-self: center; }
  .stats { grid-template-columns: 1fr; }
  .stat { flex-direction: row; align-items: baseline; justify-content: space-between; }
}
