/* Shared styles for interactive notes (posts/<id> built from notes/<id>/).
   Everything is scoped under `.note` so it can sit
   inside the site chrome. Colour tokens mirror styles/site.css, and the
   canvas/SVG drawing reads the same values from PAL in note.js. */

.note {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --ink: #212529;
  --ink-2: #3d434a;
  --muted: #5c636a;
  --rule: #e3e5e8;
  --faint: #eceef1;
  --head: #2b58a6;
  --head-2: #5b82c6;
  --head-3: #1c3f7d;
  --tail: #c45f1c;
  --tail-2: #de8a4e;
  --tail-3: #9a4712;
  --mix: #6d4aa8;
  --good: #2f7a55;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  padding: 0 24px 24px;
  color: var(--ink);
}

:root[data-theme='dark'] .note {
  --bg: #141517;
  --surface: #1b1d21;
  --ink: #e6e6e4;
  --ink-2: #c3c7cc;
  --muted: #a3a7ac;
  --rule: #2a2d31;
  --faint: #24272b;
  --head: #7ea6ec;
  --head-2: #a9c3f2;
  --head-3: #5a86d6;
  --tail: #ee9657;
  --tail-2: #f5b786;
  --tail-3: #d27432;
  --mix: #b394ea;
  --good: #6bc49a;
}

/* Text and figures share the site's content width. */
.note .col {
  max-width: 692px;
  margin-inline: auto;
}

.note .wide {
  max-width: 692px;
  margin-inline: auto;
}

.note p {
  margin: 0;
}

.note .prose {
  display: grid;
  gap: 1em;
}

.note .label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.note .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.note .H {
  color: var(--head);
}

.note .T {
  color: var(--tail);
}

.note .X {
  color: var(--mix);
}

/* ---------- Hero ---------- */

.note .note-hero {
  display: grid;
  gap: 14px;
  padding-top: 40px;
}

.note .note-hero .eyebrow {
  margin: 0;
  color: var(--muted); /* the note's --faint is a surface tint, not a text colour */
}

.note .note-hero h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-wrap: balance;
}

.note .note-hero h1 .amp {
  color: var(--muted);
  font-weight: 400;
}

.note .byline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--muted);
  font-size: 15px;
}

.note .byline strong,
.note .byline .venue {
  color: var(--ink);
  font-weight: 600;
}

.note .note-hero .pub-links {
  font-size: 15px;
}

.note .version-note {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.note .tldr {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.note .tldr div {
  display: grid;
  gap: 6px;
  align-content: start;
}

.note .tldr p {
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.55;
}

.note .tldr .label {
  color: var(--ink);
}

/* ---------- Sections ---------- */

.note section {
  margin-top: 0;
  padding-top: 56px;
}

.note .sec-head {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.note .sec-head h2 {
  margin: 0;
}

.note .eq {
  overflow-x: auto;
  padding-block: 4px;
}

/* ---------- Figures ---------- */

.note figure {
  margin: 30px auto 26px;
}

.note .fig {
  display: grid;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.note figcaption {
  max-width: 692px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.note figcaption b {
  color: var(--ink-2);
  font-weight: 600;
}

.note .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: center;
  font-size: 14px;
}

.note .ctl {
  display: grid;
  flex: 1 1 240px;
  gap: 4px;
  min-width: 220px;
  max-width: 420px;
}

.note .ctl-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.note .ctl-top output {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
}

.note .ctl .hint {
  color: var(--muted);
  font-size: 12.5px;
}

.note input[type='range'] {
  width: 100%;
  margin: 4px 0;
  accent-color: var(--link);
}

.note .btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note button {
  padding: 6px 12px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.note button:hover {
  background: var(--button-hover);
}

.note button[aria-pressed='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.note :focus-visible {
  outline: 2px solid var(--mix);
  outline-offset: 2px;
}

.note .panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.note .panels.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
}

.note .panel {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
}

/* Title above a small sub-label, so narrow panels don't wrap mid-phrase. */
.note .panel-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.note .panel-title span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.note canvas,
.note svg.chart {
  display: block;
  width: 100%;
  height: auto;
}

.note .sq {
  aspect-ratio: 1 / 1;
  max-width: 100%;
  border-radius: 4px;
  background: var(--bg);
}

.note .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 12.5px;
}

.note .legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: -1px;
}

.note .legend i.ring {
  border: 2px solid var(--head);
  background: transparent;
}

.note .legend i.dash {
  width: 16px;
  height: 0;
  border-radius: 0;
  border-top: 2px dashed var(--ink-2);
  vertical-align: 3px;
}

.note .legend i.line {
  width: 16px;
  height: 0;
  border-radius: 0;
  border-top: 2px solid var(--ink);
  vertical-align: 3px;
}

.note .readout {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  color: var(--ink-2);
  font-size: 13.5px;
}

.note .readout b {
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 500;
}

.note .status {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--faint);
  color: var(--ink-2);
  font-size: 13.5px;
}

.note .status b {
  font-weight: 600;
}

.note .status.ok b {
  color: var(--good);
}

.note .status.bad b {
  color: var(--tail);
}

/* ---------- Theorem boxes ---------- */

.note .thm {
  display: grid;
  gap: 8px;
  padding: 4px 0 4px 20px;
  border-left: 2px solid var(--ink);
}

.note .thm .label {
  color: var(--ink);
}

.note details.math {
  color: var(--muted);
  font-size: 14px;
}

.note details.math summary {
  cursor: pointer;
}

.note details.math > div {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  color: var(--ink-2);
  font-size: 15.5px;
}

/* ---------- Bars ---------- */

.note .bars {
  display: grid;
  gap: 10px;
  font-size: 13px;
}

.note .bar {
  display: grid;
  grid-template-columns: 70px 1fr 46px;
  gap: 10px;
  align-items: center;
}

.note .bar .track {
  height: 10px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--faint);
}

.note .bar .fill {
  width: 0;
  height: 100%;
  transition: width 160ms linear;
}

.note .bar .v {
  color: var(--ink);
  font-family: var(--mono);
  text-align: right;
}

.note .tickwrap {
  position: relative;
}

.note .tick {
  position: absolute;
  top: -2px;
  width: 0;
  height: 22px;
  border-left: 1.5px solid var(--good);
  pointer-events: none;
}

.note .tick-label {
  color: var(--good);
  font-size: 12px;
}

/* ---------- Evidence ---------- */

.note .evidence {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.note .card {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 20px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

/* Reset the site's divider-style h3 for card titles. */
.note .card h3 {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: normal;
  line-height: 1.35;
  text-transform: none;
}

.note .card h3::after {
  content: none;
}

.note .card p {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.55;
}

.note .card.span {
  grid-column: 1 / -1;
}

.note .tablewrap {
  overflow-x: auto;
}

.note table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.note th,
.note td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--rule);
  text-align: right;
  white-space: nowrap;
}

.note th:first-child,
.note td:first-child {
  text-align: left;
}

.note th {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.note td {
  font-family: var(--mono);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.note td:first-child {
  font-family: inherit;
  font-size: 14px;
}

.note tr.ours td {
  background: var(--faint);
  color: var(--ink);
  font-weight: 600;
}

.note tr.ours td:first-child {
  color: var(--mix);
}

.note .big {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 28px;
  line-height: 1;
}

/* ---------- Cite ---------- */

.note pre.bib {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
}

.note .note-foot {
  display: grid;
  gap: 6px;
  margin-top: 40px;
  color: var(--muted);
  font-size: 13.5px;
}

.note .back {
  margin-top: 28px;
  font-size: 15px;
}

/* ---------- Shared components (group bars, quotes, citation) ---------- */

.note q {
  quotes: '\201C' '\201D';
}

.note .groups {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 13px;
}

.note .grow {
  display: grid;
  grid-template-columns: 128px 1fr 40px;
  gap: 10px;
  align-items: center;
}

.note .grow .name {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--ink-2);
}

.note .grow.worst .name {
  color: var(--ink);
  font-weight: 600;
}

.note .grow .track {
  height: 10px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--faint);
}

.note .grow .fill {
  width: 0;
  height: 100%;
  transition: width 160ms linear;
}

.note .grow .v {
  color: var(--ink);
  font-family: var(--mono);
  text-align: right;
}

.note .dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border: 2px solid;
  border-radius: 50%;
}

.note .cite {
  display: grid;
  gap: 10px;
}

@media (max-width: 640px) {
  .note .grow {
    grid-template-columns: 112px 1fr 38px;
  }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
  .note .panels,
  .note .panels.two {
    grid-template-columns: minmax(0, 1fr);
  }

  .note .panels .panel {
    justify-self: center;
    width: 100%;
    max-width: 520px;
  }
}

@media (max-width: 640px) {
  .note {
    padding-inline: 16px;
  }

  .note .note-hero h1 {
    font-size: 27px;
  }

  .note .tldr,
  .note .evidence {
    grid-template-columns: minmax(0, 1fr);
  }

  .note .fig {
    padding: 14px;
  }

  .note section {
    padding-top: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .note .bar .fill,
  .note .grow .fill {
    transition: none;
  }
}

/* Light theme: darken coloured text so it clears 4.5:1 (the hues stay full strength in charts). */
:root:not([data-theme='dark']) .note .T,
:root:not([data-theme='dark']) .note .status.bad b {
  color: color-mix(in srgb, var(--tail) 70%, #000);
}

:root:not([data-theme='dark']) .note .status.ok b {
  color: color-mix(in srgb, var(--good) 80%, #000);
}
