@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

/* Material Design dark theme: the baseline #121212 surface, its lighter
   elevation overlays, and white text at the standard emphasis levels. */
:root {
  color-scheme: dark;
  --bg: #121212; /* also CONFIG.background in js/main.js */
  --surface-1: #1e1e1e;
  --surface-2: #242424;
  --text: rgba(255, 255, 255, 0.87);
  --text-2: rgba(255, 255, 255, 0.6);
  --text-3: rgba(255, 255, 255, 0.38);
  --line: rgba(255, 255, 255, 0.12);
  --focus: #90caf9;
  --pad: clamp(22px, 3.1vw, 46px);
  --wide: 1080px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue",
    "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(255, 255, 255, 0.2);
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── name ──────────────────────────────────────────────────────────── */

.name {
  margin: 0;
  font-size: clamp(0.98rem, 0.9rem + 0.28vw, 1.16rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.012em;
  font-feature-settings: "ss01", "cv11";
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
}

.role {
  margin: 0.62em 0 0;
  font-size: clamp(0.84rem, 0.79rem + 0.2vw, 0.96rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.004em;
  white-space: nowrap;
  color: #cccccc;
}

/* ── home: two screens, and the page rests on one or the other ─────── */

html.home {
  scroll-snap-type: y mandatory;
}

.hero,
.about {
  scroll-snap-align: start;
}

/* ── home: the scene, behind both screens ──────────────────────────── */

/* Fixed to the viewport; the two screens of the home page scroll over it.
   Sized to the largest viewport so a phone's collapsing toolbar never
   resizes (and so re-allocates) it mid-scroll. */
#scene {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  display: block;
  opacity: 0;
  transition: opacity 1.4s var(--ease);
}

/* ── home: first screen ────────────────────────────────────────────── */

.hero {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100svh;
  min-height: 380px;
}

.is-ready #scene {
  opacity: 1;
}

.masthead {
  position: absolute;
  top: 0;
  left: 0;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad) var(--pad)
    max(var(--pad), env(safe-area-inset-left));
  pointer-events: none;
}

/* pure CSS, so the name is there even if the scene never loads */
.masthead > * {
  pointer-events: auto;
  animation: rise-in 1.8s var(--ease) 0.2s both;
}

.masthead > .role {
  animation-delay: 0.45s;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translate3d(0, 6px, 0);
  }
}

/* loading hairline: only shows if the data takes a moment */
.loader {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 112px;
  height: 1px;
  margin-left: -56px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.is-loading .loader {
  opacity: 1;
  transition-delay: 0.3s;
}

.loader span {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  transform: scaleX(var(--progress, 0));
  transform-origin: 0 50%;
  transition: transform 0.25s ease-out;
}

/* fades in when the opening animation has played (js/main.js adds .is-settled) */
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: max(clamp(14px, 3.2vh, 30px), env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  margin-left: -22px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 1.2s var(--ease),
    color 0.2s ease;
}

.is-settled .scroll-cue {
  opacity: 1;
  pointer-events: auto;
}

.scroll-cue:hover {
  color: var(--text);
}

.scroll-cue svg {
  width: 20px;
  height: 20px;
  animation: nudge 2.6s ease-in-out infinite;
}

@keyframes nudge {
  50% {
    transform: translateY(5px);
  }
}

/* no WebGL: keep the hero dignified */
.is-static .hero {
  background: radial-gradient(120% 90% at 50% 55%, var(--surface-2) 0%, var(--bg) 62%);
}

/* ── home: second screen ───────────────────────────────────────────── */

/* A full screen of its own, over the scene, which turns to its dorsal view
   and dims on the way here (CONFIG.scroll in js/main.js). */
.about {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: center;
  padding: clamp(72px, 13vh, 150px) var(--pad);
}

.about__inner {
  max-width: var(--wide);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: clamp(44px, 8vw, 120px);
  align-items: start;
}

.about__text p {
  margin: 0 0 1.15em;
  max-width: 35em;
  font-size: clamp(1.06rem, 1rem + 0.36vw, 1.3rem);
  line-height: 1.62;
  letter-spacing: -0.006em;
  text-align: justify;
  text-align-last: left;
}

.about__text p:last-child {
  margin-bottom: 0;
}

.pages {
  display: grid;
  border-top: 1px solid var(--line);
}

.pages a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 1.02em 0;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.02rem, 0.98rem + 0.2vw, 1.14rem);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  transition: color 0.2s ease;
}

.pages svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--text-3);
  transition:
    transform 0.35s var(--ease),
    color 0.2s ease;
}

.pages a:hover svg,
.pages a:focus-visible svg {
  transform: translateX(5px);
  color: var(--text);
}

/* Spread across most of the width of the links above, and centred under
   them. The icons sit 12px inside their 44px targets, hence the 24px. */
.socials {
  display: flex;
  justify-content: space-between;
  width: calc(80% + 24px);
  max-width: 100%;
  margin: clamp(26px, 4vh, 40px) auto 0;
  padding: 0;
  list-style: none;
}

.socials a {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text-2);
  transition:
    color 0.2s ease,
    background-color 0.2s ease;
}

.socials a:hover,
.socials a:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.socials svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

@media (max-width: 760px) {
  .about__inner {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── inner pages ───────────────────────────────────────────────────── */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px 32px;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad) 0;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  font-size: 0.95rem;
}

.site-nav a {
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-nav a:hover,
.site-nav a[aria-current] {
  color: var(--text);
}

.page {
  max-width: calc(var(--wide) + 2 * var(--pad));
  margin: 0 auto;
  padding: clamp(48px, 10vh, 104px) var(--pad) clamp(88px, 14vh, 150px);
}

.page h1 {
  margin: 0;
  font-size: clamp(2rem, 1.55rem + 1.9vw, 3rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.028em;
}

.page__note {
  margin: 0.9em 0 0;
  color: var(--text-2);
  font-size: 0.95rem;
}

.page__body,
.page > .empty {
  margin-top: clamp(36px, 6vh, 64px);
}

.empty {
  margin: 0;
  padding: 28px 0;
  border-top: 1px solid var(--line);
  color: var(--text-2);
}

/* ── publications and projects ─────────────────────────────────────── */

.pubs {
  position: relative; /* the projects beside the list, and their lines, are placed against it */
  --media: 15rem; /* a project's picture or loop, in the column to the right of the list */
  --gap: 3rem;
  --line-to: rgba(255, 255, 255, 0.3); /* outlines, and the line from a citation to its project */
  --line-lit: rgba(255, 255, 255, 0.62);
}

.pubs__year {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  padding: 30px 0 6px;
  border-top: 1px solid var(--line);
}

.pubs__year h2 {
  margin: 0.14em 0 0;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.pubs__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pub {
  margin: 0 0 26px;
  max-width: 46em;
}

.pub__title {
  font-size: 1.08rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.008em;
  text-decoration: none;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

.pub__title:hover {
  text-decoration: underline;
}

.pub__meta {
  margin: 0.38em 0 0;
  font-size: 0.93rem;
  line-height: 1.5;
  color: var(--text-2);
}

.pub__meta strong {
  font-weight: 500;
  color: var(--text);
}

.pub__meta em {
  font-style: italic;
}

.pubs__body {
  min-width: 0;
}

/* Projects: pictures or loops. On a narrow page, one that goes with a
   publication sits under its citation, and a year's other projects follow
   that year's publications as a grid, names beneath. */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: 22px 16px;
  margin: 4px 0 30px;
}

.project {
  display: block;
  text-decoration: none;
}

.project--linked {
  width: min(100%, 20rem);
  margin-top: 14px;
}

.project--linked .project__name {
  display: none; /* its citation, or the line to it, says what it is */
}

.project__frame {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--line-to);
  transition:
    box-shadow 0.25s ease,
    filter 0.25s ease;
}

.project__frame img,
.project__frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* a cut-out, or any picture marked "fit": "contain": whole, on black */
.project--contain .project__frame {
  background: #000;
}

.project--contain .project__frame img,
.project--contain .project__frame video {
  box-sizing: border-box;
  padding: 7px;
  object-fit: contain;
}

.project__name {
  display: block;
  margin-top: 10px;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text-2);
  transition: color 0.2s ease;
}

a.project:hover .project__frame,
a.project:focus-visible .project__frame {
  filter: brightness(1.1);
}

.project:hover .project__frame,
.project:focus-visible .project__frame,
.project.is-lit .project__frame {
  box-shadow: 0 0 0 1px var(--line-lit);
}

a.project:hover .project__name,
a.project:focus-visible .project__name {
  color: var(--text);
}

.pubs__lines {
  display: none; /* wide pages only */
}

@media (min-width: 900px) {
  /* every citation leaves the right-hand column to the projects */
  .pubs--projects .pub {
    max-width: min(46em, calc(100% - var(--media) - var(--gap)));
  }

  /* each stands beside its year, at the height publications.js works out (--top) */
  .projects {
    display: contents;
  }

  .project {
    position: absolute;
    top: var(--top, 0);
    right: 0;
    width: var(--media);
    margin: 0;
  }

  /* the name of a project on its own: over the foot of the picture, on hover */
  .project__name {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    margin: 0;
    padding: 26px 12px 9px;
    border-radius: 0 0 6px 6px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.86), rgba(0, 0, 0, 0));
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
  }

  .project:hover .project__name,
  .project:focus-visible .project__name {
    opacity: 1;
  }

  /* the lines: under a citation, across the gap, into its project's outline */
  .pubs__lines {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: visible;
    pointer-events: none;
  }

  .pubs__lines path {
    fill: none;
    stroke: var(--line-to);
    stroke-width: 1;
    stroke-linejoin: round;
    transition: stroke 0.25s ease;
  }

  .pubs__lines path.is-lit {
    stroke: var(--line-lit);
  }
}

/* nothing to hover with (a tablet held sideways): the names stay on */
@media (min-width: 900px) and (hover: none) {
  .project__name {
    opacity: 1;
  }
}

@media (max-width: 560px) {
  .pubs__year {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
}

/* ── gallery: posters and journal covers ───────────────────────────── */

/* Rows of cards of one height, whatever their shapes: each card's share of a
   row is its width-to-height ratio (--ar, set per card), so a wide poster
   and an upright cover line up side by side. */
.gallery {
  --row: clamp(150px, 22vw, 280px); /* the height a row aims for; rows grow from it to fill the width */
  --stretch: 2; /* how far past that a card alone on a row may grow */
  display: flex;
  flex-wrap: wrap;
  gap: clamp(26px, 3.6vw, 44px) clamp(22px, 3vw, 36px);
  align-items: flex-start;
}

.card {
  display: block;
  flex: var(--ar, 1) 1 calc(var(--ar, 1) * var(--row));
  min-width: 0;
  max-width: min(100%, calc(var(--ar, 1) * var(--row) * var(--stretch)));
  text-decoration: none;
}

@media (min-width: 700px) {
  .gallery {
    --stretch: 1.4; /* not much taller than a full row */
  }
}

/* the still frame the pointer is measured against; the face tilts inside it */
.card__frame {
  display: block;
  perspective: 1100px;
}

.card__face {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-1);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--lift, 1));
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 4px 14px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.7s var(--ease),
    box-shadow 0.4s ease;
  will-change: transform;
}

.card.is-tilting .card__face {
  transition-duration: 0.14s, 0.4s; /* follow the pointer closely, settle slowly */
}

.card:hover .card__face,
.card:focus-visible .card__face {
  --lift: 1.025;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.4),
    0 22px 48px rgba(0, 0, 0, 0.5);
}

.card__face img {
  display: block;
  width: 100%;
  height: auto;
}

/* a soft highlight that follows the pointer */
.card__face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--gx, 50%) var(--gy, 50%),
    rgba(255, 255, 255, 0.09),
    rgba(255, 255, 255, 0) 58%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.card.is-tilting .card__face::after {
  opacity: 1;
}

.card__title {
  display: block;
  margin-top: 14px;
  font-size: 0.93rem;
  line-height: 1.4;
  color: var(--text-2);
  transition: color 0.2s ease;
}

.card:hover .card__title,
.card:focus-visible .card__title {
  color: var(--text);
}

/* full-size view */
.lightbox {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.88);
}

.lightbox figure {
  height: 100%;
  margin: 0;
  padding: clamp(14px, 3vmin, 34px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  justify-items: center;
  cursor: zoom-out;
}

.lightbox img {
  width: auto; /* keep the image's own proportions inside the limits below */
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  align-self: center;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
}

.lightbox figcaption {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 22px;
  font-size: 0.93rem;
  color: var(--text-2);
  cursor: default;
}

.lightbox figcaption a,
.lightbox figcaption button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--text-3);
  cursor: pointer;
}

/* ── motion preferences ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  #scene,
  .loader,
  .loader span,
  .card__face {
    transition-duration: 0.01s;
    transition-delay: 0s;
  }

  .masthead > *,
  .scroll-cue svg {
    animation: none;
  }
}
