/* ===== type =====
   IM Fell: revivals of the 17th-century Fell types (Oxford), cut in the same decades
   Robert Hooke named the "cell" in Micrographia (1665). Display + text sizes.
   Atkinson Hyperlegible Next / Mono: Braille Institute's legibility-first family,
   for reading text and the microscope read-outs. All self-hosted, SIL OFL. */
@font-face { font-family: 'Fell Canon'; src: url(fonts/fell-canon.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Fell Canon'; src: url(fonts/fell-canon-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Fell English'; src: url(fonts/fell-english.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Fell English'; src: url(fonts/fell-english-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url(fonts/atkinson-next.woff2) format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url(fonts/atkinson-next-italic.woff2) format('woff2'); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: 'Atkinson Mono'; src: url(fonts/atkinson-mono.woff2) format('woff2'); font-weight: 200 800; font-style: normal; font-display: swap; }

/* ===== tokens ===== */
:root {
  color-scheme: dark;
  --bg: #03050a;
  --bg-2: #080c16;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --ink: #e8edf6;
  --ink-2: #b7c1d3;
  --muted: #7f8aa0;
  --nuc: #6f93ff; --mito: #ff5b4f; --er: #3ddc84; --golgi: #ffc845;
  --lyso: #ff4fd2; --centro: #3fe3ea; --mem: #b49cff;
  --c: var(--mem);
  --veil: var(--bg);
  --display: 'Fell Canon', 'Fell English', Georgia, serif;
  --serif: 'Fell English', Georgia, serif;
  --sans: 'Atkinson Next', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Atkinson Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --gutter: clamp(16px, 4vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before { /* faint camera noise / vignette */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1200px 800px at 70% 40%, rgba(80, 90, 160, 0.10), transparent 60%),
    radial-gradient(900px 700px at 10% 90%, rgba(180, 156, 255, 0.06), transparent 60%);
}
a { color: inherit; }
img { max-width: 100%; display: block; }
.mono { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.04em; }
:focus-visible { outline: 2px solid var(--c); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== home ===== */
.stage {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  grid-template-areas: "intro scope" "legend scope";
  grid-template-rows: auto 1fr;
  gap: 8px clamp(24px, 4vw, 64px);
  padding: clamp(24px, 4vh, 48px) var(--gutter);
  max-width: 1440px; margin: 0 auto;
  align-items: center;
}
.intro { grid-area: intro; align-self: end; transition: opacity .3s; }
.kicker { color: var(--muted); text-transform: uppercase; margin: 0 0 18px; }
.kicker em { font-style: italic; text-transform: none; }
.intro h1 {
  font: 400 clamp(2.7rem, 5.2vw, 4.3rem)/0.98 var(--display); margin: 0 0 18px;
}
.role { color: var(--ink); margin: 0 0 14px; font-weight: 500; }
.role span { color: var(--muted); font-weight: 400; font-size: 0.92em; }
.lede { color: var(--ink-2); margin: 0 0 22px; max-width: 34ch; }

.specimen-card {
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 14px; padding: 14px 16px;
  height: 142px; overflow: hidden; /* fixed, so changing text never reflows the page */
}
.sc-head { display: flex; align-items: center; gap: 10px; color: var(--ink); text-transform: uppercase; }
.sc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 10px currentColor; transition: background .2s; }
.specimen-card p { margin: 8px 0 0; color: var(--ink-2); font-size: 0.95rem; }

.scope { grid-area: scope; margin: 0; position: relative; justify-self: center; width: min(100%, 88vh); }
.cell { width: 100%; height: auto; aspect-ratio: 1; display: block; overflow: visible; touch-action: manipulation; }
.hud {
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--muted); text-transform: uppercase; pointer-events: none;
}
.hud-top { margin-bottom: 4px; }
.hud-bottom { margin-top: 4px; align-items: center; }
#hud-coord, .scalebar { text-transform: none; }
.scalebar { display: inline-flex; align-items: center; gap: 8px; }
.scalebar i { display: inline-block; height: 3px; width: 80px; background: var(--ink); border-radius: 2px; }

/* svg interactivity */
.cell .deco, .cell .labels text { pointer-events: none; }
.hit { fill: transparent; stroke: none; }
.hero-art .hit { display: none; }
.cell .hit-stroke { fill: none; stroke: transparent; stroke-width: 34; pointer-events: stroke; }
.cell .org, .cell .lab { cursor: pointer; transition: opacity .35s ease, filter .35s ease; outline: none; }
.cell.has-active .org:not(.is-active),
.cell.has-active .lab:not(.is-active) { opacity: 0.22; }
.cell .org.is-active { filter: drop-shadow(0 0 10px currentColor) brightness(1.15); }
.lab-pill { fill: rgba(3, 5, 10, 0.72); stroke: currentColor; stroke-opacity: .55; stroke-width: 1.5; }
.lab.is-active .lab-pill { fill: rgba(3, 5, 10, 0.9); stroke-opacity: 1; }
.lab-org { font: 500 15px var(--mono); letter-spacing: .08em; fill: currentColor; }
.lab-page { font: 400 28px var(--serif); fill: #fff; }
.drift { animation: drift 9s ease-in-out infinite alternate; }
.drift.d1 { animation-duration: 11s; animation-delay: -3s; }
.drift.d2 { animation-duration: 8s; animation-delay: -5s; }
.drift.d3 { animation-duration: 12s; animation-delay: -1s; }
.drift.d4 { animation-duration: 10s; animation-delay: -7s; }
@keyframes drift { from { transform: translate(-4px, 3px); } to { transform: translate(5px, -4px); } }

.legend { grid-area: legend; align-self: start; }
.legend ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.legend a {
  --c: var(--mem);
  display: grid; grid-template-columns: 26px 1fr auto; align-items: baseline; gap: 10px;
  padding: 9px 10px; border-radius: 10px; text-decoration: none;
  border: 1px solid transparent; transition: background .2s, border-color .2s, opacity .2s;
}
.legend .n { color: var(--c); }
.legend .on { color: var(--muted); text-transform: uppercase; font-size: .7rem; }
.legend .pg { font: 400 1.35rem/1.1 var(--serif); }
.legend a:hover, .legend a.is-active { background: var(--panel); border-color: color-mix(in srgb, var(--c) 40%, transparent); }
body.has-active .legend a:not(.is-active) { opacity: .45; }

.zoom-veil {
  position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--veil) 22%, var(--bg)) 0%, var(--bg) 70%);
  transition: opacity .35s ease .5s;
}
body.zooming .zoom-veil { opacity: 1; }
body.zooming .intro, body.zooming .legend, body.zooming .hud { opacity: 0; transition: opacity .3s; }
.cell.zooming .labels { opacity: 0; transition: opacity .2s; }

@media (max-width: 860px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "intro" "scope" "legend";
    grid-template-rows: auto;
    align-items: start; gap: 20px; padding-top: 28px;
  }
  .intro { align-self: start; }
  .intro h1 br { display: none; }
  .scope { width: 100%; max-width: 620px; }
  .legend ol { grid-template-columns: 1fr 1fr; gap: 6px; }
  .legend a { grid-template-columns: 22px 1fr; border-color: var(--line); background: var(--panel); }
  .legend .on { grid-column: 2; order: 3; }
  .legend .pg { grid-column: 2; font-size: 1.2rem; }
  .specimen-card { display: none; }
}
@media (max-width: 720px) {
  .lab-org { display: none; }
  .lab-page { font-size: 42px; }
}
@media (max-width: 340px) {
  .legend ol { grid-template-columns: 1fr; }
}

/* ===== inner pages ===== */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 18px;
  padding: 12px var(--gutter);
  background: rgba(3, 5, 10, 0.78);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.home-link { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; flex: none; font-weight: 500; }
.home-link svg { width: 30px; height: 30px; }
.home-link span { white-space: nowrap; }
.onav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-left: auto; min-width: 0; }
.onav::-webkit-scrollbar { display: none; }
.onav a {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 6px 11px; border-radius: 999px; text-decoration: none; font-size: .88rem; color: var(--ink-2);
  border: 1px solid transparent; transition: background .2s, color .2s;
}
.onav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); flex: none; }
.onav a:hover { background: var(--panel-2); color: var(--ink); }
.onav a.current { color: var(--ink); border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 10%, transparent); }

.sheet { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 0 var(--gutter) 40px; animation: focus-in .7s ease-out both; }
@keyframes focus-in { from { opacity: 0; filter: blur(10px); transform: scale(1.03); } to { opacity: 1; filter: none; transform: none; } }

.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center;
  gap: clamp(16px, 4vw, 48px); padding: clamp(32px, 7vh, 72px) 0 clamp(24px, 4vh, 40px);
  border-bottom: 1px solid var(--line);
}
.hero .kicker { color: var(--c); margin-bottom: 12px; }
.hero h1 { font: 400 clamp(2.8rem, 7vw, 5rem)/1 var(--display); margin: 0 0 16px; }
.hero .fn { color: var(--ink-2); margin: 0; max-width: 42ch; font-size: 1.05rem; }
.hero-art { width: 100%; max-height: 320px; overflow: visible; animation: float 10s ease-in-out infinite alternate; }
@keyframes float { from { transform: translateY(-4px) rotate(-0.6deg); } to { transform: translateY(5px) rotate(0.6deg); } }

.content { max-width: 760px; padding-top: 36px; }
.content > p, .content li { color: var(--ink-2); }
.content p { margin: 0 0 1.1em; }
.content strong { color: var(--ink); font-weight: 600; }
.content a { color: var(--ink); text-decoration-color: color-mix(in srgb, var(--c) 70%, transparent); text-underline-offset: 3px; }
.content a:hover { color: var(--c); }
.section-h { display: flex; align-items: baseline; gap: 12px; margin: 48px 0 16px; }
.section-h h2 { font: 400 2rem/1.1 var(--display); margin: 0; }
.section-h .mono { color: var(--c); }
.content > .section-h:first-child { margin-top: 8px; }

.pull {
  margin: 28px 0; padding: 4px 0 4px 22px; border-left: 2px solid var(--c);
  font: italic 400 clamp(1.3rem, 2.6vw, 1.6rem)/1.35 var(--serif); color: var(--ink);
}
.card {
  border: 1px solid var(--line); background: var(--panel); border-radius: 16px;
  padding: 20px 22px; margin: 0 0 14px;
}
.card h3 { margin: 0 0 6px; font-size: 1.08rem; font-weight: 600; color: var(--ink); }
.card .meta { color: var(--c); text-transform: uppercase; display: block; margin-bottom: 8px; }
.card p { margin: 0 0 .6em; color: var(--ink-2); }
.card ul { margin: 6px 0 0; padding-left: 1.1em; color: var(--ink-2); }
.card li { margin: 3px 0; }
.card li::marker { color: var(--c); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-2 .card { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chips li, .chip {
  font: 500 .8rem var(--mono); color: var(--ink-2); padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
}
button.chip { cursor: pointer; }
button.chip[aria-pressed="true"] { color: var(--bg); background: var(--c); border-color: var(--c); }

/* about */
.about-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; align-items: start; }
.portrait { position: relative; margin: 0; }
.portrait img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; object-position: 50% 28%; border-radius: 50%; border: 3px solid var(--nuc); box-shadow: 0 0 0 8px rgba(111, 147, 255, 0.12), 0 0 40px rgba(111, 147, 255, 0.35); }
.facts { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; font-size: .92rem; }
.facts li { display: grid; gap: 2px; color: var(--ink); }
.facts .mono { color: var(--muted); text-transform: uppercase; font-size: .7rem; }

/* timeline (news + cv) */
.timeline { list-style: none; margin: 0; padding: 0 0 0 28px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--c), color-mix(in srgb, var(--c) 10%, transparent)); border-radius: 2px; }
.timeline > li { position: relative; margin: 0 0 22px; }
.timeline > li::before {
  content: ''; position: absolute; left: -27px; top: 6px; width: 14px; height: 14px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 30%, var(--bg)); border: 2px solid var(--c); box-shadow: 0 0 12px var(--c);
}
.timeline .when { color: var(--c); text-transform: uppercase; display: block; }
.timeline h3 { margin: 2px 0 4px; font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.timeline p { margin: 0; color: var(--ink-2); }

/* publications */
.pubs { list-style: none; margin: 0; padding: 0; counter-reset: pub; }
.pub { padding: 18px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 4px 12px; }
.pub::before { counter-increment: pub; content: counter(pub, decimal-leading-zero); font: 500 .8rem var(--mono); color: var(--c); padding-top: 4px; }
.pub[hidden] { display: none; }
.pub .t { font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1.4; }
.pub a.t:hover { color: var(--c); }
.pub .au { color: var(--muted); font-size: .9rem; margin: 4px 0 2px; }
.pub .au b { color: var(--ink); font-weight: 600; }
.pub .j { color: var(--ink-2); font-size: .92rem; }
.pub .j em { color: var(--ink); }
.badge { display: inline-block; font: 500 .68rem var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); color: var(--c); margin-left: 6px; vertical-align: 2px; }
.pub > div { grid-column: 2; }

.btn {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  padding: 12px 18px; border-radius: 12px; font-weight: 600;
  background: var(--c); color: var(--bg) !important;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--ink) !important; border: 1px solid var(--line); }

.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.contact-list a.card { display: grid; grid-template-columns: 1fr auto; align-items: center; text-decoration: none; margin: 0; transition: border-color .2s, background .2s; }
.contact-list a.card:hover { border-color: color-mix(in srgb, var(--c) 55%, transparent); background: var(--panel-2); color: var(--ink); }
.contact-list .arrow { color: var(--c); font-size: 1.3rem; }

.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px;
  margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem;
}
.foot a[data-next] { display: grid; gap: 2px; text-decoration: none; }
.foot a[data-next] .mono { color: var(--muted); text-transform: uppercase; }
.foot a[data-next] strong { font: 400 1.4rem var(--serif); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
  .home-link span { font-size: .95rem; }
  .onav { order: 3; width: 100%; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); flex: 1 0 100%; }
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 28px; }
  .hero-art { order: -1; max-height: 190px; }
  .about-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .portrait { max-width: 180px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .pub { grid-template-columns: 36px minmax(0, 1fr); }
}

/* ===== microscope intro (home) ===== */
.intro-screen { display: none; }
html.intro body { overflow: hidden; }
html.intro .intro-screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 2vh, 20px); padding: 24px 16px; text-align: center;
  background: radial-gradient(900px 640px at 50% 38%, #0d1426 0%, var(--bg) 70%);
  transition: background .6s ease;
}
.scope-art {
  height: min(56vh, 500px); width: auto; max-width: 94vw; overflow: visible; cursor: pointer;
  transition: transform .95s cubic-bezier(.55, 0, .85, .35), opacity .35s ease .6s;
}
.scope-lens { transition: filter .25s ease; }
.scope-art:hover .scope-lens, .scope-enter:hover ~ * .scope-lens { filter: drop-shadow(0 0 6px #3fe3ea) brightness(1.4); }
.scope-halo, .scope-beam { animation: lamp 3.2s ease-in-out infinite alternate; }
.scope-led { animation: led 2.4s ease-in-out infinite; }
.scope-lasers { animation: lasers 2.6s ease-in-out infinite alternate; }
@keyframes lasers { from { opacity: .7; } to { opacity: 1; } }
.scope-led.l2 { animation-delay: -.6s; } .scope-led.l3 { animation-delay: -1.2s; } .scope-led.l4 { animation-delay: -1.8s; }
@keyframes led { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.scope-specimen { animation: specimen 4s ease-in-out infinite alternate; }
@keyframes lamp { from { opacity: .75; } to { opacity: 1; } }
@keyframes specimen { from { opacity: .7; } to { opacity: 1; } }
.intro-copy { transition: opacity .3s ease; }
.intro-copy .kicker { margin: 0 0 6px; }
.intro-name { font: 400 clamp(2rem, 5vw, 3.2rem)/1 var(--display); margin: 0 0 18px; color: var(--ink); }
.scope-enter {
  font: 400 1.25rem/1 var(--serif); color: var(--ink); cursor: pointer;
  padding: 13px 26px; border-radius: 999px; border: 1px solid rgba(63, 227, 234, .45);
  background: rgba(63, 227, 234, .06); transition: background .2s, box-shadow .2s, border-color .2s;
}
.scope-enter:hover, .scope-enter:focus-visible { background: rgba(63, 227, 234, .14); border-color: #3fe3ea; box-shadow: 0 0 24px rgba(63, 227, 234, .35); outline: none; }
.intro-hint { color: var(--muted); margin: 10px 0 0; }
@media (hover: none) { .intro-hint { display: none; } }

.intro-screen.entering { background: var(--bg); }
.intro-screen.entering .intro-copy { opacity: 0; }
.intro-screen.entering .scope-art { transform: scale(var(--zoom, 12)); opacity: 0; }
.stage.revealing {
  z-index: 50; background: var(--bg);
  clip-path: circle(0 at var(--rx) var(--ry));
  filter: blur(14px); transform: scale(1.18); transform-origin: var(--rx) var(--ry);
}
.stage.revealing.open {
  clip-path: circle(var(--rr) at var(--rx) var(--ry)); filter: blur(0); transform: none;
  transition: clip-path .95s cubic-bezier(.3, 0, .2, 1), filter 1.1s ease-out .1s, transform 1.15s cubic-bezier(.2, .7, .2, 1);
}

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