/* ============================================================
   FORMA — A FIELD GUIDE TO MAKING BY HAND
   Direction: editorial field-guide frontispiece (Bodoni + Karla
   + Plex Mono), bone paper, oxblood ink, a dark specimen cabinet.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --paper:      #f2efe9;
  --paper-2:    #e9e4d8;
  --paper-3:    #ded6c6;
  --ink:        #1a1817;
  --muted:      #6c6459;
  --line:       #c9c0af;
  --line-soft:  #d8d0c1;

  --oxblood:    #6b2f26;
  --oxblood-2:  #8a3b2e;
  --accent-dark:#d98a6e;

  --night:      #15110f;
  --night-2:    #211a16;
  --bone:       #efe9dd;
  --bone-muted: #b3a99a;

  --focus:      var(--oxblood);

  --font-display: 'Bodoni Moda', Didot, Georgia, 'Times New Roman', serif;
  --font-body:    'Karla', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --gut: clamp(20px, 5vw, 72px);
  --rule: 1px solid var(--line);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-sm: 2px;
  --r-md: 4px;
  --shadow-plate: 0 18px 40px -26px rgba(26, 24, 23, 0.55);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  font-weight: 400;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; height: auto; }
button, input, select { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }

/* Paper grain */
body:has(dialog[open]) { overflow: hidden; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Shared type ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--oxblood);
}
.eyebrow--dark { color: var(--accent-dark); }
.plate-no { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }

h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.1rem, 4.6vw, 3.9rem);
  line-height: 1.02;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p { text-wrap: pretty; }

.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;
}

/* ---------- Focus & skip link ---------- */
:focus { outline: 3px solid var(--focus); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: 3px solid var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.cabinet :focus, .detail :focus { outline-color: var(--accent-dark); }

.skip-link {
  position: absolute; left: 12px; top: -60px;
  z-index: 10000;
  background: var(--ink); color: var(--bone);
  padding: 12px 18px; border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: 13px; text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: 46px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  transition: transform 0.18s var(--ease), background-color 0.18s var(--ease),
              color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.btn--primary { background: var(--oxblood); color: var(--paper); border-color: var(--oxblood); }
.btn--ghost { color: var(--ink); border-color: var(--line); background: transparent; }
.btn:active { transform: scale(0.97); }

/* ============================================================
   MASTHEAD
   ============================================================ */
.masthead {
  display: flex;
  align-items: baseline;
  gap: clamp(16px, 4vw, 48px);
  max-width: 1440px;
  margin-inline: auto;
  padding: 18px var(--gut) 16px;
  border-bottom: var(--rule);
  background: var(--paper);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  padding: 6px 4px;
  margin-left: -4px;
}
.brand__mark { color: var(--oxblood); font-size: 20px; line-height: 1; }
.brand__name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.masthead__strap {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: auto;
}
.masthead__nav { display: flex; gap: clamp(14px, 2.6vw, 34px); }
.masthead__nav a {
  position: relative;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.05em;
  padding-block: 12px;
}
.masthead__nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  height: 1px;
  background: var(--oxblood);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s var(--ease);
}
.masthead__nav a:active { opacity: 0.6; }

/* ============================================================
   HERO / FRONTISPIECE
   ============================================================ */
.hero {
  position: relative;
  padding: clamp(28px, 5vw, 56px) var(--gut) 0;
  overflow: clip;
}
.hero__kicker {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--oxblood);
  animation: rise 0.7s var(--ease) both;
}
.hero__word {
  margin: 0.08em 0 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(4.4rem, 21vw, 18rem);
  line-height: 0.82;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  color: var(--ink);
}
.hero__word-main {
  display: block;
  animation: sweep 0.9s var(--ease) 0.05s both;
}
.hero__word-sub {
  display: block;
  margin-top: 0.55em;
  font-family: var(--font-body);
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--muted);
  max-width: 30ch;
  animation: rise 0.7s var(--ease) 0.22s both;
}
.hero__lede {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px 48px;
  margin-top: clamp(20px, 3vw, 34px);
  animation: rise 0.7s var(--ease) 0.34s both;
}
.hero__lede p { max-width: 52ch; }
.hero__cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__plate {
  position: relative;
  margin: clamp(28px, 4vw, 48px) calc(-1 * var(--gut)) 0;
  border-top: var(--rule);
  border-bottom: var(--rule);
  background: var(--paper-2);
}
.hero__plate img {
  width: 100%;
  height: clamp(260px, 44vh, 520px);
  object-fit: cover;
  filter: saturate(0.86) contrast(1.02);
}
.hero__annot {
  position: absolute;
  left: 5%;
  top: 10%;
  width: min(34%, 320px);
  height: auto;
  pointer-events: none;
}
.hero__annot path {
  fill: none;
  stroke: var(--paper);
  stroke-width: 2;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 2px rgba(20, 15, 12, 0.65));
  stroke-dasharray: 540;
  stroke-dashoffset: 540;
  animation: draw 1.1s var(--ease) 0.6s forwards;
}
.hero__annot-label {
  position: absolute;
  left: 5%;
  top: 6%;
  padding: 3px 8px;
  background: var(--paper);
  color: var(--oxblood);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  transform: rotate(-2deg);
}
.hero__plate figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  padding: 12px var(--gut) 14px;
  font-size: 14.5px;
  color: var(--muted);
}
.hero__spine {
  position: absolute;
  top: 34%;
  right: clamp(8px, 1.4vw, 20px);
  writing-mode: vertical-rl;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================================
   INDEX
   ============================================================ */
.index {
  max-width: 1280px;
  margin-inline: auto;
  padding: clamp(56px, 8vw, 120px) var(--gut) clamp(40px, 6vw, 80px);
  scroll-margin-top: 20px;
}
.section-head { max-width: 760px; }
.section-head h2 { margin-top: 8px; }
.section-head__note {
  margin-top: 18px;
  max-width: 60ch;
  color: var(--muted);
  font-size: 16.5px;
}
.draw-line { margin-top: 18px; }
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 2px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--oxblood);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
  transition: color 0.18s var(--ease), transform 0.18s var(--ease);
}
.link-btn:active { transform: scale(0.97); }

/* Controls */
.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.8fr) auto;
  gap: 18px 22px;
  align-items: end;
  margin-top: clamp(32px, 4vw, 52px);
  padding-top: 22px;
  border-top: var(--rule);
}
.control { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.control label, .control__label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.control input,
.control select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 16px;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.control input::placeholder { color: var(--muted); opacity: 1; }
.control input:focus, .control select:focus { background: #fff; border-color: var(--oxblood); }
.control select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b2f26' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* Shortlist toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: var(--ink);
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease),
              color 0.18s var(--ease), transform 0.18s var(--ease);
}
.toggle__dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid var(--oxblood);
  background: transparent;
  transition: background-color 0.18s var(--ease);
}
.toggle[aria-pressed="true"] {
  background: var(--oxblood);
  color: var(--paper);
  border-color: var(--oxblood);
}
.toggle[aria-pressed="true"] .toggle__dot { background: var(--paper); border-color: var(--paper); }
.toggle:active { transform: scale(0.97); }

.result-line {
  margin-top: 26px;
  padding-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Specimen rows ---------- */
.specimens { margin-top: 8px; }
.specimen {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(20px, 3vw, 44px);
  align-items: start;
  padding-block: clamp(30px, 4vw, 56px);
  border-top: var(--rule);
}
.specimen__plate {
  position: relative;
  grid-column: 1 / 7;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  padding: 10px;
  box-shadow: var(--shadow-plate);
}
.specimen__plate img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  filter: saturate(0.85) contrast(1.02);
}
.specimen__annot {
  position: absolute;
  inset: -14px -16px auto auto;
  width: 62%;
  height: 60%;
  pointer-events: none;
  overflow: visible;
}
.specimen__annot path {
  fill: none;
  stroke: var(--oxblood);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.4;
  stroke-dasharray: 540;
  stroke-dashoffset: 0;
}
.specimen__caption {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.specimen__seal {
  position: absolute;
  top: -14px;
  left: -14px;
  display: none;
  place-items: center;
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--oxblood);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.25;
  transform: rotate(-11deg);
  box-shadow: 0 6px 14px -8px rgba(26,24,23,0.8);
}
.specimen.is-saved .specimen__seal { display: grid; animation: press 0.35s var(--ease) both; }

.specimen__body { grid-column: 7 / 13; padding-top: 4px; }
.specimen__fig {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.specimen__fig-num { color: var(--oxblood); font-weight: 500; }
.specimen__class { color: var(--muted); }
.specimen__title { margin-top: 14px; font-size: clamp(1.7rem, 3.2vw, 2.7rem); }
.specimen__latin {
  margin-top: 6px;
  font-style: italic;
  color: var(--muted);
  font-size: 15.5px;
}
.specimen__desc { margin-top: 16px; max-width: 46ch; }
.specimen__data {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
}
.specimen__data div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--line); padding-bottom: 7px; }
.specimen__data dt { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.specimen__data dd { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.specimen__actions { display: flex; align-items: center; gap: 16px; margin-top: 22px; }
.specimen__saveflag {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--oxblood);
  display: none;
}
.specimen.is-saved .specimen__saveflag { display: inline; }

/* Alternating */
.specimen:nth-child(even) .specimen__plate { grid-column: 7 / 13; grid-row: 1; }
.specimen:nth-child(even) .specimen__body { grid-column: 1 / 7; grid-row: 1; }

/* ---------- Empty state ---------- */
.empty {
  margin-top: 24px;
  padding: clamp(40px, 6vw, 72px) clamp(24px, 4vw, 48px);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  background: var(--paper-2);
  text-align: center;
}
.empty__fig { font-family: var(--font-display); font-size: 64px; line-height: 1; color: var(--oxblood); }
.empty__title { margin-top: 10px; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.empty__text { margin: 12px auto 24px; max-width: 46ch; color: var(--muted); }

/* ============================================================
   CABINET — inverted band
   ============================================================ */
.cabinet {
  margin-top: clamp(40px, 6vw, 80px);
  background: var(--night);
  color: var(--bone);
  padding-block: clamp(64px, 10vw, 128px);
  overflow: clip;
}
.cabinet__grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(32px, 6vw, 80px);
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--gut);
}
.cabinet__intro h2 { color: var(--bone); margin-top: 10px; }
.cabinet__intro p { margin-top: 18px; max-width: 48ch; color: var(--bone-muted); }
.cabinet__contents {
  align-self: start;
  padding: 26px 28px;
  border: 1px solid #3a2f28;
  background: var(--night-2);
}
.cabinet__count { font-family: var(--font-display); font-size: 54px; line-height: 1; color: var(--accent-dark); font-variant-numeric: lining-nums; }
.cabinet__count-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bone-muted); }
.cabinet__list { margin-top: 18px; }
.cabinet__list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px dotted #4a3d34;
  font-size: 15.5px;
}
.cabinet__list li span:last-child { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent-dark); }
.cabinet__empty { margin-top: 14px; font-size: 15px; color: var(--bone-muted); }
.cabinet__seal {
  position: absolute;
  right: -30px;
  bottom: -90px;
  display: grid;
  place-content: center;
  gap: 4px;
  width: 170px; height: 170px;
  border: 2px solid #4a3a31;
  border-radius: 50%;
  color: #4a3a31;
  font-family: var(--font-display);
  font-size: 19px;
  text-align: center;
  transform: rotate(9deg);
  pointer-events: none;
}
.cabinet__seal span:first-child { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; }

/* ============================================================
   FIELD NOTES
   ============================================================ */
.notes {
  max-width: 1280px;
  margin-inline: auto;
  padding: clamp(64px, 9vw, 128px) var(--gut) clamp(40px, 6vw, 72px);
}
.section-head--wide { max-width: none; }
.notes__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
  margin-top: clamp(32px, 5vw, 56px);
}
.notes__steps { border-top: 2px solid var(--ink); }
.notes__steps li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 24px;
  padding: clamp(22px, 3vw, 34px) 0;
  border-bottom: var(--rule);
}
.notes__num {
  grid-row: 1 / 3;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  line-height: 0.9;
  color: var(--oxblood);
}
.notes__steps h3 { font-size: clamp(1.35rem, 2.2vw, 1.8rem); }
.notes__steps p { margin-top: 8px; max-width: 46ch; color: var(--muted); }
.notes__plate { position: relative; border: 1px solid var(--line-soft); padding: 10px; background: var(--paper-2); }
.notes__plate img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; filter: saturate(0.8) contrast(1.03); }
.notes__plate figcaption { display: flex; gap: 12px; align-items: baseline; margin-top: 10px; font-size: 14.5px; color: var(--muted); }

/* ============================================================
   VISIT
   ============================================================ */
.visit {
  position: relative;
  max-width: 1280px;
  margin-inline: auto;
  padding: clamp(56px, 8vw, 120px) var(--gut) clamp(64px, 8vw, 120px);
  border-top: var(--rule);
  overflow: clip;
}
.visit__word {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(4rem, 15vw, 13rem);
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: #8a8175;
  margin-bottom: 0.1em;
  user-select: none;
}
.visit__body { max-width: 640px; position: relative; }
.visit__body h2 { margin-top: 10px; }
.visit__body p { margin-top: 18px; color: var(--muted); max-width: 56ch; }
.visit__cta { margin-top: 26px; }
.visit__facts {
  margin-top: 36px;
  border-top: var(--rule);
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.9fr;
  gap: 0;
}
.visit__facts div { padding: 16px 0; border-bottom: var(--rule); }
.visit__facts div + div { border-left: var(--rule); padding-left: 20px; }
.visit__facts dt { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.visit__facts dd { margin-top: 5px; font-size: 15.5px; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  max-width: 1280px;
  margin-inline: auto;
  padding: 40px var(--gut) 56px;
  border-top: 2px solid var(--ink);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
  align-items: baseline;
}
.footer__brand { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.footer__brand span { color: var(--oxblood); }
.footer__meta { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.footer__fine { flex-basis: 100%; font-size: 13.5px; color: var(--muted); max-width: 70ch; }

/* ============================================================
   DETAIL DIALOG
   ============================================================ */
.detail {
  width: min(100%, 1120px);
  max-width: 100%;
  max-height: 92vh;
  margin: auto;
  padding: 0;
  border: 1px solid #3a2f28;
  border-radius: var(--r-md);
  background: var(--night);
  color: var(--bone);
  overflow: hidden;
}
.detail::backdrop { background: rgba(21, 17, 15, 0.74); }
.detail__scroll { max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; }
.detail__topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(18px, 3vw, 34px);
  background: var(--night-2);
  border-bottom: 1px solid #3a2f28;
}
.detail__fig { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-dark); }
.detail__close {
  min-height: 44px;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid #4a3d34;
  border-radius: var(--r-sm);
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}
.detail__close:active { transform: scale(0.97); }
.detail__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(24px, 4vw, 52px);
  padding: clamp(22px, 3.5vw, 44px) clamp(18px, 3vw, 34px) clamp(28px, 4vw, 48px);
}
.detail__plate { align-self: start; border: 1px solid #3a2f28; padding: 10px; background: var(--night-2); }
.detail__plate img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; filter: saturate(0.82) contrast(1.02); }
.detail__plate figcaption { display: flex; gap: 12px; align-items: baseline; margin-top: 10px; font-size: 13.5px; color: var(--bone-muted); }
.detail__text h2 { color: var(--bone); font-size: clamp(2rem, 4vw, 3.2rem); }
.detail__latin { margin-top: 8px; font-style: italic; color: var(--accent-dark); font-size: 16px; }
.detail__lead { margin-top: 20px; font-size: 18px; line-height: 1.6; color: #ded7ca; max-width: 56ch; }
.detail__data {
  margin-top: 26px;
  border-top: 1px solid #3a2f28;
}
.detail__data div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px dotted #4a3d34; }
.detail__data dt { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bone-muted); }
.detail__data dd { font-family: var(--font-mono); font-size: 14px; text-align: right; }
.detail__actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 30px; align-items: center; }

.seal-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 22px 10px 12px;
  border: 1px solid var(--accent-dark);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--accent-dark);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease), border-color 0.18s var(--ease);
}
.seal-btn__seal {
  display: grid;
  place-content: center;
  width: 30px; height: 30px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 14px;
}
.seal-btn[aria-pressed="true"] { background: var(--accent-dark); color: var(--night); border-color: var(--accent-dark); }
.seal-btn:active { transform: scale(0.97); }

/* ============================================================
   HOVER STATES  (all inside hover media query)
   ============================================================ */
@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: var(--oxblood-2); border-color: var(--oxblood-2); }
  .btn--ghost:hover { border-color: var(--oxblood); color: var(--oxblood); }
  .link-btn:hover { color: var(--ink); }
  .masthead__nav a:hover { color: var(--oxblood); }
  .masthead__nav a:hover::after { transform: scaleX(1); }
  .brand:hover .brand__name { color: var(--oxblood); }
  .control input:hover, .control select:hover { border-color: var(--muted); }
  .toggle:hover { border-color: var(--oxblood); }
  .toggle[aria-pressed="true"]:hover { background: var(--oxblood-2); border-color: var(--oxblood-2); }
  .specimen:hover .specimen__plate img { filter: saturate(1) contrast(1.04); }
  .specimen:hover .specimen__annot path,
  .specimen:focus-within .specimen__annot path { animation: draw 0.7s var(--ease) forwards; opacity: 1; }
  .specimen__plate img { transition: filter 0.3s var(--ease); }
  .detail__close:hover { background: var(--bone); color: var(--night); border-color: var(--bone); }
  .seal-btn:hover { background: var(--accent-dark); color: var(--night); }
  .seal-btn[aria-pressed="true"]:hover { background: transparent; color: var(--accent-dark); }
  .footer a:hover { color: var(--oxblood); }
}
/* focus-within annotation must work without hover too */
.specimen:focus-within .specimen__annot path { animation: draw 0.7s var(--ease) forwards; opacity: 1; }

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes sweep { from { opacity: 0; transform: translateY(0.12em) scaleY(0.94); } to { opacity: 1; transform: none; } }
@keyframes draw { from { stroke-dashoffset: 540; } to { stroke-dashoffset: 0; } }
@keyframes press { from { transform: rotate(-11deg) scale(1.5); opacity: 0; } to { transform: rotate(-11deg) scale(1); opacity: 1; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Living detail: the cabinet seal breathes slowly */
.cabinet__seal { animation: sealPulse 9s ease-in-out infinite; }
@keyframes sealPulse { 0%, 100% { transform: rotate(9deg) scale(1); } 50% { transform: rotate(9deg) scale(1.035); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1080px) {
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .control--saved { grid-column: 1 / -1; }
  .toggle { width: 100%; justify-content: center; }
  .cabinet__grid { grid-template-columns: 1fr; }
  .cabinet__seal { display: none; }
}

@media (max-width: 860px) {
  .masthead { flex-wrap: wrap; row-gap: 4px; }
  .masthead__strap { display: none; }
  .masthead__nav {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 22px;
    padding-inline-end: 28px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .masthead__nav a { white-space: nowrap; flex: 0 0 auto; }
  .masthead__nav a::after { bottom: 4px; }

  .hero__lede { grid-template-columns: 1fr; align-items: start; }
  .hero__spine { display: none; }

  .specimen { grid-template-columns: 1fr; }
  .specimen__plate,
  .specimen:nth-child(even) .specimen__plate,
  .specimen__body,
  .specimen:nth-child(even) .specimen__body { grid-column: 1 / -1; grid-row: auto; }
  .specimen__body { padding-top: 18px; }

  .notes__grid { grid-template-columns: 1fr; }
  .notes__plate { max-width: 460px; }
  .visit__facts { grid-template-columns: 1fr; }
  .visit__facts div + div { border-left: none; padding-left: 0; }

  .detail__grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .controls { grid-template-columns: 1fr; }
  .specimen__data { grid-template-columns: 1fr; }
  .hero__word { font-size: clamp(3.6rem, 24vw, 7rem); }
  .hero__word-sub { max-width: 24ch; }
  .visit__word { font-size: clamp(3.2rem, 20vw, 6rem); }
  .footer { flex-direction: column; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .hero__word-main, .hero__word-sub, .hero__kicker, .hero__lede { opacity: 1; transform: none; }
  .specimen__annot path { opacity: 0.4; stroke-dashoffset: 0; }
}
