/* Play Sports case study. The layout (sidebar, slides, grid) is shared: case.css and
   case.js. This file holds each slide's backdrop (.stage) and what sits on it: the
   original 2021 motion pieces as videos, and screens and cards from Figma and Sketch. */

:root {
  --brand: #58d475; /* Play Sports green, from the old case page */
  --paper-app: #f5f5f5; /* the light grey the screens were shown on */
  --dark: #0e0f0e;
  --mist: #eef0f2; /* a light cool grey, so the cards' shadows read */
  --mint: #ecfbef; /* the 2020 case's pale green */
  --deep: #163d24; /* a deep version of the app's green (#42af5c) */
  --navy: #0f172f; /* the website's night blue, behind Djokovic */
  --screen-shadow: 0 30px 60px rgba(0, 0, 0, 0.22), 0 8px 16px rgba(0, 0, 0, 0.12);
  --pad: clamp(20px, 5vw, 64px);
}

img,
video {
  -webkit-user-drag: none;
}

/* ── Stages ─────────────────────────────────────────────── */

.stage {
  position: relative;
  overflow: hidden;
  padding: var(--pad);
}

.stage-brand { background: var(--brand); }
.stage-paper { background: var(--paper-app); }
.stage-white { background: #fff; }
.stage-dark { background: var(--dark); }
.stage-mist { background: var(--mist); }
.stage-mint { background: var(--mint); }
.stage-deep { background: var(--deep); }
.stage-navy { background: var(--navy); }

/* shapes go on the slide, not on the stretched stage (Firefox), with width: 100% (Chrome) */
.shot-wide { width: 100%; aspect-ratio: 16 / 10; }
.shot-tile { width: 100%; aspect-ratio: 3 / 4; }
.shot-landing { width: 100%; aspect-ratio: 10 / 9; }

/* a flat screen with the iPhone's rounded corners (39 of 375 × 812 pt) */
.screen {
  display: block;
  border-radius: 10.4% / 4.8%;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--screen-shadow);
}

.screen img,
.screen video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 750 / 1624;
}

.stage-dark .screen {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 30px 60px rgba(0, 0, 0, 0.5);
}

/* a screen as tall as its tile, minus the padding */
.phone-fit {
  position: absolute;
  top: 8%;
  bottom: 8%;
  left: 50%;
  aspect-ratio: 750 / 1624;
  translate: -50% 0;
}

.phone-fit > video,
.phone-fit > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* no white behind a video: it showed as a hairline along the rounded edge */
.screen:has(> video) {
  background: transparent;
}

/* ── 2. The app on three screens ────────────────────────── */

.shot-phones { width: 100%; aspect-ratio: 16 / 10; }

/* three phones as tall as the slide minus equal margins, side by side */
.phones-row {
  position: absolute;
  inset: 8% 0;
  display: flex;
  justify-content: center;
  gap: 5%;
}

.phones-row > .screen {
  position: relative;
  height: 100%;
  aspect-ratio: 375 / 812;
  flex: none;
}

.phones-row > .screen > video {
  height: 100%;
  object-fit: cover;
}

/* search: every layer is the whole 750 × 1624 screen, so they line up by stacking;
   the club page is longer and scrolls */
.m-search > * {
  position: absolute;
  left: 0;
  top: 0;
}

.screen.m-search > img {
  width: 100%;
  height: auto;
}

.screen.m-search > .ms-club {
  aspect-ratio: 750 / 2824;
}

/* without motion the search with its results shows; these only appear while it plays */
.m-search > .ms-field-empty,
.m-search > .ms-popular,
.m-search > .ms-caret,
.m-search > .ms-keyboard,
.m-search > .ms-key,
.m-search > .ms-club,
.m-search > .tap {
  opacity: 0;
  visibility: hidden;
}

/* a fingertip, as the iOS simulator shows touches (44 pt) */
.m-search > .tap {
  width: calc(44 / 375 * 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.28);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

/* ── 4. Cards ───────────────────────────────────────────── */

/* the cards cut out with their shadows baked in (transparent around them) */
.card-cols {
  position: absolute;
  inset: 0 -6%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: start;
}

/* each card once; the columns start above the slide at their own offsets
   (in % of the board's width) so they overrun it top and bottom wherever they drift */
.card-col {
  will-change: transform;
}

.card-col img {
  display: block;
  width: 100%;
  height: auto;
}

.card-col:nth-child(1) { margin-top: -9%; }
.card-col:nth-child(2) { margin-top: -5.8%; }
.card-col:nth-child(3) { margin-top: -15%; }
.card-col:nth-child(4) { margin-top: -7.5%; }

/* ── 5. Landing page ────────────────────────────────────── */

/* a window onto the page; play-sports.js moves the page through it as the slide scrolls past */
.landing-window {
  position: absolute;
  top: 7%;
  bottom: 7%;
  left: 50%;
  width: 72%;
  translate: -50% 0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--screen-shadow);
}

.landing-window img {
  display: block;
  width: 100%;
  will-change: transform;
}

/* ── Homepage hero ──────────────────────────────────────── */

/* the homepage's dark hero (1440 × 900), centred with equal margins */
.site-window {
  position: absolute;
  top: 9%;
  bottom: 9%;
  left: 50%;
  aspect-ratio: 1440 / 900;
  translate: -50% 0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 30px 80px rgba(0, 0, 0, 0.45);
}

.site-window img {
  display: block;
  width: 100%;
  height: 100%;
}

/* the header in its two states, stacked; Nadal's shows only while it is the active story */
.header-carousel > img {
  position: absolute;
  inset: 0;
}

.header-carousel .header-next {
  opacity: 0;
}

/* the active item's progress line (2 pt, the app's green) under one of the four stories,
   which sit at x 80 + 330n, 290 wide, on the 1440 × 900 header */
.header-progress {
  position: absolute;
  left: calc((80 + 330 * var(--item)) / 1440 * 100%);
  top: calc(866 / 900 * 100%);
  width: calc(290 / 1440 * 100%);
  height: calc(2 / 900 * 100%);
  min-height: 1px;
  background: #42af5c;
  transform: scaleX(0.5);
  transform-origin: 0 50%;
}

/* ── 1. Hero: the website ───────────────────────────────── */

/* the site in a window with rounded corners all round, centred, the same margin
   above and below */
.web-screen {
  position: absolute;
  top: 9%;
  bottom: 9%;
  left: 50%;
  aspect-ratio: 1440 / 1000;
  translate: -50% 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--screen-shadow);
}

.web-screen video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 699px) {
  .shot-landing { aspect-ratio: 3 / 4; }
  .landing-window { width: 88%; }
  .card-cols { inset: 0 -20%; }
  .shot-wide { aspect-ratio: 4 / 5; }
  .shot-phones { aspect-ratio: 4 / 3; }
  .phones-row { inset: 10% 0; gap: 3%; }
  .web { justify-content: center; }
  .web-screen { position: static; translate: none; width: 100%; height: auto; }
  .site { justify-content: center; }
  .site-window { position: relative; top: auto; bottom: auto; left: auto; translate: none; width: 100%; }
}
