/* Drive Project — coming soon. The game's attract mode as a scroll: the logo revs, the montage hits, every mode gets
   its chapter sprayed the way the main menu sprays it, then the shots, then the title card. */

@font-face {
  font-family: "Mona Sans";
  src: url("assets/fonts/MonaSans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Mona Sans";
  src: url("assets/fonts/MonaSans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Mona Sans";
  src: url("assets/fonts/MonaSans-ExtraBoldItalic.woff2") format("woff2");
  font-weight: 800;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Mona Sans Display Condensed";
  src: url("assets/fonts/MonaSansDisplayCondensed-BlackItalic.woff2") format("woff2");
  font-weight: 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Kaushan Script";
  src: url("assets/fonts/KaushanScript-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  /* The game's inks (DESIGN.md): ink for bars and ground, paper type, red spray and the main action, yellow for tags
     and for whatever is under the cursor. */
  --ink: #0b0b0d;
  --paper: #ffffff;
  --paper-muted: rgba(255, 255, 255, 0.72);
  --red: #ff2d1f;
  --yellow: #ffe100;

  --display: "Mona Sans Display Condensed", "Mona Sans", sans-serif;
  --title: "Mona Sans", sans-serif;
  --tag: "Kaushan Script", cursive;

  --gutter: clamp(16px, 4vw, 64px);
  --out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
}

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

html {
  scrollbar-color: var(--red) var(--ink);
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font: 500 17px/1.45 "Mona Sans", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--red);
  color: var(--paper);
}

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

img,
video,
svg {
  display: block;
}

/* ---- The game's voices ---- */

/* A title is sprayed on: white condensed black italic on red paint, tilted (DESIGN.md, the Spray Rule). */
.spray {
  position: relative;
  z-index: 0;
  display: inline-block;
  margin: 0;
  padding: 0.16em 0.46em 0.2em 0.34em;
  font: italic 900 clamp(64px, 10.5vw, 192px) / 0.86 var(--display);
  text-transform: uppercase;
  color: var(--paper);
  transform: rotate(-2deg);
  transform-origin: 0 100%;
}

.spray::before {
  content: "";
  position: absolute;
  inset: -0.32em -0.18em -0.44em -0.24em;
  z-index: -1;
  background: url("assets/spray-red.webp") center / 100% 100% no-repeat;
  clip-path: inset(0 var(--paint, 0%) 0 0);
  transition: clip-path 0.5s var(--out);
}

.spray--small {
  font-size: clamp(30px, 3.2vw, 52px);
}

/* A tag adds attitude, never a translation: yellow brush hand, hard ink shadow, tilted the other way. */
.tag {
  margin: 0;
  font: 400 clamp(28px, 3.1vw, 58px) / 1 var(--tag);
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--ink);
  transform: rotate(3deg);
}

/* Standing facts sit on flat ink bars, the way a broadcast puts up a lower third. */
.mode__place,
.still__caption {
  display: inline-flex;
  flex-wrap: wrap;
  margin: 0;
  background: var(--ink);
  font: 700 13px / 1 var(--title);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mode__place span,
.still__caption span {
  padding: 11px 14px 10px;
}

.mode__place span + span,
.still__caption span + span {
  padding-left: 0;
  color: var(--paper-muted);
}

/* The game's chips split their facts with a slash ("ROUNDS  /  FREE ROAM"); here it is the red one. */
.mode__place span + span::before,
.still__caption span + span::before {
  content: "/";
  margin-right: 14px;
  color: var(--red);
}

/* ---- Buttons: flat and square; red is the main action, yellow is under the cursor ---- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 24px 0 20px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: italic 800 19px / 1 var(--title);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.button--primary {
  background: var(--red);
}

.button:hover,
.button:focus-visible {
  background: var(--yellow);
  color: var(--ink);
}

.button:disabled {
  background: var(--ink);
  color: rgba(255, 255, 255, 0.28);
  cursor: default;
}

.button--icon {
  width: 54px;
  padding: 0;
  justify-content: center;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: currentColor;
}

.icon--line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.icon--line .icon__speaker {
  fill: currentColor;
  stroke: none;
}

.icon__waves,
[aria-pressed="true"] .icon__mute {
  display: none;
}

[aria-pressed="true"] .icon__waves {
  display: inline;
}

/* ---- The logo: the D is a rev counter ---- */

.logo__drive {
  fill: var(--paper);
}

.logo__project,
.logo__needle {
  fill: var(--red);
}

.logo__needle {
  transform-box: view-box;
  transform-origin: 89.5px 82.3px;
  transform: rotate(-118deg);
}

.is-revving .logo__needle {
  animation: rev 1.6s 0.25s cubic-bezier(0.3, 1.45, 0.45, 1) both;
}

@keyframes rev {
  from {
    transform: rotate(-118deg);
  }

  to {
    transform: rotate(0deg);
  }
}

/* ---- The opening: the logo on black, then the montage behind it ---- */

.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  background: var(--ink);
}

.hero__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 0.9s ease, transform 2.4s var(--out);
}

.is-live .hero__video {
  opacity: 1;
  transform: scale(1);
}

.hero__lockup {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(14px, 2.4vh, 26px);
  padding: 0 var(--gutter);
  transition: transform 1.4s var(--out);
}

.is-live .hero__lockup {
  transform: translateY(calc(-7vh - var(--leave, 0) * 10vh)) scale(calc(0.8 - var(--leave, 0) * 0.1));
}

.hero__title {
  margin: 0;
}

.hero .logo {
  width: min(44vw, 760px);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 10px 32px rgba(0, 0, 0, 0.55));
}

/* COMING SOON is standing information: an ink TV bar, legible over any frame. */
.hero__soon,
.close__soon {
  margin: 0;
  padding: 0.72em 0.5em 0.66em 0.92em;
  background: var(--ink);
  font: 700 clamp(14px, 1.25vw, 20px) / 1 var(--title);
  letter-spacing: 0.42em;
  text-transform: uppercase;
}

.hero__soon {
  opacity: 0;
  transition: opacity 0.6s ease 0.9s;
}

.is-revving .hero__soon {
  opacity: 1;
}

/* The montage runs above a flat ink TV bar: the mode on the left, the actions on the right. */
.hero__bar {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px max(var(--gutter), env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  background: var(--ink);
}

.hero__mode {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.is-live .hero__mode {
  opacity: 1;
}

.hero__mode .tag {
  font-size: clamp(22px, 2vw, 34px);
  margin-bottom: -0.1em;
}

.hero__mode.is-changing .spray::before {
  animation: paint 0.42s var(--out) both;
}

.hero__mode.is-changing .hero__mode-name,
.hero__mode.is-changing .hero__mode-tag {
  animation: land 0.42s var(--out) both;
}

@keyframes paint {
  from {
    clip-path: inset(0 100% 0 0);
  }
}

@keyframes land {
  from {
    opacity: 0;
    translate: -14px 0;
  }
}

.hero__actions {
  display: flex;
  gap: 6px;
}

/* ---- The modes: one chapter each, the footage full-bleed ---- */

.mode {
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: end;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(80px, 12vh, 140px) max(var(--gutter), env(safe-area-inset-right)) clamp(40px, 8vh, 96px)
    max(var(--gutter), env(safe-area-inset-left));
  overflow: hidden;
  background: var(--ink);
}

.mode__video {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(calc(1.08 - 0.08 * var(--enter, 1)));
}

.mode__words {
  display: grid;
  justify-items: start;
  max-width: min(100%, 980px);
}

.mode__tag {
  margin: -0.15em 0 0 clamp(36px, 7vw, 150px);
}

.mode__rule {
  margin: clamp(26px, 4vh, 44px) 0 0;
  padding: 14px 18px 15px;
  max-width: 36ch;
  background: var(--ink);
  font: 500 clamp(17px, 1.35vw, 21px) / 1.35 var(--title);
}

.mode__meta {
  margin: 0;
  padding: 9px 18px 8px;
  background: var(--paper);
  color: var(--ink);
  font: 700 12px / 1 var(--title);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.mode__place {
  position: absolute;
  top: clamp(24px, 5vh, 56px);
  right: max(var(--gutter), env(safe-area-inset-right));
}

.mode--right .mode__words {
  justify-self: end;
  justify-items: end;
  text-align: right;
}

.mode--right .mode__place {
  right: auto;
  left: max(var(--gutter), env(safe-area-inset-left));
}

/* The paint sprays on left to right as the chapter arrives; the words follow it in. */
.mode .spray::before,
.play .spray::before,
.stills .spray::before {
  clip-path: inset(0 100% 0 0);
}

.mode.is-in .spray::before,
.play.is-in .spray::before,
.stills.is-in .spray::before {
  clip-path: inset(0 0 0 0);
}

.mode .spray,
.mode .mode__tag,
.mode .mode__rule,
.mode .mode__meta,
.play .play__title > *,
.stills .stills__title > * {
  opacity: 0;
  translate: -24px 0;
  transition: opacity 0.5s ease, translate 0.7s var(--out);
}

.mode--right .spray,
.mode--right .mode__tag,
.mode--right .mode__rule,
.mode--right .mode__meta {
  translate: 24px 0;
}

.mode.is-in .spray,
.mode.is-in .mode__tag,
.mode.is-in .mode__rule,
.mode.is-in .mode__meta,
.play.is-in .play__title > *,
.stills.is-in .stills__title > * {
  opacity: 1;
  translate: 0 0;
}

.mode.is-in .spray {
  transition-delay: 0.08s;
}

.mode.is-in .mode__tag,
.play.is-in .play__title .tag,
.stills.is-in .stills__title .tag {
  transition-delay: 0.3s;
}

.mode.is-in .mode__rule {
  transition-delay: 0.42s;
}

.mode.is-in .mode__meta {
  transition-delay: 0.5s;
}

/* ---- Gameplay: the Game view as it is played, HUD and all, never cropped ---- */

.play {
  padding-top: clamp(56px, 8vh, 110px);
}

/* The screen runs edge to edge like the mode chapters; the words keep the page's margin. */
.play__head,
.play__caption {
  margin-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

.play .spray {
  font-size: clamp(52px, 6.4vw, 116px);
}

.play__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(18px, 3vh, 32px);
}

.play__title {
  display: grid;
  justify-items: start;
}

.play__tabs {
  display: flex;
  gap: 6px;
}

/* The game's choices: flat ink, white once chosen, yellow under the cursor. */
.play__tab {
  height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 0;
  background: #17171b;
  color: var(--paper);
  font: italic 800 17px / 1 var(--title);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.play__tab[aria-selected="true"] {
  background: var(--paper);
  color: var(--ink);
}

.play__tab:hover,
.play__tab:focus-visible {
  background: var(--yellow);
  color: var(--ink);
}

.play__screen {
  aspect-ratio: 16 / 9;
  background: #000;
}

.play__video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- The shots: a strip moved with the arrows ---- */

.stills {
  padding: clamp(90px, 14vh, 170px) 0 clamp(60px, 10vh, 120px);
}

.stills__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  margin-bottom: clamp(34px, 5vh, 56px);
}

.stills__title {
  display: grid;
  justify-items: start;
}

.stills__nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stills__count {
  margin: 0 14px 0 0;
  font: italic 900 clamp(34px, 3vw, 48px) / 1 var(--display);
  font-variant-numeric: tabular-nums;
}

.stills__current {
  color: var(--red);
}

.stills__total {
  color: rgba(255, 255, 255, 0.45);
}

.stills__track {
  display: flex;
  gap: clamp(10px, 1.4vw, 20px);
  margin: 0;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) 18px max(var(--gutter), env(safe-area-inset-left));
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: max(var(--gutter), env(safe-area-inset-left));
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--red) transparent;
}

.still {
  flex: 0 0 min(72vw, 1320px);
  display: grid;
  justify-items: start;
  scroll-snap-align: start;
}

.still__open {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #17171b;
  cursor: zoom-in;
}

.still__open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s var(--out);
}

.still__open:hover img {
  transform: scale(1.035);
}

.still__open:focus-visible {
  outline-offset: -3px;
}

/* ---- The close ---- */

.close {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(22px, 3.4vh, 34px);
  min-height: 92vh;
  min-height: 92svh;
  padding: clamp(80px, 12vh, 140px) var(--gutter) max(40px, env(safe-area-inset-bottom));
  text-align: center;
}

.close__backdrop {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.close::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(11, 11, 13, 0.62);
}

.close__logo {
  width: min(60vw, 820px);
  height: auto;
  overflow: visible;
}

.close .button {
  margin-top: clamp(8px, 2vh, 20px);
}

/* ---- The trailer and the shot viewer ---- */

dialog {
  padding: 0;
  border: 0;
  background: var(--ink);
  color: var(--paper);
}

dialog::backdrop {
  background: rgba(11, 11, 13, 0.94);
}

.player {
  width: min(94vw, calc(86vh * 16 / 9));
  max-width: none;
  overflow: visible;
}

.player__video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--ink);
}

.player__close {
  position: absolute;
  right: 0;
  bottom: 100%;
}

.lightbox {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  max-width: none;
  max-height: none;
}

.lightbox__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lightbox__caption {
  position: absolute;
  left: max(var(--gutter), env(safe-area-inset-left));
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
}

.lightbox__prev,
.lightbox__next {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
}

.lightbox__prev {
  left: max(var(--gutter), env(safe-area-inset-left));
}

.lightbox__next {
  right: max(var(--gutter), env(safe-area-inset-right));
}

.lightbox__close {
  position: absolute;
  top: max(var(--gutter), env(safe-area-inset-top));
  right: max(var(--gutter), env(safe-area-inset-right));
}

/* ---- Upright screens ---- */

@media (orientation: portrait) {
  .hero .logo {
    width: min(80vw, 560px);
  }

  .is-live .hero__lockup {
    transform: translateY(calc(-14vh - var(--leave, 0) * 8vh)) scale(calc(0.86 - var(--leave, 0) * 0.08));
  }

  .hero__bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }

  .hero__actions {
    width: 100%;
  }

  .hero__actions .button--primary {
    flex: 1;
    justify-content: center;
  }

  .play__head {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Upright, the Race loop opens from above with the F40 low in the frame: its words take the empty road on top. */
  #race {
    align-content: start;
    padding-top: clamp(90px, 13svh, 130px);
  }

  #race .mode__place {
    top: auto;
    bottom: clamp(24px, 5vh, 56px);
  }

  .play__tabs {
    align-self: stretch;
    flex-wrap: wrap;
  }

  .play__tab {
    flex: 1 1 40%;
  }

  .stills {
    padding-bottom: 36px;
  }

  .close {
    min-height: 78svh;
  }

  .mode--right .mode__words {
    justify-self: start;
    justify-items: start;
    text-align: left;
  }

  .mode__place,
  .mode--right .mode__place {
    left: max(var(--gutter), env(safe-area-inset-left));
    right: auto;
  }

  .still {
    flex-basis: 86vw;
  }

  .close__logo {
    width: min(84vw, 560px);
  }
}

@media (max-width: 560px) {
  .stills__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .stills__nav {
    align-self: flex-end;
  }

  .mode__rule {
    font-size: 16px;
  }

  .mode__place,
  .still__caption {
    flex-wrap: nowrap;
    font-size: 11px;
    letter-spacing: 0.1em;
  }

  .mode__place span,
  .still__caption span {
    padding: 10px 10px 9px;
  }

  .mode__place span + span::before,
  .still__caption span + span::before {
    margin-right: 10px;
  }

  .still__caption span {
    white-space: nowrap;
  }

  .play__caption span:nth-child(3) {
    display: none;
  }
}

/* ---- Still frames for those who asked for less motion ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  .logo__needle {
    transform: none;
  }

  .mode__video {
    transform: none;
  }

  .stills__track {
    scroll-behavior: auto;
  }
}
