/* Research pages: same family as the Trail homepage (home.css). Light only. */

:root {
  color-scheme: light;
  --paper: #f7f4ee;
  --ink: #18212b;
  --muted: #5f6670;
  --line: #e2ddd3;
  --line-strong: #c9c2b5;
  --pane: #1c2a38;
  --pane-ink: #f1ebdf;
  --pane-muted: #a9b2bc;
  --pane-line: rgba(241, 235, 223, 0.16);
  --accent: #7a2b3a;
  --accent-pane: #dba5b0;
  --accent-wash: #eedde0;
  --surface: #fbf9f4;
  --code-bg: #efebe3;
  --error: #8a2a1f;
  --focus: #1b56c6;

  --display: "Segoe UI Variable Display", "SF Pro Display", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Charter, "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Reading column system. */
  --measure: 42rem;
  --wide: 68rem;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --cols:
    [full-start] minmax(var(--gutter), 1fr)
    [wide-start] minmax(0, calc((var(--wide) - var(--measure)) / 2))
    [content-start] min(var(--measure), calc(100% - 2 * var(--gutter)))
    [content-end] minmax(0, calc((var(--wide) - var(--measure)) / 2))
    [wide-end] minmax(var(--gutter), 1fr)
    [full-end];
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1;
}

::selection { background: var(--accent-wash); }

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: 1.5px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute; left: 1rem; top: 1rem; z-index: 10;
  padding: 0.6rem 1rem; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-weight: 600; text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* Header band: the navy identity pane, flattened */

.site-header { background: var(--pane); color: var(--pane-ink); }
.site-header-inner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 2rem;
  max-width: var(--wide); margin: 0 auto; padding: 0.9rem var(--gutter);
}
.site-name {
  font-family: var(--display); font-weight: 600; font-size: 1.0625rem;
  letter-spacing: -0.02em; text-decoration: none; color: var(--pane-ink);
}
.site-header nav { max-width: none; margin: 0; padding: 0; }
.site-header ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.site-header a {
  display: inline-block; padding: 0.25rem 0;
  color: var(--pane-ink); font-family: var(--sans); font-size: 0.9375rem;
  text-decoration: none; transition: color 120ms;
}
.site-header a:hover { color: #ffffff; text-decoration: underline; text-decoration-color: var(--pane-muted); }
.site-header a[aria-current="page"] {
  text-decoration: underline; text-decoration-color: var(--accent-pane);
  text-decoration-thickness: 1.5px; text-underline-offset: 0.35em;
}
.site-header :focus-visible { outline-color: #9cc0ff; }

/* Document: one reading column, deliberate wide figures */

.doc {
  display: grid;
  grid-template-columns: var(--cols);
  padding: clamp(2.5rem, 7vh, 4.5rem) 0 4rem;
}
.doc > * { grid-column: content; min-width: 0; }
.doc > section, .doc > article { grid-column: full; display: grid; grid-template-columns: var(--cols); }
.doc > section > *, .doc > article > * { grid-column: content; min-width: 0; }
.doc .wide { grid-column: wide; }
.doc :where(h1, h2, h3, h4, p, ul, ol, dl, blockquote, pre, details, figure, .note, .status-box, .lede, .button-row, .table-wrap) {
  margin-left: 0; margin-right: 0; max-width: none;
}
.doc li > :where(p, ul, ol, dl) { max-width: none; }

.eyebrow {
  display: block; margin: 0 0 0.75rem;
  font-family: var(--sans); font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}

h1 {
  margin: 0 0 1rem;
  font-family: var(--display); font-weight: 600;
  font-size: clamp(2rem, 1.5rem + 1.6vw, 2.75rem); line-height: 1.05;
  letter-spacing: -0.03em; text-wrap: balance; overflow-wrap: break-word;
}
.lede { margin: 0 0 1.5rem; font-size: 1.1875rem; line-height: 1.6; text-wrap: pretty; }

h2 {
  margin: 3rem 0 0.75rem; padding-top: 1rem;
  border-top: 1px solid var(--line-strong);
  font-family: var(--serif); font-weight: 400; font-size: 1.75rem; line-height: 1.15;
  text-wrap: balance;
}
h3 { margin: 2rem 0 0.5rem; font-family: var(--sans); font-weight: 600; font-size: 1rem; line-height: 1.35; }
h4 { margin: 1.5rem 0 0.4rem; font-family: var(--sans); font-weight: 600; font-size: 0.9375rem; }

section[id], article[id], h2[id], h3[id] { scroll-margin-top: 1rem; }

p, ul, ol, dl { margin: 0 0 1rem; }
li { margin: 0.3rem 0; }

/* On-this-page nav: a sans line, not a list of bullets */
nav[aria-label="On this page"] ul {
  list-style: none; margin: 0 0 1.5rem; padding: 0.75rem 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem;
  font-family: var(--sans); font-size: 0.9375rem;
}
nav[aria-label="On this page"] li { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

code, kbd, samp {
  font-family: var(--mono); font-size: 0.86em; background: var(--code-bg);
  padding: 0.05em 0.3em; border-radius: 3px; overflow-wrap: anywhere;
}
pre {
  margin: 0.75rem 0 1.25rem; padding: 0.9rem 1rem;
  font-family: var(--mono); font-size: 0.8125rem; line-height: 1.55;
  background: var(--code-bg); border: 1px solid var(--line); overflow-x: auto;
}
pre code { background: none; padding: 0; font-size: inherit; }
pre.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

blockquote { margin: 1rem 0; padding: 0.25rem 0 0.25rem 1rem; border-left: 2px solid var(--line-strong); }
blockquote p { margin: 0; }

.note, .status-box {
  margin: 1rem 0; padding: 0.8rem 1rem;
  border-left: 3px solid var(--accent); background: var(--accent-wash);
  font-family: var(--sans); font-size: 0.9375rem; line-height: 1.55;
}
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }
.error-box { border-left-color: var(--error); }

dl { margin: 0 0 1.25rem; }
dt { margin-top: 0.75rem; font-family: var(--sans); font-weight: 600; font-size: 0.9375rem; }
dt code { font-weight: 600; }
dd { margin: 0.15rem 0 0; }
dl.kv { display: grid; grid-template-columns: minmax(9rem, max-content) 1fr; gap: 0.25rem 1rem; }
dl.kv dt, dl.kv dd { margin: 0; }
dl.kv dd { overflow-wrap: anywhere; }

/* Tables */

.table-wrap { margin: 1rem 0 0.5rem; border: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
caption { caption-side: top; text-align: left; padding: 0.6rem 0.9rem 0.4rem; font-size: 0.8125rem; font-weight: 600; }
th, td { padding: 0.55rem 0.9rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1.5px solid var(--line-strong);
}
tbody th[scope="row"] { font-weight: 600; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.mono, th.mono, .mono { font-family: var(--mono); font-size: 0.8125rem; font-weight: 400; }
td.run { white-space: nowrap; }
.table-source { margin: 0.35rem 0 1.5rem; font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); }

/* Lists of pages, downloads and runs */

.page-list { list-style: none; margin: 0 0 1.5rem; padding: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.page-list li { margin: 0; padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.page-list li:last-child { border-bottom: none; }
.page-list a { font-size: 1.25rem; line-height: 1.25; }
.page-list p { margin: 0.35rem 0 0; }

.download-list { list-style: none; padding: 0; }
.download-list li { margin: 0 0 0.6rem; }
.download-list a { font-family: var(--mono); font-size: 0.875rem; }

.run-list { padding-left: 1.5rem; font-family: var(--sans); font-size: 0.9375rem; }
.run-list a { font-family: var(--mono); font-size: 0.8125rem; }
.run-list .interrupted { color: var(--muted); }

/* Details */

details { margin: 0.75rem 0; padding: 0.5rem 1rem; border: 1px solid var(--line); background: var(--surface); }
summary { cursor: pointer; padding: 0.25rem 0; font-family: var(--sans); font-weight: 600; font-size: 0.9375rem; }
details[open] > summary { margin-bottom: 0.5rem; }

/* Transcript reader */

.controls { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: flex-end; margin: 1.25rem 0; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.controls .field { margin: 0; max-width: 100%; }
label { font-family: var(--sans); font-weight: 600; font-size: 0.875rem; }
select, button {
  font: inherit; font-family: var(--sans); font-size: 1rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 2px;
  padding: 0.45rem 0.7rem; max-width: 100%;
}
button { cursor: pointer; }
button:hover, select:hover { border-color: var(--ink); }
select:disabled, button:disabled { opacity: 0.6; cursor: not-allowed; }

.selected-runs { list-style: none; padding: 0; margin: 0 0 1.5rem; border-top: 1px solid var(--line); }
.selected-runs li { margin: 0; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.selected-runs .role { display: block; margin-top: 0.2rem; color: var(--muted); font-family: var(--sans); font-size: 0.9rem; }

.turn-index { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; list-style: none; padding: 0; font-family: var(--sans); font-size: 0.875rem; }
.turn { margin: 1.25rem 0; padding: 0.25rem 1.1rem 1rem; border: 1px solid var(--line); background: var(--surface); }
.turn h4 { margin-top: 0.75rem; }
.turn blockquote { white-space: pre-wrap; overflow-wrap: anywhere; }
.turn .table-wrap { margin: 0.75rem 0; }
.hash { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; }
.turn-meta { font-size: 0.9rem; }
.label { margin: 0.9rem 0 0.25rem; font-family: var(--sans); font-weight: 600; font-size: 0.875rem; }

/* Footer */

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-family: var(--sans); font-size: 0.875rem; }
.site-footer p { max-width: var(--wide); margin: 0 auto; padding: 1.25rem var(--gutter); }

/* Narrow screens */

@media (max-width: 860px) {
  :root { --gutter: 1.25rem; }
  body { font-size: 1rem; }
  .doc { padding-top: 2rem; }
  .site-header-inner { padding: 0.75rem var(--gutter); }
  th, td { padding: 0.5rem 0.65rem; }
  dl.kv { grid-template-columns: 1fr; }
  dl.kv dd { margin-bottom: 0.4rem; }
}

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

@media print {
  .site-header, .skip-link, .controls { display: none; }
  .table-wrap { overflow: visible; }
  body { background: #ffffff; }
}
/* Integration details: keep transcript cards in the reading column. */
.doc > article.turn { grid-column: content; display: block; }
h1.run-id { font-family: var(--mono); font-size: 1.25rem; line-height: 1.4; letter-spacing: 0; overflow-wrap: anywhere; }
.breadcrumbs { font-family: var(--sans); font-size: .875rem; color: var(--muted); margin-bottom: 1rem; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.site-header a { min-height: 44px; display: inline-flex; align-items: center; }
.site-header-inner { align-items: center; }
@media print { .table-scroll { overflow: visible; } }
