/* ============================================================
   Compensation Lab — interactive layer.
   Extends story.css. Same editorial dark palette, but built for
   interaction: controls, matrix, tile map, distribution ladder.
   ============================================================ */

[data-story="comp"] { --accent:#b8892b; --accent-2:#e2b455; --accent-dim:rgba(184,137,43,.16);
  /* Caption tone for the neutral/secondary labels ("vs national", row keys) and
     for deltas too small for the sample to call a direction.
     --ink-3/--ink-4 measure 3.5:1 and 2.1:1 on this background, which fails
     WCAG AA for small text — unacceptable for the labels that carry the
     honesty of the comparison. This clears 5.5:1 at 9px. */
  --ink-cap:#968f85; }

.lab-head {
  padding: 20vh 0 7vh;
  position: relative; overflow: hidden;
}
.lab-head::after {
  content:""; position:absolute; inset:0; pointer-events:none;
  background:
    radial-gradient(55% 45% at 15% 10%, var(--accent-dim), transparent 70%),
    radial-gradient(45% 40% at 88% 70%, rgba(63,157,143,.10), transparent 70%);
}
.lab-head .standfirst { max-width: 36rem; }

.lab-section { padding: 8vh 0; border-top: 1px solid var(--line-2); }
.lab-section.alt { background: rgba(244,241,236,.018); }

.lab-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--accent-2); margin-bottom: 12px;
}
.lab-h2 {
  font-family: var(--serif); font-size: clamp(1.6rem,3.8vw,2.6rem);
  font-weight: 600; letter-spacing: -.025em; line-height: 1.1;
  margin: 0 0 14px; text-wrap: balance;
}
.lab-intro { color: var(--ink-2); max-width: 44rem; margin: 0 0 26px; font-size: 1rem; }
.lab-intro b { color: var(--ink); }
.lab-note { font-size: .85rem; color: var(--ink-3); margin-top: 16px; max-width: 46rem; line-height: 1.6; }
.lab-note a { color: var(--accent-2); }

/* ---------- Controls ---------- */
.controls {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
  padding: 18px 20px; margin-bottom: 26px;
  background: rgba(244,241,236,.03); border: 1px solid var(--line-2);
  border-radius: 3px;
}
.ctl { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ctl label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--ink-3);
}
.ctl select {
  background: var(--void-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 9px 11px; font-size: 14px; font-family: var(--sans);
  min-width: 168px; max-width: 240px; cursor: pointer;
}
.ctl select:hover { border-color: var(--accent); }
.ctl-btn {
  padding: 10px 15px; border: 1px solid var(--line); border-radius: 3px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--ink-2); background: var(--void-2);
  transition: border-color .15s, color .15s;
}
.ctl-btn:hover { border-color: var(--accent-2); color: var(--ink); }

/* ---------- Comparison matrix ---------- */
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.matrix-table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 13.5px; }
table.matrix-table th, table.matrix-table td {
  padding: 11px 13px; text-align: right;
  border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2);
  white-space: nowrap;
}
table.matrix-table thead th {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .9px;
  text-transform: uppercase; color: var(--ink-3); font-weight: 600;
  vertical-align: bottom; border-bottom: 1px solid var(--line);
}
table.matrix-table th.rowhead {
  text-align: left; color: var(--ink); font-family: var(--sans);
  font-size: 13.5px; letter-spacing: 0; text-transform: none; font-weight: 500;
  position: sticky; left: 0; background: var(--void); z-index: 2;
  max-width: 210px; white-space: normal;
}
.lab-section.alt table.matrix-table th.rowhead { background: #1a1815; }
table.matrix-table tbody tr:hover th.rowhead { color: var(--accent-2); }
td.cell { position: relative; font-variant-numeric: tabular-nums; }
td.cell .v { position: relative; z-index: 1; font-weight: 600; }
td.cell .heat {
  position: absolute; inset: 2px; border-radius: 2px;
  background: var(--accent); z-index: 0;
}
td.cell .b {
  display: block; font-family: var(--mono); font-size: 9.5px;
  color: var(--ink-4); font-weight: 400; margin-top: 2px; position: relative; z-index: 1;
}
td.sup { color: var(--ink-4); font-size: 11px; font-family: var(--mono); letter-spacing: .5px; }
td.total, th.total { background: rgba(244,241,236,.035); font-weight: 700; }
tr.total-row td, tr.total-row th { border-top: 1px solid var(--line); background: rgba(244,241,236,.035); }

/* ---------- Tile map ---------- */
.map-layout { display: grid; grid-template-columns: 1fr 290px; gap: 30px; align-items: start; }
@media (max-width: 900px) { .map-layout { grid-template-columns: 1fr; } }

.tilemap {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 5px;
}
.tile {
  aspect-ratio: 1; border: 1px solid var(--line-2); border-radius: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; cursor: pointer; position: relative;
  background: rgba(244,241,236,.028);
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.tile:hover, .tile:focus-visible {
  transform: scale(1.09); border-color: var(--accent-2); z-index: 3;
  box-shadow: 0 4px 18px rgba(0,0,0,.5);
}
.tile[aria-pressed="true"] { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2); }
.tile .ab {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .3px; color: var(--ink); position: relative; z-index: 1;
}
.tile .tv {
  font-size: 9px; font-family: var(--mono); color: var(--ink-2);
  position: relative; z-index: 1; font-variant-numeric: tabular-nums;
}
.tile .fill { position: absolute; inset: 0; border-radius: 2px; z-index: 0; }
.tile.empty { opacity: .17; cursor: default; }
.tile.empty:hover { transform: none; border-color: var(--line-2); box-shadow: none; }
.tile.sup .tv { color: var(--ink-4); }
.tile-spacer { aspect-ratio: 1; }

.map-scale {
  display: flex; align-items: center; gap: 10px; margin-top: 20px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .8px;
  color: var(--ink-3); flex-wrap: wrap;
}
.scale-ramp {
  display: flex; height: 9px; width: 190px; border-radius: 2px; overflow: hidden;
}
.scale-ramp i { flex: 1; }

.state-panel {
  border: 1px solid var(--line-2); padding: 22px 20px; border-radius: 3px;
  background: rgba(244,241,236,.022); position: sticky; top: 88px;
}
.state-panel h3 {
  font-family: var(--serif); font-size: 1.5rem; font-weight: 600;
  margin: 0 0 4px; letter-spacing: -.02em;
}
.state-panel .sp-sub {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 18px;
}
.sp-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 9px 0; border-top: 1px solid var(--line-2); font-size: 13px;
}
.sp-row:first-of-type { border-top: none; }
.sp-row .k { color: var(--ink-2); }
.sp-row .v { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.sp-row .v.dim { color: var(--ink-4); font-weight: 500; font-size: 11px; font-family: var(--mono); }
.sp-empty { color: var(--ink-3); font-size: 13.5px; line-height: 1.6; }

/* Comparison rows sit tight under the figure they annotate, visually
   subordinate to it — the state's own number is the headline, the delta
   against the national average is the footnote. */
.sp-row.cmp {
  border-top: none; padding: 0 0 8px; margin-top: -6px;
  font-size: 11.5px;
}
.sp-row.cmp .k {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .9px;
  text-transform: uppercase; color: var(--ink-cap);
}
.sp-row.cmp .v { font-weight: 500; }
.sp-delta {
  font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 1px 5px; border-radius: 2px; font-size: 11px;
}
.sp-delta.up   { color: #7fd4c4; background: rgba(63,157,143,.15); }
.sp-delta.down { color: #e2946f; background: rgba(194,96,58,.15); }
/* Differences the sample can't distinguish from zero get no directional
   colour — reading them as "above" or "below" average would be wrong. */
.sp-delta.flat { color: var(--ink-cap); background: rgba(244,241,236,.05); }
.sp-gapdir { font-size: 11px; color: var(--ink-2); margin-left: 4px; font-weight: 500; }
.sp-vs {
  display: block; margin-top: 3px; color: var(--accent-2);
  letter-spacing: 1.1px;
}
.sp-hint {
  margin: 18px 0 0; padding-top: 13px; border-top: 1px solid var(--line-2);
  color: var(--ink-2); font-size: 12px; line-height: 1.55;
}
.sp-clear {
  margin-top: 18px; width: 100%; padding: 9px 12px;
  background: rgba(244,241,236,.04); border: 1px solid var(--line-2);
  border-radius: 3px; color: var(--ink-2); cursor: pointer;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 1px;
  text-transform: uppercase; transition: background .12s, color .12s, border-color .12s;
}
.sp-clear:hover { background: rgba(244,241,236,.09); color: var(--ink); border-color: var(--accent); }

/* ---------- Region × gender ---------- */
.region-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px;
}
.rg-card { border: 1px solid var(--line-2); padding: 20px; border-radius: 3px; }
.rg-name {
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 16px;
}
.rg-pair { display: flex; flex-direction: column; gap: 12px; }
.rg-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; }
.rg-row .g {
  font-family: var(--mono); font-size: 10px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--ink-cap);
}
.rg-bar { height: 20px; background: rgba(244,241,236,.05); border-radius: 2px; overflow: hidden; }
.rg-bar i { display: block; height: 100%; border-radius: 2px; }
.rg-row .amt { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rg-delta {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2);
  font-size: 11.5px; font-family: var(--mono); letter-spacing: .5px; color: var(--ink-2);
}
.rg-delta b { font-size: 13px; }
.rg-delta.up b { color: #6fc9ba; }
.rg-delta.down b { color: #e88f76; }
/* A difference the sample can't distinguish from zero gets neutral treatment —
   no directional colour, because there is no established direction. */
.rg-delta.flat b { color: var(--ink-cap); }

/* ---------- Distribution ladder ---------- */
.ladder { display: flex; flex-direction: column; gap: 4px; }
.lad-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 14px; align-items: center; }
.lad-band { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lad-track { height: 26px; background: rgba(244,241,236,.045); border-radius: 2px; overflow: hidden; }
.lad-fill {
  height: 100%; border-radius: 2px; background: var(--accent);
  transition: width .5s cubic-bezier(.2,.8,.25,1);
}
.lad-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.lad-val small { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--ink-4); font-weight: 400; }
.lad-meta {
  margin-top: 18px; display: flex; flex-wrap: wrap; gap: 14px 28px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .9px;
  text-transform: uppercase; color: var(--ink-3);
}
.lad-meta b { font-family: var(--serif); font-size: 1.25rem; color: var(--accent-2); letter-spacing: -.02em; }
@media (max-width: 620px) {
  .lad-row { grid-template-columns: 108px 1fr 74px; gap: 9px; }
  .lad-band { font-size: 11.5px; }
}

/* ---------- Warning box ---------- */
.warn-box {
  margin-top: 26px; padding: 18px 20px;
  border: 1px solid rgba(232,192,90,.26); background: rgba(232,192,90,.05);
  border-radius: 3px; font-size: .92rem; color: #d8c69a; line-height: 1.62;
  max-width: 58rem;
}
.warn-box b { color: #e8c05a; }
.warn-box em { color: #efe0bb; font-style: italic; }

/* ---------- Empty / loading ---------- */
.lab-empty {
  padding: 40px 20px; text-align: center; color: var(--ink-3);
  border: 1px dashed var(--line); border-radius: 3px; font-size: 14px;
}
