:root {
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #555555;
  --serif: Georgia, "Gelasio", "Times New Roman", serif;
  --gutter: clamp(16px, 2.4vw, 28px);
  --lower: calc(var(--gutter) + 64px); /* captions during the intro, section links on the site */
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- Intro ---------- */

.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  cursor: none;
  transition: opacity 700ms ease;
}

.intro:focus-visible { outline: none; }
.intro:focus-visible .figure { outline: 1px dashed var(--muted); outline-offset: 12px; }

.figure {
  /* Height-led on desktop (60vh, up to 540px); on narrow screens the width caps it instead,
     so the character always keeps its shape. */
  width: min(94vw, calc(min(60vh, 540px) * 380 / 228));
  height: auto;
  aspect-ratio: 380 / 228;
  display: block;
}

.prompt {
  font-size: 16px;
  color: var(--muted);
  display: none;
}

.cursor-label {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 160ms ease;
  z-index: 10;
}

body.is-intro .cursor-label.is-visible { opacity: 1; }

@media (hover: none) {
  .intro { cursor: pointer; }
  .prompt { display: block; }
  .cursor-label { display: none; }
}

body.is-playing .intro { cursor: default; pointer-events: none; }
body.is-playing .prompt,
body.is-playing .cursor-label,
body.is-playing .cursor-label.is-visible,
body.is-site .cursor-label { opacity: 0; }

body.is-site .intro { opacity: 0; pointer-events: none; }

/* ---------- Site ---------- */

.site {
  position: fixed;
  inset: 0;
  opacity: 0;
  transition: opacity 900ms ease 150ms;
}

.site[hidden] { display: none; }
body.is-site .site { opacity: 1; }

.slides {
  position: absolute;
  inset: 0 0 calc(var(--lower) + 44px) 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: var(--gutter) var(--gutter) 24px;
}

.tabs button:focus-visible, .slide a:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}

/* Section pages read like the Alive Prize letter: a small label, then one left-aligned column. */
.slide {
  width: 100%;
  max-width: 660px;
  margin: 0 auto auto;
  padding-top: clamp(24px, 9vh, 96px);
  font-size: 19px;
  line-height: 1.75;
  color: var(--ink);
  transition: opacity 260ms ease, transform 260ms ease;
}

.slide.is-leaving { opacity: 0; transform: translateY(6px); }

/* Fixed letter spacing, so text looks identical while it glitches in and after. */
.slide, .tabs { font-kerning: none; font-variant-ligatures: none; }

/* More below: the bottom of the page fades out. */
.site.has-more .slides {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 90px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 90px), transparent);
}

.slide p { margin: 0 0 1.15em; }

.slide .label {
  margin-bottom: 2.2em;
  font-size: 12.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.slide .muted { color: var(--muted); font-size: 0.86em; }

.slide a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* The landing line sits in the middle, set like the Alive Prize homepage: Georgia 26/39. */
.slide.is-home {
  max-width: none;
  margin: auto;
  padding-top: 0;
  text-align: center;
}

.slide.is-home .lede {
  margin: 0;
  font-size: 26px;
  line-height: 39px;
  text-wrap: balance;
}

/* Arrival: after a quiet beat, the line rises in, then the links follow. */
@keyframes arrive {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

body.is-arriving .site { transition: none; }
body.is-arriving .slide.is-home .lede { animation: arrive 700ms cubic-bezier(.2, .7, .2, 1) both; }
@keyframes arrive-nav {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
body.is-arriving .tabs { animation: arrive-nav 500ms cubic-bezier(.2, .7, .2, 1) 650ms both; }

.tabs {
  position: absolute;
  left: 50%;
  bottom: var(--lower);
  transform: translateX(-50%);
  display: flex;
  gap: 2.2em;
  font-size: 19px;
  white-space: nowrap;
}

.tabs button {
  color: var(--ink);
  text-decoration: underline transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: text-decoration-color 160ms ease;
}

.tabs button:hover,
.tabs button[aria-current="true"] { text-decoration-color: currentColor; }

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

/* ---------- Captions (intro only) ---------- */

.caption {
  position: fixed;
  left: 50%;
  bottom: var(--lower);
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100vw - 32px);
  text-align: center;
  font-size: 17px;
  font-style: italic;
  color: var(--ink);
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
  z-index: 5;
}

.caption.is-visible { opacity: 1; }
body.is-site .caption { opacity: 0; transition: opacity 300ms ease; }   /* none once the homepage is up */

/* ---------- Text glitch ---------- */

/* A colon stands in for each letter, centred in that letter's own width. */
.gl { position: relative; color: transparent; }
.gl::after {
  content: ":";
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--ink);
}
a .gl::after { text-decoration: none; }

@media (max-width: 640px) {
  :root { --lower: calc(var(--gutter) + 28px + env(safe-area-inset-bottom, 0px)); }   /* clear the iPhone home bar */
  .slides { padding: var(--gutter) 20px 24px; }
  .slide { font-size: 17px; }
  .slide.is-home .lede { font-size: 21px; line-height: 32px; }
  .wide-only { display: none; }
  /* five links across a phone: spread them edge to edge instead of overflowing */
  .tabs { width: calc(100vw - 24px); justify-content: space-between; gap: 0; font-size: 16px; }
}

/* Touch screens: no grey tap flash, and an underline only on the page you're on (no sticky hover). */
@media (hover: none) {
  button, a { -webkit-tap-highlight-color: transparent; }
  .tabs button:hover { text-decoration-color: transparent; }
  .tabs button[aria-current="true"] { text-decoration-color: currentColor; }
}

@media (prefers-reduced-motion: reduce) {
  .slide, .site, .intro { transition: none; }
  body.is-arriving .slide.is-home .lede, body.is-arriving .tabs { animation: none; }
}
