/* ==========================================================================
   "What am I worth?" — page-specific components
   Loaded ONLY by /playground/worth/, after calstrs.css (which supplies the
   shared calculator pieces: .calc-card, .formula, .segmented, sliders, the
   disclaimer). main.css is never modified.

   Every colour is a main.css token (the map ramp mixes them). Light mode only,
   like calstrs.css. Amber TEXT uses --amber-text; --amber is graphics-only.
   ========================================================================== */

@layer components {

  /* the choropleth ramp: emerald-soft → emerald-bright → emerald */
  .w-mapbox, .w-legend {
    --w1: var(--emerald-soft);
    --w2: color-mix(in oklab, var(--emerald-soft), var(--emerald-bright) 25%);
    --w3: color-mix(in oklab, var(--emerald-soft), var(--emerald-bright) 50%);
    --w4: color-mix(in oklab, var(--emerald-soft), var(--emerald-bright) 75%);
    --w5: var(--emerald-bright);
    --w6: color-mix(in oklab, var(--emerald-bright), var(--emerald) 50%);
    --w7: var(--emerald);
  }

  .w-lbl {
    display: block; font-size: var(--fs-small); font-weight: 700;
    color: var(--ink); margin-bottom: 5px;
  }

  /* ── search comboboxes ────────────────────────────────────────────── */
  .w-search { position: relative; min-width: 0; }
  .calc-body .w-search input[type="search"] {
    width: 100%; padding: 9px 11px; font-size: 1rem;
    font-family: var(--sans); color: var(--ink);
    background: var(--paper); border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
  }
  .calc-body .w-search input[type="search"]:focus-visible {
    outline: 2px solid var(--emerald); outline-offset: 1px;
  }
  .w-search.has-mine input[type="search"] { border-color: var(--amber); }
  .w-results {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
    margin: 0; padding: 4px; list-style: none;
    background: #fff; border: 1px solid var(--rule);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
    max-height: 300px; overflow: auto;
  }
  .w-results li button {
    width: 100%; text-align: left; font: inherit; font-size: .9375rem;
    color: var(--ink); background: none; border: 0; border-radius: 8px;
    padding: 8px 9px; cursor: pointer;
    display: flex; justify-content: space-between; gap: var(--s1);
  }
  .w-results li button:hover, .w-results li button.active { background: var(--emerald-soft); }
  .w-results small { color: var(--ink-soft); white-space: nowrap; }
  .w-results .none { padding: 8px 9px; font-size: var(--fs-small); color: var(--ink-soft); }
  .w-linkbtn {
    font: inherit; font-size: var(--fs-small); color: var(--emerald);
    background: none; border: 0; padding: 6px 0 0; cursor: pointer;
    text-decoration: underline; text-underline-offset: 2px;
  }

  /* ── the controls card: compact, so the map starts on the first screen ── */
  .w-hero { padding-block: var(--s4) 0; }
  .w-subtitle {
    margin: 4px 0 0; font-family: var(--serif); font-style: italic; font-weight: 400;
    font-size: clamp(1.125rem, 2vw, 1.375rem); line-height: 1.3; color: var(--ink-soft);
  }
  #yearsWrap.is-off input[type="range"] { opacity: .45; }
  .w-sw-mine { box-shadow: 0 0 0 2px var(--paper); }
  .w-body { padding-top: var(--s3); }
  .w-controls { padding: var(--s3); margin-top: 0; }
  .w-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--s2) var(--s3); align-items: start;
  }
  .w-yrs { font-family: var(--mono); color: var(--emerald); margin-left: 4px; white-space: nowrap; }
  .calc-body #yearsWrap input[type="range"] { margin-top: 10px; }
  .w-row2 {
    display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: end;
    margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--rule-soft);
  }
  .w-row2 .seg { padding: 7px 12px; font-size: .875rem; }
  @media (max-width: 560px) {
    /* phones: job + years share a row */
    .w-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
    .w-row .w-search { grid-column: 1 / -1; }
    .w-controls { padding: var(--s2); }
    .w-regions { width: 100%; }
    /* phones: region buttons wrap into two rows */
    .w-regions .w-regionbtns { gap: 6px 4px; }
    .w-regions .w-regionbtns button { padding: 0 8px; font-size: .75rem; letter-spacing: -.01em; }
    .w-bar { white-space: normal; font-size: .875rem; line-height: 1.3; padding-top: 10px; }
  }
  .w-summary {
    margin: 0; padding: 12px 14px; border-radius: 9px;
    background: var(--emerald-soft); color: var(--ink); font-size: .9375rem;
  }
  .w-summary strong { font-variant-numeric: tabular-nums; }

  /* ── region shortcuts ─────────────────────────────────────────────── */
  .w-regions { min-width: 0; }
  .w-regionbtns { display: flex; flex-wrap: wrap; gap: 6px; }
  .w-regionbtns button {
    font: inherit; font-size: .8125rem; font-weight: 700;
    color: var(--emerald); background: #fff;
    border: 1px solid var(--rule); border-radius: 999px;
    min-height: 44px; padding: 0 12px; cursor: pointer;
  }
  .w-regionbtns button:hover { background: var(--emerald-soft); border-color: var(--emerald-bright); }
  .w-regionbtns button:focus-visible,
  .w-zoom button:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

  /* ── map + side column ────────────────────────────────────────────── */
  .w-main {
    display: grid; grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--s3); align-items: start; margin-top: var(--s3);
  }
  @media (max-width: 900px) { .w-main { grid-template-columns: minmax(0, 1fr); } }

  .w-mapbox {
    position: relative; background: #fff; border: 1px solid var(--rule-soft);
    border-radius: var(--radius-sm); overflow: hidden; min-width: 0;
  }
  .w-mapbox svg {
    display: block; width: 100%; height: auto; max-height: 82vh;
    touch-action: pan-y; cursor: grab;
  }
  .w-mapbox svg.zoomed { touch-action: none; }
  .w-mapbox svg:active { cursor: grabbing; }
  .w-mapbox path.d {
    stroke: #fff; stroke-width: .5px; vector-effect: non-scaling-stroke; cursor: pointer;
  }
  .w-mapbox path.d.off { display: none; }
  .w-mapbox .county {
    fill: none; stroke: var(--ink-soft); stroke-opacity: .4; stroke-width: .9px;
    vector-effect: non-scaling-stroke; pointer-events: none;
  }
  .w-mapbox .hl {
    fill: none; stroke: var(--ink); stroke-width: 2.2px;
    vector-effect: non-scaling-stroke; pointer-events: none;
  }
  .w-mapbox .mine {
    fill: none; stroke: var(--amber); stroke-width: 3px;
    vector-effect: non-scaling-stroke; pointer-events: none;
  }
  /* a paper halo under the amber line, so it reads on the dark greens too */
  .w-mapbox .mine-halo {
    fill: none; stroke: var(--paper); stroke-width: 7px; stroke-linejoin: round;
    vector-effect: non-scaling-stroke; pointer-events: none;
  }
  .w-loading {
    position: absolute; inset: 0 0 auto 0; padding: var(--s4);
    text-align: center; color: var(--ink-soft); font-size: var(--fs-small);
  }
  .w-loading[hidden] { display: none; }

  /* zoom controls: 44px targets, top-right corner */
  .w-zoom {
    position: absolute; top: 10px; right: 10px;
    display: grid; gap: 6px; justify-items: end;
  }
  .w-zoom button {
    min-width: 44px; height: 44px; padding: 0 12px;
    font: 700 1.375rem/1 var(--sans); color: var(--ink);
    background: #fff; border: 1px solid var(--rule); border-radius: 10px;
    box-shadow: var(--shadow-1); cursor: pointer;
  }
  .w-zoom button:hover { background: var(--emerald-soft); }
  .w-zoom .w-zall { font-size: var(--fs-small); }

  .w-wheelhint {
    position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
    background: var(--ink); color: var(--paper-on-ink);
    padding: 10px 16px; border-radius: 999px; font-size: var(--fs-small);
    font-weight: 700; pointer-events: none; opacity: 0;
    transition: opacity .2s; white-space: nowrap;
  }
  .w-wheelhint.show { opacity: .92; }

  .w-legend {
    display: grid; gap: 6px; padding: 12px var(--s2) var(--s2);
    border-top: 1px solid var(--rule-soft);
  }
  .w-legend b { color: var(--ink); }
  .w-bins, .w-binlabels {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px;
  }
  .w-bins div { height: 12px; }
  .w-bins div:first-child { border-radius: 4px 0 0 4px; }
  .w-bins div:last-child { border-radius: 0 4px 4px 0; }
  .w-binlabels {
    font-family: var(--mono); font-size: .6875rem; color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
  }
  .w-keys {
    display: flex; flex-wrap: wrap; gap: 6px 16px;
    font-size: var(--fs-small); color: var(--ink-soft);
  }
  .w-keys span { display: inline-flex; align-items: center; gap: 6px; }
  .w-sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; flex: none; }
  .w-sw-nd {
    background: repeating-linear-gradient(135deg, var(--paper-deep) 0 3px, var(--rule) 3px 5px);
    border: 1px solid var(--rule);
  }
  .w-sw-mine { border: 3px solid var(--amber); }

  .w-side { display: grid; gap: var(--s3); min-width: 0; }
  .w-card {
    background: #fff; border: 1px solid var(--rule-soft);
    border-radius: var(--radius-sm); padding: var(--s3); min-width: 0;
  }
  #card { display: grid; gap: 12px; border-left: 5px solid var(--emerald); }
  #card.is-mine { border-left-color: var(--amber); }
  .w-state {
    display: flex; justify-content: space-between; align-items: baseline; gap: var(--s1);
    font-family: var(--mono); font-size: var(--fs-eyebrow);
    text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft);
  }
  .w-card h2 {
    font-size: 1.5rem; line-height: 1.15; margin: 0; overflow-wrap: anywhere;
  }
  .w-meta { font-size: var(--fs-small); color: var(--ink-soft); margin-top: 2px; }
  .w-minebadge {
    display: inline-block; font-family: var(--sans); font-size: .75rem; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase; color: var(--amber-text);
    background: #fff; border: 1px solid var(--amber); border-radius: 999px; padding: 1px 8px;
    margin-left: 6px; vertical-align: 3px;
  }
  .w-fig {
    font-family: var(--mono); font-size: clamp(2rem, 6vw, 2.5rem);
    line-height: 1.05; font-weight: 700; letter-spacing: -.03em;
    color: var(--ink); font-variant-numeric: tabular-nums;
  }
  .w-figlabel { font-size: var(--fs-small); color: var(--ink-soft); }
  .w-delta { font-size: var(--fs-small); font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
  .w-delta.up { color: var(--emerald); }
  .w-delta.down { color: var(--amber-text); }
  .w-delta.same, .w-delta.none { color: var(--ink-soft); font-weight: 400; }

  .w-curve svg { width: 100%; height: auto; display: block; overflow: visible; }
  .w-curve .axis { stroke: var(--rule); stroke-width: 1; }
  .w-curve .ln { fill: none; stroke: var(--emerald); stroke-width: 2; }
  .w-curve .area { fill: var(--emerald-bright); opacity: .12; }
  .w-curve .knot { fill: #fff; stroke: var(--emerald); stroke-width: 2; }
  .w-curve .now { fill: var(--amber); stroke: #fff; stroke-width: 2; }
  .w-curve .nowline { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 3 3; }
  .w-curve text { font-family: var(--mono); font-size: 10.5px; fill: var(--ink-soft); }

  .w-btns { display: flex; flex-wrap: wrap; gap: var(--s1); }
  .w-btns .btn { font-size: var(--fs-small); }
  .w-ghost {
    font: inherit; font-size: var(--fs-small); font-weight: 700; color: var(--emerald);
    background: #fff; border: 1px solid var(--rule); border-radius: 999px;
    min-height: 44px; padding: 0 16px; cursor: pointer;
  }
  .w-ghost:hover { background: var(--emerald-soft); }

  dl.w-pts {
    margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px var(--s2); font-size: var(--fs-small);
  }
  dl.w-pts dt { color: var(--ink-soft); min-width: 0; }
  dl.w-pts dd {
    margin: 0; text-align: right; font-family: var(--mono); font-weight: 700;
    color: var(--ink); font-variant-numeric: tabular-nums;
  }
  .w-sub {
    margin: 4px 0 0; font-family: var(--mono); font-size: var(--fs-eyebrow);
    text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft);
    padding-top: 8px; border-top: 1px solid var(--rule-soft);
  }
  .w-cardnote { font-size: var(--fs-eyebrow); color: var(--ink-soft); margin: 0; }

  .w-top h3 { margin-top: 0; font-family: var(--serif); font-weight: 400; font-size: 1.375rem; }
  .w-top ol { margin: var(--s1) 0 0; padding: 0; list-style: none; }
  .w-top li button {
    width: 100%; display: grid; grid-template-columns: 2.5ch minmax(0, 1fr) auto;
    gap: 10px; align-items: baseline; font: inherit; font-size: .9375rem;
    color: var(--ink); background: none; border: 0; border-top: 1px solid var(--rule-soft);
    padding: 9px 2px; min-height: 44px; text-align: left; cursor: pointer;
  }
  .w-top li button:hover { background: var(--emerald-soft); }
  .w-top li.is-mine button { background: var(--amber-soft); }
  .w-top .rk { color: var(--ink-soft); font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
  .w-top .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .w-top .nm small { color: var(--ink-soft); }
  .w-top .v { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
  .w-rank {
    margin: var(--s1) 0 0; padding-top: var(--s1);
    border-top: 2px solid var(--amber); font-size: var(--fs-small); color: var(--ink-soft);
  }
  .w-rank b { color: var(--ink); }

  /* ── one column right (card) and the units list ─────────────────── */
  .w-colgap {
    margin: 0; padding: 10px 12px; border-radius: 9px;
    background: var(--emerald-soft); font-size: var(--fs-small); color: var(--ink);
  }
  .w-colgap b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  .w-colgap a { color: var(--emerald); white-space: nowrap; }
  .w-pd h3 { margin-top: 0; }
  .w-pd h3 + .calc-note { margin-bottom: var(--s1); }
  .w-pdlist { list-style: none; margin: var(--s1) 0 var(--s4); padding: 0; }
  .w-pdlist:last-of-type { margin-bottom: var(--s2); }
  .w-pdlist li {
    display: grid; gap: 2px; padding: 12px 0; border-top: 1px solid var(--rule-soft);
  }
  .w-pdlist a { font-weight: 700; color: var(--emerald); overflow-wrap: anywhere; }
  .w-price {
    font-size: var(--fs-small); font-weight: 700; color: var(--ink);
    font-variant-numeric: tabular-nums;
  }
  .w-pdline { font-size: var(--fs-small); color: var(--ink-soft); }
  .w-pdnote { margin: 0; padding-top: var(--s2); border-top: 1px solid var(--rule-soft); }

  /* ── result bar: one line, always in view ───────────────────────── */
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .w-bar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    display: block; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--ink); color: var(--paper-on-ink); text-decoration: none;
    font-size: .9375rem; font-weight: 700; text-align: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    box-shadow: 0 -4px 16px rgba(23, 26, 43, .12);
  }
  .w-bar:hover { color: #fff; }
  .w-bar:focus-visible { outline: 2px solid var(--amber); outline-offset: -4px; }
  .w-bar .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  .w-copyout { width: 100%; margin-top: 6px; font: inherit; font-size: var(--fs-small); padding: 6px 8px;
    border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--ink); }
  .w-career { margin-top: 2px; font-size: var(--fs-small); color: var(--ink-soft); }
  .w-career b { color: var(--ink); font-variant-numeric: tabular-nums; }
  .w-results .dym { padding: 8px 9px 2px; font-size: var(--fs-small); color: var(--ink-soft); }

  @media (prefers-reduced-motion: reduce) {
    .w-wheelhint { transition: none; }
  }
  @media print {
    .w-zoom, .w-regions, .w-wheelhint, .w-bar { display: none; }
  }
}
