/* Long-form article theme: one serif reading column, sans headings, booktabs
   tables, and provenance as evaluation badges. Supporting material opens in a
   dialog (notes.js). System fonts only, so the site has no runtime dependencies. */
:root {
  --bg: #fefefd;
  --fg: #1a1a19;
  --muted: #5d5c58;
  --line: #d9d8d3;
  --rule: #1a1a19;
  --panel: #f5f5f2;
  --link: #1f4a8a;
  --accent: #1f4a8a;
  --ok: #1e6b3a;
  --bad: #a3231b;
  --captured-fg: #1e6b3a;
  --static-fg: #1f4a8a;
  --na-fg: #8a5a00;
  --na-bg: #fbf6ea;
  --plot: #1f4a8a;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
/* Light is the default; dark applies only when chosen with the toggle. */
:root[data-theme="dark"] {
  --bg: #17181a;
  --fg: #e6e4df;
  --muted: #a3a19b;
  --line: #36373a;
  --rule: #cfccc5;
  --panel: #1f2023;
  --link: #93b4ea;
  --accent: #93b4ea;
  --ok: #7cc795;
  --bad: #f08c82;
  --captured-fg: #7cc795;
  --static-fg: #93b4ea;
  --na-fg: #e0b458;
  --na-bg: #26221a;
  --plot: #93b4ea;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 18px/1.65 var(--serif);
  font-kerning: normal;
}
main,
header.site,
footer.site {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 16px;
}
main {
  padding-bottom: 3rem;
}
a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:focus-visible,
pre:focus-visible,
summary:focus-visible,
.table-wrap:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
h1,
h2,
h3,
h4 {
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  letter-spacing: -0.01em;
  margin: 0.25rem 0 0.5rem;
}
h2 {
  font-size: 1.45rem;
  margin: 3.5rem 0 0.5rem;
}
h3 {
  font-size: 1.08rem;
  margin: 2rem 0 0.25rem;
}
code {
  font-family: var(--mono);
  font-size: 0.82em;
  overflow-wrap: anywhere;
}
.lede {
  font-style: italic;
  color: var(--muted);
}
.meta {
  color: var(--muted);
  font: 0.85rem/1.5 var(--sans);
}

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 16px;
  top: 8px;
  background: var(--bg);
  padding: 0.25rem 0.5rem;
  z-index: 1;
}

/* Top bar: only the theme switch */
header.site {
  display: flex;
  justify-content: flex-end;
  min-height: 3rem;
  padding-top: 1rem;
}
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: 0.85rem var(--sans);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0.25rem;
  cursor: pointer;
}
.theme-switch .track {
  position: relative;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--panel);
  transition: background 0.15s;
}
.theme-switch .thumb {
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: var(--fg);
  transition: transform 0.15s;
}
.theme-switch[aria-checked="true"] .track {
  background: var(--fg);
}
.theme-switch[aria-checked="true"] .thumb {
  background: var(--bg);
  transform: translateX(1rem);
}
.theme-switch:hover {
  color: var(--fg);
}
.theme-switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Footer as a footnote block */
footer.site {
  color: var(--muted);
  font-size: 0.85rem;
  padding-top: 0.5rem;
  padding-bottom: 2rem;
}
footer.site::before {
  content: "";
  display: block;
  width: 30%;
  border-top: 1px solid var(--muted);
  margin-bottom: 0.5rem;
}

/* Article */
.post-head {
  margin: 1.5rem 0 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.kicker {
  margin: 0;
  font: 600 0.8rem var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.dek {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}
.byline {
  margin: 1rem 0 0;
  font: 0.85rem var(--sans);
  color: var(--muted);
}
ol.stages {
  padding-left: 1.25rem;
}
ol.stages li {
  margin: 0.3rem 0;
}
.toc {
  margin: 2rem 0 0;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border-left: 3px solid var(--rule);
}
.toc-h {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ol {
  margin: 0;
  padding-left: 1.25rem;
}
.toc li {
  margin: 0.35rem 0;
}
.toc .meta {
  display: block;
}
section.project,
section.project > h3 {
  scroll-margin-top: 1rem;
}
section.project > h2 {
  padding-top: 2rem;
  border-top: 1.5px solid var(--rule);
}
section.project > h2 .num {
  color: var(--muted);
  font-weight: 400;
}
.facts {
  font: 0.85rem/1.7 var(--sans);
  color: var(--muted);
  margin: 0.75rem 0 1.5rem;
}
p.see {
  margin: -0.4rem 0 0;
  font: 0.9rem/1.5 var(--sans);
}
p.see a::after {
  content: " →";
}
.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--na-fg);
  background: var(--na-bg);
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
}
.callout p {
  margin: 0.25rem 0;
}

/* Notes: an appendix without JS, a modal dialog with it (notes.js) */
.appendix {
  margin-top: 4rem;
  border-top: 1.5px solid var(--rule);
}
.note {
  margin: 2.5rem 0;
}
.note h3 {
  margin-top: 0.1rem;
}
.note-from {
  margin: 0;
  font: 600 0.75rem var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.note ul.caps {
  padding-left: 1.25rem;
}
.note ol.arch {
  list-style: none;
  padding: 0;
}
.note ol.arch li {
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}
.note ol.arch h4 {
  margin: 0;
  font-size: 1rem;
}
.note ol.arch p {
  margin: 0.2rem 0 0;
}
.note-dialog {
  width: min(52rem, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.note-dialog[open] {
  display: flex;
  flex-direction: column;
}
.note-dialog::backdrop {
  background: rgba(20, 20, 18, 0.55);
}
.note-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0.4rem 0.5rem 0;
}
.note-close {
  width: 2.25rem;
  height: 2.25rem;
  font: 1.5rem/1 var(--sans);
  color: var(--muted);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.note-close:hover {
  color: var(--fg);
  border-color: var(--line);
}
.note-body {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 1.75rem 1.75rem;
}
.note-body .note {
  margin: 0;
}
body:has(.note-dialog[open]) {
  overflow: hidden;
}

/* Provenance, styled after artifact-evaluation badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: currentColor;
}
.badge.captured {
  color: var(--captured-fg);
}
.badge.static {
  color: var(--static-fg);
}
.badge.unavailable {
  color: var(--na-fg);
}
.badge.unavailable::before {
  background: none;
  border: 1.5px solid currentColor;
}

/* Artifacts are captioned like figures */
.artifact {
  margin: 1.75rem 0;
}
.artifact-title {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}
.prov {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
div.unavailable {
  padding: 0.6rem 0.9rem;
  border: 1px dashed var(--na-fg);
  font-size: 0.95rem;
}
pre {
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
  overflow: auto;
  max-height: 32rem;
  font: 0.8rem/1.5 var(--mono);
  position: relative;
}
pre code {
  font-size: inherit;
  overflow-wrap: normal;
}
details {
  margin: 0.5rem 0;
}
summary {
  cursor: pointer;
  color: var(--link);
  font-size: 0.95rem;
}
.copy {
  display: block;
  font: 0.8rem var(--sans);
  margin: 0.5rem 0 -0.25rem auto;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

ul.diags,
ul.diff,
ul.expected {
  list-style: none;
  padding: 0;
}
ul.diags li {
  margin: 0.35rem 0;
  font-size: 0.95rem;
}
.sev {
  font: 600 0.75rem var(--mono);
  text-transform: uppercase;
}
.sev-error {
  color: var(--bad);
}
.sev-note,
.sev-remark {
  color: var(--muted);
}
.d-added code {
  color: var(--ok);
}
.d-removed code {
  color: var(--bad);
}
.ok {
  color: var(--ok);
}
.bad {
  color: var(--bad);
}

/* Booktabs tables */
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  border-bottom: 1.5px solid var(--rule);
}
caption {
  text-align: left;
  padding-bottom: 0.4rem;
  font-size: 0.9rem;
}
thead tr {
  border-top: 1.5px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
th {
  font-weight: 600;
}
th,
td {
  text-align: left;
  padding: 0.25rem 0.5rem;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.plot {
  width: 30%;
}
.bar {
  display: block;
  height: 0.55rem;
  width: var(--w);
  background: var(--plot);
}
.depth-1 {
  padding-left: 1.5rem;
}
.depth-2 {
  padding-left: 2.5rem;
}
.depth-3 {
  padding-left: 3.5rem;
}

/* Floating terminal (terminal.js). Dark in both themes, like a real one. */
body.has-term {
  padding-bottom: 5rem;
}
.term {
  --t-bg: #141517;
  --t-bar: #1c1d20;
  --t-fg: #dcdad4;
  --t-dim: #8d8b85;
  --t-line: #2c2d31;
  --t-prompt: #e0b458;
  --t-ok: #7cc795;
  --t-err: #f08c82;
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(56rem, calc(100% - 24px));
  background: var(--t-bg);
  color: var(--t-fg);
  border: 1px solid var(--t-line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font: 0.8rem/1.5 var(--mono);
  color-scheme: dark;
  overflow: hidden;
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  background: var(--t-bar);
}
.term.open .term-bar {
  border-bottom: 1px solid var(--t-line);
}
.term-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 600;
  color: var(--t-fg);
  background: none;
  border: 0;
  padding: 0.2rem 0.3rem;
  cursor: pointer;
}
.term-glyph {
  color: var(--t-prompt);
}
.term-select {
  font: inherit;
  color: var(--t-fg);
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  border-radius: 5px;
  padding: 0.15rem 0.4rem;
}
.term-note {
  margin-left: auto;
  color: var(--t-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.term-body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: min(45vh, 26rem);
}
.term-chips {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.5rem 0.6rem;
  scrollbar-width: thin;
}
.term-chip {
  flex: none;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  color: var(--t-fg);
  background: var(--t-bar);
  border: 1px solid var(--t-line);
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  cursor: pointer;
}
.term-chip:hover {
  border-color: var(--t-dim);
}
.term-out {
  overflow: auto;
  padding: 0.25rem 0.75rem 0.5rem;
  min-height: 0;
}
.term-out .line {
  margin: 0 0 0.35rem;
  padding: 0;
  background: none;
  border: 0;
  max-height: none;
  overflow: visible;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--t-fg);
}
.term-out .cmd {
  color: var(--t-prompt);
  margin-top: 0.6rem;
}
.term-out .dim {
  color: var(--t-dim);
}
.term-out .ok {
  color: var(--t-ok);
}
.term-out .err {
  color: var(--t-err);
}
.term-out .warn {
  color: var(--t-prompt);
}
.term-in {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid var(--t-line);
}
.term-prompt {
  color: var(--t-prompt);
}
.term-in input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--t-fg);
  background: none;
  border: 0;
  outline: none;
}
.term-in input::placeholder {
  color: var(--t-dim);
}
.term-in:focus-within {
  box-shadow: inset 0 0 0 1px var(--t-prompt);
}
.term :focus-visible {
  outline: 2px solid var(--t-prompt);
  outline-offset: 1px;
}

/* Resize handle: only used for the side-by-side split */
.term-resize {
  display: none;
}

@media (min-width: 900px) {
  /* The page keeps the left side; the terminal takes the right. */
  body.term-open {
    margin-right: var(--term-w, 50vw);
    padding-bottom: 0;
  }
  .term.open {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    transform: none;
    width: var(--term-w, 50vw);
    border: 0;
    border-left: 1px solid var(--t-line);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: visible;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .term.open .term-body {
    flex: 1;
    height: auto;
    min-height: 0;
  }
  .term:not(.open) {
    left: auto;
    right: 16px;
    transform: none;
    width: auto;
  }
  .term:not(.open) .term-note {
    display: none;
  }
  .term.open .term-resize {
    display: block;
    position: absolute;
    z-index: 1;
    top: 0;
    bottom: 0;
    left: -5px;
    width: 10px;
    cursor: col-resize;
    touch-action: none;
  }
  .term-resize::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 4px;
    width: 2px;
    background: transparent;
    transition: background 0.15s;
  }
  .term-resize:hover::after,
  .term-resize:focus-visible::after,
  .term-dragging .term-resize::after {
    background: var(--t-prompt);
  }
  .term-resize:focus-visible {
    outline: none;
  }
  body.term-dragging {
    cursor: col-resize;
    user-select: none;
  }
}

@media (max-width: 600px) {
  .term-note {
    display: none;
  }
  .term-body {
    height: 55vh;
  }
  body {
    font-size: 17px;
  }
  .note-dialog {
    width: 100%;
    max-height: calc(100dvh - 16px);
    margin-bottom: 0;
    border-radius: 10px 10px 0 0;
  }
  .note-body {
    padding: 0 16px 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
