/* Loop case study. The layout (sidebar, slides, grid) is shared: case.css and
   case.js. This file holds each slide's backdrop (.stage) and the pieces of the
   app laid out on it: phone mockups and screens exported at 2x from Figma. */

:root {
  /* the app's own night sky, sampled from its screens: pale blue top left, mauve, violet on the right */
  --sky:
    radial-gradient(42% 70% at 6% 0%, #aac8f0 0%, rgba(170, 200, 240, 0) 70%),
    radial-gradient(45% 80% at 30% 18%, #a19bca 0%, rgba(161, 155, 202, 0) 70%),
    radial-gradient(40% 70% at 46% 30%, #7b537f 0%, rgba(123, 83, 127, 0) 75%),
    radial-gradient(34% 60% at 96% 62%, #52407c 0%, rgba(82, 64, 124, 0) 80%),
    #131115;
  /* the morning reflection's gold */
  --dawn:
    radial-gradient(50% 80% at 8% 0%, #c9dcd6 0%, rgba(201, 220, 214, 0) 70%),
    radial-gradient(60% 90% at 40% 30%, #c8bf86 0%, rgba(200, 191, 134, 0) 75%),
    #e9e1cc;
  --night: #131115; /* the screens' own background: the onboarding visuals fade into it */
  --mist: #e4e0ec;
  --ink: #1d1a21;
  --phone-shadow: 0 30px 60px rgba(10, 6, 20, 0.35), 0 8px 16px rgba(10, 6, 20, 0.2);
  --pad: clamp(20px, 5vw, 64px);
}

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

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

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

.stage-sky,
.tile-sky { background: var(--sky); }
.stage-night { background: var(--night); }
.stage-mist,
.tile-mist { background: var(--mist); }
.stage-dawn,
.tile-dawn { background: var(--dawn); }
.stage-ink,
.tile-ink { background: var(--ink); }

/* 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: 4 / 3; }

.shots .shot > .stage { align-items: center; }

/* a flat screen with the phone's rounded corners (47 of 390 × 844 pt) */
.screen {
  display: block;
  border-radius: 12% / 5.57%;
  overflow: hidden;
  box-shadow: var(--phone-shadow);
}

.screen img {
  display: block;
  width: 100%;
}

/* ── 1. Hero ────────────────────────────────────────────── */

.shot > .stage.hero {
  justify-content: center;
  perspective: 1600px;
}

/* the three phones sit in the middle of the slide, the outer two a step lower */
.hero-phones {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3%;
  transform-origin: 50% 0;
}

.hero-phone {
  position: relative;
  width: 23%;
}

/* the mockup photo, which also shows the screen as designed when nothing runs */
.hero-bezel {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 40px 50px rgba(10, 6, 20, 0.35));
}

.hero-phone:nth-child(2) {
  translate: 0 -5%;
}

.hero-phone:nth-child(1),
.hero-phone:nth-child(3) {
  translate: 0 5%;
}

/* The live screen, laid over the photo's screen: x 35–865, y 31 of the 900 × 1863
   mockup, at the design's 390 × 844 shape, with the glass's rounded corners.
   Its layers are placed in the design's points (--x, --y, --w). */
.hero-screen {
  position: absolute;
  left: calc(35 / 900 * 100%);
  top: calc(31 / 1863 * 100%);
  width: calc(830 / 900 * 100%);
  aspect-ratio: 390 / 844;
  border-radius: 13.98% / 6.46%;
  overflow: hidden;
  background: #131115;
  visibility: hidden;
}

.hero.is-live .hero-screen,
.hero.is-live .hero-island {
  visibility: visible;
}

.hero-orbs,
.hero-grain,
.hero-ui {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-screen [style*="--x"] {
  position: absolute;
  left: calc(var(--x) / 390 * 100%);
  top: calc(var(--y) / 844 * 100%);
  width: calc(var(--w) / 390 * 100%);
  height: auto;
}

.hero-word,
.hero-reply {
  will-change: opacity, filter, transform;
}

.hero-bar {
  transform-origin: 50% 50%;
}

/* the Dynamic Island, back on top of the live screen */
.hero-island {
  position: absolute;
  left: calc(321 / 900 * 100%);
  top: calc(58 / 1863 * 100%);
  width: calc(259 / 900 * 100%);
  height: auto;
  visibility: hidden;
}

/* ── 2. Onboarding ──────────────────────────────────────── */

/* the phone, as tall as the slide; its layers are placed in the design's own
   points (390 × 844), set as --x, --y and --w on each */
.ob {
  position: absolute;
  top: 6%;
  bottom: 6%;
  left: 50%;
  aspect-ratio: 390 / 844;
  translate: -50% 0;
  border-radius: 12% / 5.57%;
  overflow: hidden;
  background: #131115;
  box-shadow: 0 40px 80px rgba(40, 30, 70, 0.3), 0 10px 24px rgba(40, 30, 70, 0.18);
}

.ob-still,
.ob-live,
.ob-sky,
.ob-orbs {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* the finished screen shows until loop.js takes over */
.ob-live { display: none; }
.ob.is-live .ob-live { display: block; }
.ob.is-live .ob-still { display: none; }

.ob-live [style*="--x"] {
  position: absolute;
  left: calc(var(--x) / 390 * 100%);
  top: calc(var(--y) / 844 * 100%);
  width: calc(var(--w) / 390 * 100%);
  height: auto;
}

/* a page's copy: the whole screen, so its lines keep their places when it moves */
.ob-copy {
  position: absolute;
  inset: 0;
}

.ob-copy,
.ob-dots,
.ob-button {
  opacity: 0;
}

/* ── 3. Tonight's soundscape ───────────────────────────── */

.stage-stone { background: var(--night); } /* the dark of the first slide */

/* two screens side by side, as they are */
.pair {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7%;
}

/* a screen rebuilt in layers, placed in the design's points (--x, --y, --w) */
.live {
  position: relative;
}

.live > img:first-child {
  display: block;
  width: 100%;
}

.live [style*="--x"] {
  position: absolute;
  left: calc(var(--x) / 390 * 100%);
  top: calc(var(--y) / 844 * 100%);
  width: calc(var(--w) / 390 * 100%);
  height: auto;
}

.stream-word,
.stream-after {
  will-change: opacity, filter, transform;
}

/* Customize: Rain is selected, the duration is All night, as designed */
.tile-on:not([data-tile="1"]),
.duration:not([data-value="All night"]) {
  opacity: 0;
}

/* a fingertip, for the taps and the drag */
.live .touch {
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4), 0 4px 14px rgba(0, 0, 0, 0.25);
  translate: -50% -50%;
  opacity: 0;
  pointer-events: none;
}

.pair > .screen {
  width: 25%;
  height: auto;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.09), 0 30px 60px rgba(0, 0, 0, 0.5); /* a hairline keeps the screen's edge on the same dark */
}

/* ── 4. Morning reflection and history ──────────────────── */

/* two phones side by side */
.dawn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7%;
}

.dawn-phone,
.dawn > .history {
  position: relative;
  width: 25%;
}

.dawn-phone > .screen,
.dawn > .history {
  display: block;
  height: auto;
  box-shadow: 0 30px 60px rgba(70, 58, 30, 0.3), 0 8px 16px rgba(70, 58, 30, 0.16);
}

.dawn-phone > .screen,
.dawn > .history > img:first-child {
  width: 100%;
}

/* History: the filled star from Harbor of Stillness, over the outline ones
   (26 × 26 at x 340 of 390 × 844) */
.history .star {
  position: absolute;
  left: calc(340 / 390 * 100%);
  top: calc((var(--y) - 13) / 844 * 100%);
  width: calc(26 / 390 * 100%);
  height: auto;
}

/* ── Small screens ──────────────────────────────────────── */

@media (max-width: 699px) {
  .shot-wide { aspect-ratio: 4 / 5; }
  .hero-phone { width: 46%; }
  .hero-phone:nth-child(1) { display: none; }
  .dawn-phone,
  .dawn > .history,
  .pair > .screen { width: 42%; }
}
