/* ============================================================
   styles.css 
   ============================================================ */

:root {
  --paper: #ffffff;
  --ink: #000000;
  --ink-2: #1a1a1a;
  --ink-3: #4b5563;
  --ink-4: #6b7280;
  --rule: #000000;
  --rule-soft: #d1d5db;
  --link: #0000EE;
  --link-visited: #551A8B;
  --hl: #FFFF00;
  --box-bg: #f9f9f9;

  /* typography */
  --f-display: 'Fraunces', 'abril-titling', Georgia, serif;
  --f-body: 'abril-titling', 'Fraunces', Georgia, Garamond, serif;

  --ease: cubic-bezier(0.32, 0.72, 0.24, 1);
}

/* alt themes  */
[data-theme='cream'] { --paper: #fbf7ee; --box-bg: #f4eedf; }
[data-theme='dark']  {
  --paper: #111111; --ink: #f5f5f5; --ink-2: #eaeaea; --ink-3: #a0a0a0; --ink-4: #7a7a7a;
  --rule: #f5f5f5; --rule-soft: #333; --box-bg: #1a1a1a;
  --link: #7aa7ff; --link-visited: #b58eff; --hl: #ffcf3d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { background: var(--paper); color: var(--ink); }
body {
  font-family: var(--f-body);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--hl); color: var(--ink); }

/* Links: classic blue, yellow highlight on hover */
a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
a:visited { color: var(--link-visited); }
a:hover { background: var(--hl); color: var(--ink); }

/* Rules */
hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 40px 0;
}

/* ESSAY layout */
.essay {
  max-width: 48rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* MASTHEAD */
.masthead {
  padding: 12px 0 20px;
}
.masthead-kicker {
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--ink-3);
  margin-bottom: 12px;
  font-style: italic;
}
.masthead-title {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(48px, 9vw, 96px);
  line-height: 0.94;
  letter-spacing: -0.025em;
  margin: 0 0 18px;
  font-variation-settings: '"SOFT" 100, "opsz" 144, "wght" 500';
  font-optical-sizing: auto;
  text-wrap: balance;
}
.masthead-title em {
  font-style: italic;
  font-variation-settings: '"SOFT" 100, "opsz" 144, "wght" 500';
}

/* ---------- draggable masthead ---------- */
.masthead-title--drop {
  font-size: clamp(96px, 18vw, 200px) !important;
  line-height: 0.88 !important;
  letter-spacing: -0.035em;
  font-weight: 500;
  display: block;
  margin: 20px 0 24px;
  user-select: none;
}
.mt-word { display: inline-block; }
.mt-space { display: inline-block; width: 0.35em; }
.mt-letter {
  position: relative;
  display: inline-block;
  color: var(--ink);
  isolation: isolate;
}
.mt-glyph {
  position: relative;
  z-index: 2;
  pointer-events: none;
}
.mt-letter > .egg-slot {
  z-index: 1;
}
.egg-slot {
  position: absolute;
  display: block;
  pointer-events: auto;
  border-radius: 50% 50% 48% 48% / 58% 58% 42% 42%;
  overflow: hidden;
  transition: box-shadow 180ms var(--ease), transform 180ms var(--ease);
  cursor: copy;
}
.egg-slot svg {
  display: block;
  width: 100%;
  height: 100%;
}
.egg-slot.is-hover {
  box-shadow: 0 0 0 3px var(--hl), 0 0 0 4px var(--ink);
  transform: scale(1.06) !important;
}

/* gentle hint text */
.masthead-hint {
  font-style: italic;
  color: var(--ink-3);
  font-size: 0.92em;
}


.ornamental .orn-cell { cursor: grab; }
.ornamental .orn-cell:active { cursor: grabbing; }
.ornamental .orn-cell[draggable="true"]:hover { background: var(--hl); }
.masthead-title-sub {
  display: inline-block;
  font-size: 0.42em;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-2);
  letter-spacing: 0;
  margin-top: 6px;
}
.masthead-title-sub em { font-style: italic; color: var(--ink); }
.masthead-sub {
  font-family: var(--f-body);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 38em;
  margin-bottom: 28px;
}
.masthead-sub em { font-style: italic; }

/* small animations */
.rotating-letter { display: inline-block; animation: rotL 3s ease-in-out forwards; animation-iteration-count: 1; }
@keyframes rotL { 0% { transform: rotate(0); } 40% { transform: rotate(180deg); } 60% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }
.drifting { display: inline-block; animation: drift 20s ease-in-out infinite; }
@keyframes drift { 0%,100% { transform: translateX(0); } 50% { transform: translateX(8px); } }
.rgb-glitch { position: relative; animation: rgbSplit 6s infinite; }
@keyframes rgbSplit {
  0%, 96%, 100% { text-shadow: none; }
  97% { text-shadow: -2px 0 red, 2px 0 cyan; }
  98% { text-shadow: 2px 0 red, -2px 0 cyan; }
  99% { text-shadow: -1px 0 red, 1px 0 cyan; }
}
.blink { animation: blink 1.6s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

.masthead-figures { margin-top: 6px; }

/* ornamental row */
.ornamental {
  display: flex; flex-wrap: wrap;
  gap: 10px 18px;
  align-items: flex-end;
  padding: 14px 0 4px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  justify-content: space-between;
}
.orn-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.orn-num {
  font-family: var(--f-body);
  font-size: 11px;
  color: var(--ink-3);
  font-style: italic;
}

/* PROSE */
.prose { padding: 18px 0 10px; }
.prose p {
  margin: 0 0 1.1em;
  font-size: 18px;
  line-height: 1.72;
  text-wrap: pretty;
}
.prose p.drop { margin-top: 18px; }
.drop-cap {
  float: left;
  font-family: var(--f-display);
  font-size: 68px;
  line-height: 0.88;
  padding: 8px 12px 0 0;
  color: var(--ink);
  font-weight: 500;
  font-variation-settings: '"SOFT" 50, "opsz" 144, "wght" 500';
}
.prose strong { font-weight: 700; color: var(--ink); }
.prose em { font-style: italic; }

/* Chapter header — big bold serif like section heads */
.chapter {
  margin: 48px 0 14px;
}
.chapter-num {
  font-family: var(--f-body);
  font-size: 13px;
  font-style: italic;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.chapter-title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 30px;
  line-height: 1.1;
  margin: 0 0 4px;
  font-variation-settings: '"SOFT" 40, "opsz" 72, "wght" 700';
}
.chapter-sub {
  font-family: var(--f-body);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-3);
}
.chapter-rule { display: none; }

/* Epigraph */
.epigraph {
  position: relative;
  margin: 20px 0 32px;
  padding: 6px 0 6px 20px;
  border-left: 2px solid var(--ink);
  font-family: var(--f-display);
  font-style: italic;
  font-size: 22px;
  line-height: 1.4;
  color: var(--ink);
  font-variation-settings: '"SOFT" 60, "opsz" 48, "wght" 400';
  text-wrap: balance;
}
.epigraph-mark { display: none; }
.epigraph p { margin: 0 0 6px; }
.epigraph cite {
  display: block;
  font-family: var(--f-body);
  font-style: normal;
  font-size: 14px;
  color: var(--ink-3);
}

/* Equation — serif italic, not monospace */
.equation {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 22px;
  text-align: center;
  padding: 18px 0;
  margin: 22px 0;
  color: var(--ink);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-variation-settings: '"SOFT" 30, "opsz" 48, "wght" 400';
  letter-spacing: 0.01em;
}
.equation sup { font-size: 0.62em; vertical-align: 0.6em; }

/* Envoi */
.envoi { margin-top: 24px; font-style: italic; }
.envoi-rule {
  text-align: center;
  margin: 48px 0;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-3);
  display: flex; justify-content: center; gap: 18px; align-items: center;
}

/* FOOTNOTES — dotted-underline trigger with hover popover */
.fn {
  position: relative;
  display: inline;
  cursor: help;
}
.fn sup {
  color: var(--link);
  font-size: 0.7em;
  padding: 0 1px;
  font-weight: 500;
  transition: background 0.15s;
}
.fn:hover sup, .fn:focus-within sup { background: var(--hl); color: var(--ink); }
.fn-pop {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  transform: translateY(4px);
  width: 300px;
  max-width: 90vw;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 10px 12px 12px;
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
  z-index: 100;
}
.fn-pop::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 18px;
  width: 10px; height: 10px;
  background: var(--paper);
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  transform: translateY(-50%) rotate(45deg);
}
.fn:hover .fn-pop, .fn:focus-within .fn-pop {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.fn-num { font-style: italic; color: var(--ink-3); margin-right: 6px; }
.fn-cite { font-weight: 600; }
.fn-work { font-style: italic; }
.fn-pub { color: var(--ink-3); }

/* MINI FIGURE — understated, like a figure inside a blog post */
.mini-figure {
  margin: 28px 0 32px;
  padding: 20px 0 18px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  align-items: center;
  position: relative;
  background: var(--box-bg);
  padding: 20px 20px;
}
.mini-figure::before {
  content: 'fig.';
  position: absolute;
  top: 8px; left: 12px;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
}
.mini-figure-plate {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.mini-figure-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 18px;
}
@media (min-width: 600px) {
  .mini-figure-controls { grid-template-columns: 1fr 1fr; }
}
.mini-figure-eq {
  display: block;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dotted var(--ink);
  font-family: var(--f-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
}
.mini-figure-eq em {
  display: block;
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--ink-3);
  font-style: italic;
  margin-top: 4px;
}

/* Sliders */
input.nat-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1px;
  background: var(--ink);
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
}
input.nat-slider::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--ink);
}
input.nat-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  margin-top: -6px;
  transition: transform 0.1s;
}
input.nat-slider::-webkit-slider-thumb:hover { transform: scale(1.2); background: var(--hl); }
input.nat-slider::-moz-range-track { height: 1px; background: var(--ink); }
input.nat-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--paper); border: 1.5px solid var(--ink); cursor: pointer;
}

/* slider labels in mini fig */
.slider-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 3px;
}
.slider-sym {
  font-family: var(--f-display);
  font-style: italic;
  color: var(--ink);
  margin-right: 4px;
  font-size: 15px;
}
.slider-val {
  font-family: var(--f-body);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   DESIGNER 
   ============================================================ */
.designer-wrap {
  margin-top: 60px;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 0 24px;
}
@media (max-width: 900px) {
  .designer-wrap { margin-left: 0; margin-right: 0; padding: 0; }
}
.designer {
  max-width: 1240px;
  margin: 20px auto 0;
  border: 1px solid var(--ink);
  padding: 24px;
  background: var(--paper);
}
.designer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
}
@media (max-width: 900px) {
  .designer-inner { grid-template-columns: 1fr; }
}

.d-stage {
  border: 1px solid var(--ink);
  padding: 22px 22px 18px;
  position: relative;
  display: flex; flex-direction: column;
  min-height: 500px;
  background: var(--paper);
}
.d-stage-chrome {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 12px; border-bottom: 1px solid var(--ink);
  margin-bottom: 16px;
  font-family: var(--f-body);
  text-transform: lowercase;
  white-space: nowrap;
}
.d-stage-tag {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-3);
  white-space: nowrap;
}
.d-metric-lbl { text-transform: lowercase; }
.d-egg-cap { text-transform: lowercase; }
.d-stage-name {
  font-family: var(--f-display);
  font-size: 17px;
  color: var(--ink);
  font-weight: 500;
}
.d-stage-name em {
  font-style: italic;
  color: var(--ink-3);
  font-weight: 400;
}
.d-stage-dot { margin: 0 6px; color: var(--ink-3); }

.d-stage-egg {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  min-height: 340px;
  overflow: hidden;
}
.d-stage-egg svg { max-width: 100%; height: auto; }
.d-egg-pair {
  display: flex; align-items: center; gap: 36px; flex-wrap: wrap; justify-content: center;
}
.d-egg-side, .d-egg-end { display: flex; flex-direction: column; align-items: center; }
.d-egg-cap {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 2px;
}

.end-view { display: flex; align-items: center; justify-content: center; }
.end-view.end-spin svg { animation: endspin 6s linear infinite; transform-origin: center; }
@keyframes endspin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.d-egg-pair.spinning .d-egg-side svg {
  animation: sideshimmer 6s var(--ease) infinite alternate; transform-origin: center;
}
@keyframes sideshimmer {
  0% { transform: rotateY(0) scale(1); }
  100% { transform: rotateY(28deg) scale(1.02); }
}

/* Metrics rail */
.d-metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--ink);
}
.d-metric {
  text-align: center;
  padding: 6px 4px;
  border-right: 1px dotted var(--ink);
}
.d-metric:last-child { border-right: none; }
.d-metric-lbl {
  font-family: var(--f-body);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 2px;
}
.d-metric-val {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.d-metric-val span {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-3);
  margin-left: 3px;
  vertical-align: 4px;
}

/* Rail (right side) */
.d-rail { display: flex; flex-direction: column; gap: 22px; }
.d-section {
  border: 1px solid var(--ink);
  padding: 14px 16px 16px;
  background: var(--paper);
}
.d-section-head {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 14px;
  display: flex; align-items: baseline; gap: 8px;
  font-variation-settings: '"SOFT" 40, "opsz" 48, "wght" 700';
  text-transform: lowercase;
}
.d-section-head span:first-child {
  color: var(--ink-3);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
}

.d-mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.d-mode-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--ink);
  cursor: pointer;
  text-align: left;
  font-family: var(--f-body);
  color: var(--ink);
  transition: background 0.15s var(--ease);
}
.d-mode-btn:hover { background: var(--hl); }
.d-mode-btn.is-active { background: var(--ink); color: var(--paper); }
.d-mode-yr { font-family: var(--f-body); font-style: italic; font-size: 12px; opacity: 0.8; }
.d-mode-nm {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1;
}

.d-controls { display: flex; flex-direction: column; gap: 10px; }
.d-slider { display: flex; flex-direction: column; gap: 4px; }
.d-slider-head {
  display: flex; align-items: baseline; gap: 6px;
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--ink-3);
}
.d-slider-sym {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 16px;
  color: var(--ink);
  font-weight: 500;
  min-width: 16px;
}
.d-slider-lbl { color: var(--ink-3); }
.d-slider-val {
  margin-left: auto;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* swatches */
.d-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}
.d-sw {
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s;
}
.d-sw:hover { transform: scale(1.12); z-index: 2; box-shadow: 0 0 0 2px var(--hl); }
.d-sw.is-active { box-shadow: 0 0 0 2px var(--hl); transform: scale(1.08); }

.d-distrib { display: flex; gap: 4px; margin-top: 8px; margin-bottom: 6px; }
.d-dist-btn {
  flex: 1;
  font-family: var(--f-body);
  font-size: 13px;
  padding: 5px 4px;
  background: var(--paper);
  border: 1px solid var(--ink);
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s;
}
.d-dist-btn:hover { background: var(--hl); }
.d-dist-btn.is-active { background: var(--ink); color: var(--paper); }

.d-reseed {
  width: 100%;
  margin-top: 6px;
  font-family: var(--f-display);
  font-style: italic;
  font-size: 14px;
  padding: 7px;
  background: var(--paper);
  border: 1px dashed var(--ink);
  cursor: pointer;
  color: var(--ink);
  transition: all 0.12s;
}
.d-reseed:hover { border-style: solid; background: var(--hl); }

/* species cabinet */
.d-species-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.d-sp {
  background: var(--paper);
  border: 1px solid var(--ink);
  cursor: pointer;
  padding: 8px 6px 10px;
  text-align: center;
  transition: background 0.12s var(--ease);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: inherit;
}
.d-sp:hover { background: var(--hl); }
.d-sp.is-active { background: var(--ink); color: var(--paper); }
.d-sp.is-active .d-sp-sci { color: var(--paper); opacity: 0.75; }
.d-sp-lbl {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.1;
  padding: 0 2px;
}
.d-sp-sci {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.15;
  padding: 2px 2px 0;
}

/* actions */
.d-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.d-act {
  font-family: var(--f-body);
  font-size: 14px;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--ink);
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s;
  text-align: center;
}
.d-act:hover { background: var(--hl); }
.d-act.is-active { background: var(--ink); color: var(--paper); }

/* compare grid */
.d-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 6px;
}
.d-compare-cell {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 12px;
  background: var(--paper);
  border: 1px solid var(--ink);
}
.d-compare-head {
  display: flex; gap: 10px; align-items: baseline;
  margin-bottom: 6px;
}
.d-compare-yr {
  font-family: var(--f-body);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
}
.d-compare-nm {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
}

/* REFS */
.refs { margin-top: 70px; }
.refs ol {
  list-style: none; padding: 0; margin: 0;
  counter-reset: ref;
  column-count: 2; column-gap: 28px;
}
@media (max-width: 720px) { .refs ol { column-count: 1; } }
.refs ol li {
  counter-increment: ref;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 10px;
  padding-left: 28px;
  position: relative;
  break-inside: avoid;
  color: var(--ink-3);
}
.refs ol li::before {
  content: '[' counter(ref) ']';
  position: absolute; left: 0; top: 0;
  font-family: var(--f-body);
  font-style: italic;
  color: var(--link);
}
.ref-cite { color: var(--ink); font-weight: 600; }
.ref-work { font-style: italic; }

.colophon {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink-3);
  text-align: center;
}
.colophon em {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 15px;
  color: var(--ink);
}

/* INLINE FIGURES (newly added) */
.essay-fig {
  margin: 28px auto;
  text-align: center;
}
.essay-fig.no-frame .essay-fig-img { border: none; background: transparent; padding: 0; }
.essay-fig-img {
  display: inline-block;
  background: var(--paper-soft, #f6f1e8);
  border: 1px solid var(--rule-soft);
  padding: 6px;
  max-width: 100%;
}
.essay-fig-img img {
  display: block;
  max-width: 100%;
  height: auto;
}
.essay-fig-missing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 220px;
  min-height: 140px;
  padding: 20px 18px;
  font-family: var(--f-body);
  font-size: 12px;
  color: var(--ink-3);
  background: repeating-linear-gradient(
    45deg,
    transparent 0 8px,
    rgba(0,0,0,0.04) 8px 9px
  );
}
.essay-fig-missing code {
  font-family: var(--f-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--ink-2);
  background: rgba(0,0,0,0.05);
  padding: 2px 6px;
  border-radius: 2px;
}
.essay-fig figcaption {
  font-family: var(--f-body);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-3);
  margin-top: 10px;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
}
.essay-fig-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 28px 0;
}
.essay-fig-row .essay-fig { margin: 0; }

/* HOVER NOTES (newly added) */
.hover-note {
  position: relative;
  display: inline;
  cursor: help;
}
.hover-note-anchor {
  display: inline-block;
  color: var(--link);
  font-size: 0.78em;
  vertical-align: super;
  line-height: 1;
  padding: 0 2px;
  border-bottom: 1px dotted var(--link);
}
.hover-note-pop {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -8px);
  width: min(360px, 80vw);
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 12px 14px;
  font-family: var(--f-body);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 50;
  white-space: normal;
}
.hover-note-pop::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}
.hover-note:hover .hover-note-pop,
.hover-note:focus .hover-note-pop,
.hover-note:focus-within .hover-note-pop {
  opacity: 1;
  pointer-events: auto;
}
.hover-note-img {
  display: block;
  margin: 0 0 10px;
  border: 1px solid var(--rule-soft);
  background: var(--paper-soft, #f6f1e8);
  min-height: 60px;
}
.hover-note-img img {
  display: block;
  width: 100%;
  height: auto;
}
.hover-note-body { display: block; }
.hover-note-body a { color: var(--link); }

/* TWEAKS */
.tweaks-panel {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 14px 16px 16px;
  font-family: var(--f-body);
  z-index: 1000;
  box-shadow: 4px 4px 0 var(--ink);
  max-width: 260px;
}
.tweaks-head {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 16px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--ink);
}
.tweak-row { margin-bottom: 10px; }
.tweak-row:last-child { margin-bottom: 0; }
.tweak-row .tlab {
  display: block;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.tweak-themes { display: flex; gap: 4px; }
.tweak-themes button {
  flex: 1; padding: 6px 4px;
  font-family: var(--f-body);
  font-size: 13px;
  background: var(--paper);
  border: 1px solid var(--ink);
  cursor: pointer;
  color: var(--ink);
  transition: background 0.12s;
}
.tweak-themes button:hover { background: var(--hl); }
.tweak-themes button.is-active { background: var(--ink); color: var(--paper); }

/* RESPONSIVE */
@media (max-width: 720px) {
  body { font-size: 17px; }
  .essay { padding: 2rem 1.25rem 4rem; }
  .mini-figure { grid-template-columns: 1fr; }
  .mini-figure-plate { width: 100%; max-width: 260px; }
  .d-metrics { grid-template-columns: repeat(3, 1fr); }
  .d-egg-pair { gap: 20px; }
  .fn-pop { width: 260px; font-size: 13px; }
}
