/* SciAgentTrace — project site
   Vanilla CSS, no build step, no framework, no external fonts or JS. */

/* ---------- tokens: light is the base definition ---------- */
:root {
  color-scheme: light;

  --surface:        #ffffff;
  --surface-sunken: #f4f5f7;
  --surface-raised: #ffffff;
  --surface-code:   #f4f5f7;

  --ink:            #14161a;
  --ink-secondary:  #4a4f57;
  --ink-muted:      #646a73;

  --rule:           #d9dce1;
  --rule-strong:    #b9bec6;

  --accent:         #1c5cab;
  --accent-hover:   #104281;
  --accent-soft:    #eaf1fb;

  /* ordinal ramp for the coverage meter (validated: light surface #ffffff) */
  --meter-full:     #256abf;
  --meter-partial:  #86b6ef;

  --status-note:    #8a5a00;
  --status-note-bg: #fdf4e3;
  --status-note-br: #e8c98a;

  --focus:          #104281;

  --measure: 68ch;
  --page-max: 1080px;
  --radius: 10px;
  --radius-sm: 6px;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* dark: OS setting, unless the page is explicitly stamped light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --surface:        #14161a;
    --surface-sunken: #1b1e24;
    --surface-raised: #1b1e24;
    --surface-code:   #1b1e24;

    --ink:            #f2f4f7;
    --ink-secondary:  #c3c8d0;
    --ink-muted:      #9aa1ab;

    --rule:           #2c3039;
    --rule-strong:    #3d434e;

    --accent:         #7fb2f0;
    --accent-hover:   #a8cbf6;
    --accent-soft:    #1d2734;

    --meter-full:     #0d366b;
    --meter-partial:  #184f95;

    --status-note:    #f0c675;
    --status-note-bg: #2a2317;
    --status-note-br: #5c4a22;

    --focus:          #a8cbf6;
  }
}

/* dark: explicit stamp wins in both directions */
:root[data-theme="dark"] {
  color-scheme: dark;

  --surface:        #14161a;
  --surface-sunken: #1b1e24;
  --surface-raised: #1b1e24;
  --surface-code:   #1b1e24;

  --ink:            #f2f4f7;
  --ink-secondary:  #c3c8d0;
  --ink-muted:      #9aa1ab;

  --rule:           #2c3039;
  --rule-strong:    #3d434e;

  --accent:         #7fb2f0;
  --accent-hover:   #a8cbf6;
  --accent-soft:    #1d2734;

  --meter-full:     #0d366b;
  --meter-partial:  #184f95;

  --status-note:    #f0c675;
  --status-note-bg: #2a2317;
  --status-note-br: #5c4a22;

  --focus:          #a8cbf6;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-hover); }

:where(a, button, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 .5em;
  font-weight: 650;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 5.2vw, 3.1rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.45rem, 3.2vw, 1.95rem); }
h3 { font-size: 1.12rem; font-weight: 640; }

p { margin: 0 0 1rem; }
p, li { max-width: var(--measure); }

code, kbd, samp, pre { font-family: var(--mono); font-size: .875em; }

code:not(pre code) {
  background: var(--surface-code);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .1em .36em;
  overflow-wrap: anywhere;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: .7rem 1.1rem;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; color: #fff; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: 20px;
}

section { border-top: 1px solid var(--rule); }
section > .wrap { padding-block: clamp(2.75rem, 6vw, 4.25rem); }

.lede {
  font-size: 1.08rem;
  color: var(--ink-secondary);
  max-width: var(--measure);
}

.eyebrow {
  font-size: .76rem;
  font-weight: 680;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 .7rem;
}

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.nav > .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1.25rem;
  padding-block: .7rem;
}
.nav-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.02rem;
  margin-right: auto;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .9rem;
}
.nav-links a {
  color: var(--ink-secondary);
  text-decoration: none;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- hero ---------- */
.hero > .wrap { padding-block: clamp(2.5rem, 7vw, 4.5rem) clamp(2rem, 5vw, 3rem); }
.hero h1 { margin-bottom: .35rem; }
.hero-sub {
  font-size: clamp(1.05rem, 2.4vw, 1.28rem);
  color: var(--ink-secondary);
  max-width: 62ch;
  margin-bottom: 1.4rem;
}
.venue {
  display: inline-block;
  font-size: .82rem;
  font-weight: 620;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px;
  padding: .3rem .85rem;
  margin-bottom: 1.1rem;
}
.authors {
  font-size: .95rem;
  color: var(--ink-secondary);
  margin-bottom: 1.5rem;
  max-width: var(--measure);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 0 0 2.25rem;
  padding: 0;
  list-style: none;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .58rem 1.05rem;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 560;
  text-decoration: none;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  background: var(--surface-raised);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn[aria-disabled="true"] {
  color: var(--ink-muted);
  border-style: dashed;
  cursor: not-allowed;
  background: var(--surface-sunken);
}
.btn[aria-disabled="true"]:hover { border-color: var(--rule-strong); color: var(--ink-muted); }

/* ---------- stat tiles ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  /* surface, not rule: an unfilled grid track must not render as a gray block */
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0;
}
.stat {
  background: var(--surface-raised);
  box-shadow: 0 0 0 1px var(--rule);
  padding: 1.1rem 1.15rem 1.2rem;
  margin: 0;
}
.stats dd { margin: 0; }
.stat-value {
  display: block;
  font-size: clamp(1.6rem, 3.6vw, 2.15rem);
  font-weight: 680;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--ink);
  margin: 0 0 .2rem;
}
.stat-label {
  display: block;
  font-size: .855rem;
  color: var(--ink-secondary);
  line-height: 1.4;
  max-width: none;
}

/* ---------- generic cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 1rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
}
.card {
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem 1.3rem;
}
.card h3, .card h4 { margin-bottom: .4rem; font-size: 1.12rem; font-weight: 640; line-height: 1.2; letter-spacing: -0.015em; margin-top: 0; }
.card p { margin-bottom: 0; color: var(--ink-secondary); font-size: .95rem; max-width: none; }
.card-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--ink-muted);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .05rem .4rem;
  margin-bottom: .55rem;
}

/* ---------- tables ---------- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin: 1.75rem 0 .75rem;
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: .94rem;
}
caption {
  text-align: left;
  font-size: .9rem;
  color: var(--ink-secondary);
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-sunken);
}
th, td {
  text-align: left;
  padding: .66rem 1rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
thead th {
  font-size: .8rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  font-weight: 640;
  background: var(--surface-sunken);
  white-space: nowrap;
}
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tfoot td {
  font-weight: 640;
  background: var(--surface-sunken);
  border-top: 2px solid var(--rule-strong);
  border-bottom: 0;
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody th { font-weight: 600; }
.table-note {
  font-size: .87rem;
  color: var(--ink-muted);
  max-width: var(--measure);
  margin-top: 0;
}

/* ---------- coverage meter ---------- */
.meter-block { margin: 1.75rem 0 0; }
.meter {
  display: flex;
  width: 100%;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--surface-sunken);
  gap: 2px;
}
.meter-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 620;
  color: #fff;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.meter-seg-full    { background: var(--meter-full); flex: 39918 1 0; }
.meter-seg-partial { background: var(--meter-partial); flex: 13306 1 0; color: #10233c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .meter-seg-partial { color: #ffffff; }
}
:root[data-theme="dark"] .meter-seg-partial { color: #ffffff; }

.meter-key {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  list-style: none;
  margin: .85rem 0 0;
  padding: 0;
  font-size: .9rem;
}
.meter-key li {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  max-width: 44ch;
  color: var(--ink-secondary);
}
.swatch {
  flex: none;
  width: 13px; height: 13px;
  border-radius: 3px;
  margin-top: .34rem;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
}
.swatch-full    { background: var(--meter-full); }
.swatch-partial { background: var(--meter-partial); }

/* ---------- callout ---------- */
.callout {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  padding: 1.05rem 1.2rem;
  margin: 1.5rem 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout h3 { margin-bottom: .35rem; font-size: 1rem; }

.callout-todo {
  border-left-color: var(--status-note-br);
  background: var(--status-note-bg);
}
.callout-todo h3 { color: var(--status-note); }

.todo {
  font-family: var(--mono);
  font-size: .8em;
  font-weight: 700;
  color: var(--status-note);
  background: var(--status-note-bg);
  border: 1px dashed var(--status-note-br);
  border-radius: 4px;
  padding: .06em .4em;
  /* long TODO sentences must wrap, never force horizontal scroll */
  white-space: normal;
  overflow-wrap: anywhere;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- definition-style lists ---------- */
.deflist { margin: 1.5rem 0 0; }
.deflist dt {
  font-weight: 640;
  margin-top: 1.1rem;
  color: var(--ink);
}
.deflist dt:first-of-type { margin-top: 0; }
.deflist dd {
  margin: .2rem 0 0;
  color: var(--ink-secondary);
  max-width: var(--measure);
}

/* ---------- code block ---------- */
pre {
  background: var(--surface-code);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  line-height: 1.55;
  -webkit-overflow-scrolling: touch;
}
pre code { white-space: pre; }

/* ---------- link list ---------- */
.linklist {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
  gap: 1rem;
}
.linklist li {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  background: var(--surface-raised);
  max-width: none;
}
.linklist .ll-title { font-weight: 620; display: block; margin-bottom: .2rem; }
.linklist .ll-desc {
  display: block;
  font-size: .89rem;
  color: var(--ink-secondary);
  word-break: break-word;
}

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--rule);
  background: var(--surface-sunken);
}
footer > .wrap { padding-block: 2.25rem 2.75rem; }
footer p {
  font-size: .89rem;
  color: var(--ink-muted);
  margin-bottom: .5rem;
}

/* ---------- narrow screens ---------- */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding-inline: 16px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .meter { height: 52px; }
  .meter-seg { font-size: .74rem; }
}

@media print {
  .nav, .skip-link { display: none; }
  body { font-size: 11pt; }
  a { text-decoration: underline; }
}

/* Protocol information-flow figure */
.protofig {
  margin: 1.75rem 0 2rem;
  padding: 0;
}
.protofig img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: #fff;
}
.protofig figcaption {
  margin-top: .75rem;
  color: var(--ink-muted);
  font-size: .92rem;
  line-height: 1.55;
}
