:root {
  --void: #050405;
  --blush: #f2dcdc;
  --bone: #cdc2c3;
  --ash: #8a8385;
  --signal: #e5343f;
  --signal-deep: #cf2733;
  --ember: rgba(150, 18, 32, 0.42);
  --warn: #ff9097;
  --line: rgba(242, 220, 220, 0.055);
  --edge: rgba(242, 220, 220, 0.18);

  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --gutter: clamp(1.25rem, 5vw, 3.5rem);

  /* Film grain: grayscale fractal noise, tiled over everything. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  color-scheme: dark;
}

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

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--void);
  color: var(--bone);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Grain sits on top of everything, text included, like the banner and avatar. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background-image: var(--grain);
  background-size: 240px;
  opacity: 0.1;
}

a {
  color: inherit;
}

::selection {
  background: var(--signal);
  color: #fff;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

/* `isolation` makes .page the group the photo's `lighten` blend happens in, so .page
   needs its own opaque background. Without it the photo blends against the
   mostly transparent glow layer and its black backdrop shows as a dark box. */
.page {
  position: relative;
  isolation: isolate;
  background: var(--void);
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  width: min(100% - 2 * var(--gutter), 76rem);
  margin-inline: auto;
  padding-block: clamp(3rem, 9vh, 6rem) 2rem;
}

/* ---------- Copy ---------- */

.copy {
  max-width: 34rem;
}

.wordmark {
  margin: 0 0 2.25rem;
  color: var(--blush);
  font-size: clamp(3.75rem, 2.2rem + 6vw, 7.5rem);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: 'opsz' 72;
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.pitch {
  max-width: 38ch;
  text-wrap: pretty;
  margin: 0 0 2rem;
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  line-height: 1.6;
}

/* ---------- Form ---------- */

/* Reserves the form's height so the column doesn't shift when it's swapped for the confirmation. */
.signup {
  max-width: 27rem;
  min-height: 6rem;
}

.field {
  display: flex;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field:focus-within {
  border-color: rgba(242, 220, 220, 0.55);
  box-shadow: 0 0 0 3px rgba(242, 220, 220, 0.08);
}

.field input {
  flex: 1;
  min-width: 0;
  padding: 0.9rem 1rem;
  border: 0;
  background: transparent;
  color: var(--blush);
  font: inherit;
  font-size: 1.0625rem;
  outline: none;
}

.field input::placeholder {
  color: #6f686a;
}

.field button {
  flex: none;
  margin: 4px;
  padding: 0 1.4rem;
  border: 0;
  border-radius: 4px;
  background: var(--signal-deep);
  color: #fff;
  font: italic 1.125rem/1 var(--serif);
  cursor: pointer;
  transition: background-color 0.15s;
}

.field button:hover {
  background: var(--signal);
}

.field button:focus-visible {
  outline: 2px solid var(--blush);
  outline-offset: 2px;
}

.field button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.signup.is-invalid .field {
  border-color: var(--warn);
}

.trap {
  position: absolute;
  left: -9999px;
}

.fineprint,
.status-msg {
  margin: 0.85rem 0 0;
  font-size: 0.9375rem;
}

.fineprint {
  color: var(--ash);
}

.status-msg {
  display: none;
}

.status-msg.is-good {
  color: var(--blush);
}

.status-msg.is-bad {
  color: var(--warn);
}

/* Shown by script (.is-shown), or by the no-JavaScript redirect to /#status-… (:target). */
.status-msg.is-shown,
.status-msg:target {
  display: block;
}

.signup:has(.status-msg.is-shown, .status-msg:target) .fineprint {
  display: none;
}

.signup.is-done .field,
.signup:has(#status-joined:target, #status-already:target) .field {
  display: none;
}

.signup.is-done .status-msg.is-good {
  margin-top: 0;
  font-size: 1.1875rem;
  font-style: italic;
}

/* ---------- Figure ---------- */

/* The fade keeps the whole head visible and only dissolves the cut-off shoulders
   (bottom) and the photo's edges (sides, plus a sliver at the very top). */
.figure {
  --figure-fade:
    linear-gradient(to bottom, transparent 0, #000 5%, #000 64%, transparent 97%),
    linear-gradient(to right, transparent 0, #000 13%, #000 87%, transparent 100%);
  position: relative;
  justify-self: end;
  width: min(100%, 37rem, 70svh);
  margin: 0;
  aspect-ratio: 1;
}

/* `lighten` lets the photo's black backdrop disappear into the page's red glow. */
.figure img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: lighten;
  animation: lights-up 1.8s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}

.figure img,
.figure::before,
.figure::after {
  -webkit-mask-image: var(--figure-fade);
  -webkit-mask-composite: source-in;
  mask-image: var(--figure-fade);
  mask-composite: intersect;
}

/* Glitch copies: a red-only and a cyan-only version of the photo, hidden until
   hover, then flashed in shifted horizontal slices (RGB split). `lighten` means a
   copy only shows where it's offset past an edge, so it reads as colour fringing
   instead of washing the face out. */
.figure::before,
.figure::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/avatar.jpg?v=d75b60d433');
  background-position: center;
  background-size: cover;
  background-blend-mode: multiply;
  mix-blend-mode: lighten;
  opacity: 0;
  pointer-events: none;
}

.figure::before {
  background-color: #ff2433;
}

.figure::after {
  background-color: #39e0ff;
}

/* Only the copies move. Animating .figure itself would give it its own stacking
   context, cutting the photo's `lighten` blend off from the page (its black
   backdrop would show as a square). */
@media (hover: hover) {
  .figure:hover::before {
    animation: glitch-red 2.8s steps(1, end) infinite;
  }

  .figure:hover::after {
    animation: glitch-cyan 2.8s steps(1, end) infinite;
  }
}

/* Short bursts with long pauses between them, so it reads as a flicker, not a strobe.
   Each burst opens with a full-frame split, then breaks into slices. */
@keyframes glitch-red {
  0% { opacity: 1; transform: translate(-6px, 0); clip-path: inset(0 0 0 0); }
  2% { opacity: 1; transform: translate(7px, 0); clip-path: inset(14% 0 68% 0); }
  4% { opacity: 1; transform: translate(-5px, 1px); clip-path: inset(46% 0 36% 0); }
  6% { opacity: 0.9; transform: translate(4px, 0); clip-path: inset(28% 0 58% 0); }
  8%, 47% { opacity: 0; }
  48% { opacity: 1; transform: translate(-5px, 0); clip-path: inset(0 0 0 0); }
  50% { opacity: 0.9; transform: translate(6px, -1px); clip-path: inset(60% 0 22% 0); }
  52%, 100% { opacity: 0; }
}

@keyframes glitch-cyan {
  0% { opacity: 0.9; transform: translate(6px, 0); clip-path: inset(0 0 0 0); }
  2% { opacity: 0.9; transform: translate(-6px, 0); clip-path: inset(36% 0 48% 0); }
  4% { opacity: 0.8; transform: translate(5px, -1px); clip-path: inset(18% 0 70% 0); }
  6%, 47% { opacity: 0; }
  48% { opacity: 0.85; transform: translate(5px, 0); clip-path: inset(0 0 0 0); }
  50%, 100% { opacity: 0; }
}

/* The one load moment: the figure comes up out of the dark. */
@keyframes lights-up {
  from {
    opacity: 0;
    filter: brightness(0.15) contrast(1.4);
  }
  to {
    opacity: 1;
    filter: none;
  }
}

/* ---------- Decor (from the banner) ---------- */

/* Clipped here rather than on .page, so focusing the form can't scroll the page sideways or down. */
.decor {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow {
  position: absolute;
  top: -35vh;
  right: -20vw;
  width: 75vw;
  height: 75vw;
  max-width: 1100px;
  max-height: 1100px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ember), transparent 62%);
}

.grid {
  position: absolute;
  width: 380px;
  height: 260px;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
}

.grid--top {
  top: 0;
  left: 0;
  -webkit-mask-image: radial-gradient(circle at 20% 20%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 20% 20%, #000, transparent 72%);
}

.grid--bottom {
  right: 0;
  bottom: 0;
  -webkit-mask-image: radial-gradient(circle at 80% 80%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 80% 80%, #000, transparent 72%);
}

/* The cross: two circuit traces meeting at a node. Everything is placed
   relative to the node, so the pulses always leave from its exact center. */
.junction {
  --left-x: 4.5vw;   /* trace length to the left of the node (to the page edge) */
  --reach-x: 20vw;   /* trace length to the right */
  --reach-y: 16vh;   /* trace length above and below */
  position: absolute;
  left: var(--left-x);
  bottom: 22%;
}

.trace {
  position: absolute;
  overflow: hidden;
  background: rgba(242, 220, 220, 0.07);
}

.trace--h {
  top: 0;
  left: calc(-1 * var(--left-x));
  width: calc(var(--left-x) + var(--reach-x));
  height: 1px;
}

.trace--v {
  top: calc(-1 * var(--reach-y));
  left: 0;
  width: 1px;
  height: calc(2 * var(--reach-y));
}

.node {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--signal);
  box-shadow: 0 0 8px var(--signal);
}

/* The ping ring that expands from the node when it fires. */
.node::after {
  content: '';
  position: absolute;
  top: -19.5px;
  left: -19.5px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--signal);
  border-radius: 50%;
  opacity: 0;
}

.ring {
  position: absolute;
  right: -90px;
  bottom: -150px;
  width: 340px;
  height: 340px;
  border: 1px solid rgba(242, 220, 220, 0.07);
  border-radius: 50%;
}

.glyph {
  position: absolute;
  color: rgba(242, 220, 220, 0.22);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.glyph--code {
  top: 9.5rem;
  left: 8.5vw;
}

.glyph--braces {
  top: 22vh;
  right: 4vw;
}

.dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--signal);
  box-shadow: 0 0 8px var(--signal);
}

.dot--1 { top: 4.25rem; left: 14vw; }
.dot--3 { top: 30vh; right: 4vw; }
.dot--4 { bottom: 9%; right: 13vw; }

/* ---------- Ambient motion: slow, out of sync, off for reduced motion ---------- */

.glow {
  animation: breathe 11s ease-in-out infinite alternate;
}

/* Status-LED blink; each dot on its own clock so they never sync up. */
.dot {
  animation: blink 4s ease-in-out infinite;
}

.dot--1 { animation-duration: 3.7s; }
.dot--3 { animation-duration: 4.6s; animation-delay: -2.9s; }
.dot--4 { animation-duration: 6.2s; animation-delay: -0.8s; }

/* The junction fires every 6s: the node flares, a ring pings out, and a
   pulse leaves the node along each of the four arms, fading as it slows.
   Arm timings are proportional to arm length, so all pulses move at about the same speed. */
.node {
  animation: fire 6s ease-out infinite;
}

.node::after {
  animation: ping 6s ease-out infinite;
}

.trace::before,
.trace::after {
  content: '';
  position: absolute;
  opacity: 0;
  animation-duration: 6s;
  animation-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  animation-iteration-count: infinite;
}

/* Right arm: head on the right, starts with its head at the node. */
.trace--h::after {
  top: 0;
  left: var(--left-x);
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--signal));
  animation-name: pulse-right;
}

/* Left arm (short, to the page edge). */
.trace--h::before {
  top: 0;
  left: var(--left-x);
  width: 40px;
  height: 1px;
  background: linear-gradient(270deg, transparent, var(--signal));
  animation-name: pulse-left;
}

/* Up arm. */
.trace--v::before {
  top: var(--reach-y);
  left: 0;
  width: 1px;
  height: 60px;
  background: linear-gradient(0deg, transparent, var(--signal));
  animation-name: pulse-up;
}

/* Down arm. */
.trace--v::after {
  top: var(--reach-y);
  left: 0;
  width: 1px;
  height: 60px;
  background: linear-gradient(180deg, transparent, var(--signal));
  animation-name: pulse-down;
}

/* A faint point orbiting the ring. */
.ring {
  animation: orbit 48s linear infinite;
}

.ring::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--blush);
  opacity: 0.45;
}

/* The code glyphs flicker briefly, like a bad monitor. */
.glyph {
  animation: flicker 9s steps(1) infinite;
}

.glyph--braces {
  animation-duration: 12s;
  animation-delay: -5s;
}

@keyframes breathe {
  from {
    opacity: 0.75;
    transform: scale(1);
  }
  to {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@keyframes fire {
  0% { opacity: 0.4; scale: 1; }
  2% { opacity: 1; scale: 2; }
  12% { opacity: 1; scale: 1; }
  45%, 100% { opacity: 0.4; scale: 1; }
}

@keyframes ping {
  0% { opacity: 0.7; scale: 0.1; }
  28%, 100% { opacity: 0; scale: 1; }
}

@keyframes pulse-right {
  0% { opacity: 0; transform: translateX(-80px); }
  3% { opacity: 1; }
  28% { opacity: 1; }
  40%, 100% { opacity: 0; transform: translateX(var(--reach-x)); }
}

@keyframes pulse-left {
  0% { opacity: 0; transform: translateX(0); }
  2% { opacity: 1; }
  7% { opacity: 1; }
  11%, 100% { opacity: 0; transform: translateX(calc(-1 * var(--left-x) - 40px)); }
}

@keyframes pulse-up {
  0% { opacity: 0; transform: translateY(0); }
  3% { opacity: 1; }
  17% { opacity: 1; }
  25%, 100% { opacity: 0; transform: translateY(calc(-1 * var(--reach-y) - 60px)); }
}

@keyframes pulse-down {
  0% { opacity: 0; transform: translateY(-60px); }
  3% { opacity: 1; }
  17% { opacity: 1; }
  25%, 100% { opacity: 0; transform: translateY(var(--reach-y)); }
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

@keyframes flicker {
  0%, 91%, 97%, 100% { opacity: 1; }
  92%, 94%, 96% { opacity: 0.15; }
  93%, 95% { opacity: 0.7; }
}

/* ---------- Footer ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  width: min(100% - 2 * var(--gutter), 76rem);
  margin-inline: auto;
  padding-block: 1.5rem 2rem;
  color: var(--ash);
  font-size: 0.9375rem;
}

.elsewhere {
  display: flex;
  gap: 1.5rem;
}

.elsewhere a {
  font-style: italic;
  text-decoration: none;
  text-underline-offset: 0.2em;
}

.elsewhere a:hover {
  color: var(--blush);
  text-decoration: underline;
}

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

.footer small {
  font-size: inherit;
  white-space: nowrap;
}

/* ---------- Small screens: the figure goes on top ---------- */

@media (max-width: 52rem) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 0;
  }

  .figure {
    --figure-fade:
      linear-gradient(to bottom, transparent 0, #000 5%, #000 58%, transparent 94%),
      linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%);
    order: -1;
    justify-self: center;
    width: min(100%, 26rem);
    margin-bottom: -2.5rem;
  }

  .copy {
    position: relative;
  }

  .wordmark {
    margin-bottom: 1.5rem;
  }

  .glow {
    top: -25vw;
    right: -40vw;
    width: 120vw;
    height: 120vw;
  }

  .glyph--code,
  .grid--bottom,
  .junction,
  .ring {
    display: none;
  }

  .glyph--braces {
    top: 1.5rem;
    right: 14vw;
  }

  .dot--3 {
    top: 3rem;
  }
}

@media (max-width: 24rem) {
  .field button {
    padding-inline: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .figure img,
  .figure:hover::before,
  .figure:hover::after,
  .glow,
  .dot,
  .node,
  .node::after,
  .ring,
  .glyph {
    animation: none;
  }

  .trace::before,
  .trace::after {
    display: none;
  }
}
