/*
  Shared style for the explainers under /education. Linen ground, black ink, and pastel or
  bright accents reserved for the details a reader should track. Pages link this file and
  /ventures/back-home.css, then add only what is specific to their figures.
*/
:root {
  color-scheme: light;
  --linen: #faf0e6;
  --sheet: #fdf8f1;       /* figures and panels sit on a slightly lighter sheet */
  --ink: #12100d;
  --ink-2: #4a4339;
  --ink-3: #7c7366;
  --rule: #ddd0bb;
  --rule-strong: #12100d;

  /* pastel accents: one per recurring idea, filled behind black text */
  --mint: #9fe6c4;
  --sky: #a9d0ff;
  --peach: #ffbf96;
  --lilac: #d2b6f7;
  --butter: #ffe48a;
  --rose: #ffb3c4;

  /* bright accents: thin marks and labels that must contrast with linen */
  --coral: #e8452c;
  --cobalt: #2d55d8;
  --jade: #0f8a5f;
  --plum: #8a3fc0;

  --measure: 40rem;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--linen);
  color: var(--ink);
  font: 17px/1.62 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

.paper { max-width: 1012px; margin: 0 auto; padding: 0 16px 6rem; }
.paper > * { max-width: var(--measure); margin-left: auto; margin-right: auto; }
.paper > .wide { max-width: 980px; }

/* title block, set like the first page of a proceedings paper */
.masthead { text-align: center; padding: 3.5rem 0 1.5rem; }
.masthead .kicker {
  font: 500 0.72rem/1 var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 1.4rem;
}
.masthead h1 {
  font-size: clamp(1.9rem, 4.6vw, 2.7rem); line-height: 1.12; font-weight: 700;
  letter-spacing: -0.01em; margin: 0 auto; max-width: 22ch; text-wrap: balance;
}
.masthead .byline { margin: 1.1rem 0 0; color: var(--ink-2); font-size: 0.98rem; }
.masthead .byline a { color: inherit; }

.abstract {
  margin: 1.8rem auto 2.4rem; padding: 1.1rem 1.4rem 1.2rem;
  border-top: 1.5px solid var(--rule-strong); border-bottom: 1.5px solid var(--rule-strong);
  font-size: 0.96rem;
}
.abstract h2 {
  font: 700 0.78rem/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  margin: 0 0 0.6rem;
}
.abstract p { margin: 0; }

h2.section, h3.subsection { font-weight: 700; line-height: 1.25; text-wrap: balance; }
h2.section { font-size: 1.35rem; margin: 3rem auto 0.8rem; }
h3.subsection { font-size: 1.08rem; margin: 2rem auto 0.5rem; }
.section .num, .subsection .num { font-family: var(--mono); font-weight: 600; margin-right: 0.6ch; }

p { margin: 0 auto 1rem; }
a { color: var(--cobalt); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
em { font-style: italic; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
sup.fn { font-size: 0.7em; }

/* pastel highlighter for a defined term or an operator name */
.hl { padding: 0 0.28em; border-radius: 3px; background: var(--butter); white-space: nowrap; }
.hl--insert { background: var(--mint); }
.hl--new { background: var(--sky); }
.hl--merge { background: var(--peach); }
.hl--split { background: var(--lilac); }
.hl--a { background: none; color: var(--coral); font-weight: 700; padding: 0; }
.hl--b { background: none; color: var(--cobalt); font-weight: 700; padding: 0; }
.hl--jade { background: none; color: var(--jade); font-weight: 700; padding: 0; }

.eq { position: relative; overflow-x: auto; margin: 0.4rem auto 1.2rem; padding: 0.2rem 0; }
.eq .katex-display { margin: 0.4rem 0; }

/* figures */
figure.fig {
  margin: 1.8rem auto 2.2rem; padding: 18px 18px 14px;
  background: var(--sheet); border: 1.5px solid var(--rule-strong);
}
figure.fig figcaption {
  margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule);
  font-size: 0.9rem; color: var(--ink-2); line-height: 1.5;
}
figcaption b:first-child { color: var(--ink); }
.fig-note {
  display: inline-block; margin-left: 0.4ch; padding: 0 0.4em; border: 1px solid var(--ink-3);
  border-radius: 999px; font: 500 0.68rem/1.6 var(--mono); color: var(--ink-2);
  vertical-align: 1px; letter-spacing: 0.04em; text-transform: uppercase;
}

/* controls */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.controls .label { font: 600 0.74rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.btn {
  appearance: none; cursor: pointer;
  min-height: 34px; padding: 0 12px;
  border: 1.5px solid var(--ink); border-radius: 0; background: var(--linen); color: var(--ink);
  font: 600 0.8rem/1 var(--mono);
}
.btn:hover { background: var(--butter); }
.btn:focus-visible, .seg button:focus-visible, .chip:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: default; background: var(--linen); color: var(--ink); }
.btn--primary { background: var(--ink); color: var(--linen); }
.btn--primary:hover { background: #2c2720; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1.5px solid var(--ink); }
.seg button {
  appearance: none; cursor: pointer; min-height: 34px; padding: 0 12px;
  border: 0; border-right: 1.5px solid var(--ink); background: var(--linen); color: var(--ink);
  font: 600 0.8rem/1 var(--mono);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--linen); }
.seg button[data-tone][aria-pressed="true"] { color: var(--ink); }
.seg button[data-tone="insert"][aria-pressed="true"] { background: var(--mint); }
.seg button[data-tone="new"][aria-pressed="true"] { background: var(--sky); }
.seg button[data-tone="merge"][aria-pressed="true"] { background: var(--peach); }
.seg button[data-tone="split"][aria-pressed="true"] { background: var(--lilac); }

input[type="range"] { accent-color: var(--ink); width: 180px; max-width: 100%; }
output { font: 600 0.82rem/1 var(--mono); }

/* tables in the register of a paper: rules above and below, none between rows */
table.tbl { border-collapse: collapse; margin: 0 auto; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
table.tbl caption { caption-side: top; text-align: left; font-size: 0.88rem; color: var(--ink-2); padding-bottom: 6px; }
table.tbl th, table.tbl td { padding: 4px 10px; text-align: right; white-space: nowrap; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl th[colspan] { text-align: center; }
table.tbl thead tr:first-child th { border-top: 1.5px solid var(--ink); }
table.tbl thead tr:last-child th { border-bottom: 1px solid var(--ink); }
table.tbl tbody tr:last-child td { border-bottom: 1.5px solid var(--ink); }
table.tbl .best { font-weight: 700; }
/* tables of prose cells read left-aligned and may wrap */
table.tbl--text td, table.tbl--text th { text-align: left; white-space: normal; }
/* positioned, so KaTeX's absolutely placed MathML stays inside the scroll box */
.tbl-wrap { position: relative; overflow-x: auto; margin: 1.4rem auto 1.8rem; }

/* shared figure parts: a tree beside a readout panel, probability bars, step narration */
.split-fig { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
/* a flex row keeps an overflowing tree scrollable from its left edge instead of clipped */
.tree-scroll { display: flex; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
.tree-scroll svg { display: block; flex: none; margin: 0 auto; }

.panel {
  border: 1.5px solid var(--ink); background: var(--linen);
  padding: 12px 14px; font-size: 0.88rem; line-height: 1.45; min-height: 120px;
}
.panel h4 { margin: 0 0 8px; font: 700 0.8rem/1.3 var(--mono); letter-spacing: 0.04em; }
.panel p { margin: 0 0 8px; }
.panel .muted { color: var(--ink-3); }
.panel .eqline { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-2); }

/* probability bars inside panels */
.dist { margin: 0 0 10px; }
.dist-name { font: 600 0.7rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 4px; }
.dist-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 40px; align-items: center; gap: 8px; margin: 2px 0; }
.dist-row .v { font: 500 0.76rem/1.2 var(--mono); display: inline-flex; align-items: center; gap: 5px; }
.dist-row .track { height: 10px; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.dist-row .bar { height: 100%; background: var(--ink); }
.dist-row .num { font: 500 0.74rem/1 var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.dist-row.is-top .bar { background: var(--jade); }

.stepcount { color: var(--ink-3); font-size: 0.78rem; }
.ops-nav { margin: 10px 0 0; justify-content: center; }
.line-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; margin-top: 8px; font: 500 0.72rem/1.3 var(--mono); color: var(--ink-2); }
.line-legend i { display: inline-block; width: 22px; height: 0; border-top: 2px solid; margin-right: 5px; vertical-align: 3px; }
.narration { font-size: 0.93rem; line-height: 1.5; margin: 0; min-height: 4.5em; }

/* references */
.colophon { font-size: 0.88rem; color: var(--ink-2); }

ol.refs { padding-left: 1.4rem; font-size: 0.88rem; color: var(--ink-2); }
ol.refs li { margin-bottom: 0.45rem; }

.footnotes { border-top: 1px solid var(--rule); margin-top: 2.5rem; padding-top: 0.8rem; font-size: 0.84rem; color: var(--ink-2); }

svg text { font-family: var(--mono); }

@media (max-width: 760px) {
  .split-fig { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  figure.fig { padding: 14px 12px 12px; margin-left: -4px; margin-right: -4px; }
  .abstract { padding: 1rem 0.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
