/* Intro screen: black/white/gray comic-style splash shown once per visit. */
:root {
  --intro-gray: #a6a6a3;
  --intro-ink: #0b0b0b;
  --intro-paper: #fff;
  --intro-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --intro-snap: cubic-bezier(0.7, 0, 0.2, 1);
}

.intro {
  display: none;
}

.intro-active .intro {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--intro-paper);
  background: var(--intro-ink);
  cursor: pointer;
  font-family: var(--font-display);
}

.intro-active body {
  overflow: hidden;
}

/* Background: halftone dots and diagonal stripes sweeping across. */
.intro__halftone {
  position: absolute;
  inset: -10%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.13) 1.4px, transparent 1.6px) 0 0 / 14px 14px;
  transform: rotate(-12deg);
  animation: intro-drift 6s linear infinite;
}

.intro__stripe {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 22vh;
  background: var(--intro-gray);
  transform: rotate(-14deg) translateX(-110%);
  animation: intro-stripe-in 0.55s var(--intro-snap) forwards;
}

.intro__stripe--one {
  top: 8%;
  animation-delay: 0.05s;
}

.intro__stripe--two {
  top: 62%;
  height: 9vh;
  background: var(--intro-paper);
  animation-delay: 0.18s;
}

.intro__stripe--three {
  top: 76%;
  height: 4vh;
  animation-delay: 0.28s;
}

/* Jagged white burst behind the name. */
.intro__burst {
  position: absolute;
  width: min(92vw, 62rem);
  aspect-ratio: 1.9;
  background: var(--intro-paper);
  clip-path: polygon(
    0% 18%, 14% 8%, 22% 0%, 38% 10%, 52% 2%, 66% 12%, 82% 4%, 92% 16%, 100% 30%,
    94% 46%, 100% 64%, 88% 76%, 92% 94%, 72% 88%, 58% 100%, 42% 90%, 26% 98%,
    14% 86%, 2% 92%, 6% 72%, 0% 56%, 5% 40%
  );
  transform: rotate(-6deg) scale(0);
  animation: intro-burst 0.5s var(--intro-ease) 0.3s forwards;
}

.intro__burst::after {
  content: "";
  position: absolute;
  inset: 5%;
  background: var(--intro-ink);
  clip-path: inherit;
}

/* Name made of mismatched letter tiles. */
.intro__name {
  position: relative;
  display: grid;
  gap: clamp(0.3rem, 1.2vw, 0.8rem);
  justify-items: center;
  margin: 0;
  transform: rotate(-6deg);
}

.intro__row {
  display: flex;
  align-items: center;
  gap: clamp(0.15rem, 0.6vw, 0.4rem);
}

.intro__row:last-child {
  margin-left: clamp(2rem, 8vw, 6rem);
}

.intro__tile {
  display: inline-grid;
  place-items: center;
  min-width: 0.8em;
  padding: 0.04em 0.12em;
  font-size: clamp(2.6rem, 10vw, 7.5rem);
  line-height: 1;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(-40%) rotate(var(--tilt, 0deg)) scale(2.2);
  animation: intro-tile-in 0.32s var(--intro-ease) forwards;
  animation-delay: calc(0.55s + var(--i) * 0.05s);
}

.intro__tile--paper {
  color: var(--intro-ink);
  background: var(--intro-paper);
}

.intro__tile--ink {
  color: var(--intro-paper);
  background: var(--intro-ink);
  outline: 0.06em solid var(--intro-paper);
}

.intro__tile--gray {
  color: var(--intro-ink);
  background: var(--intro-gray);
}

.intro__tile--serif {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(2.3rem, 9vw, 6.6rem);
}

.intro__tile--mono {
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
  font-size: clamp(2.2rem, 8.6vw, 6.4rem);
}

.intro__tile--small {
  font-size: clamp(2rem, 7.6vw, 5.6rem);
}

/* Tagline box and loading bar. */
.intro__tag {
  position: absolute;
  bottom: 21%;
  left: 50%;
  margin: 0;
  padding: 0.55rem 1.4rem 0.5rem;
  color: var(--intro-ink);
  background: var(--intro-paper);
  font-family: var(--font-body);
  font-size: clamp(0.62rem, 1.6vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  white-space: nowrap;
  transform: translateX(150vw) rotate(-6deg) skewX(-14deg);
  animation: intro-tag-in 0.45s var(--intro-ease) 1.15s forwards;
}

.intro__tag span {
  display: inline-block;
  transform: skewX(14deg);
}

.intro__loader {
  position: absolute;
  right: var(--page-gutter);
  bottom: clamp(1.5rem, 5vh, 3rem);
  display: grid;
  gap: 0.4rem;
  justify-items: end;
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
  opacity: 0;
  animation: intro-fade-in 0.3s ease 0.4s forwards;
}

.intro__loader-label {
  letter-spacing: 0.06em;
  font-style: italic;
}

.intro__bar {
  width: clamp(9rem, 22vw, 16rem);
  height: 0.7rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
  transform: skewX(-24deg);
}

.intro__bar i {
  display: block;
  height: 100%;
  background: var(--intro-paper);
  transform: scaleX(0);
  transform-origin: left;
  animation: intro-bar 1.9s var(--intro-snap) 0.4s forwards;
}

.intro__skip {
  position: absolute;
  z-index: 1;
  top: clamp(1rem, 3vh, 1.8rem);
  right: var(--page-gutter);
  padding: 0.5rem 1rem 0.45rem;
  color: var(--intro-ink);
  background: var(--intro-paper);
  border: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  transform: skewX(-14deg);
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.intro__skip:hover,
.intro__skip:focus-visible {
  color: var(--intro-paper);
  background: var(--intro-ink);
  outline: 2px solid var(--intro-paper);
  transform: skewX(-14deg) scale(1.08);
}

/* Exit: white then black slabs wipe across, then the whole layer slides away. */
.intro__wipe {
  position: absolute;
  z-index: 2;
  inset: -30% -60%;
  background: var(--intro-paper);
  transform: rotate(-14deg) translateX(-120%);
  pointer-events: none;
}

.intro__wipe--ink {
  background: var(--intro-ink);
}

.intro.is-leaving .intro__wipe {
  animation: intro-wipe 0.45s var(--intro-snap) forwards;
}

.intro.is-leaving .intro__wipe--ink {
  animation-delay: 0.1s;
}

.intro.is-leaving {
  pointer-events: none;
  animation: intro-out 0.45s var(--intro-snap) 0.55s forwards;
}

@keyframes intro-drift {
  to {
    background-position: 140px 70px;
  }
}

@keyframes intro-stripe-in {
  to {
    transform: rotate(-14deg) translateX(0);
  }
}

@keyframes intro-burst {
  70% {
    transform: rotate(-4deg) scale(1.06);
  }
  to {
    transform: rotate(-6deg) scale(1);
  }
}

@keyframes intro-tile-in {
  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--tilt, 0deg)) scale(1);
  }
}

@keyframes intro-tag-in {
  to {
    transform: translateX(-50%) rotate(-6deg) skewX(-14deg);
  }
}

@keyframes intro-fade-in {
  to {
    opacity: 1;
  }
}

@keyframes intro-bar {
  to {
    transform: scaleX(1);
  }
}

@keyframes intro-wipe {
  to {
    transform: rotate(-14deg) translateX(0);
  }
}

@keyframes intro-out {
  to {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
  }
}

/* Tall phone screens: bigger name, taller burst, tag pushed below it. */
@media (max-aspect-ratio: 3/4) {
  .intro__burst {
    width: 112vw;
    aspect-ratio: 1.25;
  }

  .intro__tile {
    font-size: 13.5vw;
  }

  .intro__tile--serif,
  .intro__tile--mono {
    font-size: 12vw;
  }

  .intro__tile--small {
    font-size: 10.5vw;
  }

  .intro__tag {
    bottom: 26%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro-active .intro {
    display: none;
  }

  .intro-active body {
    overflow: auto;
  }
}
