/* ===========================================================================
   page.css: the CAC write-up's own components (explorer controls, channel
   table, CAC panel, range, diagram, reconciliation, ledger, dataset viewer).
   The shared shell is /static/blog/css/base.css, loaded before this; the
   shared visual system is /static/blog/css/system.css, loaded after.
   =========================================================================== */
/* ── Controls (compact) ─────────────────────────────────────── */
.controls { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.ctrl-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.ctrl-label { font-size: 12px; font-weight: 500; color: var(--text-tertiary); width: 56px; flex-shrink: 0; }

.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.seg-btn {
  position: relative;
  border: none; background: none; cursor: pointer;
  font: 500 12.5px var(--font); color: var(--text-tertiary);
  padding: 7px 12px; border-radius: var(--radius-sm);
  white-space: nowrap; line-height: 1.4;
  transition: color var(--transition), background var(--transition);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { color: var(--text); background: var(--pill-active-bg); }
.seg-btn:focus-visible { outline: 1.5px solid var(--text-tertiary); outline-offset: 2px; }

/* A whisper of colour per control: the label carries its hue, and the active
   pill picks up a faint tint + coloured ink (same treatment as the grade
   chips). Track and inactive options stay monochrome. */
.ctrl-row--rule   .ctrl-label { color: var(--ctrl-rule); }
.ctrl-row--cost   .ctrl-label { color: var(--ctrl-cost); }
.ctrl-row--timing .ctrl-label { color: var(--ctrl-timing); }
.ctrl-row--rule   .seg-btn.is-active { color: var(--ctrl-rule);   background: var(--ctrl-rule-bg); }
.ctrl-row--cost   .seg-btn.is-active { color: var(--ctrl-cost);   background: var(--ctrl-cost-bg); }
.ctrl-row--timing .seg-btn.is-active { color: var(--ctrl-timing); background: var(--ctrl-timing-bg); }

/* ── Tooltips (minimal) ─────────────────────────────────────── */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) translateY(3px);
  background: var(--color-3); color: oklch(0.95 0 0);
  font: 400 11.5px/1.4 var(--font); text-align: left;
  padding: 6px 8px; border-radius: var(--radius-md);
  width: max-content; max-width: 200px; white-space: normal;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; z-index: 40;
  transition: opacity 120ms ease, transform 120ms ease;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Channel table (Channel / bar / customers / revenue) ────── */
.chan-list { display: flex; flex-direction: column; gap: 1px; margin-top: var(--s4); }
.chan-head, .chan-row {
  display: grid; grid-template-columns: 116px 1fr 64px 64px;
  gap: var(--s3); align-items: center;
}
.chan-head {
  font-size: 11px; font-weight: 500; letter-spacing: 0;
  color: var(--text-tertiary); padding: 0 var(--s2) var(--s2);
  border-bottom: 1px solid var(--border-light); margin-bottom: var(--s1);
}
.chan-head .r { text-align: right; }
.chan-row { padding: 6px var(--s2); border-radius: var(--radius-md); }
.chan-row.is-focus { background: var(--accent-surface); }
.chan-name { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; min-width: 0; }
.chan-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-name .focus-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text); flex-shrink: 0; }
.chan-track { height: 6px; border-radius: var(--radius-pill); background: var(--bg-active); overflow: hidden; }
.chan-fill { height: 100%; border-radius: var(--radius-pill); background: var(--bar-fill); transition: width 460ms cubic-bezier(0.22,1,0.36,1); }
.chan-row.is-focus .chan-fill { background: var(--text); }
.chan-cust, .chan-rev { text-align: right; font-variant-numeric: tabular-nums; }
.chan-cust { font-size: 13.5px; font-weight: 600; color: var(--text); }
.chan-rev { font-size: 13px; color: var(--text-tertiary); }

/* ── CAC panel (compact) ────────────────────────────────────── */
.cac-panel { margin-top: var(--s5); margin-bottom: var(--s5); padding: var(--s4); border-radius: var(--radius-lg); background: var(--bg); }
.cac-label { font-size: 12px; color: var(--text-tertiary); letter-spacing: 0; margin-bottom: var(--s1); }
.cac-num { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1; }
.cac-num .cur { font-size: 0.5em; color: var(--text-tertiary); vertical-align: 0.3em; margin-right: 1px; }
.cac-formula { font-size: 12px; color: var(--text-tertiary); margin-top: 6px; font-variant-numeric: tabular-nums; }
.cac-formula strong { color: var(--text-secondary); }

/* two half-width stat cards under the CAC figure */
.cac-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s4); }
.cac-stat { background: var(--bg-elevated); border-radius: var(--radius-md); padding: var(--s3); }
.cs-label { font-size: 11px; color: var(--text-tertiary); }
.cs-val { font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* slider-style range indicator — draggable, snaps to each achievable figure */
.range { margin-top: var(--s4); }
.range-track { position: relative; height: 4px; border-radius: var(--radius-pill); background: var(--bg-active); cursor: pointer; touch-action: none; }
/* taller invisible hit area so the 4px track is easy to grab */
.range-track::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; bottom: -12px; }
.range-track:focus-visible { outline: none; }
.range-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: var(--radius-pill); background: var(--color-8); transition: width 460ms cubic-bezier(0.22,1,0.36,1); }
.range-marker { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transform: translate(-50%, -50%); transition: left 460ms cubic-bezier(0.22,1,0.36,1); box-shadow: 0 1px 3px oklch(0 0 0 / 0.4), 0 0 0 4px var(--bg); cursor: grab; }
.range-track:hover .range-marker { transform: translate(-50%, -50%) scale(1.12); }
.range-track:focus-visible .range-marker { box-shadow: 0 1px 3px oklch(0 0 0 / 0.4), 0 0 0 4px var(--bg), 0 0 0 6px var(--focus-ring); }
.range-track.is-dragging { cursor: grabbing; }
.range-track.is-dragging .range-marker { cursor: grabbing; transition: left 130ms ease; }
.range-track.is-dragging .range-fill { transition: width 130ms ease; }
.range-ticks { display: flex; justify-content: space-between; margin-top: var(--s2); font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.range-note { margin-top: var(--s3); font-size: 12px; line-height: 1.5; color: var(--text-secondary); }
.range-note strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Light-theme explorer tuning ─────────────────────────────
   Several explorer fills/surfaces used the fixed dark neutral ramp
   (--color-*), which doesn't flip between themes — so in light they came
   through pale (channel bars) or near-invisible (the recessed CAC inset sat
   at 0.988 inside a 1.0 module). Re-tune only the handful that need it;
   dark is untouched. */
:root[data-theme="light"] {
  --bar-fill: oklch(0.60 0 0);              /* channel bars: clear mid-grey on white */
}
:root[data-theme="light"] .module { border: 1px solid var(--border-light); }
:root[data-theme="light"] .cac-panel { background: oklch(0.963 0 0); }
:root[data-theme="light"] .range-fill { background: oklch(0.55 0 0); }

/* ── Diagram ────────────────────────────────────────────────── */
.diagram { margin: var(--s7) 0; }
.diagram-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.diagram-col { border-radius: var(--radius-lg); background: var(--bg-elevated); padding: var(--s4); }
.diagram-col.miss { background: var(--bg); }
.diagram-col h4 { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.diagram-col .dc-sub { font-size: 12px; color: var(--text-tertiary); margin-bottom: var(--s3); }
.diagram-items { display: flex; flex-direction: column; gap: var(--s1); }
.diagram-item { display: flex; align-items: center; gap: var(--s2); font-size: 13px; color: var(--text-secondary); }
.diagram-col.miss .diagram-item { color: var(--text-tertiary); }
.di-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text); flex-shrink: 0; }
.diagram-col.miss .di-dot { background: var(--text-disabled); }
.diagram-cap { font-size: 12px; line-height: 1.5; color: var(--text-tertiary); margin-top: var(--s3); }

/* ── Self-report (no right-side chips) ──────────────────────── */
/* proportion bar: the 70 deals split four ways, one hue per bucket (agree =
   green, conflict = red, untracked = amber, blank = blue). Each segment shows
   its colour muted; hovering a filter previews it; the active bucket goes full. */
.recon-bar { display: flex; gap: 2px; height: 8px; margin-bottom: var(--s3); }
.recon-bar-seg {
  min-width: 3px; border-radius: 2px;
  --seg: var(--text);
  background: color-mix(in oklch, var(--seg) 42%, transparent);
  transition: background var(--transition);
}
.recon-bar-seg[data-k="agree"]    { --seg: var(--bucket-agree); }
.recon-bar-seg[data-k="conflict"] { --seg: var(--bucket-conflict); }
.recon-bar-seg[data-k="dark"]     { --seg: var(--bucket-untracked); }
.recon-bar-seg[data-k="blank"]    { --seg: var(--bucket-blank); }
.recon-bar-seg.is-hover { background: color-mix(in oklch, var(--seg) 68%, transparent); }
.recon-bar-seg.is-active { background: var(--seg); }

/* segmented filter = the legend: a count + short label per bucket */
.recon-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); margin-bottom: var(--s4); }
.recon-seg-btn {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: var(--s2) var(--s3); text-align: left; cursor: pointer;
  border: 1px solid var(--border-light); border-radius: var(--radius-md);
  background: var(--bg);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.recon-seg-btn:hover { border-color: var(--border); }
.recon-seg-btn.is-active { background: var(--pill-active-bg); border-color: transparent; }
.recon-seg-btn:active { transform: scale(0.96); }
.recon-seg-btn:focus-visible { outline: 1.5px solid var(--text-tertiary); outline-offset: 2px; }
.rsg-n { font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.rsg-l { font-size: 12px; color: var(--text-tertiary); }
.recon-seg-btn.is-active .rsg-l { color: var(--text-secondary); }

.recon-explain { font-size: 13px; line-height: 1.5; color: var(--text-secondary); margin-bottom: var(--s3); text-wrap: pretty; }

/* example rows: outlined quotes, tight; capped list, no inner scroll */
.recon-list { display: flex; flex-direction: column; gap: var(--s2); }
.recon-row { padding: var(--s3); border-radius: var(--radius-md); background: transparent; border: 1px solid var(--border-light); }
.rr-said { font-size: 14px; font-style: italic; color: var(--text); }
.rr-said .blank { color: var(--text-tertiary); }
.rr-tracked { font-size: 11.5px; color: var(--text-tertiary); margin-top: var(--s2); display: flex; flex-wrap: wrap; gap: var(--s1); align-items: center; }
.rr-lead { color: var(--text-tertiary); margin-right: 2px; }
.rr-chip { padding: 1px 7px; border-radius: var(--radius-sm); background: var(--tag-bg); color: var(--tag-text); font-size: 11px; font-weight: 500; }
.rr-chip.match { background: var(--accent-surface); color: var(--text); }
.rr-note { font-size: 11.5px; line-height: 1.4; color: var(--text-tertiary); margin-top: var(--s2); }
.recon-more { font-size: 12px; color: var(--text-tertiary); padding-top: var(--s1); }

/* ── Evidence ledger + statement ────────────────────────────── */
.ledger-block { margin-top: var(--s5); }
.ledger-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.lh-title { font-size: 12px; font-weight: 600; color: var(--text-tertiary); }
.lh-tally { font-size: 11.5px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.ledger { display: flex; flex-direction: column; }
.ledger-row { display: grid; grid-template-columns: 1fr 84px; gap: var(--s3); align-items: start; padding: var(--s3) var(--s1); border-bottom: 1px solid var(--border-light); }
.ledger-row:last-child { border-bottom: none; }
.lr-input { font-size: 13px; font-weight: 500; color: var(--text); }
.lr-why { font-size: 12px; line-height: 1.45; color: var(--text-tertiary); margin-top: 2px; }
.lr-note { font-size: 11.5px; line-height: 1.4; color: var(--text-disabled); margin-top: var(--s2); font-style: italic; }

/* upgrade toggle: "flag the evidence you have" */
.lr-have {
  margin-top: var(--s2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  font: 500 11.5px var(--font); color: var(--text-tertiary);
  padding: 3px var(--s2); border-radius: var(--radius-sm);
  border: 1px dashed var(--border); background: none;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.lr-have .lh-plus { font-size: 13px; line-height: 1; }
.lr-have:hover { color: var(--text); border-color: var(--text-tertiary); }
.lr-have.is-on {
  color: var(--grade-measured-text); background: var(--grade-measured-bg);
  border-style: solid; border-color: var(--grade-border);
}
.lr-have:focus-visible { outline: 1.5px solid var(--text-tertiary); outline-offset: 2px; }
.lr-then { font-size: 11.5px; line-height: 1.45; color: var(--grade-measured-text); margin-top: var(--s2); max-height: 0; opacity: 0; overflow: hidden; transition: max-height var(--transition), opacity var(--transition), margin var(--transition); }
.ledger-row.is-upgraded .lr-then { max-height: 60px; opacity: 1; }
.grade-chip, .lr-grade {
  justify-self: end; display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 600; letter-spacing: 0;
  padding: var(--s1) var(--s2); border-radius: var(--radius-sm); white-space: nowrap;
}
.grade-chip { margin-right: var(--s2); }
.measured { background: var(--grade-measured-bg); color: var(--grade-measured-text); border: 1px solid var(--grade-border); }
.modelled { background: var(--grade-modelled-bg); color: var(--grade-modelled-text); border: 1px solid var(--grade-border); }
.assumed { background: var(--grade-assumed-bg); color: var(--grade-assumed-text); border: 1px solid var(--grade-border); }

.stmt-controls { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.stmt-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.stmt-label { font-size: 12px; color: var(--text-tertiary); width: 52px; flex-shrink: 0; }

.statement { padding: var(--s4); border-radius: var(--radius-lg); background: var(--bg); }
.statement p { font-size: 15px; line-height: 1.6; color: var(--text-secondary); text-wrap: pretty; }
.statement .fig { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Commit-and-bound band (payoff module) ──────────────────── */
/* The reported number sits at the top of a band; each unflagged input keeps the
   floor low. Flagging one lifts the floor toward the point—the interval closes. */
.band { margin-top: var(--s4); }
.band-track { position: relative; height: 6px; border-radius: var(--radius-pill); background: var(--bg-active); }
.band-span { position: absolute; top: 0; height: 100%; min-width: 2px; border-radius: var(--radius-pill); background: var(--color-8); transition: left 460ms cubic-bezier(0.22,1,0.36,1), width 460ms cubic-bezier(0.22,1,0.36,1); }
.band-point { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--text); transform: translate(-50%, -50%); box-shadow: 0 1px 3px oklch(0 0 0 / 0.4), 0 0 0 4px var(--bg); transition: left 460ms cubic-bezier(0.22,1,0.36,1); }
.band-ticks { display: flex; justify-content: space-between; margin-top: var(--s2); font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.band-ticks span:nth-child(2) { color: var(--text-secondary); }

.lr-have:active { transform: scale(0.96); }

/* measured share of the reported cost — rises as agency/staff turn measured,
   while the band above stays put (the honest point: spread isn't measurement) */
.cost-grade { margin: var(--s3) 0 var(--s4); }
.cost-grade-bar { height: 5px; border-radius: var(--radius-pill); background: var(--bg-active); overflow: hidden; }
.cost-grade-bar span { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--grade-measured-text); transition: width 460ms cubic-bezier(0.22,1,0.36,1); }
.cost-grade-note { font-size: 11.5px; line-height: 1.45; color: var(--text-tertiary); margin-top: var(--s2); }
.statement-foot { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border-light); font-size: 12px; line-height: 1.5; color: var(--text-tertiary); }
.statement-foot strong { color: var(--text-secondary); }

/* Range bar — a CAC span with the defensible figure marked. Dot + pick position
   are set inline (left: X%) per instance. */
.rangebar { margin: var(--s7) 0 var(--s5); }
.rangebar .track { position: relative; height: 6px; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--color-6), var(--color-11)); }
.rangebar .dot { position: absolute; top: 50%; left: 50%; width: 13px; height: 13px;
  border-radius: 50%; background: var(--text); border: 3px solid var(--bg);
  transform: translate(-50%, -50%); }
.rangebar .pick { position: absolute; bottom: calc(100% + 10px); transform: translateX(-50%);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px;
  color: var(--text); white-space: nowrap; }
.rangebar .pick::after { content: ""; position: absolute; top: calc(100% + 2px); left: 50%;
  transform: translateX(-50%); width: 1px; height: 7px; background: var(--text-tertiary); }
.rangebar .ends { display: flex; justify-content: space-between; margin-top: var(--s2);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-tertiary); }
.rangebar .ends b { display: block; color: var(--text-secondary); font-weight: 500; }

/* ── Dataset download ───────────────────────────────────────── */
.dataset-actions { margin-bottom: var(--s3); }
.dl-btn {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: 13px; font-weight: 500; color: var(--text);
  text-decoration: none;
  padding: var(--s2) var(--s4);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-elevated);
  transition: background var(--transition), border-color var(--transition);
}
.dl-btn::before {
  content: ""; width: 15px; height: 15px; flex-shrink: 0;
  background: currentColor;
  -webkit-mask: no-repeat center / contain; mask: no-repeat center / contain;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M5 21h14'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M5 21h14'/%3E%3C/svg%3E");
}
.dl-btn:hover { background: var(--bg-active); border-color: var(--text-tertiary); }
.dl-btn:focus-visible { outline: 1.5px solid var(--text-tertiary); outline-offset: 2px; }

@media (max-width: 820px) {
  /* on mobile the top nav keeps only Home + Skill; the in-page section links
     (everything after the first separator) drop off */
  .nav-sep ~ .nav-item { display: none; }
}

@media (max-width: 560px) {
  .recon-seg { grid-template-columns: repeat(2, 1fr); }
  .diagram-grid { grid-template-columns: 1fr; }
  .chan-head, .chan-row { grid-template-columns: 88px 1fr 52px; }
  .chan-head .r.rev, .chan-rev { display: none; }
  .ledger-row { grid-template-columns: 1fr; }
  .lr-grade { justify-self: start; margin-top: var(--s2); }
  /* keep the widest stat figure (e.g. revenue) inside its card on narrow screens */
  .cac-stat { padding: var(--s2); }
  .cs-val { font-size: 16px; }
}

/* ── Hero: every achievable LinkedIn CAC (js/app.js) ─────────── */
.cac-hero { margin: 0; text-align: left; }
.cac-hero-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; }
.cac-hero-svg { display: block; width: 100%; height: auto; margin: 18px 0 6px; overflow: visible; }
.cac-hero-svg circle { stroke: var(--surface-screen); stroke-width: 2; }
.cac-hero-axis { stroke: var(--hairline-strong); }
.cac-hero-ends { display: flex; justify-content: space-between; font: 500 22px var(--font-mono); color: var(--ink-1); font-variant-numeric: tabular-nums; }
.cac-hero-ends small { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.cac-hero-ends div:last-child { text-align: right; }
#explorer { margin-bottom: var(--s3); }
@media (max-width: 560px) { .cac-hero-ends { font-size: 17px; } }

/* The explorer breaks out less than other wide figures: 848px, not 992 */
@media (min-width: 1240px) { #explorer.fig--wide { margin-left: -72px; margin-right: -72px; } }

/* The explorer needs a firmer edge than other figures to stand off the page */
#explorer.fig { box-shadow: 0 0 0 1px var(--hairline-strong), 0 16px 48px oklch(0 0 0 / 0.28); }
:root[data-theme="light"] #explorer.fig { box-shadow: 0 0 0 1px var(--hairline-strong), 0 12px 32px oklch(0 0 0 / 0.08); }
