/* Every page under studies/: one column of reading built from a small set of components
   (site/README.md § Study pages; research/studies/market-perception/site_kit.py writes them).
   Header, key numbers, sections, figures (chart, diagram, still, clip), tables with an
   optional colour scale, a callout, a quote, and one disclosure that is never nested.
   Builds on ../style.css, whose fonts, inks and grounds it uses and never redefines. */

main.study { max-width: 800px; }

/* Series colours: identity, never rank. Validated categorical slots 1-3 (blue, orange,
   aqua), a neutral grey for the control, and the verdict colours for the scales. */
.study, .research-index {
  --s-control: #6b6964; --s-1: #2a78d6; --s-2: #eb6834; --s-3: #1baf7a; --s-4: #8a8781;
  --s-bad: #b3261e; --s-good: #2b7a4b;
}
:root[data-theme="dark"] :is(.study, .research-index) {
  --s-control: #a3a19b; --s-1: #3987e5; --s-2: #d95926; --s-3: #199e70; --s-4: #9b9992;
  --s-bad: #e66767; --s-good: #8fb87a;
}

/* HEADER. A small badge, the finding as the title, one paragraph. */
.study header .badge { display: inline-block; margin: 0 0 1rem; padding: .25rem .65rem; border: 1px solid var(--line);
  border-radius: 999px; font-size: var(--t-small); color: var(--muted); line-height: 1.4; }
.study h1 { font-size: clamp(1.75rem, 1.15rem + 1.9vw, 2.6rem); line-height: 1.12; letter-spacing: -.035em; }
.study header p.lede { font-size: var(--t-title); color: var(--muted); line-height: 1.55; margin: 0; max-width: 64ch; }

/* KEY NUMBERS. One row, no boxes. */
.study .keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem 1.75rem; margin: 2rem 0 2.25rem; }
.study .keys b { display: block; font-size: clamp(1.45rem, 1.1rem + 1vw, 1.95rem); font-weight: 550; letter-spacing: -.04em;
  line-height: 1.05; color: var(--ink); font-variant-numeric: tabular-nums; }
.study .keys span { display: block; font-size: var(--t-small); color: var(--muted); margin-top: .35rem; line-height: 1.4; }

/* SECTIONS. The report's order: question, method, results, limits, reproduce. */
.study h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; margin: 2.25rem 0 .5rem; color: var(--ink); }
.study h4 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 .4rem; color: var(--ink); }
.study ul, .study ol { padding-left: 1.2rem; }
.study ul.outline, .study ul.outline ul { list-style: none; padding-left: 1rem; margin: .2rem 0; }
.study ul.outline { padding-left: 0; }
.study ul.outline li { font-size: .875rem; line-height: 1.5; margin: .15rem 0; }
.study li + li { margin-top: .35rem; }

/* FIGURES. Charts, diagrams, stills and clips, each with a caption under it. */
.study figure.fig { margin: 2.25rem 0; }
.study figure.fig > figcaption { margin-top: .8rem; color: var(--muted); font-size: var(--t-small); line-height: 1.6; }
.study figure.fig > figcaption b { color: var(--ink); font-weight: 600; }
.study .media-frame video, .study .media-frame img { display: block; width: 100%; height: auto;
  border-radius: var(--media-radius); background: var(--surface); box-shadow: var(--media-shadow); }
.study .media-frame { position: relative; }
@media (min-width: 1000px) {
  .study figure.wide { width: min(1160px, calc(100vw - 64px)); position: relative; left: 50%; transform: translateX(-50%); }
  .study figure.wide > figcaption { max-width: 800px; margin-left: auto; margin-right: auto; }
}
/* A clip for a reader who asked for less motion: the poster and one button (clips.js). */
.study .clip-play { position: absolute; left: 1rem; bottom: 1rem; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 999px;
  background: var(--bar); color: var(--ink); display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px); }
.study .clip-play:hover { background: var(--surface-2); }
.study .clip-play:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* SVG charts: thin marks, a recessive grid, text in the text inks. Marks carry a hover
   title but no focus: their numbers are in the table beside them. */
.study svg.chart { width: 100%; height: auto; display: block; font-family: var(--sans); }
.study svg.chart .grid { stroke: var(--line); stroke-width: 1; }
.study svg.chart .tick { fill: var(--faint); font-size: 10px; }
.study svg.chart .cat { fill: var(--ink-2); font-size: 11.5px; }
.study svg.chart .val, .study svg.chart .lab { fill: var(--ink-2); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.study svg.chart .ci { stroke: var(--ink-2); stroke-width: 1.2; opacity: .75; }
.study svg.chart .line { fill: none; stroke-width: 2; }
.study svg.chart .dot { stroke: var(--bg); stroke-width: 1.5; }
.study svg.chart .faded { fill-opacity: .55; }

/* Dot-and-interval and stacked rows: charts as HTML, readable at phone width. */
.dots { --label: 13rem; --val: 9.5rem; margin: 1rem 0 .5rem; font-size: var(--t-small); }
.dots-axis, .dots-row { display: grid; grid-template-columns: var(--label) 1fr var(--val); align-items: center; gap: .75rem; }
.dots-axis { height: 1.4rem; color: var(--faint); }
.dots-axis .dv-track { position: relative; height: 100%; }
.dots-axis i { position: absolute; top: 0; transform: translateX(-50%); font-style: normal; }
.dots-axis b { font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dots-row { min-height: 1.9rem; }
.dots-row .dv-label { color: var(--ink-2); line-height: 1.3; }
.dots-row.sub .dv-label { padding-left: 1rem; color: var(--muted); }
.dots-row .dv-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.dots-row .dv-track { position: relative; height: 1.9rem; }
.dots-row .dv-track i { position: absolute; display: block; }
.dots-row .dv-grid { top: 0; bottom: 0; width: 1px; background: var(--line); opacity: .6; }
.dots-row .dv-zero { top: 0; bottom: 0; width: 1px; background: var(--muted); }
.dots-row .dv-ci { top: calc(50% - 1px); height: 2px; border-radius: 1px; background: var(--s-control); }
.dots-row .dv-dot, .dv-legend .dv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--s-control);
  box-shadow: 0 0 0 2px var(--bg); }
.dots-row .dv-dot { top: calc(50% - 5px); margin-left: -5px; }
.dots-head { margin: .9rem 0 .2rem; font-weight: 600; color: var(--ink); font-size: var(--t-small); }
.dv-dot.s1, .dv-ci.s1 { background: var(--s-1); }
.dv-dot.s2, .dv-ci.s2 { background: var(--s-2); }
.dv-dot.s3, .dv-ci.s3 { background: var(--s-3); }
.dv-dot.s4, .dv-ci.s4 { background: var(--s-4); }
.dv-dot.bad, .dv-ci.bad { background: var(--s-bad); }
.dv-dot.dv-hollow { background: var(--bg) !important; border: 2px solid var(--s-control); box-sizing: border-box; }
.dv-dot.dv-hollow.s1 { border-color: var(--s-1); } .dv-dot.dv-hollow.s2 { border-color: var(--s-2); } .dv-dot.dv-hollow.s3 { border-color: var(--s-3); }
.dots-row .dv-seg { top: 20%; bottom: 20%; background: var(--s-control); box-shadow: inset -2px 0 0 var(--bg); }
.dots-row .dv-seg.s1 { background: var(--s-1); } .dots-row .dv-seg.s2 { background: var(--s-2); }
.dots-row .dv-seg.s3 { background: var(--s-3); } .dots-row .dv-seg.s4 { background: var(--s-4); }
.dots-row .dv-seg.muted, .dv-legend .dv-dot.muted { background: var(--surface-2); }
/* A chart's series, above it. */
.dv-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: var(--t-small); color: var(--muted); margin: .5rem 0 .75rem; }
.dv-legend span { display: inline-flex; align-items: center; gap: .45rem; }
.dv-legend .dv-dot { display: inline-block; position: static; }
.dv-legend .dv-dot.square { border-radius: 2px; }
@media (max-width: 640px) {
  .dots { --val: 0; }
  .dots-axis { grid-template-columns: 0 1fr 0; gap: 0; }
  .dots-row { grid-template-columns: 1fr auto; grid-template-areas: "label val" "track track"; gap: 0 .5rem; padding: .2rem 0; }
  .dots-row .dv-label { grid-area: label; }
  .dots-row .dv-val { grid-area: val; }
  .dots-row .dv-track { grid-area: track; height: 1.4rem; }
}

/* TABLES. One style. Numbers right-aligned in tabular figures; a heat cell's ground is its
   tone mixed in proportion to its level (at most a third, so the ink keeps its contrast). */
.study .table-wrap { margin: 1.5rem 0; overflow-x: auto; }
.study table.data { border-collapse: collapse; width: 100%; font-size: var(--t-small); font-variant-numeric: tabular-nums; }
.study table.data caption { caption-side: top; text-align: left; color: var(--ink); font-weight: 500; padding: 0 0 .6rem; }
.study table.data th, .study table.data td { text-align: right; padding: .5rem .65rem; border-bottom: 1px solid var(--line);
  color: var(--ink-2); vertical-align: top; }
.study table.data thead th { color: var(--muted); font-weight: 500; vertical-align: bottom; }
.study table.data tbody th { color: var(--ink); font-weight: 500; }
.study table.data th:first-child { text-align: left; }
.study table.data.text td, .study table.data.text th { text-align: left; }
.study table.data td.heat { --tone: var(--s-1); background: color-mix(in srgb, var(--tone) calc(var(--h) * 34%), transparent); color: var(--ink); }
.study table.data td.heat.bad { --tone: var(--s-bad); }
.study table.data td.heat.good { --tone: var(--s-good); }
.study table.data .soft { color: var(--faint); }
.study table.data tr.total th, .study table.data tr.total td { font-weight: 600; color: var(--ink); }
.study p.scale { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin: .4rem 0 1.75rem; font-size: .8125rem; color: var(--muted); }
.study p.scale span { display: inline-flex; align-items: center; gap: .4rem; }
.study p.scale i { width: 26px; height: 10px; border-radius: 2px; display: inline-block; --tone: var(--s-1);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--tone) 34%, transparent)); box-shadow: inset 0 0 0 1px var(--line); }
.study p.scale i.bad { --tone: var(--s-bad); } .study p.scale i.good { --tone: var(--s-good); }
.study p.scale span:last-child { color: var(--faint); }

/* CALLOUT. One note the reader must not miss. */
.study .callout { margin: 1.5rem 0; padding: .9rem 1.1rem; border-left: 3px solid var(--ink); background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0; }
.study .callout p { margin: 0; color: var(--ink-2); }
.study .callout p + p { margin-top: .5rem; }

/* QUOTE. A participant's words. */
.study blockquote { margin: 1.25rem 0; padding: .1rem 0 .1rem 1rem; border-left: 2px solid var(--line); }
.study blockquote p { margin: .3rem 0; color: var(--ink-2); }
.study blockquote .cite, .study .cite { font-size: var(--t-small); color: var(--faint); }

/* DISCLOSURE. The one way to put something away: a line with a plus, a hairline under it.
   Never nested, never a whole section. */
.study details.disclosure { margin: .75rem 0 1.5rem; border-bottom: 1px solid var(--line); }
.study details.disclosure > summary { list-style: none; cursor: pointer; position: relative; padding: .55rem 2rem .55rem 0;
  font-size: var(--t-small); color: var(--muted); }
.study details.disclosure > summary::-webkit-details-marker { display: none; }
.study details.disclosure > summary::after { content: "+"; position: absolute; right: .2rem; top: .3rem; font-size: 1.2rem;
  font-weight: 300; color: var(--muted); }
.study details.disclosure[open] > summary::after { content: "−"; }
.study details.disclosure > summary:hover { color: var(--ink); }
.study details.disclosure > .disclosure-body { padding: 0 0 1rem; }
.study details.disclosure .table-wrap { margin: .25rem 0 0; }
.study details.disclosure pre { white-space: pre-wrap; }

/* A still grid (forking, policy checks): one fork's branches side by side. */
.study .stills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.study .stills figure { margin: 0; }
.study .stills figcaption { margin-top: .5rem; color: var(--muted); font-size: var(--t-small); line-height: 1.5; }
.study .stills img { display: block; width: 100%; height: auto; border-radius: var(--radius); background: var(--surface); }
@media (max-width: 560px) { .study .stills { grid-template-columns: minmax(0, 1fr); } }

/* The brain-encoder study's maps: the encoder's own renderings, two to a row, one on a phone. */
.maps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; margin: 0; }
.maps .map { margin: 0; }
.maps .map img { display: block; width: 100%; height: auto; border-radius: 8px; background: #fff; }
.maps .map figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
@media (max-width: 720px) { .maps { grid-template-columns: 1fr; } }

/* An interactive diagram (the executive end-games tree): edge to edge, no frame or ground,
   the nodes are the picture. A panel beside it says what the chosen node holds. */
.study figure.diagram { width: 100vw; position: relative; left: 50%; transform: translateX(-50%); margin: 2.25rem 0; }
.study figure.diagram > figcaption { max-width: 800px; margin: .8rem auto 0; padding: 0 var(--margin); }
.study .diagram-tools { margin: 0 0 .75rem; padding: 0 var(--margin); display: flex; flex-wrap: wrap;
  align-items: center; gap: .5rem 1.25rem; }
.study .pills { display: flex; flex-wrap: wrap; gap: .35rem; }
.study .pills button { font: inherit; font-size: .8125rem; padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.study .pills button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.study .pills button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.study .diagram-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0 1.5rem; padding: 0 var(--margin); }
.study .diagram-view { overflow: auto; max-height: min(78vh, 760px); cursor: grab; scrollbar-width: thin; touch-action: pan-x pan-y; }
.study .diagram-view.dragging { cursor: grabbing; user-select: none; }
.study .diagram-view svg { display: block; font-family: var(--sans); }
.study .diagram-view .node rect.box { fill: var(--bg); stroke: var(--line); }
.study .diagram-view .node.sel rect.box { stroke: var(--ink); stroke-width: 1.6; }
.study .diagram-view .node.path rect.box { stroke: var(--muted); }
.study .diagram-view .node text { fill: var(--ink); font-size: 11.5px; }
.study .diagram-view .node text.n { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.study .diagram-view .node { cursor: pointer; }
.study .diagram-view .node:focus { outline: none; }
.study .diagram-view .node:focus-visible rect.box { stroke: var(--ink); stroke-width: 2; }
.study .diagram-view .link { fill: none; stroke: var(--context); }
.study .diagram-view .link.path { stroke: var(--faint); }
.study .diagram-view .stagehead { fill: var(--muted); font-size: 11px; font-weight: 600; }
.study .diagram-panel { max-height: min(78vh, 760px); overflow: auto; font-size: var(--t-small); padding-bottom: 1rem; }
.study .diagram-panel .eyebrow { color: var(--faint); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; margin: 0; }
.study .diagram-panel h3 { margin: .2rem 0 .6rem; font-size: 1.05rem; line-height: 1.3; }
.study .diagram-panel .big { font-size: 1.6rem; font-weight: 550; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.study .diagram-panel .big small { font-size: var(--t-small); font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: .35rem; }
.study .diagram-panel .split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: .5rem 0 .4rem; background: var(--surface); }
.study .diagram-panel .split i { display: block; height: 100%; }
.study .diagram-panel .bars { display: grid; grid-template-columns: auto 1fr auto; gap: .3rem .6rem; align-items: center; margin: .4rem 0 1rem; }
.study .diagram-panel .bars span { color: var(--ink-2); font-size: .8125rem; }
.study .diagram-panel .bars b { font-weight: 500; color: var(--ink); font-size: .8125rem; font-variant-numeric: tabular-nums; text-align: right; }
.study .diagram-panel .bars i { display: block; height: 6px; border-radius: 3px; background: var(--s-1); }
.study .diagram-panel .bars i.bad { background: var(--s-bad); }
.study .diagram-panel .bars i.good { background: var(--s-good); }
.study .diagram-panel h4 { margin: 1rem 0 .35rem; font-size: .75rem; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.study .diagram-panel .runs { list-style: none; padding: 0; margin: 0; }
.study .diagram-panel .runs li { margin: 0; border-top: 1px solid var(--line); }
.study .diagram-panel .runs button { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 10px 1fr auto;
  gap: .5rem; align-items: center; padding: .45rem .1rem; cursor: pointer; font-size: .8125rem; color: var(--ink-2); }
.study .diagram-panel .runs button:hover { color: var(--ink); }
.study .diagram-panel .runs button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.study .diagram-panel .runs button[aria-expanded="true"] { color: var(--ink); font-weight: 500; }
.study .diagram-panel .runs button i { width: 8px; height: 8px; border-radius: 50%; }
.study .diagram-panel .runs button em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.study .diagram-panel .events { margin: 0 0 .6rem 1.1rem; padding: 0; }
.study .diagram-panel .events li { border: 0; font-size: .8125rem; line-height: 1.5; color: var(--muted); margin: .25rem 0; }
.study .diagram-panel .refs { margin: 0 0 .7rem 1.1rem; font-size: .75rem; color: var(--faint); }
.study .diagram-panel .note { color: var(--faint); font-size: .8125rem; line-height: 1.5; margin-top: 1rem; }
@media (max-width: 860px) {
  .study .diagram-body { grid-template-columns: minmax(0, 1fr); }
  .study .diagram-view { max-height: 60vh; }
  .study .diagram-panel { max-height: none; margin-top: 1rem; }
}

/* THE RESEARCH INDEX: a grid of studies, each led by a picture. */
main.study.research-index { max-width: 1120px; }
.research-index .lede { max-width: 62ch; }
.research-index .study-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1.25rem;
  margin: 1.25rem 0 3rem; }
.research-index .study-grid.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }
.research-index .study-card { display: flex; flex-direction: column; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: var(--media-radius); overflow: hidden; background: var(--bg);
  transition: border-color .15s ease, transform .15s var(--ease); }
.research-index .study-card:hover { border-color: var(--muted); transform: translateY(-2px); }
.research-index .study-card .thumb { aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface); position: relative; }
.research-index .study-card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: left top; display: block; }
.research-index .study-card .thumb video { width: 100%; height: 100%; object-fit: contain; display: block; }
.research-index .study-card .thumb svg { width: 100%; height: 100%; display: block; }
.research-index .study-card .thumb .kind { position: absolute; right: .6rem; top: .6rem; padding: .15rem .5rem; border-radius: 999px;
  background: var(--bar); color: var(--ink-2); font-size: .72rem; backdrop-filter: blur(6px); }
.research-index .study-card .text { padding: 1rem 1.1rem 1.15rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.research-index .study-card b { color: var(--ink); font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; line-height: 1.3; }
.research-index .study-card span { color: var(--muted); font-size: var(--t-small); line-height: 1.5; }
.research-index .study-card .num { margin-top: auto; padding-top: .5rem; display: flex; align-items: baseline; gap: .5rem; }
.research-index .study-card .num strong { white-space: nowrap; font-size: 1.5rem; font-weight: 550; letter-spacing: -.03em; color: var(--ink);
  font-variant-numeric: tabular-nums; }
.research-index .study-card .num em { font-style: normal; font-size: .78rem; color: var(--faint); line-height: 1.35; }

/* The factor registry as a grid: one square per factor, by measurement kind. */
.factor-map { margin: 1rem 0 .5rem; display: grid; gap: .55rem; }
.factor-map .fm-row { display: grid; grid-template-columns: 8.5rem 1fr; gap: .75rem; align-items: center; font-size: var(--t-small); }
.factor-map .fm-row > span { color: var(--ink-2); }
.factor-map .fm-row > span small { color: var(--faint); margin-left: .3rem; }
.factor-map .fm-cells { display: flex; flex-wrap: wrap; gap: 4px; }
.factor-map i { width: 16px; height: 16px; border-radius: 3px; background: var(--surface-2); display: block; }
.factor-map i.benchmarked { background: var(--holds); }
.factor-map i.null { background: var(--faint); }
.factor-map i.hypothesis { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.factor-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .8rem; color: var(--muted); margin: .5rem 0 0; }
.factor-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.factor-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--surface-2); }
.factor-legend i.benchmarked { background: var(--holds); } .factor-legend i.null { background: var(--faint); }
.factor-legend i.hypothesis { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
@media (max-width: 560px) { .factor-map .fm-row { grid-template-columns: 1fr; gap: .3rem; } }
