/* Tools: shared styles for /tools/ and every tool page under it.
 *
 * Load after styles.css. Site components cover the rest: .eyebrow for step
 * labels, .btn for actions, .glossary-list for definitions, and the global
 * field style for inputs. A tool page is built from:
 *   .tool-page       on <main>; left-aligns card headings
 *   .tool-crumb      "Tools / <name>" link row above the eyebrow
 *   .tool-lede       intro paragraph under the h1
 *   .tool-card       panel for the form, results, and explainers
 *   .tool-row        two-column field grid (one column on phones)
 *   .tool-field      label + input + optional .tool-help
 *   .tool-money      wrap a money input to show a "$" prefix
 *   .tool-percent    wrap a rate input to show a "%" suffix
 *   .tool-modes      pill-style radio group
 *   .tool-hint       live "add X to see your result" message
 *   .tool-results    result panel; set data-tone="caution|good|great"
 *   .tool-band       big italic verdict word, coloured by data-tone
 *   .tool-gauge      three-zone meter with a moving .tool-marker
 *   .tool-stats      row of four .tool-stat figures
 *   .tool-callout    boxed aside inside results
 *   .tool-next       pill links to assessments and guides
 *   .tool-formula    centred formula callout
 * Tool-specific pieces stay in the page's own <style> block.
 */

/* ---------- Tool page ---------- */
/* Tools toggle panels with the hidden attribute; never let a display rule win. */
.tool-page [hidden] { display: none !important; }

/* .page-content centers its header; tool pages read left like articles. */
.tool-page > header { text-align: left; }
.tool-page > header h1,
.tool-page > header p { margin-left: 0; margin-right: 0; }
/* Section labels are h2s for the outline but look like the site eyebrow. */
.tool-page h2.eyebrow { font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 2.6px; line-height: 1.6; }

.tool-page .tool-card .section-heading { text-align: left; margin-top: 0; }
.tool-page .tool-results .section-heading { margin-top: 26px; }

.tool-crumb { font-size: 13px; font-weight: 600; color: var(--ink-subtle); margin: 0 0 8px; }
.page-content .tool-crumb a { color: var(--ink-subtle); }
.page-content .tool-crumb a:hover { color: var(--ink); }

.tool-lede { font-size: 18px; color: var(--ink-soft); max-width: 58ch; margin-bottom: 26px; }

.tool-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  padding: 26px;
  margin-bottom: 26px;
}

/* Form */
.tool-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.tool-help { display: block; font-size: 12px; color: var(--ink-subtle); margin-top: 5px; }
.tool-money { position: relative; display: block; }
.tool-money::before {
  content: "$"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-subtle); font-size: 16px; pointer-events: none;
}
.tool-money input[type="text"] { padding-left: 28px; }
.tool-percent { position: relative; display: block; }
.tool-percent::after {
  content: "%"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-subtle); font-size: 16px; pointer-events: none;
}
.tool-percent input[type="text"] { padding-right: 32px; }
.tool-field input[type="text"] { font-variant-numeric: tabular-nums; }
.tool-modes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; border: 0; padding: 0; }
.tool-modes legend { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.tool-modes input { position: absolute; opacity: 0; pointer-events: none; }
.tool-modes label {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; margin: 0;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--paper);
  font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.tool-modes input:checked + label { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tool-modes input:focus-visible + label { outline: 2px solid var(--dim); outline-offset: 2px; }
.tool-hint { font-size: 14px; color: var(--ink-subtle); margin: 14px 0 0; min-height: 1.4em; }
.tool-submit { margin-top: 18px; }
.tool-privacy { font-size: 13px; color: var(--ink-subtle); }

/* Results */
.tool-results { --tone: var(--ink); }
.tool-results[data-tone="caution"] { --tone: var(--band-mixed); }
.tool-results[data-tone="good"] { --tone: var(--d-financial); }
.tool-results[data-tone="great"] { --tone: var(--d-security); }
.tool-verdict { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.tool-band { font-family: var(--serif); font-size: clamp(30px, 6vw, 42px); font-style: italic; font-weight: 600; letter-spacing: -0.8px; color: var(--tone); }
.tool-ratio { font-size: 15px; color: var(--ink-soft); }
.tool-ratio strong { font-family: var(--serif); font-size: 22px; color: var(--ink); }
.tool-summary { color: var(--ink-soft); margin: 10px 0 22px; }

/* Three-zone gauge. Set the zone widths with --zones on .tool-gauge
   (default 1fr 3fr 2fr) and move .tool-marker with style.left = "NN%". */
.tool-gauge { --zones: 1fr 3fr 2fr; position: relative; margin: 8px 0 34px; }
.tool-gauge-track { display: grid; grid-template-columns: var(--zones); height: 14px; border-radius: var(--r-pill); overflow: hidden; }
.tool-gauge-track span:nth-child(1) { background: color-mix(in srgb, var(--band-mixed) 30%, var(--paper)); }
.tool-gauge-track span:nth-child(2) { background: color-mix(in srgb, var(--d-financial) 30%, var(--paper)); }
.tool-gauge-track span:nth-child(3) { background: color-mix(in srgb, var(--d-security) 30%, var(--paper)); }
.tool-marker {
  position: absolute; top: -5px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%;
  background: var(--ink); border: 4px solid var(--card); box-shadow: 0 2px 8px rgba(0,0,0,.25);
  transition: left .35s ease;
}
.tool-gauge-labels { display: grid; grid-template-columns: var(--zones); font-size: 12px; font-weight: 600; color: var(--ink-subtle); margin-top: 8px; }
.tool-gauge-labels span:nth-child(2) { text-align: center; }
.tool-gauge-labels span:nth-child(3) { text-align: right; }

.tool-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.tool-stat { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.tool-stat span { display: block; font-size: 12px; color: var(--ink-subtle); }
.tool-stat strong { font-family: var(--serif); font-size: 20px; font-variant-numeric: tabular-nums; }
.tool-note { font-size: 14px; color: var(--ink-soft); }
.tool-callout {
  font-size: 14px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px; margin: 14px 0 0;
}
.tool-steps { padding-left: 20px; }
.tool-steps li { margin-bottom: 6px; }
.tool-next { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.page-content .tool-next a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none;
}
.page-content .tool-next a:hover { border-color: var(--dim); }

.tool-formula {
  font-family: var(--serif); font-size: 20px; text-align: center; padding: 16px;
  border: 1px dashed var(--line); border-radius: var(--r-md); margin: 12px 0 16px;
}

@media (max-width: 640px) {
  .tool-card { padding: 20px 16px; }
  .tool-row { grid-template-columns: 1fr; }
  .tool-stats { grid-template-columns: 1fr 1fr; }
  .tool-submit { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .tool-marker { transition: none; }
}

/* ---------- /tools/ landing page ---------- */
.tools-promises { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.page-content .tools-promises { margin: 0; }
.tools-promises li {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--card);
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.tools-promises svg { color: var(--m-accent); flex-shrink: 0; }

.tools-section { margin: 0 0 40px; }
.tools-section > .eyebrow { margin-bottom: 14px; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.tool-tile {
  --tile: var(--m-accent);
  position: relative; display: flex; flex-direction: column; gap: 6px; overflow: hidden;
  padding: 22px 22px 22px 26px; border-radius: var(--r-lg); background: var(--card);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool-tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tile); }
.page-content a.tool-tile { color: var(--ink); }
.page-content a.tool-tile:hover, .page-content a.tool-tile:focus-visible {
  transform: translateY(-2px); box-shadow: var(--card-shadow); border-color: var(--tile); text-decoration: none;
}
.tool-tile-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tool-tile-dim { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--tile); }
.tool-tile-time { font-size: 12px; color: var(--ink-subtle); }
.page-content .tool-tile-title { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -0.3px; margin: 2px 0 0; }
.page-content .tool-tile-question { font-style: italic; color: var(--ink-soft); margin: 0; }
.page-content .tool-tile-desc { font-size: 14px; color: var(--ink-soft); margin: 0; flex: 1; }
.tool-tile-cta { margin-top: 10px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--tile); }

.tool-tile--featured { padding: 28px 28px 28px 32px; background: color-mix(in srgb, var(--tile) 7%, var(--card)); }
.page-content .tool-tile--featured .tool-tile-title { font-size: clamp(26px, 4vw, 32px); }
@media (min-width: 641px) {
  .tool-tile--featured { grid-column: 1 / -1; display: grid; grid-template-columns: 1.3fr 1fr; column-gap: 32px; align-items: start; }
  .tool-tile--featured > .tool-tile-meta,
  .tool-tile--featured > .tool-tile-title,
  .tool-tile--featured > .tool-tile-question,
  .tool-tile--featured > .tool-tile-cta { grid-column: 1; }
  .tool-tile--featured > .tool-tile-desc { grid-column: 2; grid-row: 1 / span 4; align-self: center; }
}

.tool-tile--soon { background: transparent; border-style: dashed; }
.tool-tile--soon::before { opacity: .45; }
.tool-tile-soon-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--r-pill); border: 1px solid var(--line); color: var(--ink-subtle);
}

.tools-how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.page-content .tools-how h3 { font-family: var(--serif); font-size: 18px; margin: 0 0 6px; }
.page-content .tools-how p { font-size: 14px; color: var(--ink-soft); margin: 0; }
@media (max-width: 640px) { .tools-how { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .tool-tile { transition: none; } }

/* Tile accent per wealth dimension: add tool-tile--<dimension>. */
.tool-tile--financial { --tile: var(--d-financial); }
.tool-tile--retirement { --tile: var(--d-retirement); }
.tool-tile--security { --tile: var(--d-security); }
.tool-tile--medical { --tile: var(--d-medical); }
.tool-tile--physical { --tile: var(--d-physical); }
.tool-tile--mental { --tile: var(--d-mental); }
.tool-tile--social { --tile: var(--d-social); }
.tool-tile--time { --tile: var(--d-time); }

/* ---------- Result charts (tool-charts.js) ----------
   Categorical slots s1–s4 are the validated reference order (blue, orange,
   aqua, yellow): adjacent CVD ΔE ≥ 9.1 light / 8.4 dark, normal-vision
   ΔE ≥ 22.9 / 19.8 on this site's card surfaces; s1–s3 also pass all-pairs.
   Aqua and yellow sit under 3:1 on the light card, so every chart carries
   direct labels and a table view. accent = the page's dimension color for
   the one emphasized mark; muted = context. Text never wears a series color. */
.viz {
  --viz-s1: #2a78d6; --viz-s2: #eb6834; --viz-s3: #1baf7a; --viz-s4: #eda100;
  --viz-muted: #cfc8be;
  --viz-grid: var(--grid-line);
  --viz-axis: var(--line);
  margin: 26px 0 8px;
}
[data-theme="dark"] .viz {
  --viz-s1: #3987e5; --viz-s2: #d95926; --viz-s3: #199e70; --viz-s4: #c98500;
  --viz-muted: #4a433c;
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .viz {
    --viz-s1: #3987e5; --viz-s2: #d95926; --viz-s3: #199e70; --viz-s4: #c98500;
    --viz-muted: #4a433c;
  }
}
.viz-c-s1 { --c: var(--viz-s1); }
.viz-c-s2 { --c: var(--viz-s2); }
.viz-c-s3 { --c: var(--viz-s3); }
.viz-c-s4 { --c: var(--viz-s4); }
.viz-c-accent { --c: var(--dim); }
.viz-c-muted { --c: var(--viz-muted); }

.viz-figure { margin: 0; }
.viz-title { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); margin: 0 0 2px; }
.page-content .viz-subtitle { font-size: 13px; color: var(--ink-subtle); margin: 0 0 10px; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-key { display: inline-block; flex-shrink: 0; background: var(--c); }
.viz-key--line { width: 14px; height: 2px; border-radius: 1px; }
.viz-key--rect { width: 10px; height: 10px; border-radius: 3px; }

.viz-plot { position: relative; }
.viz-svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tick { font-size: 11px; fill: var(--ink-subtle); font-variant-numeric: tabular-nums; }
.viz-axis-title { font-size: 11px; fill: var(--ink-subtle); }
.viz-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area { fill: var(--c); opacity: .1; stroke: none; }
.viz-dot { fill: var(--c); stroke: var(--card); stroke-width: 2; }
.viz-ref { stroke: var(--ink-subtle); stroke-width: 1; }
.viz-ref-label { font-size: 12px; font-weight: 600; fill: var(--ink-soft); paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
.viz-end-value { font-size: 12px; font-weight: 700; fill: var(--ink); }
.viz-end-name { font-size: 11px; fill: var(--ink-subtle); }
.viz-cross { stroke: var(--ink-subtle); stroke-width: 1; pointer-events: none; }
.viz-hit { fill: transparent; cursor: crosshair; }
.viz-hit:focus { outline: none; }
.viz-hit:focus-visible { outline: none; stroke: var(--dim); stroke-width: 2; }

.viz-bar { fill: var(--c); transition: opacity .15s; }
.viz-bar-hit { fill: transparent; }
.viz-bar-row { cursor: default; outline: none; }
.viz-bar-row:hover .viz-bar, .viz-bar-row:focus .viz-bar { opacity: .8; }
.viz-bar-row:focus-visible .viz-bar-hit { stroke: var(--dim); stroke-width: 2; }
.viz-bar-label { font-size: 13px; fill: var(--ink-soft); }
.viz-bar-label--em { font-weight: 700; fill: var(--ink); }
.viz-bar-value { font-size: 13px; fill: var(--ink-soft); font-variant-numeric: tabular-nums; }
.viz-bar-value--em { font-weight: 700; fill: var(--ink); }
.viz-seg-label { font-size: 12px; font-weight: 700; fill: #fff; pointer-events: none; }
.viz-seg-label--ink { fill: #1c1917; }

.viz-tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 120px; max-width: 240px;
  padding: 8px 10px; border-radius: var(--r-sm); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--card-shadow); font-size: 13px; color: var(--ink-soft);
}
.viz-tip[hidden] { display: none; }
.viz-tip-title { font-size: 12px; color: var(--ink-subtle); margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.viz-tip-row strong { color: var(--ink); font-size: 14px; }
.viz-tip-name { color: var(--ink-subtle); }

.viz-table { margin-top: 10px; font-size: 13px; }
.viz-table summary { cursor: pointer; color: var(--ink-subtle); font-weight: 600; width: max-content; }
.viz-table summary:hover { color: var(--ink); }
.viz-table-wrap { overflow-x: auto; margin-top: 8px; }
.viz-table table { border-collapse: collapse; width: 100%; }
.viz-table caption { text-align: left; font-size: 12px; color: var(--ink-subtle); padding-bottom: 6px; }
.viz-table th, .viz-table td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; color: var(--ink-soft); }
.viz-table thead th { font-weight: 700; color: var(--ink); }
.viz-table .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .viz-bar { transition: none; } }
@media print { .viz-table { display: none; } }

.tool-optional { font-weight: 400; color: var(--ink-subtle); }
