@property --lens {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}

:root {
  --bg: #0a0a0b;
  --bg-2: #111113;
  --ink: #e8e8e6;
  --ink-2: #a3a3a0;
  --ink-3: #5f5f5d;
  --line: #262628;
  --film-hi: #f4f4f2;
  --film-mid: #8d8d8a;
  --film-glow: rgba(244, 244, 242, 0.35);
  --bone: #d9d9d6;
  --grid: rgba(232, 232, 230, 0.07);
  --grain-opacity: 0.11;

  --serif: 'Instrument Serif', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'Archivo', system-ui, sans-serif;

  --gutter: clamp(16px, 4vw, 56px);
  --contrast: 1;
  --brightness: 1;
  --mx: 50%;
  --my: 50%;
  --lens: 0px;
}

:root[data-theme='light'] {
  --bg: #ecebe8;
  --bg-2: #e2e1dd;
  --ink: #141414;
  --ink-2: #4c4c4a;
  --ink-3: #8a8a87;
  --line: #cdccc8;
  --film-hi: #101010;
  --film-mid: #6b6b69;
  --film-glow: rgba(16, 16, 16, 0.22);
  --bone: #262626;
  --grid: rgba(20, 20, 20, 0.07);
  --grain-opacity: 0.08;
}

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

html { background: var(--bg); scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.5s, color 0.5s;
}

a { color: inherit; }

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

/* ---------- Overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg);
}
/* Fade content out beneath the corner annotations */
.overlay::before, .overlay::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 96px;
}
.overlay::before { top: 0; background: linear-gradient(var(--bg) 45%, transparent); }
.overlay::after { bottom: 0; background: linear-gradient(transparent, var(--bg) 55%); }

.ov {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 18px var(--gutter);
  z-index: 1;
}
.ov b { color: var(--ink); font-weight: 500; }
.ov-tl { top: 0; left: 0; }
.ov-tr { top: 0; right: 0; text-align: right; }
.ov-bl { bottom: 0; left: 0; }
.ov-br { bottom: 0; right: 0; text-align: right; }

.inv {
  position: fixed;
  z-index: 21;
  right: var(--gutter);
  bottom: 62px;
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.1em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink-3);
  border-radius: 999px;
  padding: 7px 11px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.inv:hover, .inv:focus-visible { border-color: var(--ink); outline: none; }
.inv[aria-pressed='true'] { background: var(--ink); color: var(--bg); }

/* ---------- Hero / film ---------- */

.hero {
  position: relative;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: pan-y;
  user-select: none;
}

.film {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, var(--bg-2) 0%, var(--bg) 75%);
}
/* Windowing acts on the whole film, like a real PACS viewer */
.film {
  filter: contrast(var(--contrast)) brightness(var(--brightness));
  transition: filter 0.45s cubic-bezier(.2,.7,.2,1);
}
.film.dragging { transition: none; }
.surface { filter: drop-shadow(0 0 28px var(--film-glow)); }

.layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.name {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--sans);
  font-weight: 800;
  font-variation-settings: 'wdth' 62;
  text-transform: uppercase;
  line-height: 0.82;
  letter-spacing: -0.01em;
  font-size: min(clamp(64px, 17vw, 300px), 24svh);
  text-align: center;
}

.surface .name {
  color: transparent;
  background: radial-gradient(ellipse 60% 70% at 50% 45%, var(--film-hi) 0%, var(--film-mid) 70%, var(--ink-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  animation: expose 2.2s cubic-bezier(.2,.7,.2,1) both;
}
.surface .name span:last-child { font-size: 0.62em; letter-spacing: 0.01em; }

@keyframes expose {
  from { opacity: 0; filter: blur(18px) drop-shadow(0 0 0 transparent); transform: scale(1.04); }
  to   { opacity: 1; }
}

/* X-ray layer, revealed only through the lens */
.xray {
  background: var(--bg);
  -webkit-mask-image: radial-gradient(circle var(--lens) at var(--mx) var(--my), #000 0 96%, transparent 100%);
          mask-image: radial-gradient(circle var(--lens) at var(--mx) var(--my), #000 0 96%, transparent 100%);
  transition: --lens 0.3s;
}
.name-bones {
  color: transparent;
  -webkit-text-stroke: 1.2px var(--bone);
}
.name-bones span:last-child { font-size: 0.62em; letter-spacing: 0.01em; }

.grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center;
}

/* aka + caliper hang off the name itself, so they track its size */
.bones { position: relative; }
.caliper {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 14px);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--bone);
  text-align: center;
}
.caliper i {
  display: block;
  height: 9px;
  border: 1px solid var(--bone);
  border-top: 0;
  margin-bottom: 8px;
}
.caliper em { font-style: normal; letter-spacing: 0.08em; }
.caliper em::before { content: 'Dist: '; color: var(--ink-3); }

.aka {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 2.2vw, 30px);
  color: var(--ink-2);
  white-space: nowrap;
}
.aka b { font-family: var(--mono); font-style: normal; font-weight: 500; color: var(--bone); font-size: 0.8em; }

/* Film grain */
.grain {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: var(--grain-opacity);
  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='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
:root[data-theme='light'] .grain { filter: invert(1); }
@keyframes grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3%, 2%); }
  50%  { transform: translate(2%, -3%); }
  75%  { transform: translate(-2%, -1%); }
  100% { transform: translate(0, 0); }
}

.presets {
  position: absolute;
  left: 50%;
  bottom: clamp(84px, 12vh, 120px);
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 3;
}
.presets button {
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}
.presets button:hover, .presets button:focus-visible { color: var(--ink); border-color: var(--ink-3); outline: none; }
.presets button.on { color: var(--bg); background: var(--ink); border-color: var(--ink); }

.hint {
  position: absolute;
  left: 50%;
  bottom: clamp(56px, 8vh, 84px);
  transform: translateX(-50%);
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-3);
  z-index: 3;
}

/* ---------- Report sections ---------- */

.block {
  position: relative;
  padding: clamp(96px, 16vh, 180px) var(--gutter);
  max-width: 1320px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
}

.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: clamp(28px, 5vh, 56px);
}

.lede {
  font-family: var(--serif);
  font-size: clamp(38px, 6.4vw, 96px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  max-width: 15ch;
}
.lede em { color: var(--ink-2); }

.about-top {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 340px);
  gap: clamp(32px, 6vw, 96px);
  align-items: end;
}

/* Portrait as a scout image: line art tinted by the theme ink */
.scout { margin: 0; }
.scout-frame {
  position: relative;
  aspect-ratio: 520 / 740;
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg-2);
  overflow: hidden;
}
.scout-frame::before, .scout-frame::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--ink-2);
  z-index: 2;
}
.scout-frame::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.scout-frame::after { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }
.portrait {
  position: absolute;
  inset: 6% 4% 0;
  background: var(--ink);
  -webkit-mask: url('img/portrait.png') center bottom / contain no-repeat;
          mask: url('img/portrait.png') center bottom / contain no-repeat;
}
.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--ink);
  box-shadow: 0 0 18px 2px var(--film-glow);
  opacity: 0;
}
.scout figcaption {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Acquisition: the scan line sweeps down and exposes the portrait */
.scout.reveal { opacity: 1; transform: none; }
.scout.reveal .portrait { clip-path: inset(0 0 100% 0); }
.scout.reveal.in .portrait { animation: acquire 1.8s cubic-bezier(.45,.05,.35,1) 0.2s forwards; }
.scout.reveal.in .scan-line { animation: sweep 1.8s cubic-bezier(.45,.05,.35,1) 0.2s forwards; }
@keyframes acquire { to { clip-path: inset(0 0 0 0); } }
@keyframes sweep {
  0% { top: 0; opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(20px, 3vw, 48px);
  margin-top: clamp(48px, 8vh, 96px);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-2);
}
.cols p { border-top: 1px solid var(--line); padding-top: 16px; }

/* Findings */
.finding {
  display: grid;
  grid-template-columns: 64px minmax(160px, 1fr) 2fr auto;
  gap: clamp(16px, 3vw, 40px);
  align-items: baseline;
  padding: 32px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  position: relative;
}
.finding:last-child { border-bottom: 1px solid var(--line); }
.f-no { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.f-title {
  font-weight: 700;
  font-variation-settings: 'wdth' 70;
  text-transform: uppercase;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 0.95;
}
.f-body { color: var(--ink-2); font-size: 17px; line-height: 1.5; max-width: 52ch; }
.f-body i { font-family: var(--serif); font-size: 1.15em; color: var(--ink); }
.talk { display: block; }
.talk + .talk { margin-top: 12px; }
.talk b { display: block; color: var(--ink); font-weight: 500; }
.f-go { font-family: var(--mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }

a.finding::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.5s cubic-bezier(.2,.7,.2,1);
  z-index: -1;
}
a.finding { isolation: isolate; transition: color 0.4s; }
a.finding:hover, a.finding:focus-visible { outline: none; }
a.finding:hover::after, a.finding:focus-visible::after { transform: scaleY(1); }
a.finding:hover *, a.finding:focus-visible * { color: var(--bg); }

/* Prior studies */
.study-list { list-style: none; font-size: 17px; }
.study-list li {
  display: grid;
  grid-template-columns: 120px 1fr 1fr;
  gap: clamp(16px, 3vw, 40px);
  padding: 18px 0;
  border-top: 1px solid var(--line);
  transition: padding 0.3s, color 0.3s;
  color: var(--ink-2);
}
.study-list li:last-child { border-bottom: 1px solid var(--line); }
.study-list li:hover { color: var(--ink); padding-left: 12px; }
.study-list time { font-family: var(--mono); font-size: 13px; color: var(--ink-3); padding-top: 3px; }
.study-list li span:nth-child(2) { color: var(--ink); }

/* Conclusion */
.links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 48px; }
.links a {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-decoration: none;
  padding: 14px 20px;
  border: 1px solid var(--ink-3);
  border-radius: 999px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.links a:hover, .links a:focus-visible { background: var(--ink); color: var(--bg); border-color: var(--ink); outline: none; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: clamp(96px, 16vh, 180px);
  padding-bottom: 48px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.9s, transform 0.9s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .ov { font-size: 10px; padding: 14px 16px; }
  .ov-tr span:nth-child(2) { display: none; }
  .inv { right: 16px; bottom: 56px; }
  .hero { cursor: default; }
  .presets { flex-wrap: wrap; justify-content: center; width: calc(100% - 32px); bottom: 92px; }
  .hint { display: none; }
  .cols { grid-template-columns: 1fr; }
  .about-top { grid-template-columns: 1fr; }
  .scout { width: min(240px, 70%); }
  .finding { grid-template-columns: 1fr; gap: 12px; padding: 28px 0; }
  .study-list li { grid-template-columns: 1fr; gap: 4px; }
  .study-list li:hover { padding-left: 0; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  .scout.reveal .portrait { clip-path: none; }
  html { scroll-behavior: auto; }
}
