/* =============================================================
   Article styles — Epidemiology Matters Journal
   Inherits design tokens from main.css (load main.css FIRST)
   ============================================================= */

/* ------- Article page chrome ------- */

.article {
  background: var(--bg-paper);
}

.article__cover {
  background: var(--bg);
  padding: clamp(3rem, 7vw, 6rem) 0 clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}
.article__cover::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(40% 60% at 90% 10%, rgba(15, 118, 110, 0.06), transparent 60%),
    radial-gradient(50% 50% at 10% 90%, rgba(194, 65, 12, 0.05), transparent 60%);
  pointer-events: none;
}
.article__cover-inner { position: relative; max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }

.article__breadcrumb {
  display: flex; gap: 0.5rem; align-items: center;
  font-size: 0.85rem; color: var(--ink-mute); margin-bottom: 2rem;
}
.article__breadcrumb a { color: var(--ink-mute); text-decoration: none; }
.article__breadcrumb a:hover { color: var(--rust-deep); }
.article__breadcrumb svg { width: 12px; height: 12px; }

.article__topic {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--rust-deep);
  margin-bottom: 1.25rem;
}
.article__topic .dot {
  width: 6px; height: 6px; background: var(--rust); border-radius: 50%;
}

.article__title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  line-height: 1.08; letter-spacing: -0.015em;
  margin: 0 0 1.25rem;
  color: var(--ink);
}
.article__title em { font-style: italic; color: var(--rust); font-weight: 500; }

.article__lede {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1.5vw, 1.4rem);
  line-height: 1.45; color: var(--ink-soft);
  margin: 0 0 2rem; max-width: 56ch;
}

.article__meta {
  display: flex; flex-wrap: wrap; gap: 1.5rem 2rem;
  padding-top: 1.5rem; border-top: 1px solid var(--rule);
  font-size: 0.88rem; color: var(--ink-soft);
}
.article__meta-block .label {
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-mute); margin-bottom: 0.35rem; display: block;
}
.article__meta-block strong { color: var(--ink); font-weight: 500; }
.article__meta-block a { color: var(--rust-deep); text-decoration: none; }
.article__meta-block a:hover { text-decoration: underline; }

/* ------- Article body ------- */

.article__body {
  max-width: 720px; margin: 0 auto;
  padding: clamp(2.5rem, 5vw, 4rem) var(--gutter) clamp(3rem, 6vw, 5rem);
}
.article__body > p {
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.7;
  color: var(--ink);
  margin: 0 0 1.4em;
  max-width: none;
}
.article__body > h2 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.6rem, 2.5vw, 2rem);
  line-height: 1.2; letter-spacing: -0.01em;
  margin: 3rem 0 1rem; color: var(--ink);
}
.article__body > h2::before {
  content: ""; display: block; width: 32px; height: 2px;
  background: var(--rust); margin-bottom: 1rem;
}
.article__body > h3 {
  font-family: var(--serif); font-weight: 600;
  font-size: 1.3rem; line-height: 1.3;
  margin: 2rem 0 0.75rem;
}
.article__body em { font-style: italic; }
.article__body strong { font-weight: 600; color: var(--ink); }
.article__body code {
  font-family: var(--mono); font-size: 0.9em;
  background: var(--bg-soft); padding: 0.1em 0.35em;
  border-radius: 3px; color: var(--rust-deep);
}

/* Pullquote / aside */
.aside {
  margin: 2.5rem 0;
  padding: 1.5rem 1.75rem;
  background: var(--bg-soft);
  border-left: 3px solid var(--rust);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--sans);
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.aside .label {
  display: block;
  font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--rust-deep); font-weight: 600;
  margin-bottom: 0.5rem;
}
.aside p { margin: 0 0 0.75em; max-width: none; font-family: var(--sans); font-size: 0.98rem; line-height: 1.6; }
.aside p:last-child { margin-bottom: 0; }

/* Footnote refs */
.fn {
  font-size: 0.7em; vertical-align: super;
  color: var(--rust-deep); text-decoration: none;
  font-weight: 500; margin: 0 0.05em;
  font-family: var(--sans);
}
.fn::before { content: "["; }
.fn::after { content: "]"; }
.fn:hover { color: var(--rust); }

/* ------- Figure containers ------- */

.figure {
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--bg-soft);
  border-radius: var(--radius-lg);
}
.figure--full {
  margin: 2.5rem calc(50% - 50vw);
  max-width: 100vw;
  padding: 2rem clamp(1.5rem, 5vw, 4rem);
  border-radius: 0;
}
@media (max-width: 800px) {
  .figure--full { margin: 2rem calc(0px - var(--gutter)); padding: 1.5rem var(--gutter); }
}

.figure__label {
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--rust-deep); font-weight: 600; margin-bottom: 0.75rem;
  font-family: var(--sans);
}
.figure__caption {
  margin-top: 1.25rem;
  font-size: 0.92rem;
  font-family: var(--sans);
  color: var(--ink-soft);
  line-height: 1.55;
  border-top: 1px solid var(--rule);
  padding-top: 0.75rem;
}
.figure__caption strong { color: var(--ink); font-weight: 600; }

/* ------- Try-this prompt ------- */

.try {
  margin: 1.25rem 0 0;
  padding: 0.85rem 1.1rem;
  background: rgba(15, 118, 110, 0.06);
  border-left: 3px solid var(--teal);
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.try strong { color: var(--teal); font-weight: 600; }

/* =============================================================
   Component 1: Interactive DAG
   ============================================================= */

.dag {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-paper);
  border-radius: var(--radius);
  overflow: hidden;
}
.dag svg { width: 100%; height: 100%; display: block; }

.dag-node {
  cursor: pointer;
  transition: filter 200ms var(--ease);
}
.dag-node:hover { filter: brightness(1.05); }
.dag-node circle {
  fill: var(--bg);
  stroke: var(--ink);
  stroke-width: 1.5;
  transition: fill 250ms var(--ease), stroke 250ms var(--ease);
}
.dag-node.is-exposure circle { fill: var(--rust); stroke: var(--rust-deep); }
.dag-node.is-outcome   circle { fill: var(--ink); stroke: var(--ink); }
.dag-node.is-adjusted  circle {
  fill: var(--bg-paper);
  stroke: var(--teal);
  stroke-width: 3;
  stroke-dasharray: 4 3;
}
.dag-node.is-unmeasured circle {
  fill: var(--bg);
  stroke: var(--ink-mute);
  stroke-dasharray: 2 3;
  opacity: 0.7;
}
.dag-node text {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  fill: var(--ink);
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
}
.dag-node.is-exposure text, .dag-node.is-outcome text { fill: white; }
.dag-node.is-adjusted text { fill: var(--ink); }

.dag-edge {
  stroke: var(--ink-soft);
  stroke-width: 1.5;
  fill: none;
  transition: stroke 250ms var(--ease), stroke-width 250ms var(--ease);
}
.dag-edge.is-open { stroke: var(--rust); stroke-width: 2; }
.dag-edge.is-blocked {
  stroke: var(--ink-mute);
  stroke-dasharray: 5 4;
  opacity: 0.5;
}

.dag-legend {
  display: flex; flex-wrap: wrap; gap: 1.25rem;
  margin-top: 1rem; font-size: 0.82rem;
  font-family: var(--sans); color: var(--ink-soft);
}
.dag-legend__item { display: inline-flex; align-items: center; gap: 0.45rem; }
.dag-legend__swatch {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--ink);
}
.dag-legend__swatch--exposure { background: var(--rust); border-color: var(--rust-deep); }
.dag-legend__swatch--outcome  { background: var(--ink); border-color: var(--ink); }
.dag-legend__swatch--adjusted { background: var(--bg-paper); border-color: var(--teal); border-style: dashed; border-width: 2.5px; }
.dag-legend__swatch--unmeasured { background: var(--bg); border-color: var(--ink-mute); border-style: dashed; }

/* =============================================================
   Component 2: Live regression-table
   ============================================================= */

.regtable-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
@media (min-width: 700px) { .regtable-wrap { overflow-x: visible; } }
.regtable {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.92rem;
  background: var(--bg-paper);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--rule);
}
.regtable th[scope="row"], .regtable td:first-child { white-space: normal; }
@media (max-width: 699px) {
  .regtable { font-size: 0.85rem; min-width: 480px; }
  .regtable .interp { font-size: 0.72rem; }
}
.regtable th, .regtable td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}
.regtable th {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-mute); font-weight: 600;
  background: var(--bg-soft);
}
.regtable td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); white-space: nowrap; }
.regtable .row--primary { background: rgba(194, 65, 12, 0.04); }
.regtable .row--primary td { font-weight: 600; }
.regtable .interp {
  font-size: 0.78rem; color: var(--ink-mute);
  font-style: italic; font-family: var(--sans);
}
.regtable .interp.bad { color: var(--rust-deep); font-style: normal; font-weight: 500; }
.regtable .interp.good { color: var(--teal); font-weight: 500; font-style: normal; }
.regtable tbody tr:last-child th, .regtable tbody tr:last-child td { border-bottom: 0; }

.regtable__footer {
  margin-top: 0.75rem;
  font-size: 0.82rem; color: var(--ink-mute);
  font-family: var(--sans);
}

/* Slider controls strip (shared) */
.controls {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.5rem; margin-bottom: 1.25rem;
  font-family: var(--sans);
}
.controls .ctrl { display: flex; flex-direction: column; gap: 0.25rem; }
.controls .ctrl-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.82rem; color: var(--ink-soft);
}
.controls .ctrl-val {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink); font-size: 0.85rem;
}
.controls input[type="range"] { width: 100%; accent-color: var(--rust); }

.toggle-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem;
}
.toggle {
  background: var(--bg-paper);
  border: 1px solid var(--rule);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 200ms var(--ease);
}
.toggle:hover { border-color: var(--ink); color: var(--ink); }
.toggle.is-on {
  background: var(--teal); color: white; border-color: var(--teal);
}
.toggle.is-disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* =============================================================
   Component 3: Scrollytelling
   ============================================================= */

.scrolly {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin: 3rem calc(50% - 50vw);
  max-width: 100vw;
  padding: 2rem clamp(1.5rem, 5vw, 4rem);
}
@media (max-width: 900px) {
  .scrolly { grid-template-columns: 1fr; gap: 0; margin: 2rem calc(0px - var(--gutter)); padding: 1rem var(--gutter); }
}

.scrolly__steps { display: flex; flex-direction: column; gap: 4rem; padding: 4rem 0; }
@media (max-width: 900px) { .scrolly__steps { gap: 2rem; padding: 1rem 0; } }

.scrolly__step {
  background: var(--bg-paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-soft);
  opacity: 0.45;
  transition: opacity 350ms var(--ease), border-color 350ms var(--ease), transform 350ms var(--ease);
}
.scrolly__step.is-active {
  opacity: 1;
  border-color: var(--ink);
  transform: translateX(2px);
}
.scrolly__step h4 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  color: var(--ink);
}
.scrolly__step p { margin: 0; color: inherit; max-width: none; }

.scrolly__sticky {
  position: sticky; top: 80px;
  height: calc(100vh - 100px); max-height: 600px;
  display: flex; flex-direction: column; justify-content: center;
}
@media (max-width: 900px) {
  .scrolly__sticky {
    position: sticky; top: 60px; height: 60vh; max-height: 400px;
    margin-bottom: 1rem;
    background: var(--bg-paper); border-radius: var(--radius-lg);
    border: 1px solid var(--rule);
    padding: 1rem;
    z-index: 5;
  }
}

/* =============================================================
   Footnotes & references
   ============================================================= */

.refs {
  background: var(--bg-soft);
  padding: clamp(2rem, 4vw, 3rem) 0;
  border-top: 1px solid var(--rule);
}
.refs__inner { max-width: 720px; margin: 0 auto; padding: 0 var(--gutter); }
.refs h2 { font-family: var(--serif); font-size: 1.4rem; margin: 0 0 1.25rem; }
.refs ol { list-style: none; counter-reset: ref; padding: 0; margin: 0; }
.refs li {
  counter-increment: ref;
  padding: 0.6rem 0 0.6rem 2.25rem;
  position: relative;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
}
.refs li:last-child { border-bottom: 0; }
.refs li::before {
  content: counter(ref);
  position: absolute; left: 0; top: 0.65rem;
  width: 1.6rem; height: 1.6rem;
  background: var(--ink); color: var(--bg);
  border-radius: 50%;
  font-family: var(--mono); font-size: 0.78rem; font-weight: 500;
  display: grid; place-items: center;
}
.refs a { color: var(--rust-deep); text-decoration: none; word-break: break-word; }
.refs a:hover { text-decoration: underline; }

/* Citation block */
.citation {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--ink); color: var(--bg);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.82rem; line-height: 1.6;
  position: relative;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.citation > span:not(.label) { display: block; }
.citation .label {
  display: block; font-family: var(--sans);
  font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(251, 246, 238, 0.55); margin-bottom: 0.5rem;
}
.citation .copy-btn {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: rgba(251, 246, 238, 0.1); color: var(--bg);
  border: 1px solid rgba(251, 246, 238, 0.2);
  padding: 0.35rem 0.75rem; border-radius: var(--radius);
  font-family: var(--sans); font-size: 0.75rem;
  cursor: pointer;
  transition: all 200ms var(--ease);
}
.citation .copy-btn:hover { background: rgba(251, 246, 238, 0.2); }
.citation .copy-btn.is-copied { background: var(--teal); border-color: var(--teal); }

/* Exercises */
.exercises {
  background: var(--bg-paper);
  padding: clamp(2.5rem, 5vw, 4rem) 0;
  border-top: 1px solid var(--rule);
}
.exercises__inner { max-width: 720px; margin: 0 auto; padding: 0 var(--gutter); }
.exercises h2 { font-family: var(--serif); font-size: 1.6rem; margin: 0 0 0.5rem; }
.exercises__lede { font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 2rem; max-width: 50ch; font-family: var(--sans); }

.exercise {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  overflow: hidden;
}
.exercise__q {
  width: 100%; text-align: left;
  padding: 1rem 1.25rem;
  background: var(--bg-paper);
  border: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  font-family: var(--sans); font-size: 0.98rem; font-weight: 500;
  color: var(--ink); transition: background 200ms var(--ease);
}
.exercise__q:hover { background: var(--bg-soft); }
.exercise__q .num {
  font-family: var(--mono); font-size: 0.78rem;
  color: var(--rust-deep); margin-right: 0.75rem;
  font-weight: 600;
}
.exercise__q .chevron { transition: transform 200ms var(--ease); flex-shrink: 0; }
.exercise.is-open .exercise__q .chevron { transform: rotate(180deg); }
.exercise__a {
  max-height: 0; overflow: hidden;
  transition: max-height 350ms var(--ease);
  background: var(--bg-soft);
}
.exercise.is-open .exercise__a { max-height: 600px; }
.exercise__a-inner {
  padding: 1.25rem 1.5rem;
  font-family: var(--sans); font-size: 0.95rem;
  line-height: 1.6; color: var(--ink-soft);
}
.exercise__a-inner p { font-family: var(--sans); font-size: 0.95rem; max-width: none; }
.exercise__a-inner p:last-child { margin-bottom: 0; }

/* Article footer */
.article-footer {
  background: var(--ink); color: rgba(251, 246, 238, 0.85);
  padding: clamp(2.5rem, 5vw, 4rem) 0;
}
.article-footer__inner { max-width: 720px; margin: 0 auto; padding: 0 var(--gutter); }
.article-footer h3 { color: var(--bg); font-size: 1.3rem; margin: 0 0 0.5rem; }
.article-footer p { color: rgba(251, 246, 238, 0.75); font-size: 0.95rem; max-width: 55ch; }
.article-footer a.cta {
  display: inline-flex; align-items: center; gap: 0.5rem;
  margin-top: 1rem; color: #fdba74;
  text-decoration: none; font-weight: 500; font-size: 0.95rem;
}
.article-footer a.cta:hover { gap: 0.75rem; }

/* =============================================================
   Journal index page
   ============================================================= */

.journal-list {
  display: grid; grid-template-columns: 1fr; gap: 0;
  max-width: 820px; margin: 0 auto;
}

.j-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 2rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  transition: padding-left 250ms var(--ease);
}
.j-item:hover { padding-left: 0.75rem; color: inherit; }
.j-item__topic {
  font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--rust-deep); font-weight: 600;
}
.j-item__title {
  font-family: var(--serif); font-size: clamp(1.4rem, 2vw, 1.85rem);
  font-weight: 600; line-height: 1.2; margin: 0;
  color: var(--ink);
}
.j-item__title em { font-style: italic; color: var(--rust); font-weight: 500; }
.j-item__lede {
  font-size: 1rem; color: var(--ink-soft); line-height: 1.55;
  max-width: 60ch; margin: 0;
}
.j-item__meta {
  display: flex; gap: 1.5rem; font-size: 0.82rem; color: var(--ink-mute);
  margin-top: 0.25rem;
}

.j-coming {
  padding: 2rem; margin-top: 1rem;
  background: var(--bg-soft);
  border: 1px dashed var(--rule); border-radius: var(--radius-lg);
  text-align: center; font-family: var(--sans); color: var(--ink-mute);
  font-size: 0.95rem;
}
.j-coming a { color: var(--rust-deep); text-decoration: none; font-weight: 500; }
.j-coming a:hover { text-decoration: underline; }

/* Submit CTA */
.submit-cta {
  background: var(--bg-soft);
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
  padding: clamp(2rem, 4vw, 3rem);
  margin-top: 3rem;
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 2rem; align-items: center;
}
@media (max-width: 700px) { .submit-cta { grid-template-columns: 1fr; } }
.submit-cta h3 { font-size: 1.4rem; margin: 0 0 0.5rem; }
.submit-cta p { font-size: 0.95rem; margin: 0 0 1rem; max-width: none; }
