/* HistGramBench note: page-specific figure styles. Uses only the variables of /research/template.css. */

.container-wide { padding-top: 8px; padding-bottom: 8px; }
.container + .container-wide,
.container-wide + .container { padding-top: 0; }
.container.flow { padding-bottom: 8px; }
.container.flow:last-child { padding-bottom: 96px; }
.container-wide figure { margin: 8px 0 24px; }

a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Cover */
figure.cover { margin: 8px 0 8px; }
figure.cover img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: contain; }
.pending { color: var(--stone); font-style: italic; }

/* TL;DR */
.tldr li { margin-bottom: 10px; }

/* Worked example */
.example-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0;
}
.example-pair > div { background: var(--manilla); border: 1px solid var(--bone); padding: 16px; }
.example-pair img { display: block; width: 100%; height: auto; height: 220px; object-fit: contain; }
.panel-label {
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--graphite);
  margin: 12px 0 0;
}
.checks { margin: 16px 0 0; }
.checks caption,
.chart-title {
  font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--ink);
  text-align: left; margin: 0 0 4px;
}
.checks caption { padding: 0 0 8px; }
.benchmark-table.checks { margin: 20px 0 0; max-width: 700px; }
.benchmark-table.checks td.result { font-family: var(--sans); font-size: 14px; font-weight: 600; white-space: nowrap; }
.benchmark-table.checks td.missed { font-weight: 400; color: var(--graphite); }
.tally { font-family: var(--sans); font-size: 15px; font-weight: 600; margin: 14px 0 0; }

/* Bar charts (HTML; downloadable SVG/PNG copies in assets/) */
.chart { background: var(--manilla); border: 1px solid var(--bone); padding: 24px 24px 18px; }
.chart-sub { font-family: var(--sans); font-size: 14px; color: var(--graphite); margin: 0 0 20px; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li {
  display: grid;
  grid-template-columns: 11.5rem 1fr 3rem;
  align-items: center;
  column-gap: 12px;
  margin: 0 0 10px;
  font-family: var(--sans);
}
.bar-name { font-size: 14px; color: var(--ink); text-align: right; line-height: 1.3; }
.bar-track {
  position: relative; height: 22px;
  background-image: linear-gradient(to right, var(--bone) 1px, transparent 1px);
  background-size: 25% 100%;
  border-right: 1px solid var(--bone);
}
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--slate-blue); }
.bar-val { font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-axis {
  display: grid; grid-template-columns: 11.5rem 1fr 3rem; column-gap: 12px;
  font-family: var(--sans); font-size: 12px; color: var(--stone);
}
.bar-axis .ticks { display: flex; justify-content: space-between; }
.bar-axis .ticks span { width: 0; display: flex; justify-content: center; white-space: nowrap; }
.download { font-family: var(--sans); font-size: 13px; color: var(--stone); margin: 6px 0 0; }
.download a { color: var(--stone); }

/* Fact-type table */
.benchmark-table tbody th { padding: 14px 16px; border-bottom: 1px solid var(--bone); text-align: left; }
.table-wrap { overflow-x: auto; }
.benchmark-table.facts { margin: 0; }
.benchmark-table.facts th:not(.label-cell),
.benchmark-table.facts td.data-cell { text-align: right; font-variant-numeric: tabular-nums; }

.resources li { margin-bottom: 8px; }

@media (max-width: 720px) {
  .container-wide { padding-left: 20px; padding-right: 20px; }
  .eyebrow { margin-top: 16px; }
  .lede { font-size: 18px; }
  .example-pair { grid-template-columns: 1fr; }
  .example-pair img { height: auto; max-height: 220px; }
  .chart { padding: 18px 14px 14px; }
  .bars li { grid-template-columns: 1fr 2.6rem; row-gap: 4px; }
  .bar-name { grid-column: 1 / -1; text-align: left; }
  .bar-axis { grid-template-columns: 1fr 2.6rem; }
  .bar-axis > span:first-child { display: none; }
  .benchmark-table thead th,
  .benchmark-table tbody td,
  .benchmark-table tbody th { padding: 10px 8px; }
  .benchmark-table tbody td { font-size: 15px; }
  .benchmark-table .label-cell { font-size: 13px; }
  .benchmark-table thead th { font-size: 12px; }
}

/* ── Interactive layer (interactive.js) ───────────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ctl {
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--ink);
  background: var(--paper-cream); border: 1px solid var(--bone); border-radius: 2px;
  padding: 6px 12px; cursor: pointer; line-height: 1.3;
}
.ctl:hover { border-color: var(--stone); }
.ctl:focus-visible, .bar-row:focus-visible, .row-select:focus-visible, .sort-btn:focus-visible,
.check-btn:focus-visible, .chip:focus-visible, .seg button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.clear-sel.is-hidden { visibility: hidden; }
.clear-name { font-weight: 600; margin-left: 4px; }
.clear-name:empty { display: none; }

.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.chart-ctls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-ctls { justify-content: flex-end; margin: 0 0 8px; min-height: 31px; }
.seg { display: inline-flex; border: 1px solid var(--bone); background: var(--paper-cream); border-radius: 2px; padding: 2px; }
.seg button { font-family: var(--sans); font-size: 12px; font-weight: 500; border: 0; background: transparent; color: var(--graphite); padding: 5px 10px; cursor: pointer; border-radius: 2px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--manilla); }

/* Bars become buttons: the whole row is the target. */
.bars li > .bar-row {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: inherit; align-items: center; column-gap: inherit; row-gap: inherit;
  width: 100%; margin: 0; padding: 3px 0; border: 0; background: none; color: inherit;
  font: inherit; text-align: inherit; cursor: pointer; border-radius: 2px;
}
.bars li.is-sel .bar-fill { background: var(--ink); }
.bars li.is-sel .bar-name, .bars li.is-sel .bar-val { font-weight: 700; }
.bars li.is-dim .bar-fill { opacity: 0.28; }
.bars li.is-dim .bar-name, .bars li.is-dim .bar-val { color: var(--stone); }

/* Tooltip */
.hgb-tip {
  position: fixed; z-index: 30; pointer-events: none; max-width: 260px;
  background: var(--ink); color: var(--manilla); font-family: var(--sans); font-size: 12.5px; line-height: 1.45;
  padding: 7px 10px; border-radius: 2px;
}
.hgb-tip b { font-weight: 600; }

/* Fact table */
.sort-btn { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: baseline; }
.sort-btn:hover { color: var(--ink); }
.facts th.is-sorted .sort-btn { color: var(--ink); font-weight: 600; }
.facts th[aria-sort="descending"] .sort-ind::after { content: "↓"; }
.facts th[aria-sort="ascending"] .sort-ind::after { content: "↑"; }
.facts th[data-sort]:not([data-sort="model"]):not([aria-sort]) .sort-ind::after { content: "↕"; color: var(--bone); }
.row-select { all: unset; cursor: pointer; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink); }
.row-select[aria-pressed="true"]::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--ink); margin-right: 6px; vertical-align: 1px; }
.facts tr.is-sel th, .facts tr.is-sel td { background: var(--manilla-deep); }
.facts tr.is-sel .row-select, .facts tr.is-sel td { font-weight: 700; }
.facts tr.is-dim th, .facts tr.is-dim td, .facts tr.is-dim .row-select { color: var(--stone); }
.cellbar { display: block; height: 4px; width: 56px; max-width: 100%; margin: 5px 0 0 auto; background: var(--bone); position: relative; }
.cellbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--graphite); }
.facts tr.is-dim .cellbar i { background: var(--wax); }

/* Worked example */
.ex-stage { position: relative; width: 100%; margin: 0 auto; }
.ex-stage img { width: 100%; height: 100%; max-height: none; object-fit: fill; display: block; }
.example-pair .ex-panel { display: flex; flex-direction: column; justify-content: space-between; }
.example-pair .ex-stage { max-width: calc(220px * var(--ar, 2)); }
.ex-overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ex-overlay [data-el] { fill: none; stroke: var(--crail); stroke-width: 3; vector-effect: non-scaling-stroke; opacity: 0; }
.ex-overlay circle[data-el] { stroke-width: 3; }
.ex-overlay rect[data-el] { stroke-width: 2; stroke-dasharray: 4 3; }
.ex-overlay [data-el].on { opacity: 1; }
.ex-tools { margin: 10px 0 0; }
.checks.is-interactive tbody td.label-cell { padding: 0; }
.check-btn {
  all: unset; box-sizing: border-box; display: block; width: 100%; padding: 14px 16px; cursor: pointer;
  font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink);
}
.check-btn::before { content: ""; display: inline-block; width: 9px; height: 9px; border: 1.5px solid var(--stone); border-radius: 50%; margin-right: 10px; vertical-align: 0; }
.check-btn[aria-pressed="true"]::before { background: var(--crail); border-color: var(--crail); }
.checks tr.is-active td { background: var(--manilla-deep); }
.check-btn .sub { display: block; margin-left: 21px; }

/* Enlarged view */
.ex-dialog { border: 1px solid var(--bone); background: var(--paper-cream); color: var(--ink); padding: 0; width: min(1100px, 96vw); max-height: 94vh; overflow: auto; }
.ex-dialog::backdrop { background: rgba(20, 20, 20, 0.55); }
.ex-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--bone); position: sticky; top: 0; background: var(--paper-cream); z-index: 1; }
.ex-dialog-head .chart-title { margin: 0; }
.ex-dialog-body { padding: 18px; }
.ex-pair-large { grid-template-columns: 1fr 1.25fr; }
.ex-pair-large .ex-stage { max-height: none; max-width: none; }
.ex-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { font-family: var(--sans); font-size: 13px; color: var(--ink); background: var(--manilla); border: 1px solid var(--bone); border-radius: 2px; padding: 7px 10px; cursor: pointer; text-align: left; }
.chip b { font-weight: 600; margin-left: 6px; }
.chip b.missed { font-weight: 400; color: var(--graphite); }
.chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--manilla-deep); }

@media (max-width: 720px) {
  .example-pair .ex-stage { max-width: min(100%, calc(240px * var(--ar, 2))); }
  .example-pair .ex-stage { max-width: none; }
  .ex-pair-large { grid-template-columns: 1fr; }
  .chart-head .chart-ctls { width: 100%; }
  .check-btn { padding: 10px 8px; font-size: 13px; }
  .cellbar { width: 40px; }
  .row-select { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Colour scheme adopted from the HistGramBench artifact ─────────── */
:root { --tier1: #CC785C; --tier2: #3B5BBE; --tier3: #1E9068; --found: #1E9068; --missed: #CC785C; --missed-text: #A4512F; }
.bars li[data-tier="1"] .bar-fill { background: var(--tier1); }
.bars li[data-tier="2"] .bar-fill { background: var(--tier2); }
.bars li[data-tier="3"] .bar-fill { background: var(--tier3); }
.bars li > .bar-row:hover .bar-fill { filter: brightness(0.88); }
.bars li.is-sel .bar-fill { box-shadow: 0 0 0 2px var(--manilla), 0 0 0 4px var(--ink); }
.bars li[data-tier].is-sel .bar-fill { opacity: 1; }
.tier-legend { font-family: var(--sans); font-size: 12.5px; color: var(--graphite); margin: -8px 0 16px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.tier-legend .tl-title { color: var(--stone); }
.sw { display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px; }
.sw.t1 { background: var(--tier1); } .sw.t2 { background: var(--tier2); } .sw.t3 { background: var(--tier3); }
.facts tr[data-tier] th.label-cell { border-left: 4px solid transparent; }
.facts tr[data-tier="1"] th.label-cell { border-left-color: var(--tier1); }
.facts tr[data-tier="2"] th.label-cell { border-left-color: var(--tier2); }
.facts tr[data-tier="3"] th.label-cell { border-left-color: var(--tier3); }
.facts td.data-cell:nth-of-type(1) .cellbar i { background: var(--tier2); }
.facts td.data-cell:nth-of-type(2) .cellbar i { background: var(--tier1); }
.facts td.data-cell:nth-of-type(3) .cellbar i { background: var(--tier3); }
.facts tr.is-dim .cellbar i { opacity: 0.3; }
.ex-overlay.is-found [data-el] { stroke: var(--found); }
.ex-overlay.is-missed [data-el] { stroke: var(--missed); }
.check-btn[aria-pressed="true"]::before { background: var(--found); border-color: var(--found); }
.checks tr[data-result="missed"] .check-btn[aria-pressed="true"]::before { background: var(--missed); border-color: var(--missed); }
.checks td.result { color: #17704f; }
.checks td.result.missed { color: var(--missed-text); font-weight: 600; }
.chip b { color: #17704f; }
.chip b.missed { color: var(--missed-text); font-weight: 600; }
