/* =========================================================================
   The Echo Archives — bluelivingston.com
   Direction B: "The Specimen Catalogue"

   A Victorian medical catalogue that Hemoglobal has annotated in machine
   type. Paper ground, engraved plates, oxblood for anything that acts,
   verdigris for anything the corporation wrote in the margin.
   ========================================================================= */

/* ---------- tokens: light (the printed page) ---------- */
:root {
  --paper:      #E9E3D5;
  --paper-sunk: #DFD8C7;
  --paper-lift: #F2EDE2;
  --ink:        #15120E;
  --ink-soft:   #443A2F;
  --ink-faint:  #635A4A;   /* 4.9:1 on paper — the labels are 11px, so AA applies */
  --ox:         #7B1F26;
  --ox-hover:   #601319;
  --verd:       #41604F;
  --leaf:       #8E6E2B;
  --rule:       #BEB6A2;
  --rule-soft:  #D2CBB9;
  --sel:        rgba(123, 31, 38, .16);
  --plate-blend: multiply;
  --plate-invert: 0;
  --lift: 0 1px 2px rgba(21, 18, 14, .07), 0 10px 30px rgba(21, 18, 14, .09);

  --font-display: "IM Fell English", "Libre Caslon Text", Georgia, serif;
  --font-body:    "Libre Caslon Text", Georgia, "Times New Roman", serif;
  --font-data:    "Courier Prime", ui-monospace, "Courier New", monospace;

  --fs-label: 11px;
  --fs-sm:    13.5px;
  --fs-body:  17.5px;
  --fs-lead:  20px;
  --fs-h3:    clamp(19px, 2.1vw, 24px);
  --fs-h2:    clamp(25px, 3.4vw, 36px);
  --fs-h1:    clamp(38px, 6.8vw, 76px);

  --s1: 8px;  --s2: 12px; --s3: 16px; --s4: 24px;
  --s5: 32px; --s6: 48px; --s7: 72px; --s8: 104px;

  --measure: 34rem;      /* ~66 characters at body size */
  --shell:   1180px;
  --gutter:  clamp(18px, 4vw, 52px);
}

/* ---------- tokens: dark (the archive after hours) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #141210;
    --paper-sunk: #0E0C0A;
    --paper-lift: #1D1A16;
    --ink:        #E9E2D1;
    --ink-soft:   #BCB29D;
    --ink-faint:  #877D6C;
    --ox:         #C97077;
    --ox-hover:   #DC868D;
    --verd:       #86AE93;
    --leaf:       #C9A45E;
    --rule:       #322C24;
    --rule-soft:  #262119;
    --sel:        rgba(201, 112, 119, .22);
    --plate-blend: normal;
    --plate-invert: 1;
    --lift: 0 1px 2px rgba(0, 0, 0, .5), 0 14px 40px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --paper:      #141210;
  --paper-sunk: #0E0C0A;
  --paper-lift: #1D1A16;
  --ink:        #E9E2D1;
  --ink-soft:   #BCB29D;
  --ink-faint:  #877D6C;
  --ox:         #C97077;
  --ox-hover:   #DC868D;
  --verd:       #86AE93;
  --leaf:       #C9A45E;
  --rule:       #322C24;
  --rule-soft:  #262119;
  --sel:        rgba(201, 112, 119, .22);
  --plate-blend: normal;
  --plate-invert: 1;
  --lift: 0 1px 2px rgba(0, 0, 0, .5), 0 14px 40px rgba(0, 0, 0, .5);
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--sel); }

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

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

:focus-visible {
  outline: 2px solid var(--ox);
  outline-offset: 3px;
  border-radius: 1px;
}

h1, h2, h3, h4 { margin: 0; font-weight: 400; text-wrap: balance; }
p { margin: 0 0 1.05em; }
p:last-child { margin-bottom: 0; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--ox); color: #F6EFE2; padding: 10px 16px;
  font-family: var(--font-data); font-size: var(--fs-sm);
}
.skip:focus { left: 0; }

/* ---------- layout primitives ---------- */
.shell { max-width: var(--shell); margin: 0 auto; padding-inline: var(--gutter); }
.measure { max-width: var(--measure); }
.stack > * + * { margin-top: var(--s4); }

.band { padding-block: var(--s7); }
.band--sunk { background: var(--paper-sunk); }
.band--tight { padding-block: var(--s6); }
.band + .band { border-top: 1px solid var(--rule); }

/* ---------- catalogue furniture ---------- */
.label {
  font-family: var(--font-data);
  font-size: var(--fs-label);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0;
}
.label--ox   { color: var(--ox); }
.label--verd { color: var(--verd); }

.specnum {
  font-family: var(--font-data);
  font-size: var(--fs-label);
  letter-spacing: .12em;
  color: var(--ox);
}

.rule-short { width: 56px; height: 2px; background: var(--ink); border: 0; margin: var(--s4) 0; }

.rule-print {
  border: 0; height: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-top: 2px;
  margin: var(--s6) 0;
}

/* ---------- headings ---------- */
.display {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: .98;
  letter-spacing: -.005em;
}
.h2 { font-family: var(--font-display); font-size: var(--fs-h2); line-height: 1.1; }
.h3 { font-family: var(--font-display); font-size: var(--fs-h3); line-height: 1.22; }

.lede {
  font-size: var(--fs-lead);
  line-height: 1.58;
  color: var(--ink-soft);
}

/* ---------- masthead ---------- */
.masthead {
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
  position: sticky; top: 0; z-index: 40;
}
.masthead__bar {
  max-width: var(--shell); margin: 0 auto;
  padding: var(--s2) var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.wordmark {
  font-family: var(--font-display);
  font-size: clamp(15px, 1.9vw, 20px);
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--ink); }
.wordmark small {
  display: block;
  font-family: var(--font-data);
  font-size: 9.5px; letter-spacing: .2em;
  color: var(--ox); margin-top: 3px;
}

.nav { display: flex; align-items: center; gap: clamp(14px, 2vw, 30px); }
.nav a {
  font-family: var(--font-data);
  font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); text-decoration: none; white-space: nowrap;
  padding-block: 4px;
  border-bottom: 1px solid transparent;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--ox); }
.nav a[aria-current="page"] { color: var(--ox); border-bottom-color: var(--ox); }

.navtoggle {
  display: none; background: none; border: 1px solid var(--rule);
  color: var(--ink); font-family: var(--font-data); font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; padding: 7px 12px; cursor: pointer;
}

@media (max-width: 900px) {
  .navtoggle { display: block; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper); border-bottom: 2px solid var(--ink);
    padding: var(--s2) var(--gutter) var(--s4);
  }
  .nav[data-open="true"] { display: flex; }
  .nav a { padding: 11px 0; border-bottom: 1px solid var(--rule-soft); }
  .nav a:hover { border-bottom-color: var(--rule-soft); }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-data);
  font-size: 12px; letter-spacing: .17em; text-transform: uppercase;
  padding: 12px 22px; border-radius: 1px; cursor: pointer;
  text-decoration: none; border: 1px solid transparent;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn--primary { background: var(--ox); color: #F6EFE2; border-color: var(--ox); }
.btn--primary:hover { background: var(--ox-hover); border-color: var(--ox-hover); color: #F6EFE2; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--paper); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }

@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

/* ---------- plates & figures ---------- */
.plate {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
}
@media (max-width: 860px) { .plate { grid-template-columns: 1fr; } }

.figure { position: relative; margin: 0; }
.figure img { width: 100%; }
.figure--engraved img {
  mix-blend-mode: var(--plate-blend);
  filter: invert(var(--plate-invert));
}
.figcaption {
  font-family: var(--font-data);
  font-size: 10.5px; letter-spacing: .15em; text-transform: uppercase;
  color: var(--ink-faint); text-align: center; margin-top: var(--s2);
}

.callout {
  position: absolute;
  font-family: var(--font-data);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--verd); line-height: 1.4; max-width: 12ch;
}
.callout::before {
  content: ""; position: absolute; top: .55em;
  height: 1px; background: var(--verd); opacity: .7;
}
.callout--l::before { left: 100%; width: clamp(16px, 3vw, 44px); margin-left: 8px; }
.callout--r { text-align: right; }
.callout--r::before { right: 100%; width: clamp(16px, 3vw, 44px); margin-right: 8px; }
@media (max-width: 860px) { .callout { display: none; } }

/* ---------- ledger (tabular catalogue rows) ---------- */
.ledger { border-top: 1px solid var(--ink); }
.ledger__head,
.ledger__row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 9rem 8rem;
  gap: clamp(10px, 2vw, 24px);
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.ledger__head {
  font-family: var(--font-data);
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-faint);
}
.ledger__row { text-decoration: none; color: inherit; }
a.ledger__row:hover { background: var(--paper-lift); color: inherit; }
.ledger__name { font-family: var(--font-display); font-size: clamp(16px, 1.8vw, 20px); }
.ledger__kind,
.ledger__state {
  font-family: var(--font-data); font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase;
}
.ledger__kind  { color: var(--verd); }
.ledger__state { color: var(--ink-faint); }
@media (max-width: 700px) {
  .ledger__head { display: none; }
  .ledger__row {
    grid-template-columns: 3.5rem 1fr;
    row-gap: 2px;
  }
  .ledger__kind, .ledger__state { grid-column: 2; }
}

/* ---------- specimen cards (the cast) ---------- */
.specimens {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.specimen {
  background: var(--paper);
  padding: var(--s4);
  display: flex; flex-direction: column; gap: var(--s2);
}
.specimen__art {
  background: var(--paper-sunk);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
}
.specimen__art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; }
.specimen__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.specimen__name { font-family: var(--font-display); font-size: 21px; line-height: 1.15; }
.specimen__kind {
  font-family: var(--font-data); font-size: 10px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--verd);
}
.specimen p { font-size: 15px; line-height: 1.55; color: var(--ink-soft); margin: 0; }

/* ---------- mechanism steps (a real 3-part sequence) ---------- */
.mechanism {
  display: grid; gap: 1px; background: var(--rule);
  border: 1px solid var(--rule);
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 820px) { .mechanism { grid-template-columns: 1fr; } }
.step { background: var(--paper); padding: var(--s5) var(--s4); }
.step__n {
  font-family: var(--font-data); font-size: 10.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ox);
}
.step h3 { font-family: var(--font-display); font-size: 23px; margin: var(--s2) 0 var(--s1); }
.step p { font-size: 15.5px; line-height: 1.58; color: var(--ink-soft); }

/* ---------- long-form reading (Chapter One) ---------- */
.prose {
  max-width: var(--measure);
  font-size: 19px;
  line-height: 1.78;
}
.prose p { margin: 0 0 1.15em; }
.prose p + p { text-indent: 1.4em; }
/* Flush-left after any break in the flow: the opening line, a marked beat,
   and the first paragraph following a pull-quote or a scene divider. */
.prose p:first-of-type,
.prose p.noindent,
.prose blockquote + p,
.prose hr + p { text-indent: 0; }
.prose em { font-style: italic; }
.prose .dropcap::first-letter {
  font-family: var(--font-display);
  float: left;
  font-size: 4.1em;
  line-height: .82;
  padding: .06em .1em 0 0;
  color: var(--ox);
}
.prose blockquote {
  margin: var(--s6) 0;
  padding-left: var(--s4);
  border-left: 2px solid var(--ox);
  font-family: var(--font-display);
  font-size: 22px; line-height: 1.4; font-style: italic;
  color: var(--ink);
}
.prose hr {
  border: 0; text-align: center; margin: var(--s6) 0;
}
.prose hr::before {
  content: "✳︎";
  color: var(--ox); font-size: 15px; letter-spacing: .6em;
}

/* ---------- pull-quote band ---------- */
.pullquote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(22px, 3.6vw, 40px);
  line-height: 1.24;
  max-width: 22ch;
}
.pullquote__src {
  font-family: var(--font-data); font-size: 10.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-faint); margin-top: var(--s3);
}

/* ---------- hero (home) ---------- */
.hero { padding-block: var(--s7) var(--s6); }
.hero__kicker { margin-bottom: var(--s3); }
.hero .display { margin: 0; }

/* ---------- signup ---------- */
.signup { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); }
.signup input[type="email"] {
  flex: 1 1 230px; min-width: 0;
  font-family: var(--font-body); font-size: 16px;
  padding: 11px 14px;
  background: var(--paper-lift);
  border: 1px solid var(--rule);
  color: var(--ink);
  border-radius: 1px;
}
.signup input[type="email"]::placeholder { color: var(--ink-faint); }
.signup input[type="email"]:focus-visible { border-color: var(--ox); }
.finePrint { font-family: var(--font-data); font-size: 10.5px; letter-spacing: .08em; color: var(--ink-faint); margin-top: var(--s2); }

/* ---------- pre-order dialog ---------- */
dialog.preorder {
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  max-width: 460px; width: calc(100% - 32px);
  box-shadow: var(--lift);
}
dialog.preorder::backdrop { background: rgba(10, 8, 6, .62); }
.preorder__in { padding: var(--s5) var(--s5) var(--s4); }
.preorder h2 { font-family: var(--font-display); font-size: 28px; margin: var(--s2) 0 var(--s3); }
.preorder p { font-size: 16px; color: var(--ink-soft); }
.preorder__close {
  background: none; border: 0; color: var(--ink-faint); cursor: pointer;
  font-family: var(--font-data); font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; padding: 0; margin-top: var(--s3);
}
.preorder__close:hover { color: var(--ink); }

/* ---------- footer ---------- */
.footer {
  border-top: 2px solid var(--ink);
  background: var(--paper-sunk);
  padding-block: var(--s6);
}
.footer__grid {
  display: grid; gap: var(--s5);
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr));
}
@media (max-width: 780px) { .footer__grid { grid-template-columns: 1fr; } }
.footer__links { display: flex; flex-direction: column; gap: 7px; }
.footer__links a {
  font-family: var(--font-data); font-size: 11.5px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-soft); text-decoration: none;
}
.footer__links a:hover { color: var(--ox); }
.colophon {
  margin-top: var(--s6); padding-top: var(--s4);
  border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5);
  align-items: center; justify-content: space-between;
  font-family: var(--font-data); font-size: 10.5px; letter-spacing: .1em;
  color: var(--ink-faint);
}
.themetoggle {
  background: none; border: 1px solid var(--rule); color: var(--ink-faint);
  font-family: var(--font-data); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; padding: 6px 11px; cursor: pointer; border-radius: 1px;
}
.themetoggle:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ---------- page header (interior pages) ---------- */
.pagehead { padding-block: var(--s6) var(--s5); border-bottom: 1px solid var(--rule); }
.pagehead .display { font-size: clamp(32px, 5.2vw, 58px); margin-top: var(--s2); }
.pagehead .lede { margin-top: var(--s4); }

/* ---------- archives ---------- */
.post-list { border-top: 1px solid var(--ink); }
.post-item {
  display: grid; grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: var(--s4); padding: var(--s5) 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit;
}
.post-item:hover { color: inherit; }
.post-item:hover .post-item__title { color: var(--ox); }
.post-item__date { font-family: var(--font-data); font-size: 11px; letter-spacing: .12em; color: var(--ink-faint); }
.post-item__title { font-family: var(--font-display); font-size: clamp(21px, 2.6vw, 28px); line-height: 1.15; }
.post-item p { font-size: 16px; color: var(--ink-soft); margin: var(--s2) 0 0; }
@media (max-width: 640px) { .post-item { grid-template-columns: 1fr; gap: var(--s2); } }

/* ---------- misc ---------- */
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
