/* =========================================================================
   FIRE Calculator — Zhijie Tan
   Calculator-specific styles only. Brand tokens, base reset, header,
   footer, and generic atoms (buttons, glass panels, sliders, stat cards,
   the mode toggle, the controls-panel/chart-panel shell) live in
   ../shared/theme.css, loaded before this file.
   ========================================================================= */


/* ---------- Bucket + chart color tokens (additions to the shared theme) ----
   Borrowed from tfa-portal's semantic tokens so they sit in the shared
   gold palette: --pos green = investing, --info blue = savings. --fire is
   the brand gold. The theme itself (tfa-portal palette, fonts, header)
   lives in ../shared/theme.css. */

:root,
:root[data-theme="light"] {
  --b-fixed:         #6B6B78;
  --b-save:          #3F5F96;
  --b-invest:        #1A7F37;
  --b-flex:          #7D5A9E;
  --fire:            #8A6010;
  --chart-contrib:   #6B6B78;
  --seg-ink:         #FFFFFF;
}

:root[data-theme="dark"] {
  --b-fixed:         #7A7A90;
  --b-save:          #8AA4D0;
  --b-invest:        #6ABF7B;
  --b-flex:          #B59AD6;
  --fire:            #C4A055;
  --chart-contrib:   #7A7A90;
  --seg-ink:         #0B0D14;
}

/* Cormorant sets these numbers too — lining figures (see shared theme). */
.panel-title, .fire-age-suffix { font-variant-numeric: lining-nums; }

/* ---------- Header additions ---------------------------------------------- */

.lang-toggle button { min-width: 48px; }
.present-btn span { display: inline; }

/* ---------- Panel titles (shared shape for every panel on this page) ------ */

.panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  letter-spacing: 0;
}
.panel-title svg { width: 16px; height: 16px; color: var(--accent); flex: none; }

.panel-sub {
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.6;
  margin: -10px 0 16px;
  max-width: 640px;
}

.start-grid { grid-template-columns: repeat(3, 1fr); }
.assumptions-grid { grid-template-columns: repeat(5, 1fr); }

/* ---------- Step 2: paycheck split ---------------------------------------- */

.split-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.split-head .panel-sub { margin-bottom: 16px; }

.preset-toggle { flex-wrap: wrap; }
.preset-toggle button.is-warning:not(.is-active) { color: var(--danger); }
.preset-toggle button.is-warning.is-active {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger);
}
.preset-toggle button:disabled { cursor: default; }

.paycheck-bar {
  display: flex;
  height: 38px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--divider);
  margin-bottom: 18px;
}
.paycheck-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.3s ease;
  min-width: 0;
}
.paycheck-seg + .paycheck-seg { border-left: 2px solid var(--surface); }
.paycheck-seg span {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--seg-ink);
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.bucket-card {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 3px solid var(--bucket);
}
.bucket-card.is-invest { background: var(--cta-dim-bg); border-color: var(--cta-dim-bd); border-top-color: var(--bucket); }

.bucket-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bucket-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.bucket-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bucket); flex: none; }
.bucket-pct { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--bucket); }

.bucket-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
}
.bucket-amount span { font-family: var(--font-body); font-weight: 400; font-size: 12px; color: var(--ink-muted); margin-left: 2px; }

/* Bucket sliders take their bucket's color instead of the CTA green. */
input[type="range"].bucket-range {
  background: linear-gradient(to right, var(--bucket, var(--cta)) 0%, var(--bucket, var(--cta)) var(--fill, 50%), var(--divider) var(--fill, 50%), var(--divider) 100%);
}
input[type="range"].bucket-range::-webkit-slider-thumb { background: var(--bucket, var(--cta-deep)); }
input[type="range"].bucket-range::-moz-range-thumb { background: var(--bucket, var(--cta-deep)); }

/* Flexible spending has no slider — it's the remainder — so it gets a
   read-only track in the same spot. */
.bucket-remainder { padding: 6px 0; }
.bucket-remainder-track { height: 4px; border-radius: 999px; background: var(--divider); overflow: hidden; }
.bucket-remainder-track div { height: 100%; background: var(--bucket); transition: width 0.3s ease; }

.bucket-desc { font-size: 11.5px; color: var(--ink-muted); line-height: 1.5; }

.split-notes { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.split-notes p { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 7px; }

.note-warn { color: var(--danger) !important; font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.note-warn svg, .split-notes svg { width: 14px; height: 14px; flex: none; }

/* ---------- FIRE countdown + stat cards ------------------------------------ */

.results-panel {
  padding: clamp(20px, 2.6vw, 28px);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 2fr;
  gap: clamp(18px, 2.4vw, 32px);
  align-items: stretch;
  border-top: 3px solid var(--fire);
}
.results-panel.is-never { border-top-color: var(--danger); }

.fire-hero { display: flex; flex-direction: column; gap: 8px; justify-content: center; }

.fire-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}
.fire-kicker svg { width: 18px; height: 18px; color: var(--fire); flex: none; }
.fire-kicker.is-never { color: var(--danger); font-size: 16px; line-height: 1.4; align-items: flex-start; }
.fire-kicker.is-never svg { color: var(--danger); margin-top: 2px; }

.fire-age { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fire-age-num {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(56px, 8vw, 84px);
  line-height: 1;
  color: var(--fire);
  letter-spacing: -0.03em;
}
.fire-age-suffix { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--ink); }

.fire-countdown {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
}
.fire-countdown svg { width: 15px; height: 15px; }

.fire-sub { font-size: 13px; color: var(--ink-muted); line-height: 1.6; }

.fire-progress { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.fire-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}
.fire-progress-track { height: 8px; border-radius: 999px; background: var(--divider); overflow: hidden; }
.fire-progress-track div { height: 100%; background: var(--fire); border-radius: 999px; transition: width 0.3s ease; }
.fire-progress-note { font-size: 10.5px; color: var(--ink-faint); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stat-grid .stat-card-foot { font-family: var(--font-body); font-size: 11px; color: var(--ink-muted); line-height: 1.45; }

/* ---------- Lifetime chart -------------------------------------------------- */

.lifetime-panel .chart-head { margin-bottom: 10px; }
.lifetime-legend { flex-wrap: wrap; margin-bottom: 12px; font-family: var(--font-body); font-size: 11.5px; color: var(--ink-soft); }
.legend-line {
  width: 18px;
  height: 0;
  border-top: 2px dashed var(--fire);
  display: inline-block;
}
.lifetime-canvas { height: 360px; }

.dollar-toggle button { font-size: 11.5px; padding: 6px 11px; }

/* ---------- Urgency panels -------------------------------------------------- */

.urgency-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(18px, 2vw, 28px);
  align-items: stretch;
}

.urgency-panel { padding: clamp(18px, 2.4vw, 26px); display: flex; flex-direction: column; }

.wait-head,
.wait-row {
  display: grid;
  grid-template-columns: 110px 1fr 76px;
  gap: 12px;
  align-items: center;
}
.wait-head {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
}
.wait-head span:last-child { text-align: right; }

.wait-rows { display: flex; flex-direction: column; }
.wait-row { padding: 12px 0; border-bottom: 1px solid var(--divider); }
.wait-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.wait-row.is-now .wait-label { color: var(--cta-deep); }

.wait-bar-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.wait-bar { height: 10px; border-radius: 3px; background: var(--divider); overflow: hidden; }
.wait-bar div { height: 100%; background: var(--ink-faint); border-radius: 3px; transition: width 0.3s ease; }
.wait-row.is-now .wait-bar div { background: var(--b-invest); }
.wait-bar-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.wait-bar-val em { font-style: normal; color: var(--danger); font-weight: 600; }

.wait-fire {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  color: var(--fire);
}

.wait-notes { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.wait-notes p { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; padding-left: 10px; border-left: 2px solid var(--fire); }

.habit-panel .control-field { margin-bottom: 14px; }

.habit-result {
  margin-top: auto;
  padding: 16px;
  border-radius: 4px;
  background: var(--cta-dim-bg);
  border: 1px solid var(--cta-dim-bd);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.habit-result-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.habit-result-value { font-family: var(--font-mono); font-weight: 800; font-size: 30px; color: var(--cta-deep); line-height: 1.15; }
.habit-result-fire { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--fire); }
.habit-result-fire svg { width: 14px; height: 14px; flex: none; }

/* ---------- Lessons --------------------------------------------------------- */

.lessons-panel { padding: clamp(18px, 2.4vw, 26px); }
.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
}
.lesson-list li { display: flex; gap: 12px; align-items: flex-start; }
.lesson-num {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-dim-bg);
  border: 1px solid var(--accent-dim-bd);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
}
.lesson-list p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.65; }

/* ---------- Share row --------------------------------------------------------- */

.share-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.share-row .btn-primary { font-size: 14px; padding: 12px 22px; }
.share-row .btn-primary svg { width: 15px; height: 15px; }

/* ---------- Presentation mode ---------------------------------------------------
   Toggled by the header "Present" button: the page goes fullscreen and the
   key numbers + chart get bigger for screen-sharing / projectors. */

body.is-presenting .page { max-width: 1480px; }
body.is-presenting .hero-block { display: none; }
body.is-presenting .fire-age-num { font-size: clamp(80px, 10vw, 132px); }
body.is-presenting .fire-kicker { font-size: 18px; }
body.is-presenting .fire-countdown { font-size: 17px; }
body.is-presenting .stat-card-value { font-size: 30px; }
body.is-presenting .bucket-amount { font-size: 24px; }
body.is-presenting .paycheck-bar { height: 48px; }
body.is-presenting .paycheck-seg span { font-size: 16px; }
body.is-presenting .lifetime-canvas { height: 460px; }
body.is-presenting .wait-fire { font-size: 22px; }
body.is-presenting .habit-result-value { font-size: 38px; }
body.is-presenting .lesson-list p { font-size: 15.5px; }

/* ---------- Responsive ------------------------------------------------------------- */

@media (max-width: 1100px) {
  .assumptions-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
  .start-grid { grid-template-columns: repeat(2, 1fr); }
  .bucket-grid { grid-template-columns: repeat(2, 1fr); }
  .results-panel { grid-template-columns: 1fr; }
  .urgency-grid { grid-template-columns: 1fr; }
  .lesson-list { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .start-grid, .assumptions-grid { grid-template-columns: 1fr; }
  .bucket-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .bucket-card { padding: 12px; }
  .bucket-amount { font-size: 17px; }
  .bucket-desc { display: none; }
  .present-btn span { display: none; }
  .present-btn { padding: 9px; }
  .preset-toggle { width: 100%; }
  .preset-toggle button { flex: 1 1 40%; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-grid .stat-card-value { font-size: 19px; }
  .stat-grid .stat-card { padding: 12px; }
  .lifetime-canvas { height: 300px; }
  .wait-head, .wait-row { grid-template-columns: 76px 1fr 52px; gap: 8px; }
  .wait-label { font-size: 12px; }
  .dollar-toggle { width: 100%; }
  .dollar-toggle button { flex: 1; }
}
