/* Tokens from the iOS redesign build's Theme.swift (design/ios-redesign on the
   design/ios-redesign branch): the always-dark Feed palette, the dark accent, and the
   dark score colours, lowest score first. */
:root {
  --bg: #060416;
  --glow-pink: #ff00a2;
  --glow-red: #ff002b;
  --accent: oklch(0.68 0.2 320);
  --copy: rgb(255 255 255 / 0.8);
  --muted: rgb(255 255 255 / 0.6);

  --tier-1: oklch(0.62 0 0);
  --tier-2: oklch(0.93 0 0);
  --tier-3: oklch(0.68 0.17 262);
  --tier-4: oklch(0.88 0.17 98);
  --tier-5: oklch(0.74 0.19 55);
  --tier-6: oklch(0.7 0.24 330);

  --gutter: 16px;

  color-scheme: dark;
}

@media (min-width: 768px) {
  :root {
    --gutter: 24px;
  }
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/ibm-plex-sans-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/ibm-plex-sans-semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/fonts/ibm-plex-sans-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Registered so they animate smoothly: the score in tenths, its tier colour, and how far
   the taste-match circles have come together. The initial values are the end states,
   shown when motion is reduced. */
@property --t {
  syntax: "<integer>";
  inherits: true;
  initial-value: 97;
}

@property --tier {
  syntax: "<color>";
  inherits: true;
  initial-value: oklch(0.7 0.24 330);
}

@property --p {
  syntax: "<number>";
  inherits: true;
  initial-value: 1.41;
}

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

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

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
  padding: max(var(--gutter), env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  background: var(--bg);
  color: #fff;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
p {
  margin: 0;
}

main {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

/* The feed's lights (FeedGlow): the pink ellipse behind Followed and the red one behind
   Popular, sized on the app's 390pt frame (--u is one point). Here nobody switches tabs,
   so they take turns being the strong one, as on a switch but slowly, and drift around
   behind the glass on their own. Different loop lengths keep the pattern from repeating
   soon. Phones get them a little larger, since here they light the whole screen. */
.glow {
  --u: clamp(1.3px, 100vw / 300, 2.6px);
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.glow span {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  filter: blur(calc(var(--u) * 70));
  will-change: translate, opacity;
}

.glow-pink {
  width: calc(var(--u) * 302);
  height: calc(var(--u) * 254);
  margin: calc(var(--u) * -127) 0 0 calc(var(--u) * -151);
  background: var(--glow-pink);
  translate: -26vw -24vh;
  animation:
    drift-pink 26s ease-in-out infinite,
    turn-pink 9s ease-in-out infinite alternate;
}

.glow-red {
  width: calc(var(--u) * 258);
  height: calc(var(--u) * 302);
  margin: calc(var(--u) * -151) 0 0 calc(var(--u) * -129);
  background: var(--glow-red);
  opacity: 0.35;
  translate: 24vw -28vh;
  animation:
    drift-red 33s ease-in-out infinite,
    turn-red 9s ease-in-out infinite alternate;
}

/* Pink circles clockwise and red counter-clockwise, so they cross and blend. */
@keyframes drift-pink {
  0%, 100% { translate: -26vw -24vh; }
  25% { translate: 20vw -30vh; }
  50% { translate: 26vw 22vh; }
  75% { translate: -18vw 28vh; }
}

@keyframes drift-red {
  0%, 100% { translate: 24vw -28vh; }
  25% { translate: -22vw -20vh; }
  50% { translate: -26vw 26vh; }
  75% { translate: 18vw 24vh; }
}

/* Followed selected (pink 1, red 0.35) to Popular selected (pink 0.35, red 1). */
@keyframes turn-pink {
  0%, 15% { opacity: 1; }
  85%, 100% { opacity: 0.35; }
}

@keyframes turn-red {
  0%, 15% { opacity: 0.35; }
  85%, 100% { opacity: 1; }
}

/* Liquid Glass stand-in: a translucent fill over a blurred backdrop with a lit top edge.
   A faint dark tint keeps body copy readable when a light passes behind it. */
.panel {
  position: relative;
  border-radius: clamp(28px, 4vw, 44px);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.13), rgb(255 255 255 / 0.04)),
    rgb(6 4 22 / 0.28);
  border: 1px solid rgb(255 255 255 / 0.16);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.32),
    inset 0 -1px 0 rgb(255 255 255 / 0.05),
    0 30px 80px rgb(0 0 0 / 0.35);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
}

/* Shared bits */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent) 35%, rgb(255 255 255 / 0.06));
  border: 1px solid rgb(255 255 255 / 0.16);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px 2px rgb(255 255 255 / 0.6);
  animation: blink 1.6s ease-in-out infinite;
}

@keyframes blink {
  50% { opacity: 0.35; }
}

h2 {
  font-size: clamp(34px, 5vw, 60px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

/* Hero: the full-window panel */

.hero {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: calc(100vh - 2 * var(--gutter));
  min-height: calc(100svh - 2 * var(--gutter));
  padding: clamp(20px, 3vw, 32px);
}

.hero-body {
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 56px 0;
  text-align: center;
}

h1 {
  max-width: 11em;
  margin-top: 26px;
  font-size: clamp(46px, 9vw, 116px);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-wrap: balance;
  text-shadow: 0 2px 30px rgb(6 4 22 / 0.3);
}

/* A slow sheen of the two light colours across the last word. */
.shine {
  background: linear-gradient(100deg, #fff 20%, oklch(0.86 0.12 345) 40%, oklch(0.84 0.13 15) 55%, #fff 75%) 0 0 / 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  animation: shine 9s ease-in-out infinite alternate;
}

@keyframes shine {
  to { background-position: 100% 0; }
}

.lede {
  max-width: 32em;
  margin-top: 24px;
  color: var(--copy);
  font-size: clamp(17px, 1.7vw, 21px);
  line-height: 1.5;
  text-wrap: pretty;
}

.cue {
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-decoration: none;
  text-transform: uppercase;
}

.cue:hover {
  color: #fff;
}

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

.arrow {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  rotate: 45deg;
  animation: bob 1.8s ease-in-out infinite;
}

@keyframes bob {
  50% { translate: 0 5px; }
}

/* The three ideas: copy beside an abstract animation (never a screen of the app). */

.step {
  display: grid;
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
  padding: clamp(28px, 5vw, 72px);
}

@media (min-width: 900px) {
  .step {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .step:nth-of-type(2) .stage {
    order: -1;
  }
}

.copy {
  max-width: 32em;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  font-variant-numeric: tabular-nums;
}

.kicker::after {
  content: "";
  width: 36px;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--glow-pink), var(--glow-red));
}

.copy h2 {
  margin-top: 18px;
}

.copy p:not(.kicker) {
  margin-top: 18px;
  color: var(--copy);
  font-size: clamp(17px, 1.6vw, 19px);
  line-height: 1.55;
  text-wrap: pretty;
}

.stage {
  display: grid;
  place-items: center;
  min-height: clamp(280px, 32vw, 420px);
  overflow: hidden;
  border-radius: clamp(22px, 3vw, 32px);
  background: rgb(6 4 22 / 0.45);
  border: 1px solid rgb(255 255 255 / 0.08);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
}

/* 01 — a score counting up, its colour changing as it climbs. */

.meter {
  --t: 97;
  --tier: var(--tier-6);
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(100%, 380px);
  padding: 24px;
  animation: meter 12s ease-in-out infinite;
}

@keyframes meter {
  0%, 10% { --t: 15; --tier: var(--tier-1); }
  16.67%, 26.67% { --t: 32; --tier: var(--tier-2); }
  33.33%, 43.33% { --t: 54; --tier: var(--tier-3); }
  50%, 60% { --t: 71; --tier: var(--tier-4); }
  66.67%, 76.67% { --t: 88; --tier: var(--tier-5); }
  83.33%, 95% { --t: 97; --tier: var(--tier-6); }
  100% { --t: 15; --tier: var(--tier-1); }
}

.score {
  counter-reset: whole calc(round(down, var(--t) / 10)) tenth calc(mod(var(--t), 10));
  color: var(--tier);
  font-size: clamp(92px, 12vw, 152px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: 0 0 36px color-mix(in oklch, var(--tier) 55%, transparent);
}

.score::before {
  content: counter(whole) "." counter(tenth);
}

.spectrum {
  position: relative;
  width: 100%;
  height: 6px;
  margin-top: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    var(--tier-1) 0 20%,
    var(--tier-2) 20% 40%,
    var(--tier-3) 40% 60%,
    var(--tier-4) 60% 80%,
    var(--tier-5) 80% 95%,
    var(--tier-6) 95%);
}

.marker {
  position: absolute;
  top: 50%;
  left: calc(var(--t) * 1%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  translate: -50% -50%;
  box-shadow: 0 0 0 3px var(--bg), 0 0 18px 3px var(--tier);
}

/* 02 — two listeners' tastes drifting together. One value, --p, drives both the circles
   and the number, so the match is exactly how much of a circle the other one covers.
   Below zero the circles are apart (by up to 0.8 of a diameter per unit); from zero up,
   --p is the half-angle θ of the lens they share, so their centres sit cos θ diameters
   apart and the shared share of each circle is (2θ − sin 2θ) / π. 1.41 is about 80%. */

.match {
  --p: 1.41;
  --th: max(0, var(--p));
  --sep: calc(cos(var(--th)) + max(0, -1 * var(--p)) * 0.8);
  --f: calc((2 * var(--th) - sin(2 * var(--th))) / pi);
  display: grid;
  justify-items: center;
  width: min(100%, 420px);
  padding: 24px;
  animation: match 9s ease-in-out infinite;
}

@keyframes match {
  0%, 12% { --p: -0.6; }
  52%, 80% { --p: 1.41; }
  96%, 100% { --p: -0.6; }
}

.orbs {
  position: relative;
  width: 100%;
  height: clamp(100px, 13vw, 150px);
}

.orb {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  mix-blend-mode: screen;
}

/* Translate percentages are of the circle's own diameter. */
.orb.you {
  translate: calc(-50% - 50% * var(--sep)) 0;
  background: radial-gradient(circle, rgb(255 0 162 / 0.5), rgb(255 0 162 / 0.12) 62%, transparent 71%);
  border: 2px solid rgb(255 0 162 / 0.85);
  box-shadow: 0 0 40px rgb(255 0 162 / 0.45);
}

.orb.them {
  translate: calc(-50% + 50% * var(--sep)) 0;
  background: radial-gradient(circle, rgb(255 0 43 / 0.5), rgb(255 0 43 / 0.12) 62%, transparent 71%);
  border: 2px solid rgb(255 0 43 / 0.85);
  box-shadow: 0 0 40px rgb(255 0 43 / 0.45);
}

/* A spark where they meet, growing with the overlap. */
.orbs::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  translate: -50% -50%;
  scale: calc(0.4 + 0.75 * var(--f));
  opacity: calc(1.25 * var(--f));
  background: radial-gradient(circle, #fff, rgb(255 255 255 / 0) 70%);
  filter: blur(4px);
}

.pct {
  margin-top: 26px;
  counter-reset: match calc(var(--f) * 100);
  font-size: clamp(60px, 8vw, 100px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.04em;
}

.pct::before {
  content: counter(match) "%";
}

.match-label {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

/* 03 — an equaliser in the two light colours, loudest in the middle. */

.eq {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.8vw, 8px);
  height: clamp(150px, 18vw, 230px);
  padding: 0 24px;
}

.eq span {
  --a: 1;
  --d: 1.1s;
  width: clamp(5px, 0.8vw, 9px);
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(to top, var(--glow-red), var(--glow-pink) 60%, oklch(0.9 0.08 345));
  box-shadow: 0 0 18px rgb(255 0 162 / 0.35);
  scale: 1 calc(var(--a) * 0.6);
  animation: eq var(--d) ease-in-out infinite alternate;
}

.eq span:nth-child(-n + 4),
.eq span:nth-last-child(-n + 4) { --a: 0.45; }

.eq span:nth-child(n + 5):nth-child(-n + 8),
.eq span:nth-last-child(n + 5):nth-last-child(-n + 8) { --a: 0.72; }

.eq span:nth-child(3n + 1) { --d: 0.9s; }
.eq span:nth-child(3n + 2) { --d: 1.3s; }
.eq span:nth-child(4n + 1) { animation-delay: -0.2s; }
.eq span:nth-child(4n + 2) { animation-delay: -0.7s; }
.eq span:nth-child(4n + 3) { animation-delay: -0.4s; }
.eq span:nth-child(4n) { animation-delay: -1s; }

@keyframes eq {
  from { scale: 1 calc(var(--a) * 0.16); }
  to { scale: 1 var(--a); }
}

/* Closing */

.outro {
  display: grid;
  justify-items: center;
  gap: 22px;
  padding: clamp(56px, 9vw, 128px) clamp(24px, 5vw, 72px);
  text-align: center;
}

.outro h2 {
  font-size: clamp(38px, 6vw, 76px);
}

.outro p:not(.pill) {
  max-width: 30em;
  color: var(--copy);
  font-size: clamp(17px, 1.7vw, 20px);
  line-height: 1.55;
  text-wrap: pretty;
}

.outro .pill {
  margin-top: 10px;
}

.foot {
  padding: 4px 0 8px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

/* Entrances: the hero rises in on load, and each section as it scrolls into view
   (scroll-driven where the browser supports it, otherwise simply shown). */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .hero-body > *,
  .cue {
    animation: enter 1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .hero-body > :nth-child(2) { animation-delay: 0.12s; }
  .hero-body > :nth-child(3) { animation-delay: 0.24s; }
  .cue { animation-delay: 0.6s; }

  /* Each finishes by the time it is fully on screen, so the last ones still land when
     the page can scroll no further. */
  @supports (animation-timeline: view()) {
    .step .copy,
    .step .stage,
    .outro > * {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 100%;
    }

    .step .stage {
      animation-range: entry 25% entry 100%;
    }
  }
}

@keyframes enter {
  from { opacity: 0; translate: 0 24px; filter: blur(10px); }
}

@keyframes reveal {
  from { opacity: 0; translate: 0 48px; filter: blur(6px); }
}

/* Reduced motion: everything holds its end state. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
  }
}
