:root {
  --bg: #0c0d0f;
  --text: #f2f3f4;
  --muted: #9a9fa6;
  --red: #bb2227; /* matches the Wheels & Wrenches logo */
  /* One unit that scales with the window, so that everything keeps its size
     relative to the window, whatever the browser zoom. It is 1px on a 1440 by
     900 window (landscape) or a 390 by 844 window (portrait). Every size below
     is a multiple of it, so none of them grow or shrink on their own. */
  --u: min(100vh / 900, 100vw / 1440);
  --u: min(100svh / 900, 100vw / 1440);
  --wheel: calc(468 * var(--u));
  --ground: calc(56 * var(--u));
  --headroom: calc(24 * var(--u)); /* empty space above the wheel in the stage */
  --gutter: calc(48 * var(--u));
}

/* Portrait windows, such as phones. This is chosen by shape rather than by
   width, so that zooming does not switch the layout. */
@media (orientation: portrait) {
  :root {
    --u: min(100vh / 844, 100vw / 390);
    --u: min(100svh / 844, 100vw / 390);
    --wheel: calc(359 * var(--u));
    --gutter: calc(20 * var(--u));
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: calc(17 * var(--u));
  line-height: 1.6;
  overflow-x: hidden;
}

h1 {
  margin: 0;
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700;
  line-height: 1.02;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: calc(2 * var(--u)) solid var(--red);
  outline-offset: calc(3 * var(--u));
}

.container {
  width: 100%;
  max-width: calc(1080 * var(--u));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Hero */

.hero {
  position: relative;
  /* The wheel sits in the middle row, so it is vertically centered on the screen.
     The logo and the opening line sit just above it and the link just below. */
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  gap: calc(27 * var(--u));
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(54 * var(--u)) 0;
  text-align: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, #1a1c21, transparent 70%),
    var(--bg);
}

.brand {
  align-self: end;
  /* The stage has empty space above the wheel, so pull the wheel up toward the opening line. */
  margin-bottom: calc(-20 * var(--u));
}

.lead {
  max-width: 34em;
  margin: 0 auto;
  padding: 0 var(--gutter);
  color: var(--muted);
  font-size: calc(28 * var(--u));
  text-wrap: pretty;
}

/* Logo */

.logo {
  display: block;
  width: calc(468 * var(--u));
  height: auto;
  margin: 0 auto calc(14 * var(--u));
}

/* Poster: the headline is a faint outline behind the wheel, which rolls over it. */

.poster {
  position: relative;
  width: 100%;
}

.poster h1 {
  position: absolute;
  /* The headroom is the empty space above the wheel in the stage, so the text is centered on the wheel. */
  inset: var(--headroom) 0 var(--ground);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--gutter);
  font-size: calc(216 * var(--u));
  line-height: 0.92;
  text-wrap: balance;
  color: transparent;
  -webkit-text-stroke: calc(1.5 * var(--u)) rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

/* Wheel stage */

.stage {
  position: relative;
  width: 100%;
  height: calc(var(--wheel) + var(--ground) + var(--headroom));
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: var(--ground);
  background: radial-gradient(ellipse 75% 120% at 50% 100%, rgba(187, 34, 39, 0.5), transparent 72%);
  opacity: var(--glow, 1);
  pointer-events: none;
}

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--ground);
  height: calc(2 * var(--u));
  background: linear-gradient(90deg, transparent, #43474e 18%, #43474e 82%, transparent);
}

.ground::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(2 * var(--u));
  height: calc(36 * var(--u));
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent);
}

.wheel-wrap {
  position: absolute;
  left: 0;
  bottom: calc(var(--ground) + var(--u));
  width: var(--wheel);
  height: var(--wheel);
  will-change: transform;
  visibility: hidden;
}

.shadow {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: calc(-9 * var(--u));
  height: calc(18 * var(--u));
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.75), transparent 70%);
  filter: blur(calc(3 * var(--u)));
}

.disc {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 calc(60 * var(--u)) rgba(0, 0, 0, 0.6);
}

.spin {
  display: block;
  width: 100%;
  height: 100%;
  will-change: transform;
}

/* Soft highlight and edge shading. Fixed on screen while the wheel turns. */
.gloss {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.22), transparent 42%),
    radial-gradient(circle at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
}

/* Light from the upper left and shade toward the lower right, also fixed on
   screen so the lighting does not spin with the wheel. */
.shade {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.7) 0%,
    rgba(255, 255, 255, 0) 38%,
    rgba(0, 0, 0, 0) 52%,
    rgba(0, 0, 0, 0.75) 100%
  );
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.shine {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.28) 50%, transparent 62%);
  background-size: 300% 100%;
  background-position: 100% 0;
  mix-blend-mode: screen;
  /* Keep the sweep on the wheel only, not the tire. */
  -webkit-mask-image: radial-gradient(circle closest-side, #000 79%, transparent 80%);
  mask-image: radial-gradient(circle closest-side, #000 79%, transparent 80%);
  pointer-events: none;
}

.spark {
  position: absolute;
  top: 19%;
  left: 62%;
  width: 15%;
  aspect-ratio: 1;
  background: #fff;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  filter: drop-shadow(0 0 calc(6 * var(--u)) rgba(255, 255, 255, 0.9));
  transform: scale(0);
  pointer-events: none;
}

.sister {
  display: inline-flex;
  align-items: center;
  align-self: start;
  /* The stage has dark space below the road, so pull the link up toward the tire. */
  margin-top: calc(14 * var(--u) - var(--ground));
  gap: calc(12 * var(--u));
  color: var(--muted);
  font-size: calc(13 * var(--u));
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.6;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.sister img {
  display: block;
  height: calc(22 * var(--u));
  width: auto;
}

.sister:hover {
  color: var(--text);
  opacity: 1;
}

/* Phones: the headline is set in three lines that fit entirely inside the wheel.
   The wheel hides it completely when it is in the center and reveals it as it
   rolls away. All sizes follow the wheel so that this holds on every phone. */
@media (orientation: portrait) {
  .logo {
    width: calc(300 * var(--u));
  }

  .lead {
    font-size: calc(18 * var(--u));
  }

  .poster h1 {
    font-size: calc(var(--wheel) * 0.16);
    padding: 0 calc(50% - var(--wheel) * 0.36);
    -webkit-text-stroke-color: rgba(255, 255, 255, 0.4);
  }

  /* Equal padding above and below, so the content is centered on the screen and
     the black area is the same at the top and the bottom. */
  .hero {
    padding: calc(24 * var(--u)) 0;
    gap: calc(25 * var(--u));
  }
}

/* Intro: the road draws in and the headline is revealed. */
.intro .ground {
  animation: intro-draw 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 0.1s both;
}

.intro h1 {
  animation: intro-wipe 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.5s both;
}

.intro.revealed .logo {
  animation: reveal-up 1s ease both;
}

.intro.revealed .lead {
  animation: reveal-up 1s ease 0.7s both;
}

.intro.revealed .sister {
  animation: reveal-fade 1s ease 1.7s both;
}

@keyframes intro-draw {
  from { transform: scaleX(0); }
}

/* The headline is revealed from left to right. It does not move, so it never
   crosses the road line while that line is being drawn. */
@keyframes intro-wipe {
  from {
    clip-path: inset(-10% 100% -10% 0);
  }
  to {
    clip-path: inset(-10% -5% -10% -5%);
  }
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(calc(14 * var(--u)));
  }
}

@keyframes reveal-fade {
  from { opacity: 0; }
}

/* The date, the logo and the sister-shop link stay hidden until the script adds
   .revealed, when the repaired wheel reaches the center. */
.intro .lead,
.intro .logo,
.intro .sister {
  opacity: 0;
}

.intro.revealed .lead,
.intro.revealed .logo {
  opacity: 1;
}

.intro.revealed .sister {
  opacity: 0.6;
}

.intro.revealed .sister:hover {
  opacity: 1;
}
