/* Colours mirror packages/shared/src/theme/tokens.ts (palette.light, brand). */
:root {
  --blue: #2346ff;
  --blue-deep: #1938db;
  --blue-night: #0f25a8;
  --white: #ffffff;
  --white-soft: rgba(255, 255, 255, 0.78);
  --white-faint: rgba(255, 255, 255, 0.5);
  --horizon: 57svh;
  --gutter: clamp(20px, 3.2vw, 48px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --lean: 0;
  --drift: 0;
}

@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/InstrumentSans-500.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/InstrumentSans-600.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

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

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--blue);
  color: var(--white);
  font-family: "Instrument Sans", system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 70% at 50% var(--horizon), #3d5cff 0%, transparent 60%),
    linear-gradient(180deg, var(--blue-deep) 0%, var(--blue) var(--horizon), var(--blue-deep) 88%, var(--blue-night) 100%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

/* Film grain keeps the large flat blue from banding. */
.stage::after {
  content: "";
  position: absolute;
  inset: -50%;
  z-index: 5;
  pointer-events: none;
  opacity: 0.11;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -1%); }
  100% { transform: translate(0, 0); }
}

.road {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 68%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 68%, transparent 100%);
}

.glow {
  position: absolute;
  left: 50%;
  top: var(--horizon);
  width: 140vw;
  height: 60svh;
  z-index: 0;
  pointer-events: none;
  transform: translate(calc(-50% + var(--drift) * 6vw), -50%);
  background: radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 70%);
  filter: blur(20px);
  opacity: 0;
  animation: fade 2.4s var(--ease-out) 0.3s forwards;
}

.horizon {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--horizon);
  height: 1px;
  z-index: 2;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45) 30%, rgba(255, 255, 255, 0.45) 70%, transparent);
  transform: scaleX(0);
  animation: draw 1.6s var(--ease-out) 0.15s forwards;
}

@keyframes draw {
  to { transform: scaleX(1); }
}
@keyframes fade {
  to { opacity: 1; }
}

/* Header */

.bar {
  position: absolute;
  z-index: 4;
  top: max(var(--gutter), env(safe-area-inset-top));
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  letter-spacing: -0.005em;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
}

.mark svg {
  width: 34px;
  height: 34px;
  display: block;
}

.mark-ink {
  fill: var(--blue);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--white-soft);
}

.status i {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--white);
}

.status i::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--white);
  animation: ping 2.2s var(--ease-out) infinite;
}

@keyframes ping {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(3.2); opacity: 0; }
}

/* Wordmark: sits on the horizon and rises from behind it. */

.word {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  /* Baseline sits on the horizon (Instrument Sans baseline is 0.14em above the line box). */
  bottom: calc(100svh - var(--horizon) - 0.14em);
  margin: 0;
  padding: 0 var(--gutter);
  display: flex;
  justify-content: center;
  font-weight: 600;
  font-size: min(21.5vw, 36svh);
  line-height: 1;
  letter-spacing: -0.065em;
  white-space: nowrap;
  /* Letters rise from behind the horizon; the "y" descender drops below it once settled. */
  clip-path: inset(-50% -50% 0.14em -50%);
  transition: clip-path 0.9s var(--ease-out);
}

.word.is-settled {
  clip-path: inset(-50% -50% -50% -50%);
}

.word-lean {
  display: inline-flex;
  padding-right: 0.06em;
  transform: translateX(calc(var(--drift) * -1.2vw)) skewX(calc(var(--lean) * -16deg));
  transform-origin: 50% 100%;
}

.l {
  display: inline-block;
  transform: translateY(105%);
  animation: rise 1.25s var(--ease-out) forwards;
}

.l:nth-child(1) { animation-delay: 0.25s; }
.l:nth-child(2) { animation-delay: 0.31s; }
.l:nth-child(3) { animation-delay: 0.37s; }
.l:nth-child(4) { animation-delay: 0.43s; }
.l:nth-child(5) { animation-delay: 0.49s; }
.l:nth-child(6) { animation-delay: 0.55s; }
.l:nth-child(7) { animation-delay: 0.61s; }
.l:nth-child(8) { animation-delay: 0.67s; }

/* Mirror image on the asphalt, flipped around the baseline. */
.reflection {
  z-index: 1;
  opacity: 0.2;
  transform: scaleY(-1);
  transform-origin: 50% calc(100% - 0.14em);
  filter: blur(3px);
  -webkit-mask-image: linear-gradient(180deg, transparent 35%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 35%, #000 100%);
}

@keyframes rise {
  to { transform: translateY(0); }
}

/* Footer */

.foot {
  position: absolute;
  z-index: 4;
  left: var(--gutter);
  right: var(--gutter);
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 24px;
}

.pitch {
  margin: 0;
  max-width: 22em;
  font-size: clamp(16px, 1.25vw, 19px);
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--white-soft);
  text-wrap: pretty;
}

.launch {
  margin: 0;
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

.launch span {
  font-size: 15px;
  color: var(--white-soft);
}

.mark {
  text-decoration: none;
}

.launch .back {
  font-weight: 600;
  font-size: clamp(30px, 3.4vw, 54px);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--white);
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.14em;
}

.launch strong {
  font-weight: 600;
  font-size: clamp(30px, 3.4vw, 54px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.speed {
  font-size: 13px;
  color: var(--white-soft);
  letter-spacing: 0.01em;
}

.speed b {
  display: inline-block;
  min-width: 2ch;
  margin-right: 2px;
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

.hint {
  font-size: 13px;
  color: var(--white-faint);
  transition: color 0.4s ease;
}

.hint.is-max {
  color: var(--white);
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: enter 1.1s var(--ease-out) forwards;
}

.d1 { animation-delay: 0.9s; }
.d2 { animation-delay: 1.15s; }
.d3 { animation-delay: 1.3s; }
.d4 { animation-delay: 1.45s; }

@keyframes enter {
  to { opacity: 1; transform: none; }
}

/* Phones: wordmark higher, copy stacked under the road. */
@media (max-width: 720px) {
  :root {
    --horizon: 42svh;
  }

  .bar {
    font-size: 14px;
  }

  .mark svg {
    width: 30px;
    height: 30px;
  }

  .word {
    font-size: min(22.5vw, 30svh);
  }

  .stage::before {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 46svh;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, rgba(15, 37, 168, 0.55) 45%, rgba(15, 37, 168, 0.85));
  }

  .foot {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "pitch pitch"
      "launch gauge";
    row-gap: 28px;
  }

  .pitch {
    grid-area: pitch;
    font-size: 17px;
  }

  .launch {
    grid-area: launch;
    justify-self: start;
    align-items: flex-start;
    text-align: left;
  }

  .launch strong {
    font-size: 32px;
    white-space: nowrap;
  }

  .hint {
    max-width: 8.5em;
    text-wrap: balance;
  }

  .gauge {
    grid-area: gauge;
    align-items: flex-end;
    text-align: right;
  }
}

@media (max-height: 560px) and (min-width: 721px) {
  .gauge {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage::after,
  .status i::after {
    animation: none;
  }

  .l,
  .reveal,
  .horizon,
  .glow {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .word-lean {
    transform: none;
  }
}
