/* Distill.pub & NYT Editorial Academic Styling for SpecSnap */
:root {
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --bg-card: #fbfcfd;
  --ink: #1a1d21;
  --ink-muted: #586069;
  --ink-faint: #7a8288;
  --border: #e4e7eb;
  --border-strong: #cfd5dc;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --pass: #15803d;
  --pass-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --fail: #b91c1c;
  --fail-bg: #fee2e2;
  --font-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

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

/* Masthead */
.masthead {
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}

.masthead__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.masthead__brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.masthead__brand span {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-muted);
  margin-left: 0.5rem;
}

.masthead__nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.92rem;
}

.masthead__nav a {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.masthead__nav a:hover {
  color: var(--accent);
}

/* Article Layout */
.container-body {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Title Header */
.article-header {
  padding: 3.2rem 0 2rem;
  border-bottom: 1px solid var(--border);
}

.title-kicker {
  display: block;
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.article-header h1 {
  font-size: 2.35rem;
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.025em;
  color: #111;
}

.article-subtitle {
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--ink-muted);
  margin: 0;
}

/* Byline */
.byline-bar {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.2rem;
  font-size: 0.9rem;
}

.byline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
}

.byline-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.byline-val {
  color: var(--ink);
  font-weight: 500;
}

.byline-val a {
  color: var(--accent);
  text-decoration: none;
}

.byline-val a:hover {
  text-decoration: underline;
}

/* TL;DR Box */
.tldr-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin: 0 0 2.25rem;
  font-size: 0.98rem;
}

.tldr-title {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.tldr-box p {
  margin: 0.55rem 0;
}

.tldr-box p:last-child {
  margin-bottom: 0;
}

/* 3-Panel Hero Teaser */
.teaser-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.15rem;
  margin: 2rem 0 2.75rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .teaser-grid {
    grid-template-columns: 1fr;
  }
}

.tz-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.tz-card > div:first-child {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tz-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  width: fit-content;
  margin-bottom: 0.55rem;
}

.tz-heading {
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.35;
  margin: 0 0 0.45rem;
}

.tz-desc {
  font-size: 0.86rem;
  color: var(--ink-muted);
  margin: 0 0 0.9rem;
  line-height: 1.45;
  flex: 1;
}

.tz-viz {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem;
  margin-top: auto;
  margin-bottom: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
}

.bar-label {
  width: 92px;
  flex-shrink: 0;
  color: var(--ink-muted);
  font-size: 0.74rem;
}

.bar-track {
  flex: 1;
  height: 16px;
  background: #eef1f5;
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.bar-fill--fail {
  background: #dc2626;
}

.bar-fill--warn {
  background: #d97706;
}

.bar-fill--pass {
  background: #16a34a;
}

.bar-val {
  width: 48px;
  text-align: right;
  font-weight: 600;
  font-size: 0.75rem;
}

.tz-footer {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.65rem;
}

.tz-metric {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--ink);
}

.tz-metric-sub {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Typography */
h2 {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 2.6rem 0 0.85rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.015em;
}

h3 {
  font-size: 1.18rem;
  font-weight: 600;
  margin: 1.8rem 0 0.6rem;
}

p {
  margin: 0 0 1.1rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-subtle);
  padding: 0.12em 0.35em;
  border-radius: 4px;
  border: 1px solid #eaedf1;
}

pre {
  background: #161b22;
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 1rem 1.2rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0 1.4rem;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Experiment Header Pill */
.exp-header {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin: 2.1rem 0 0.65rem;
}

.exp-pill {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  background: #1f2937;
  color: #fff;
  flex-shrink: 0;
}

.exp-header h3 {
  margin: 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0 1.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #fff;
}

table.data-table th,
table.data-table td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.data-table th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--ink-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table td.num,
table.data-table th.num {
  text-align: right;
  font-family: var(--font-mono);
}

table.data-table td:first-child {
  white-space: nowrap;
}

.pill-score {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.pill-pass {
  background: var(--pass-bg);
  color: var(--pass);
}

.pill-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.pill-fail {
  background: var(--fail-bg);
  color: var(--fail);
}

/* Interactive Trace Viewer Widget */
.trace-widget {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  margin: 1.5rem 0 2.25rem;
  overflow: hidden;
}

.trace-toolbar {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.trace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.trace-tab {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.32rem 0.7rem;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.trace-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.trace-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.trace-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.trace-body {
  padding: 1.1rem 1.25rem;
  font-size: 0.88rem;
}

.trace-step {
  border-left: 3px solid var(--border-strong);
  padding: 0.4rem 0 0.4rem 0.9rem;
  margin-bottom: 0.8rem;
}

.trace-step--cutoff {
  border-left-color: #d97706;
  background: #fffbeb;
  padding: 0.6rem 0.9rem;
  border-radius: 0 5px 5px 0;
}

.trace-step--fail {
  border-left-color: #dc2626;
}

.trace-step--pass {
  border-left-color: #16a34a;
}

.trace-step-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.2rem;
}

.trace-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: #f3f4f6;
  padding: 0.45rem 0.65rem;
  border-radius: 4px;
  margin-top: 0.35rem;
  white-space: pre-wrap;
  color: #1f2937;
}

/* Citation Box */
.cite-box {
  position: relative;
  margin: 0.75rem 0 1.25rem;
}

.cite-box pre {
  background: var(--bg-subtle);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 0.85rem 4.5rem 0.85rem 1rem;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.cite-copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink-muted);
  cursor: pointer;
}

.cite-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

footer.article-footer {
  margin-top: 3.5rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--ink-muted);
}
