/* ==========================================================================
   The Environmental Basis of ME/CFS — Scott Daniska
   Design notes:
   - Palette drawn from the subject's own materials: radiographic greys,
     photographic paper, and the oxide red used for annotation arrows in
     his TEM and clinical figures. Red is reserved for annotation only.
   - Type: Archivo (signage/UI/labels) + Spectral (reading). Journal
     vernacular without imitating a journal template.
   - Layout: a narrow reading measure with figures breaking out as wider
     "plates", the way a paper sets a figure against its argument.
   ========================================================================== */

:root {
  --paper:      #f6f5f2;
  --paper-warm: #efeee9;
  --ink:        #17191b;
  --ink-soft:   #55595e;
  --ink-faint:  #64686c;
  --rule:       #d6d5cf;
  --annotate:   #a3271a;
  --field:      #1f2327;
  --positive:   #3f7a4e;

  --measure: 36rem;
  --plate: 54rem;

  --f-ui: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-read: "Spectral", Georgia, "Times New Roman", serif;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-read);
  font-size: 1.0625rem;
  line-height: 1.68;
  font-feature-settings: "onum" 1;
}

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

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

:focus-visible {
  outline: 2px solid var(--annotate);
  outline-offset: 3px;
}

/* --------------------------------------------------------------- masthead */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.masthead__inner {
  max-width: var(--plate);
  margin: 0 auto;
  padding: 1.4rem 1.5rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: baseline;
  justify-content: space-between;
}

.wordmark {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  line-height: 1.3;
  text-decoration: none;
  max-width: 15rem;
}

.wordmark span {
  display: block;
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.15rem;
}

.nav {
  font-family: var(--f-ui);
  font-size: 0.86rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.15rem;
}

.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.15rem 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover { color: var(--ink); }

.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--annotate);
}

/* ------------------------------------------------------------------- hero */

.hero { position: relative; background: var(--field); }

.hero__image {
  width: 100%;
  height: clamp(15rem, 44vh, 25rem);
  object-fit: cover;
  opacity: 0.62;
}

.hero__caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.5rem 1.5rem 1.6rem;
  background: linear-gradient(to top, rgba(20,23,26,0.88), rgba(20,23,26,0));
}

.hero__caption > div {
  max-width: var(--plate);
  margin: 0 auto;
}

.hero h1 {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: clamp(1.7rem, 4.6vw, 2.85rem);
  line-height: 1.08;
  letter-spacing: -0.022em;
  color: #fff;
  margin: 0;
  max-width: 22ch;
}

.hero p {
  font-family: var(--f-ui);
  font-size: 0.85rem;
  color: rgba(255,255,255,0.72);
  margin: 0.75rem 0 0;
}

.hero--plain {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 3.2rem 1.5rem 2.4rem;
}

.hero--plain > div { max-width: var(--plate); margin: 0 auto; }

.hero--plain h1 {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  line-height: 1.1;
  letter-spacing: -0.022em;
  color: var(--ink);
  margin: 0;
  max-width: 20ch;
}

.hero--plain .standfirst {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: var(--measure);
  margin: 1rem 0 0;
}

/* --------------------------------------------------------------- document */

.doc {
  max-width: var(--plate);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.doc > * { max-width: var(--measure); }

.doc h2 {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 1.32rem;
  letter-spacing: -0.012em;
  line-height: 1.25;
  margin: 3.2rem 0 0.9rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  max-width: var(--plate);
}

.doc h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }

.doc h3 {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 1rem;
  margin: 2rem 0 0.5rem;
}

.doc p { margin: 0 0 1.15rem; }

.doc ul, .doc ol { margin: 0 0 1.3rem; padding-left: 1.15rem; }
.doc li { margin-bottom: 0.5rem; }

.lede {
  font-size: 1.24rem;
  line-height: 1.55;
  margin-bottom: 1.6rem;
}

.pull {
  border-left: 2px solid var(--annotate);
  padding: 0.15rem 0 0.15rem 1.15rem;
  margin: 2rem 0;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--ink);
}

.pull cite {
  display: block;
  font-family: var(--f-ui);
  font-style: normal;
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: 0.6rem;
}

/* ----------------------------------------------------------------- plates */

figure.plate {
  max-width: var(--plate);
  margin: 2.6rem 0 2.8rem;
}

figure.plate img {
  border: 1px solid var(--rule);
  background: #fff;
  width: 100%;
}

figure.plate--narrow { max-width: 26rem; }

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

figcaption {
  font-family: var(--f-ui);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-top: 0.7rem;
  max-width: 42rem;
}

.figno {
  color: var(--annotate);
  font-weight: 600;
}

/* ------------------------------------------------------------- timeline */

.spine { max-width: var(--plate); margin: 0; padding: 0; list-style: none; }

.spine > li {
  position: relative;
  padding: 0 0 2.6rem 5.5rem;
  border-left: 1px solid var(--rule);
  margin-left: 3.5rem;
}

.spine > li:last-child { border-left-color: transparent; padding-bottom: 0; }

.spine .year {
  position: absolute;
  left: -3.5rem;
  top: -0.15rem;
  width: 3rem;
  text-align: right;
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink);
}

.spine > li::before {
  content: "";
  position: absolute;
  left: -3.5px;
  top: 0.5rem;
  width: 6px;
  height: 6px;
  background: var(--annotate);
  border-radius: 50%;
}

.spine h2 {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.spine p { margin: 0 0 0.9rem; max-width: var(--measure); }
.spine p:last-child { margin-bottom: 0; }

/* -------------------------------------------------------- phase sequence */

.phases { counter-reset: phase; list-style: none; padding: 0; margin: 0; max-width: var(--plate); }

.phases > li {
  counter-increment: phase;
  position: relative;
  padding: 1.5rem 0 1.5rem 3.2rem;
  border-top: 1px solid var(--rule);
}

.phases > li::before {
  content: counter(phase);
  position: absolute;
  left: 0;
  top: 1.45rem;
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--annotate);
  width: 2rem;
}

.phases h3 { margin: 0 0 0.45rem; }
.phases p { margin: 0 0 0.8rem; max-width: var(--measure); }
.phases p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ table */

.tablewrap { max-width: var(--plate); overflow-x: auto; margin: 2rem 0 1rem; }

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 40rem;
  font-size: 0.92rem;
  font-family: var(--f-ui);
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.85rem 1rem 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}

th {
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--ink);
}

td ul { margin: 0; padding-left: 1rem; }
td li { margin-bottom: 0.3rem; }

/* ------------------------------------------------------------------ chart */

.chart { max-width: var(--plate); margin: 2rem 0 1rem; font-family: var(--f-ui); }

.chart__row {
  display: grid;
  grid-template-columns: 10.5rem 1fr 2.6rem;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

.chart__num { font-size: 0.72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.chart__label { text-align: right; color: var(--ink-soft); }
.chart__label b { font-weight: 600; color: var(--ink); }

.chart__track {
  position: relative;
  height: 1.1rem;
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.chart__track::before {
  content: "";
  position: absolute;
  left: 24%;
  top: -0.15rem;
  bottom: -0.15rem;
  width: 1px;
  background: var(--ink-faint);
}

.chart__bar {
  position: absolute;
  top: 0.2rem;
  height: 0.7rem;
}

.chart__bar--pos { background: var(--positive); left: 24%; }
.chart__bar--neg { background: var(--annotate); right: 76%; }

.chart__val {
  position: absolute;
  top: 0.05rem;
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.chart__scale {
  display: grid;
  grid-template-columns: 10.5rem 1fr;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 0.6rem;
}

.chart__scale div:last-child { display: flex; justify-content: space-between; }

/* ------------------------------------------------------------------ cards */

.entries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  max-width: var(--plate);
  margin: 2.5rem 0;
}

.entries a {
  background: var(--paper);
  padding: 1.5rem 1.4rem 1.6rem;
  text-decoration: none;
  display: block;
}

.entries a:hover { background: var(--paper-warm); }

.entries h3 {
  font-family: var(--f-ui);
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 0.4rem;
}

.entries p {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}

/* ------------------------------------------------------------------ notes */

.note {
  max-width: var(--measure);
  border: 1px solid var(--rule);
  background: var(--paper-warm);
  padding: 1.1rem 1.25rem;
  font-family: var(--f-ui);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 2rem 0;
}

.note strong { color: var(--ink); font-weight: 600; }
.note p { margin: 0 0 0.6rem; }
.note p:last-child { margin-bottom: 0; }

/* ----------------------------------------------------------- bibliography */

.refs {
  max-width: var(--plate);
  font-family: var(--f-ui);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-soft);
  padding-left: 1.5rem;
}

.refs li { margin-bottom: 0.65rem; }

/* ----------------------------------------------------------------- footer */

.footer {
  border-top: 1px solid var(--rule);
  background: var(--paper-warm);
  margin-top: 3rem;
}

.footer__inner {
  max-width: var(--plate);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  font-family: var(--f-ui);
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.8rem;
}

.footer h2 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.6rem;
}

.footer ul { list-style: none; margin: 0; padding: 0; }
.footer li { margin-bottom: 0.35rem; }
.footer a { color: var(--ink-soft); }

.footer__legal {
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule);
  padding-top: 1.3rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
  max-width: 46rem;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 44rem) {
  body { font-size: 1rem; }
  .spine > li { margin-left: 0; padding-left: 1.25rem; }
  .spine .year { position: static; display: block; width: auto; text-align: left; margin-bottom: 0.3rem; }
  .chart__row, .chart__scale { grid-template-columns: 7.5rem 1fr; }
  .chart__label { font-size: 0.72rem; }
}

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

@media print {
  .masthead, .footer, .hero__image { display: none; }
  body { background: #fff; font-size: 11pt; }
}
