/* tracebrown.com: the shared stylesheet (the bench page adds its own bench.css), no webfonts, no external requests. */

:root {
  color-scheme: light;
  --bg: #F7F4EE;
  --text: #1B1A17;
  --muted: #595349;
  --rule: #D6CFC2;
  --control: #857E71;
  --accent: #1D5B98;
  --warn: #A83E1A;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 68ch;
  --page: 64rem;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161512;
    --text: #ECE6DA;
    --muted: #A69F92;
    --rule: #3B3831;
    --control: #7D776B;
    --accent: #86B6E8;
    --warn: #EF8D63;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161512;
  --text: #ECE6DA;
  --muted: #A69F92;
  --rule: #3B3831;
  --control: #7D776B;
  --accent: #86B6E8;
  --warn: #EF8D63;
}

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

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (max-width: 479.98px) {
  html { font-size: 16px; }
}

html, body { overflow-x: clip; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
}

[hidden] { display: none !important; }

/* ---------- type ---------- */

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  overflow-wrap: anywhere;
  min-width: 0;
  text-wrap: balance;
}
h1 { font-weight: 400; }
h2 { font-size: 1.5rem; font-weight: 600; margin: 0 0 0.8rem; }
h3 { font-size: 1.2rem; font-weight: 600; }

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: text-decoration-color 150ms ease;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
main:focus { outline: none; }

code { font-family: var(--font-mono); font-size: 0.9em; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.8rem;
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--control);
  border-radius: 4px;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- frame ---------- */

.page {
  width: 100%;
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--rule);
}

.brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: underline; text-decoration-thickness: 1px; }

.site-nav ul {
  display: flex;
  align-items: center;
  gap: 0.25rem 1.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.94rem;
}
.site-nav a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 479.98px) {
  .site-header { gap: 0.5rem 0.75rem; }
  .brand { font-size: 1.12rem; }
  .site-nav ul { gap: 0.25rem 0.75rem; }
  .site-nav a { font-size: 0.9rem; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--control);
  border-radius: 6px;
  cursor: pointer;
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.88rem;
}
.site-footer p { max-width: var(--measure); margin: 0; }

section { padding: 1.75rem 0 1rem; }
section > p, section > ul, section > ol, .prose { max-width: var(--measure); }

/* ---------- home ---------- */

.hero {
  display: block;
  padding: clamp(2rem, 6vw, 4.5rem) 0 2rem;
}
.hero-text { max-width: var(--measure); }
.hero h1 {
  font-size: clamp(2.5rem, 7vw, 4.25rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 0.75rem;
}
.statement {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.2vw, 2rem);
  line-height: 1.3;
  margin: 0 0 1rem;
  max-width: 32ch;
}
.subline { color: var(--muted); margin: 0 0 1.1rem; }

.contact-row, .contact-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}
.contact-list li + li { margin-top: 0.4rem; }
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.15rem 0;
}
.icon-link svg {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-figure { display: none; margin: 0 0 1.4rem; min-width: 0; }
.js .card-figure { display: block; }
.card-figure canvas {
  display: block;
  width: 100%;
  max-width: 480px;
  height: 180px;
}
.card-figure figcaption {
  margin-top: 0.35rem;
  max-width: var(--measure);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.work-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: var(--measure);
}
.card {
  display: block;
  padding: 1.1rem 0 1.2rem;
  border-top: 1px solid var(--rule);
  color: var(--text);
  text-decoration: none;
}
.work-list li:last-child .card { border-bottom: 1px solid var(--rule); }
.js .work-item .card { padding-bottom: 0.7rem; }
.card h3 { margin: 0 0 0.3rem; font-size: 1.25rem; }
.card:hover h3 {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}
.card .meta {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.card .line { margin: 0; }

/* ---------- project pages ---------- */

.page-head { padding: clamp(2rem, 5vw, 3.5rem) 0 0.5rem; }
.page-head h1 {
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  line-height: 1.12;
  margin: 0 0 0.75rem;
  max-width: 28ch;
}
.meta-line {
  color: var(--muted);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  max-width: var(--measure);
}

.status-box {
  max-width: var(--measure);
  margin: 1.25rem 0 0.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--control);
  border-radius: 4px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
}
table {
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 0.45rem 0 0.45rem 1.1rem;
  text-align: left;
  vertical-align: bottom;
  border-bottom: 1px solid var(--rule);
}
th:first-child, td:first-child { padding-left: 0; }
thead th { font-weight: 600; }
tbody th { font-weight: 400; white-space: nowrap; }
td.num, th.num { text-align: right; }
td.num { font-family: var(--font-mono); white-space: nowrap; }
tr.em th, tr.em td { font-weight: 700; }
th.group { text-align: center; border-bottom: 1px solid var(--control); }
.gap-left { padding-left: 1.75rem; }

.files { padding-left: 1.2rem; }
.files li + li { margin-top: 0.3rem; }

/* ---------- demo ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 1.25rem 0 0.6rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.88rem;
}
select, input[type="number"] {
  min-height: 2.5rem;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--control);
  border-radius: 4px;
}
input[type="number"] {
  width: 8rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.btn {
  min-height: 2.5rem;
  padding: 0.45rem 1.4rem;
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: progress; }

.status {
  min-height: 1.55em;
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.demo-canvas {
  display: block;
  width: 100%;
  height: 300px;
  margin-top: 0.5rem;
}
@media (max-width: 479.98px) {
  .demo-canvas { height: 240px; }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.3rem;
  margin: 0.6rem 0 0.4rem;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.86rem;
}
.legend li { display: inline-flex; align-items: center; gap: 0.45rem; }
.legend svg { width: 26px; height: 10px; flex: none; }
.legend line { fill: none; }
.card-figure .legend { margin: 0.4rem 0 0; font-size: 0.8rem; gap: 0.2rem 0.9rem; }
.sw-est { stroke: var(--accent); stroke-width: 2.5; }
.sw-wald { stroke: var(--warn); stroke-width: 2; stroke-dasharray: 2 3; }
.sw-perc { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 3; }
.sw-bca { stroke: var(--accent); stroke-width: 1; }

/* ---------- diagram ---------- */

.diagram {
  max-width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0 1rem;
}
.diagram svg {
  display: block;
  width: 100%;
  min-width: 480px;
  max-width: 640px;
  height: auto;
  color: var(--text);
}
.dg-box { fill: var(--bg); stroke: currentColor; stroke-width: 1.25; }
.dg-source { stroke: var(--accent); stroke-width: 2.25; }
.dg-label { font-family: var(--font-display); font-size: 17px; fill: currentColor; }
.dg-arrow { fill: none; stroke: currentColor; stroke-width: 1.25; }
.dg-note { font-family: var(--font-body); font-size: 13px; fill: var(--muted); }

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