/* Understudy: six small wireframes stacked in one floating column on a dark field. Hover (or
   tap) one and it grows in place over its neighbours, wipes to full colour and starts moving.
   Hairlines, square corners, Geist for the wordmark and Geist Mono for the metadata. */

:root {
  --ground: #0A0A0A;
  --plate: #000000;
  --ink: #EDEDED;
  --muted: #8F8F8F;
  --line: #262626;
  --line-strong: #3A3A3A;
  --signal: #FF4F00;
  --sans: "Geist", "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* six equal slots fill the height; a plate at rest is its slot less a gap, at 16:9 */
  --slot: clamp(84px, calc((100svh - 150px) / 6), 150px);
  --ph: calc(var(--slot) - 18px);
  --pw: calc(var(--ph) * 16 / 9);
  --W: min(54vw, 780px, calc((100svh - 200px) * 16 / 9));
  --grow: 600ms;
  --wipe: 460ms;
  --ease: cubic-bezier(.7, 0, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 1px solid var(--signal); outline-offset: 4px; }
.label { font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }

/* ---------- the field */
.field { position: relative; height: 100svh; min-height: 620px; overflow: hidden; }
.corner { position: absolute; z-index: 1; }
.tl { left: 32px; top: 28px; }
.tr { right: 32px; top: 30px; }
.mark { display: inline-flex; align-items: center; gap: 10px; margin: 0; font: 600 13px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; }
.mark svg { width: 16px; height: 16px; }

/* ---------- the stack: six fixed slots; each plate floats in its own */
.stack { list-style: none; margin: 0; padding: 0; position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); }
.slot { position: relative; height: var(--slot); }
.float {
  position: absolute; left: 0; right: 0; margin-inline: auto; width: var(--pw);
  animation: bob var(--bob, 10s) ease-in-out var(--d, 0s) infinite alternate;
  transition: width var(--grow) var(--ease), opacity .35s ease;
}
.float.top { top: 0; }      /* the upper three grow downward */
.float.bot { bottom: 18px; } /* the lower three grow upward */
@keyframes bob { from { transform: translate3d(0, -4px, 0); } to { transform: translate3d(0, 4px, 0); } }
.float.is-open { width: var(--W); z-index: 5; animation-play-state: paused; }
.field.has-open .float:not(.is-open) { opacity: .14; }

.plate-wrap { position: relative; }
.side {
  position: absolute; top: 50%; transform: translateY(-50%); white-space: nowrap;
  font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
}
.side.no { right: calc(100% + 20px); color: var(--muted); }
.side.name { left: calc(100% + 20px); color: var(--ink); }

.plate { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; outline: 1px solid var(--line-strong); cursor: pointer; }
.is-open .plate { background: var(--plate); outline-color: var(--line); }
.layer { position: absolute; inset: 0; }
.layer > img.fill { width: 100%; height: 100%; object-fit: cover; }
.layer > img.contain { object-fit: contain; }

/* at rest: line drawings sit on the ground itself (their black drops out) */
.rest img.lines { mix-blend-mode: screen; opacity: .62; }
.wire { color: var(--muted); }
.wire svg { width: 100%; height: 100%; display: block; }
.wire .hot { stroke: var(--signal); }

/* open: the colour layer wipes in from the left behind a 1px scan line */
.live { clip-path: inset(0 100% 0 0); transition: clip-path var(--wipe) var(--ease) 80ms; }
.is-open .live { clip-path: inset(0 0 0 0); }
.scan { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--signal); opacity: 0; pointer-events: none; z-index: 3; }
.is-open .scan { animation: scan var(--wipe) var(--ease) 80ms forwards; }
@keyframes scan { 0% { left: 0; opacity: 1; } 92% { opacity: 1; } 100% { left: 100%; opacity: 0; } }

/* motion inside an open plate */
.live img.drift { transform-origin: 50% 55%; animation: drift 14s ease-in-out infinite alternate paused; }
.is-open .live img.drift { animation-play-state: running; }
@keyframes drift { from { transform: scale(1); } to { transform: scale(1.075); } }
.strip { position: absolute; inset: 0 auto 0 0; width: 200%; animation: loop var(--dur, 10s) linear infinite paused; will-change: transform; }
.strip img { width: 100%; height: 100%; }
.is-open .live .strip { animation-play-state: running; }
@keyframes loop { to { transform: translateX(-50%); } }
.sim-label { position: absolute; font: 500 10px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; }

/* Brainwave: amber EEG over a density spectral array */
.bw { background: #0B0A08; color: #E5A83B; }
.bw .eeg, .bw-rest .eeg { position: absolute; left: 7%; right: 17%; top: 10%; height: 52%; overflow: hidden; }
.bw .dsa, .bw-rest .dsa { position: absolute; left: 7%; right: 17%; top: 70%; height: 21%; overflow: hidden; }
.bw .eeg { border: 1px solid rgba(229, 168, 59, .55); }
.bw-rest .eeg, .bw-rest .dsa { border: 1px solid var(--line-strong); }
.bw-rest .eeg img { filter: grayscale(1) brightness(1.6); opacity: .55; }
.bw-rest .dsa img { filter: grayscale(1) contrast(.5); opacity: .16; }
.bw .chans { position: absolute; left: 2.4%; top: 10%; height: 52%; display: grid; grid-template-rows: repeat(4, 1fr); align-items: center; }
.bw .index { position: absolute; right: 3%; top: 26%; text-align: right; font-family: var(--mono); }
.bw .index small { display: block; font-size: 10px; letter-spacing: .1em; color: #A8A399; }
.bw .index b { display: block; font-weight: 500; font-size: clamp(24px, 4vw, 56px); line-height: 1; margin-top: 6px; }

/* Tocosim: ten minutes of CTG on green-ruled paper; at rest the same strip, grey on black */
.ctg { background: #FBFDFB; }
.ctg-rest .strip img { filter: invert(1) grayscale(1) brightness(.9); opacity: .6; mix-blend-mode: screen; }

/* DemocraSim 360: its yellow cover page, traced at rest */
.cover { background: #FFE600; }

/* Phage VR at rest: the capsid as a wireframe, turning slowly */
.capsid-rest img { position: absolute; inset: 0; margin: auto; height: 88%; width: auto; aspect-ratio: 1; animation: spin 90s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- the rest of the metadata, under an open plate */
.meta {
  display: none; flex-wrap: wrap; align-items: center; row-gap: 6px; margin: 10px 0 0;
  font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.is-open .meta { display: flex; }
.meta > span { display: inline-flex; align-items: center; gap: 8px; }
.meta > span + span { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--line-strong); }
.meta .go { color: var(--signal); }
.sq { width: 7px; height: 7px; flex: none; border: 1px solid currentColor; }
.sq.on { background: var(--signal); border-color: var(--signal); }
.sq.half { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }

/* ---------- phones: the same stack, scrolling; number and name under each plate; a tap opens it */
@media (max-width: 719px) {
  .field { height: auto; min-height: 100svh; overflow: visible; }
  .tl { left: 16px; top: 26px; }
  .tr { right: 16px; top: 28px; }
  .stack { position: static; transform: none; padding: 92px 0 56px; }
  .slot { height: auto; margin-bottom: 40px; }
  .float, .float.top, .float.bot { position: relative; top: auto; bottom: auto; width: 64vw; }
  .float.is-open { width: calc(100vw - 32px); }
  .plate-wrap { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; }
  .plate { grid-column: 1 / -1; grid-row: 1; }
  .side { position: static; transform: none; grid-row: 2; margin-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .float { animation: none; transition: opacity .2s; }
  .live { transition: none; }
  .is-open .scan { animation: none; }
  .strip, .live img.drift, .capsid-rest img { animation: none !important; }
}
