/* Shared styles for the interactive no-login tools (life-in-weeks, the die-with-zero
   estimator). Loaded alongside guide.css, which already covers header/footer,
   typography and .btn. Keep tokens in sync with public/index.html and src/styles.css. */

.tool {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 24px 1rem;
}
.tool .crumbs { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.02em; color: var(--muted); margin-bottom: 1.6rem; }
.tool .crumbs a { color: var(--muted); text-decoration: none; }
.tool .crumbs a:hover { color: var(--ink); }
.tool .crumbs span { margin: 0 0.4rem; }
.tool h1 { font-size: clamp(1.9rem, 4.4vw, 2.7rem); margin-bottom: 0.7rem; }
.tool .lede { font-size: 1.05rem; color: var(--muted); max-width: 62ch; margin: 0 0 2.2rem; }

/* Card shell — matches .viz / .stage on the landing page. */
.tool-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: clamp(1.1rem, 3vw, 1.7rem);
  margin: 0 0 1.8rem;
}
.tool-card-title { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.03em; color: var(--muted); margin: 0 0 1.1rem; }

/* Input form */
.tool-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1.1rem 1.4rem; }
.tool-field { display: flex; flex-direction: column; gap: 0.4rem; }
.tool-field label { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.03em; color: var(--muted); }
.tool-field .unit-wrap { position: relative; }
.tool-field input {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.55rem 0.7rem;
}
.tool-field.has-prefix input { padding-left: 1.5rem; }
.tool-field .prefix {
  position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.95rem; pointer-events: none;
}
.tool-field input:focus-visible { outline: 2px solid var(--slate); outline-offset: 1px; }
.tool-field input::-webkit-outer-spin-button, .tool-field input::-webkit-inner-spin-button { opacity: 0.5; }

/* Result callout */
.tool-result { margin-top: 1.6rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.tool-result-label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.03em; color: var(--muted); margin: 0 0 0.5rem; }
.tool-result-value {
  font-family: var(--serif); font-weight: 500; font-size: clamp(2rem, 6vw, 2.9rem);
  color: var(--slate); letter-spacing: -0.015em; margin: 0; text-wrap: balance;
}
.tool-result-note { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.92rem; max-width: 58ch; }
.tool-result-note.warn { color: var(--bad); }
.tool-result-value.warn { color: var(--bad); }

.tool-aside { margin-top: 1.3rem; font-size: 0.88rem; color: var(--muted); max-width: 60ch; }
.tool-aside p + p { margin-top: 0.6rem; }

/* Comparison table (retire-on's withdrawal-rate breakdown). Roomier padding than the
   landing page's own .cmp-table — that one sits in a tighter card, this one is the main
   content on its page. */
.cmp-wrap { overflow-x: auto; }
.cmp-table { width: 100%; border-collapse: collapse; margin-top: 1.3rem; font-size: 0.95rem; }
.cmp-table th {
  text-align: left;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 1.4rem 1rem 0;
  border-bottom: 1px solid var(--line);
}
.cmp-table td {
  padding: 1rem 1.4rem 1rem 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.cmp-table td:first-child { color: var(--ink); }
.cmp-table tr:last-child td { border-bottom: 0; }

/* Life-in-weeks widget — same visual language as the landing page grid. */
.viz-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1rem; margin-bottom: 0.9rem; }
.viz-title { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.03em; color: var(--muted); }
.chip {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.03em;
  padding: 3px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; color: var(--muted);
}
.weeks-canvas-wrap canvas { display: block; width: 100%; height: auto; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.3rem; margin-top: 0.9rem; font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.02em; color: var(--muted); }
.viz-legend b { color: var(--ink); font-weight: 500; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 5px; transform: translateY(-1px); }
.sw-dot { border-radius: 50%; }
.sw-open { background: transparent; border: 1.5px solid; border-radius: 50%; }

/* Drawdown chart (retire-on's balance-over-time SVG). Same visual language as the
   landing page's net-worth chart, reduced to a single computed line — no percentile
   band, since this is one deterministic trajectory, not a Monte Carlo run. */
.dd-chart { display: block; width: 100%; height: auto; margin-top: 1.2rem; }
.dd-chart .axis { stroke: var(--muted); stroke-width: 1; }
.dd-chart .grid { stroke: var(--line); stroke-width: 1; }
.dd-chart .line { fill: none; stroke: var(--slate); stroke-width: 2.2; }
.dd-chart .dot { fill: var(--slate); }
.dd-chart .lbl { fill: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: 0.02em; }
.dd-chart .lbl.end { text-anchor: end; }
.dd-chart .lbl.axis-y { font-variant-numeric: tabular-nums; }

/* SVG text scales with the viewBox on narrow screens — 10px design-space text renders
   at ~4-5px on a phone and is unreadable. Same fix as the landing page (2026-09-22). */
@media (max-width: 620px) {
  .dd-chart .lbl { font-size: 22px; }
  .dd-chart .line { stroke-width: 4.4; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
