/* Chaos Games holding page. Colours, fonts and the banner match the store (web/src/app/globals.css). */

@font-face {
  font-family: "Unbounded";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/fonts/unbounded-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/noto-sans-latin.woff2") format("woff2");
}

:root {
  --night: #1e1f22;
  --heading: #f2f3f5;
  --brand: #ff9a00;
  --brand-dark: #e08800;
  --on-brand: #1e1f22;
  --blue: #3b5ce0;
  --blue-light: #6a88ff;
  --blue-soft: color-mix(in oklab, var(--blue), white 15%);

  --gutter: 16px;
  --pad: clamp(24px, 4.5vw, 64px);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  background: var(--night);
}

body {
  color: var(--heading);
  font-family: "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--brand);
  color: var(--on-brand);
}

.frame {
  min-height: 100svh;
  padding: var(--gutter);
  display: grid;
}

/* The store's homepage banner, grown to fill the screen. */
.banner {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 16px;
  min-height: calc(100svh - 2 * var(--gutter));
  padding: var(--pad);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "brand brand"
    "copy mark";
  column-gap: clamp(24px, 4vw, 72px);
}

.backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(70% 110% at 100% 100%, var(--blue) 0%, transparent 70%),
    linear-gradient(to bottom right, var(--blue-light), var(--blue-soft));
}

.dots,
.grain {
  position: absolute;
  inset: 0;
}

.dots {
  background-image: radial-gradient(rgb(255 255 255 / 0.55) 1.2px, transparent 1.7px);
  background-size: 14px 14px;
  opacity: 0.58;
}

.grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.4;
  mix-blend-mode: soft-light;
}

.tiles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.brand,
.copy,
.mark-slot {
  position: relative;
  z-index: 1;
}

/* The logo and name sit on the dark of the favicon's tile: the orange G nearly vanishes on the pale blue. */
.brand {
  grid-area: brand;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 8px 12px;
  border-radius: 12px;
  background: #202225;
  box-shadow: 0 8px 20px rgb(20 30 92 / 0.35);
  font-family: "Unbounded", "Noto Sans", sans-serif;
  font-size: clamp(15px, 1.15vw, 18px);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: auto;
  display: block;
}

/* The logo's space takes touches itself, so dragging a finger through the tiles moves them instead of scrolling. */
.mark-slot {
  grid-area: mark;
  align-self: center;
  justify-self: center;
  width: min(100%, calc(min(66svh, 640px) * 0.8536));
  aspect-ratio: 21.34 / 25;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.mark-fallback {
  display: block;
  width: 100%;
  height: 100%;
}

/* Once the tiles are drawing, they take the logo's place. */
.tiles-on .mark-fallback {
  visibility: hidden;
}

.copy {
  grid-area: copy;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(28px, 3.2vw, 44px);
  padding-block: clamp(16px, 4svh, 64px);
}

.headline {
  margin: 0;
  max-width: 11.5em;
  font-family: "Unbounded", "Noto Sans", sans-serif;
  /* Sized by the window's height too, so short laptop screens don't scroll. */
  font-size: clamp(2.5rem, min(5.6vw, 8.2svh), 6.25rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

/* Each word rises out of its own box. The padding keeps the tops of capitals and the descenders from being clipped. */
.word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding: 0.1em 0.03em 0.16em;
  margin: -0.1em -0.03em -0.16em;
}

.word-inner {
  display: inline-block;
  transition: transform 0.9s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 70ms);
}

/* Time left until launch, on the same dark tiles as the name. */
.countdown {
  display: flex;
  gap: 10px;
}

.countdown-date {
  margin: 0;
  font-weight: 600;
}

.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 76px;
  padding: 10px 12px 9px;
  border-radius: 12px;
  background: #202225;
  box-shadow: 0 8px 20px rgb(20 30 92 / 0.35);
}

.countdown-value {
  display: block;
  font-family: "Unbounded", "Noto Sans", sans-serif;
  font-size: clamp(22px, 2.1vw, 30px);
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

/* Each number drops in as it changes. */
.countdown-value.tick {
  animation: tick 0.35s var(--ease-out);
}

@keyframes tick {
  from {
    opacity: 0.3;
    transform: translateY(-40%);
  }
}

.countdown-label {
  font-size: 12px;
  color: #b5bac1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.email {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 6px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: clamp(16px, 1.1vw, 18px);
  font-weight: 600;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    opacity 0.7s ease,
    transform 0.9s var(--ease-out);
}

.email:hover {
  background: var(--brand-dark);
}

.email:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* The intro: hidden until the tiles have gathered, then the words rise and the rest fades in. */
.js .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition:
    background-color 0.15s ease,
    opacity 0.7s ease,
    transform 0.9s var(--ease-out);
  transition-delay: 0s, var(--delay, 0s), var(--delay, 0s);
}

.js .word-inner {
  transform: translateY(135%);
}

.js:not(.ready) .headline:not(.split) {
  opacity: 0;
}

.ready .reveal,
.ready .word-inner {
  opacity: 1;
  transform: none;
}

.brand.reveal {
  --delay: 0.15s;
}

.countdown.reveal {
  --delay: 0.6s;
}

.email.reveal {
  --delay: 0.8s;
}

/* Phones and narrow windows: the logo goes above the words. */
@media (max-width: 860px) {
  :root {
    --gutter: 12px;
  }

  .banner {
    border-radius: 12px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "brand"
      "mark"
      "copy";
  }

  .mark-slot {
    width: min(92%, calc(min(44svh, 560px) * 0.8536));
    margin-block: clamp(12px, 3svh, 40px);
  }

  /* Everything centred on the screen's middle line, under the logo. */
  .brand {
    justify-self: center;
  }

  .copy {
    padding-block: 0;
    align-items: center;
    text-align: center;
  }

  .headline {
    font-size: clamp(2.1rem, 9.4vw, 3.6rem);
  }

  .countdown {
    justify-content: center;
  }
}

/* Short phones: a smaller logo and tighter spacing, so the countdown and button still fit without scrolling. */
@media (max-width: 860px) and (max-height: 780px) {
  .mark-slot {
    width: min(80%, calc(28svh * 0.8536));
  }

  .copy {
    gap: 20px;
  }

  .countdown-unit {
    min-width: 66px;
    padding: 8px 10px 7px;
  }

  .countdown-value {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal,
  .js .word-inner {
    transition: none;
  }

  .countdown-value.tick {
    animation: none;
  }
}
