/* ============================================================
   benweinberg.info — lab-precise modern-technical
   ============================================================ */

:root {
  --paper:   #f6f4ee;
  --paper-2: #efece3;
  --ink:     #17150f;
  --ink-2:   #3a372e;
  --muted:   #6f6b60;
  --faint:   #9a958a;
  --line:    #e0dbcf;
  --line-2:  #d2ccbd;
  --accent:  #1f3cff;
  --accent-ink: #1730c9;
  --dot:     #d8d2c4;

  --panel-bg: rgba(255, 253, 247, 0.55);
  --chip-bg:  color-mix(in srgb, var(--paper) 50%, #fff);
  --on-accent: #ffffff;

  --blob-1: rgba(31, 60, 255, 0.13);
  --blob-2: rgba(28, 170, 128, 0.11);
  --blob-3: rgba(255, 138, 66, 0.10);

  --font-display: "Bricolage Grotesque", Georgia, serif;
  --font-body:    "Hanken Grotesk", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

  --maxw: 1080px;
  --pad: clamp(1.25rem, 4vw, 3.5rem);
}

:root[data-theme="dark"] {
  --paper:   #131210;
  --paper-2: #1c1a16;
  --ink:     #f2efe6;
  --ink-2:   #d6d1c4;
  --muted:   #9f998c;
  --faint:   #726d62;
  --line:    rgba(255, 255, 255, 0.10);
  --line-2:  rgba(255, 255, 255, 0.16);
  --accent:  #7f93ff;
  --accent-ink: #aab6ff;
  --dot:     rgba(255, 255, 255, 0.055);

  --panel-bg: rgba(28, 26, 21, 0.50);
  --chip-bg:  rgba(255, 255, 255, 0.05);
  --on-accent: #14130f;

  --blob-1: rgba(96, 116, 255, 0.20);
  --blob-2: rgba(44, 185, 142, 0.15);
  --blob-3: rgba(255, 150, 80, 0.13);
}

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

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(var(--dot) 1px, transparent 1.4px),
    radial-gradient(38% 40% at 12% 16%, var(--blob-1), transparent 72%),
    radial-gradient(42% 44% at 90% 10%, var(--blob-2), transparent 70%),
    radial-gradient(48% 55% at 82% 90%, var(--blob-3), transparent 72%);
  background-size: 22px 22px, 150% 150%, 150% 150%, 150% 150%;
  background-position: -11px -11px, 0 0, 0 0, 0 0;
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-attachment: scroll, fixed, fixed, fixed;
  transition: background-color .4s, color .4s;
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; text-decoration: none; }

/* ---------- shared layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--pad); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(1.4) blur(8px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  display: inline-flex; align-items: center; gap: 0.55rem;
}
.brand .mark {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-weight: 700; font-size: 0.72rem;
  transition: background .25s, color .25s, transform .25s;
}
/* Hover effects are gated on (hover: hover) throughout. A touch device latches
   :hover on tap and holds it until you tap elsewhere, so an ungated transform
   stays stuck on the element you just pressed. */
@media (hover: hover) {
  .brand:hover .mark { background: var(--accent); border-color: var(--accent); color: var(--on-accent); transform: rotate(-4deg); }
}

nav.main { display: flex; gap: clamp(0.9rem, 2.4vw, 2rem); }
nav.main a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding: 0.2rem 0;
  position: relative;
  transition: color .2s;
}
nav.main a::after {
  content: ""; position: absolute; left: 0; bottom: -2px;
  width: 100%; height: 1.5px; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform .28s ease;
}
nav.main a:hover, nav.main a[aria-current="page"] { color: var(--ink); }
nav.main a:hover::after, nav.main a[aria-current="page"]::after { transform: scaleX(1); }

.theme-toggle {
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  cursor: pointer; color: var(--muted);
  transition: color .2s, border-color .2s, transform .3s;
}
@media (hover: hover) {
  .theme-toggle:hover { color: var(--ink); border-color: var(--ink); transform: rotate(25deg); }
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline; }

/* ---------- frosted glass panel (adapted from luckcraft .lc-glass-panel) ---------- */
.panel {
  position: relative;
  background: var(--panel-bg);
  backdrop-filter: blur(14px) saturate(1.6);
  -webkit-backdrop-filter: blur(14px) saturate(1.6);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(23, 21, 15, 0.06), 0 2px 8px rgba(23, 21, 15, 0.035);
  padding: clamp(1.5rem, 3.2vw, 2.75rem);
}
/* inside a panel, drop redundant outer separators on stacked lists */
.panel .pub:first-child,
.panel .pat:first-child,
.panel .soft:first-child,
.panel .tl-row:first-child { border-top: none; }
.panel .pub:last-child,
.panel .pat:last-child,
.panel .soft:last-child,
.panel .tl-row:last-child { border-bottom: none; }

/* ---------- hero ---------- */
/* home fills the viewport as a flex column so the footer pins to the bottom (no scroll) */
body:has(.hero) { display: flex; flex-direction: column; min-height: 100vh; }
.hero { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center;
  padding-top: clamp(1rem, 3vh, 2rem); padding-bottom: clamp(1rem, 3vh, 2rem); }
.hero-card { width: 100%; padding: clamp(1.4rem, 2.6vw, 2.3rem); }
.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.82fr;
  gap: clamp(1.75rem, 4vw, 3.25rem);
  align-items: center;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-ink);
  display: inline-flex; align-items: center; gap: 0.6rem;
  margin-bottom: 0.8rem;
}
.eyebrow::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pulse 2.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

h1.name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.3rem, 5vw, 3.4rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin-bottom: 0.7rem;
}
h1.name .cred {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  vertical-align: super;
  margin-left: 0.5rem;
  top: -0.2em;
}

.lead {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.3;
  color: var(--ink-2);
  max-width: 40ch;
  margin-bottom: 0.9rem;
}
.lead .hl { color: var(--accent-ink); font-weight: 500; }

.bio { color: var(--muted); max-width: 54ch; font-size: 0.95rem; line-height: 1.45; margin-bottom: 1.2rem; }
/* Reads as a continuation of the sentence, not a control. nowrap keeps "More"
   and its arrow from splitting across a line break. */
.bio .more { color: var(--accent-ink); white-space: nowrap; }
.bio .more .arw { display: inline-block; margin-left: 0.28rem; transition: transform .2s; }
@media (hover: hover) {
  .bio .more:hover { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
  .bio .more:hover .arw { transform: translateX(3px); }
}

/* keyword chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.3rem; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  padding: 0.34rem 0.7rem;
  border: 1px solid var(--line-2);
  border-radius: 100px;
  background: var(--chip-bg);
  transition: border-color .2s, color .2s, transform .2s;
}
@media (hover: hover) {
  .chip:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-2px); }
}

/* links row */
.links { display: flex; flex-wrap: wrap; gap: 0.6rem 0.7rem; }
.btn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink);
  transition: border-color .2s, background .2s, color .2s, transform .2s;
}
@media (hover: hover) {
  .btn:hover { border-color: var(--ink); transform: translateY(-2px); }
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn svg { width: 15px; height: 15px; }
:root[data-theme="dark"] .btn.primary { color: #ffffff; }

/* portrait */
.portrait-col { padding-top: 0.5rem; }
.portrait {
  position: relative;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  background: #f0ece2;
  box-shadow: 0 16px 46px rgba(23, 21, 15, 0.16);
}
/* black & white; multiply dissolves the white studio background into the light mat */
.portrait .photo {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 18%;
  display: block;
  filter: grayscale(1) contrast(1.06);
  mix-blend-mode: multiply;
  transition: transform .7s cubic-bezier(.2, .7, .2, 1);
}
@media (hover: hover) {
  .portrait:hover .photo { transform: scale(1.04); }
}
/* dark theme: cooler mat, so the B&W print reads a touch differently on the dark page */
:root[data-theme="dark"] .portrait { background: #e4e6ea; border-color: rgba(255,255,255,0.14); }
.portrait::after {
  content: ""; position: absolute; inset: 0; z-index: 3;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
  pointer-events: none;
}
.portrait-tag {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  margin-top: 0.7rem; display: flex; justify-content: space-between;
}
.portrait-tag .dim { color: var(--faint); }

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--line);
  margin-top: clamp(3rem, 8vh, 6rem);
}
/* home hero already fills the view; keep its footer close so the page fits one screen */
.hero + .foot { margin-top: 0; }
.hero + .foot .wrap { padding-block: 1rem; }
.foot .wrap {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  padding-block: 1.6rem;
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted);
}
.foot a:hover { color: var(--accent-ink); }

/* ---------- load animation ---------- */
.reveal { opacity: 0; transform: translateY(14px); animation: rise .7s cubic-bezier(.2,.7,.2,1) forwards; }
.d1 { animation-delay: .05s; } .d2 { animation-delay: .13s; }
.d3 { animation-delay: .21s; } .d4 { animation-delay: .29s; }
.d5 { animation-delay: .37s; } .d6 { animation-delay: .45s; }
.d7 { animation-delay: .53s; }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  .eyebrow::before { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .portrait-col { order: -1; max-width: 260px; margin-inline: auto; }
  nav.main { gap: 0.9rem; }
  nav.main a { font-size: 0.72rem; }
}

/* Brand plus five links plus the toggle needs ~550px on one row, more than any
   phone has, so below 640 the bar stacks instead of overflowing the document.
   nav wraps rather than shrinking further; "Publications" sets the floor. */
@media (max-width: 640px) {
  .topbar .wrap {
    flex-direction: column;
    justify-content: center;
    height: auto;
    gap: 0.5rem;
    padding-block: 0.7rem;
  }
  nav.main {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 0.65rem;
  }
  nav.main a { font-size: 0.68rem; }
  /* 34px next to 11px nav text reads as a button bolted on. Scale it to the row. */
  .theme-toggle { width: 27px; height: 27px; border-radius: 7px; }
  .theme-toggle svg { width: 13px; height: 13px; }
}

/* ---------- generic content pages (about/pubs/patents) ---------- */
.page { padding-top: clamp(2.5rem, 6vh, 4rem); padding-bottom: 2rem; }
.page h2.section {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
}
.page .kicker {
  font-family: var(--font-mono); font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent-ink); margin-bottom: 0.8rem;
}
.page .prose p { max-width: 62ch; margin-bottom: 1.1rem; color: var(--ink-2); text-wrap: pretty; }
/* standalone intro line (publications, patents, software) sits tight above its list; give it room */
.page p.prose { margin-bottom: 1.1rem; }
/* On the About card the prose stretches full width so it wraps around the floated figures */
.page .prose:has(.cre-figure) p { max-width: none; }
.page .prose .big { font-family: var(--font-display); font-size: clamp(1.3rem,2.4vw,1.7rem); line-height: 1.35; color: var(--ink); max-width: 30ch; text-wrap: balance; }
.page .prose a.link { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.page .prose a.link:hover { color: var(--ink); }

/* section divider */
.rule { height: 1px; background: var(--line); border: 0; margin: clamp(2rem,5vh,3.2rem) 0; }

/* timeline */
.timeline { display: grid; gap: 0; margin-top: 0.5rem; }
.tl-row {
  --brand: var(--accent);
  display: grid; grid-template-columns: 7rem 2.75rem 1fr; gap: 1.25rem;
  padding: 1rem 0; border-top: 1px solid var(--line);
  align-items: center;
}
.tl-row:last-child { border-bottom: 1px solid var(--line); }
.tl-row[data-org="harborsite"] { --brand: #694cc5; }
.tl-row[data-org="tessera"]    { --brand: #5257d6; }
.tl-row[data-org="hms"]        { --brand: #a51c30; }
.tl-row[data-org="bu"]         { --brand: #cc0000; }
:root[data-theme="dark"] .tl-row[data-org="harborsite"] { --brand: #a78bfa; }
:root[data-theme="dark"] .tl-row[data-org="tessera"]    { --brand: #8a8eff; }
:root[data-theme="dark"] .tl-row[data-org="hms"]        { --brand: #e0788a; }
:root[data-theme="dark"] .tl-row[data-org="bu"]         { --brand: #ff6b6b; }
.tl-logo {
  width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line-2));
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 6%, var(--chip-bg));
  font-family: var(--font-mono); font-weight: 500;
  font-size: 0.72rem; letter-spacing: 0.03em;
  color: var(--brand);
}
.tl-when { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-ink); }
.tl-what .role { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }
.tl-what .org { color: var(--muted); font-size: 0.95rem; }

/* publications */
.pub-list { display: grid; gap: 0; counter-reset: pub; }
.pub {
  display: grid; grid-template-columns: 2.5rem 1fr auto; gap: 0.4rem 1.25rem;
  padding: 1.15rem 0; border-top: 1px solid var(--line);
  align-items: baseline; counter-increment: pub;
}
.pub::before {
  content: counter(pub, decimal-leading-zero);
  grid-column: 1; grid-row: 1;
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--faint);
}
.pub:last-child { border-bottom: 1px solid var(--line); }
.pub .title { font-family: var(--font-display); font-weight: 600; font-size: 1.12rem; line-height: 1.25; grid-column: 2; }
.pub .title a { color: inherit; text-decoration: none; transition: color 0.15s ease; }
.pub .title a:hover { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.pub .authors { grid-column: 2; color: var(--muted); font-size: 0.9rem; }
.pub .authors b { color: var(--ink); font-weight: 600; }
.pub .press { grid-column: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.4rem; margin-top: 0.15rem; font-family: var(--font-mono); font-size: 0.72rem; }
.pub .press .press-label { color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 0.15rem; }
.pub .press .sep { color: var(--faint); }
.pub .press a { color: var(--accent-ink); text-decoration: none; }
.pub .press a:hover { text-decoration: underline; text-underline-offset: 2px; }
.pub .venue { grid-column: 3; grid-row: 1 / span 2; text-align: right; font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent-ink); white-space: nowrap; }
.pub .venue .yr { display: block; color: var(--faint); margin-top: 0.2rem; }
.pub em { font-style: italic; }

@media (max-width: 640px) {
  .pub { grid-template-columns: 2.5rem 1fr; }
  .pub .venue { grid-column: 2; grid-row: auto; text-align: left; margin-top: 0.2rem; }
  .pub .venue .yr { display: inline; margin-left: 0.5rem; }
  .tl-row { grid-template-columns: 2.75rem 1fr; gap: 0.2rem 1rem; align-items: center; }
  .tl-logo { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
  .tl-when { grid-column: 2; grid-row: 1; }
  .tl-what { grid-column: 2; grid-row: 2; }
}

/* patents */
.pat-list { display: grid; gap: 0; counter-reset: pat; }
.pat {
  display: grid; grid-template-columns: 2.5rem 1fr; gap: 1rem;
  padding: 1.15rem 0; border-top: 1px solid var(--line);
}
.pat:last-child { border-bottom: 1px solid var(--line); }
.pat::before {
  counter-increment: pat; content: counter(pat, decimal-leading-zero);
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--faint);
}
.pat .p-title { font-weight: 600; }
.pat .p-meta { color: var(--muted); font-size: 0.9rem; }
.pat .p-meta .id { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-ink); }
.pat .p-meta .id a { color: inherit; text-decoration: none; }
.pat .p-meta .id a:hover { text-decoration: underline; text-underline-offset: 2px; }
.pat b { color: var(--ink); }

/* software */
.soft-group { --brand: var(--accent); margin-top: clamp(1.8rem, 4vh, 2.6rem); }
.soft-group:first-of-type { margin-top: 0.4rem; }
.soft-group[data-group="science"] { --brand: #2f57d6; }
.soft-group[data-group="tools"]   { --brand: #0f9d74; }
.soft-group[data-group="games"]   { --brand: #c9711f; }
:root[data-theme="dark"] .soft-group[data-group="science"] { --brand: #8aa0ff; }
:root[data-theme="dark"] .soft-group[data-group="tools"]   { --brand: #43c9a0; }
:root[data-theme="dark"] .soft-group[data-group="games"]   { --brand: #ffab5e; }

.soft-label {
  font-family: var(--font-mono); font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--brand); margin-bottom: 0.7rem;
}
.soft-list { display: grid; gap: 0; }
.soft {
  display: grid; grid-template-columns: 2.75rem 1fr; gap: 1.25rem;
  padding: 1.35rem 0; border-top: 1px solid var(--line); align-items: start;
}
.soft:last-child { border-bottom: 1px solid var(--line); }
.soft-mark {
  width: 2.75rem; height: 2.75rem;
  display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line-2));
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 6%, var(--chip-bg));
  font-family: var(--font-mono); font-weight: 500;
  font-size: 0.72rem; letter-spacing: 0.03em;
  color: var(--brand);
}
.soft-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.3rem 1rem;
}
.soft-name { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; line-height: 1.2; }
.soft-links { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: baseline; }
.soft-links a {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-ink);
  text-decoration: none;
}
.soft-links .sep { font-family: var(--font-mono); font-size: 0.8rem; color: var(--faint); user-select: none; }
.soft-links a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.soft-status {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.02em;
  color: var(--faint);
}
.soft-desc { color: var(--ink-2); font-size: 0.96rem; line-height: 1.5; max-width: 60ch; margin: 0.5rem 0 0.6rem; }
.soft-stack { font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.02em; color: var(--muted); }

@media (max-width: 640px) {
  .soft { grid-template-columns: 2.5rem 1fr; gap: 0.9rem; }
  .soft-head { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
}

/* Cre-on-DNA feature figure, text wraps around the molecule silhouette */
.cre-figure {
  position: relative;
  float: right;
  width: min(40%, 240px);
  margin: 0.1rem 0 0.4rem 1.9rem;
  shape-outside: polygon(48% 2%, 100% 2%, 100% 100%, 38% 100%, 6% 83%, 2% 55%, 4% 40%, 9% 30%, 1% 18%, 20% 9%);
  shape-margin: 14px;
  cursor: help;
  z-index: 2; /* sit above the .reveal-transformed paragraphs so hover registers */
}
.cre-img { display: block; width: 100%; height: auto; pointer-events: none; }
.cre-dark { display: none; }
:root[data-theme="dark"] .cre-light { display: none; }
:root[data-theme="dark"] .cre-dark { display: block; }
@media (max-width: 640px) {
  .cre-figure {
    float: none;
    width: 100%;
    max-width: 260px;
    margin: 0 auto 1.2rem;
    shape-outside: none;
  }
}

/* BLADE 2-input decoder gene circuit (full-width band) */
.blade-figure {
  position: relative;
  float: left;
  width: min(56%, 380px);
  margin: 0.35rem 1.7rem 0.4rem 0;
  color: var(--ink);
  cursor: help;
  z-index: 2; /* sit above the .reveal-transformed paragraphs so hover registers */
  --z0: #ffffff; --z1: #cfcabf; --z2: #7c7768; --z3: #3a362e;
}
:root[data-theme="dark"] .blade-figure {
  --z0: #ece7dc; --z1: #bdb8ab; --z2: #857f70; --z3: #524d42;
}
.blade-figure svg { display: block; width: 100%; height: auto; pointer-events: none; }
/* figure captions are hover tooltips, so they take no vertical space */
.blade-figure figcaption,
.cre-figure figcaption {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(100% + 6px); z-index: 6;
  width: max-content; max-width: 260px;
  margin: 0; padding: 7px 11px;
  background: var(--paper-2); color: var(--ink-2);
  border: 1px solid var(--line-2); border-radius: 9px;
  box-shadow: 0 8px 24px rgba(20, 18, 12, 0.16);
  text-align: center; font-size: 0.8rem; line-height: 1.45;
  opacity: 0; transition: opacity 0.15s ease; pointer-events: none;
}
/* transparent bridge across the gap so hover stays continuous onto the tooltip */
.blade-figure figcaption::before,
.cre-figure figcaption::before {
  content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px;
}
.blade-figure:hover figcaption,
.blade-figure:focus-within figcaption,
.cre-figure:hover figcaption,
.cre-figure:focus-within figcaption { opacity: 1; pointer-events: auto; }
/* lift the whole figure on hover so its caption clears the following text */
.blade-figure:hover, .blade-figure:focus-within,
.cre-figure:hover, .cre-figure:focus-within { z-index: 5; }
.blade-figure figcaption a,
.cre-figure figcaption a {
  color: var(--accent-ink);
  text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px;
}
@media (max-width: 640px) {
  .blade-figure figcaption,
  .cre-figure figcaption {
    position: static; transform: none; width: auto; max-width: 100%;
    background: none; border: none; box-shadow: none; padding: 0;
    color: var(--muted); opacity: 1; pointer-events: auto; margin-top: 0.7rem;
  }
}
.blade-figure .bb  { stroke: currentColor; fill: none; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.blade-figure .bbf { fill: currentColor; }
.blade-figure .frt { fill: var(--accent); }
.blade-figure .cre { fill: currentColor; }
.blade-figure .zbox { stroke: currentColor; stroke-width: 2.5; }
.blade-figure .z0 { fill: var(--z0); }
.blade-figure .z1 { fill: var(--z1); }
.blade-figure .z2 { fill: var(--z2); }
.blade-figure .z3 { fill: var(--z3); }
:root[data-theme="dark"] .blade-figure .z0 { stroke: #a49e91; }
/* the white loxP / lox2272 sites get the same soft grey outline in dark */
:root[data-theme="dark"] .blade-figure .cre { stroke: #a49e91; stroke-width: 1.5; }
.blade-figure .ztd { fill: #17150f; }
.blade-figure .ztl { fill: #f7f5ef; }
.blade-figure .zlab { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 700; }
