/* Tokens come from the App Store screenshot art and the RallyN logo. */
:root {
  --paper: #f2f2f0;
  --ink: #1f3b5c;
  --ink-soft: #4d6077;
  --brand: #3c638e;
  --ball: #d4e23c;
  --line: #c3c8cf;
  --night: #0f2440;
  --screen-top: #0b1733;
  --screen-me: #1747c9;
  --radius-watch: 3.4rem;
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --measure: 34rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--ball);
  outline-offset: 3px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.75rem, 3.6vw, 2.75rem);
  font-weight: 700;
  max-width: 22ch;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

/* Header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem var(--gutter);
}

.brand img {
  width: 132px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.social-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  color: var(--ink);
}

.social-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.social-icon:hover {
  background: rgba(31, 59, 92, 0.08);
}

.header-download {
  margin-left: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
}

.header-download:hover {
  background: var(--brand);
}

/* Hero */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: 2rem;
  padding: clamp(2rem, 6vw, 5rem) var(--gutter) clamp(3rem, 8vw, 6rem);
  overflow: hidden;
}

.court {
  position: absolute;
  inset: 4% -6% -4% 38%;
  width: 70%;
  height: 100%;
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
  z-index: 0;
}

.hero-copy,
.watch-demo {
  position: relative;
  z-index: 1;
}

h1 {
  font-size: clamp(2.75rem, 7vw, 5.25rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}

/* The highlighter stroke repeats the App Store screenshot headline. */
.mark {
  background: linear-gradient(transparent 58%, var(--ball) 58%, var(--ball) 92%, transparent 92%);
  padding: 0 0.08em;
  margin-left: -0.08em;
}

.lede {
  margin-top: 1.5rem;
  max-width: var(--measure);
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
  color: var(--ink-soft);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
  margin-top: 2rem;
}

.store-badge {
  display: inline-block;
  border-radius: 10px;
}

.store-badge img {
  width: 160px;
}

.cta-note {
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

/* Playable watch */

.watch-demo {
  margin: 0;
  display: grid;
  justify-items: center;
  padding-bottom: 4.5rem;
}

.watch {
  position: relative;
  width: min(22rem, 80vw);
  aspect-ratio: 41 / 49;
  padding: 0.85rem;
  border-radius: var(--radius-watch);
  background: linear-gradient(145deg, #2b2d31, #050506 55%, #1d1e21);
  box-shadow:
    0 0 0 2px #3a3c40,
    0 40px 60px -30px rgba(15, 36, 64, 0.55);
}

/* The band, drawn behind the case. */
.watch::before,
.watch::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  height: 24%;
  background: repeating-linear-gradient(90deg, #34363a 0 3px, #2a2c30 3px 6px);
  z-index: -1;
}

.watch::before {
  bottom: 92%;
  border-radius: 1.5rem 1.5rem 0 0;
}

.watch::after {
  top: 92%;
  border-radius: 0 0 1.5rem 1.5rem;
}

.watch-crown {
  position: absolute;
  right: -0.65rem;
  top: 24%;
  width: 0.75rem;
  height: 3.2rem;
  border-radius: 0.4rem;
  background: repeating-linear-gradient(180deg, #4a4c50 0 2px, #26282b 2px 4px);
}

.watch-button {
  position: absolute;
  right: -0.35rem;
  top: 52%;
  width: 0.4rem;
  height: 3.6rem;
  border-radius: 0.3rem;
  background: #2c2e32;
}

.watch-screen {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  height: 100%;
  border-radius: calc(var(--radius-watch) - 0.85rem);
  overflow: hidden;
  background: #000;
  color: #fff;
}

.half {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  border: 0;
  padding: 0.5rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.half-them {
  background: linear-gradient(180deg, #050a18, var(--screen-top));
}

.half-me {
  background: linear-gradient(180deg, #0a2470, var(--screen-me));
}

.half:focus-visible {
  outline-offset: -4px;
  border-radius: 0;
}

.half-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
}

.half-points {
  position: relative;
  display: flex;
  align-items: center;
  font-size: clamp(3rem, 12vw, 4.25rem);
  font-weight: 300;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  min-height: 1em;
}

.serve-ball {
  position: absolute;
  right: calc(100% + 0.6rem);
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at -20% 50%, transparent 58%, #8a9419 60%, transparent 66%),
    radial-gradient(circle at 120% 50%, transparent 58%, #8a9419 60%, transparent 66%),
    var(--ball);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s, transform 0.2s;
}

.is-serving .serve-ball {
  opacity: 1;
  transform: scale(1);
}

/* Confirms which side took the point. */
.is-scored::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.22);
  animation: tap-flash 0.35s ease-out forwards;
  pointer-events: none;
}

@keyframes tap-flash {
  to {
    opacity: 0;
  }
}

.watch-middle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: #000;
}

.undo {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #000;
  cursor: pointer;
}

.undo svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}

.undo:disabled {
  opacity: 0.35;
  cursor: default;
}

.games {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  /* Balances the undo button so the games stay centered. */
  margin-right: 2.9rem;
}

.games-row {
  display: flex;
  gap: 0.5rem;
}

.set-done {
  color: #8e8e93;
}

.is-finished .set-done {
  color: #fff;
}

/* Space below the caption leaves room for the top band. */
.watch-demo figcaption {
  margin-bottom: 4.5rem;
  max-width: 26rem;
  text-align: center;
  font-weight: 600;
}

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

.demo-cta {
  margin: 4.75rem 0 -3rem;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  background: var(--ball);
  color: var(--ink);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.demo-cta:hover {
  background: #e2ee5a;
}

/* Download bar for small screens, shown by page.js. */
.sticky-cta {
  display: none;
}

@media (max-width: 900px) {
  .sticky-cta:not([hidden]) {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0.6rem 0.6rem 1.1rem;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 0.9375rem;
    box-shadow: 0 12px 30px -12px rgba(15, 36, 64, 0.6);
  }

  .sticky-cta a {
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    background: var(--ball);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
  }
}

/* Contrast with other apps */

.contrast,
.screens,
.rules {
  padding: clamp(3.5rem, 8vw, 6.5rem) var(--gutter);
}

.contrast {
  background: #fff;
}

.contrast-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 3.5rem);
  margin-top: 3rem;
}

.contrast-grid > div {
  padding-top: 1.25rem;
  border-top: 3px solid var(--ink);
}

.contrast-grid p {
  margin-top: 0.6rem;
  color: var(--ink-soft);
  max-width: 30ch;
}

/* Screens */

.screen-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(1rem, 2.5vw, 2rem);
  margin: 3rem 0 0;
  padding: 0;
  list-style: none;
}

.screen-rail img {
  width: 100%;
  /* The store art has its own headline at the top. Crop to the phone, since the caption below carries the message. */
  aspect-ratio: 646 / 900;
  object-fit: cover;
  object-position: bottom;
  border-radius: 1.25rem;
  box-shadow: 0 24px 40px -28px rgba(15, 36, 64, 0.45);
  margin-bottom: 1.25rem;
}

.screen-rail p {
  margin-top: 0.4rem;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

/* Rules */

.rules {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 2.5rem clamp(2rem, 6vw, 5rem);
  align-items: start;
  border-top: 1px solid var(--line);
}

.rules-copy p {
  margin-top: 1rem;
  max-width: 30rem;
  color: var(--ink-soft);
}

.rule-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.rule-list li {
  padding: 0.95rem 0.5rem 0.95rem 0;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}

.rule-list li:nth-child(odd) {
  padding-right: 1.5rem;
}

/* Follow */

.follow {
  position: relative;
  overflow: hidden;
  padding: clamp(4rem, 9vw, 7rem) var(--gutter);
  background: var(--night);
  color: #fff;
}

/* The flight of a ball across the band. */
.follow-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--ball);
  stroke-width: 2;
  stroke-dasharray: 2 12;
  stroke-linecap: round;
  opacity: 0.55;
}

.follow-inner {
  position: relative;
}

.follow p {
  margin-top: 1rem;
  max-width: var(--measure);
  color: rgba(255, 255, 255, 0.78);
}

.video-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(1rem, 2.5vw, 1.75rem);
  margin: 2.75rem 0 0;
  padding: 0;
  list-style: none;
}

.video-rail video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
  border-radius: 1.25rem;
  background: #000;
}

.video-rail h3 {
  margin-top: 0.9rem;
  font-size: 1rem;
}

.follow-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.25rem;
}

.follow-link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.5rem 0.9rem 1.1rem;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.follow-link:hover {
  background: var(--ball);
}

.follow-link svg {
  width: 1.75rem;
  height: 1.75rem;
  fill: currentColor;
}

.follow-link span {
  display: grid;
  line-height: 1.25;
}

.follow-link small {
  font-size: 0.875rem;
  color: var(--ink-soft);
}

/* Closing */

.closing {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: clamp(4rem, 9vw, 7rem) var(--gutter);
  text-align: center;
}

.closing h2 {
  max-width: none;
}

.closing p {
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.closing-symbol {
  width: 72px;
}

.closing .store-badge img {
  width: 170px;
}

/* Footer */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding: 2rem var(--gutter) 2.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.site-footer nav {
  display: flex;
  gap: 1.25rem;
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.fineprint {
  flex-basis: 100%;
  font-size: 0.75rem;
}

/* Small screens */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 3.5rem;
  }

  .court {
    inset: 45% -20% 0 -20%;
    width: 140%;
    height: 55%;
  }

  .contrast-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .screen-rail {
    display: flex;
    gap: 1rem;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
  }

  .screen-rail li {
    flex: 0 0 min(15rem, 68vw);
    scroll-snap-align: start;
  }

  .rules {
    grid-template-columns: 1fr;
  }

  .video-rail {
    display: flex;
    gap: 1rem;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
  }

  .video-rail li {
    flex: 0 0 min(14rem, 62vw);
    scroll-snap-align: start;
  }
}

@media (max-width: 520px) {
  .social-icon {
    display: none;
  }

  .rule-list {
    grid-template-columns: 1fr;
  }

  .rule-list li:nth-child(odd) {
    padding-right: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .is-scored::after {
    animation: none;
    opacity: 0;
  }

  .serve-ball {
    transition: none;
  }
}
