/* CM 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
   CM app laid out on it: images cut from 2x exports of the Figma files. */

:root {
  --cm-green: #3e8844; /* the app's header */
  --cm-forest: #1f3b22;
  --cm-mint: #e8f3d2; /* the backdrop of the team's own presentation frames */
  --cm-bg: #f6f4ef; /* the screens' own background: cuts on it blend in */
  --phone-shadow: 0 30px 70px rgba(10, 40, 12, 0.28), 0 6px 16px rgba(10, 40, 12, 0.14);
  --pad: clamp(20px, 5vw, 64px);
}

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

/* keep wide content from widening the column in the one-column layout */
.case-body {
  min-width: 0;
}

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

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

.stage-green { background: var(--cm-green); }
.stage-forest { background: var(--cm-forest); }
.stage-mint { background: var(--cm-mint); }
.stage-screen { background: var(--cm-bg); }

/* A phone screen: the export with the device's rounded corners (47 of 393 px). */
.phone {
  display: block;
  width: 100%;
  border-radius: 12% / 5.5%;
  box-shadow: var(--phone-shadow);
}

/* ── 1. Home ────────────────────────────────────────────── */

.hero {
  padding-bottom: 0;
  perspective: 1400px;
}

.shot > .stage.hero {
  justify-content: flex-end;
}

.hero-screen {
  width: min(38%, 440px);
  margin: clamp(40px, 7vw, 96px) auto 0;
  border-radius: 12% 12% 0 0 / 6% 6% 0 0;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(40, 80, 20, 0.28), 0 8px 20px rgba(40, 80, 20, 0.14);
  transform-origin: 50% 0;
}

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

/* ── 2. Iterations ──────────────────────────────────────── */

#iterations {
  padding-block: clamp(48px, 8vw, 110px);
}

.iter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(12px, 3vw, 44px);
  align-items: start;
  width: min(100%, 1180px);
  margin: 0 auto;
}

.iter-row .phone {
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.2);
  will-change: transform;
}

.iter-row .phone:nth-child(even) {
  margin-top: 12%;
}

/* ── 2b. The five sections ─────────────────────────────── */

/* a row of five phones, wider than the slide; it glides along with the scroll */
#sections {
  padding-inline: 0;
  padding-block: clamp(48px, 7vw, 96px);
  contain: inline-size;
}

.section-row {
  --w: clamp(150px, 26vw, 300px); /* phone width */
  display: flex;
  gap: clamp(16px, 2.4vw, 32px);
  width: max-content;
  padding-inline: var(--pad);
  will-change: transform;
}

.section-row .phone {
  width: var(--w);
  height: auto;
  flex: none;
}

/* the step card's tile centres it (the other tiles hang a phone off the bottom) */
.shots .shot > #steps {
  justify-content: center;
  padding-bottom: var(--pad);
}

/* ── 6. Step goal ───────────────────────────────────────── */



/* The card is 672 × 316 px; the bar sits at 32–344 × 144–164 inside it. */
.steps-card {
  position: relative;
  display: grid;
  width: 86%;
  margin: auto;
  filter: drop-shadow(0 30px 50px rgba(8, 40, 10, 0.3)) drop-shadow(0 6px 12px rgba(8, 40, 10, 0.16));
}

.steps-card > img {
  width: 100%;
  height: auto;
}

.steps-card .todo,
.steps-card .done {
  grid-area: 1 / 1;
}

.steps-card .todo {
  opacity: 0;
}

.steps-card .steps-track,
.steps-card .steps-fill {
  position: absolute;
  left: calc(32 / 672 * 100%);
  top: calc(144 / 316 * 100%);
  width: calc(312 / 672 * 100%);
  height: calc(20 / 316 * 100%);
}

.steps-track {
  border-radius: 99px;
  background: #e9ebed;
}

.steps-card .steps-fill {
  clip-path: inset(0 0 0 0 round 99px); /* full: the script moves it */
}

.steps-card .steps-confetti {
  position: absolute;
  left: calc(509 / 672 * 100%);
  top: 0;
  width: calc(163 / 672 * 100%);
  transform-origin: 30% 60%;
}

/* ── 8–9. Screens on tiles ──────────────────────────────── */

.shot-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
}

/* the phone sits whole in its tile, centred; no padding above and below, so its
   size (in container units) is taken from the tile's full height */
.shots .shot > .stage {
  justify-content: center;
  align-items: center;
  padding-block: 0;
}

.tile-mint { background: var(--cm-mint); }
.tile-green { background: var(--cm-green); }
.tile-forest { background: var(--cm-forest); }
.tile-cream { background: #ebe6d8; }

/* Tiles in a row can differ in width (the grid snapping), so phones are sized by
   the tile's height: every phone in a row is the same size. */
.shots .stage {
  container-type: size;
}

/* sized by the tile's height: a 393 × 844 screen 40 % of it wide is 86 % of it tall */
.phone-wrap {
  position: relative;
  width: min(100%, 40cqh);
}

.phone-wrap .phone {
  border-radius: 12% / 5.5%;
}

/* checkboxes of the filter screen (rows 56 px apart from y 237, x 27–49 of 393 × 852) */
.filters .check {
  position: absolute;
  left: calc(27 / 393 * 100%);
  top: calc((236 + var(--row) * 56) / 852 * 100%);
  width: calc(22 / 393 * 100%);
  height: auto;
}

/* the perk detail scrolls inside a phone-shaped window; its status bar stays put */
.scroller {
  aspect-ratio: 393 / 844;
  overflow: hidden;
  border-radius: 12% / 5.5%;
  background: #fff;
  box-shadow: var(--phone-shadow);
}

.scroller img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
}

.perk-long {
  will-change: transform;
}

/* ── Candidates ─────────────────────────────────────────── */

.stage-white { background: #fff; }

/* M-score, on the design sprint's phone in the iterations slide: track (base),
   coloured arc swept in by a conic mask, the score. The layers are cut from the
   same screen, at 95, 90 – 300, 262 of its 390 × 845.5 design px, so they sit
   exactly over the gauge in the screenshot. The arc's circle is centred at
   396.8 × 435.7 of the 820 × 688 images; it runs from 268° to 49.5°. */
.iter-gauge {
  position: relative;
  overflow: hidden;
}

.iter-gauge > img {
  display: block;
  width: 100%;
  height: auto;
}

.gauge {
  --sweep: 141.5deg;
  position: absolute;
  left: calc(95 / 390 * 100%);
  top: calc(90 / 845.5 * 100%);
  width: calc(205 / 390 * 100%);
}

.gauge img {
  display: block;
  width: 100%;
  height: auto;
}

.gauge .gauge-arc {
  position: absolute;
  inset: 0;
  -webkit-mask-image: conic-gradient(from 268deg at 48.39% 63.33%, #000 var(--sweep), transparent var(--sweep));
  mask-image: conic-gradient(from 268deg at 48.39% 63.33%, #000 var(--sweep), transparent var(--sweep));
}

.gauge .gauge-score {
  position: absolute;
  left: calc(188 / 820 * 100%);
  top: calc(208 / 688 * 100%);
  width: calc(416 / 820 * 100%);
}

/* 2. Fake door: the design's dim (black, 50 %) and its modal (at 12, 412 of 393 × 844) */
.fakedoor-dim {
  position: absolute;
  inset: 0;
  border-radius: 12% 12% 0 0 / 5.5% 5.5% 0 0;
  background: rgba(0, 0, 0, 0.5);
}

.fakedoor .fakedoor-modal {
  position: absolute;
  left: calc(12 / 393 * 100%);
  top: calc(412 / 844 * 100%);
  width: calc(369 / 393 * 100%);
  height: auto;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.25));
}

/* 3. Streak: the screen's confetti, a vector group at -167, -376 (732.5 × 708.6)
   of the 393 × 844 frame, clipped to the screen like the frame clips it. */
.confetti-clip {
  position: absolute;
  inset: 0 0 auto;
  aspect-ratio: 393 / 844;
  overflow: hidden;
  border-radius: 12% / 5.5%;
  pointer-events: none;
}

.confetti {
  position: absolute;
  left: calc(-167 / 393 * 100%);
  top: calc(-376 / 844 * 100%);
  width: calc(732.457 / 393 * 100%);
  height: auto;
  overflow: visible;
}

/* 4. Sleep insight */
#sleep {
  padding-block: clamp(48px, 7vw, 96px);
}

.sleep {
  width: min(70%, 760px);
  margin: 0 auto;
  text-align: center;
}

.sleep-headline {
  width: 78%;
  height: auto;
  margin-bottom: clamp(4px, 1vw, 12px);
}

.sleep-card {
  display: grid;
  /* the export cuts the card's shadow at its edges: fade them out */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent), linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent), linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
  mask-composite: intersect;
}

.sleep-card img {
  grid-area: 1 / 1;
  width: 100%;
  height: auto;
}

/* 5. Lock screen: the notification at 10, 658 of 390 × 844 */
.lock .lock-note {
  position: absolute;
  left: calc(10 / 390 * 100%);
  top: calc(658 / 844 * 100%);
  width: calc(370 / 390 * 100%);
  height: auto;
}

/* 7. Chat: the conversation window runs from y 60 to 476 (just above the input) of
   the 844 px screen. Its top fades out the way the header's gradient fades the
   design (opaque at y 61, clear by 178). Each turn sits at its design height. */
.chat-window {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(60 / 844 * 100%);
  height: calc(416 / 844 * 100%);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28.4%);
  mask-image: linear-gradient(to bottom, transparent, #000 28.4%);
}

.chat-flow {
  position: relative;
  height: 100%;
  will-change: transform;
}

.chat-flow .turn {
  position: absolute;
  left: 0;
  top: calc((var(--top) - 60) / 416 * 100%);
  width: 100%;
  height: auto;
}

/* 8. Invitation email, rising from the tile's bottom edge */
.invite {
  width: 88%;
  height: auto;
  margin-top: 12%;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.4);
}

/* 9. Buttons */
#buttons {
  padding-block: clamp(40px, 6vw, 80px);
}

.ds-buttons {
  display: block;
  width: min(78%, 860px);
  height: auto;
  margin: 0 auto;
}

/* 10. Tab bars: five states of each, stacked */
#tabs {
  padding-block: clamp(56px, 9vw, 120px);
}

.tabs {
  display: grid;
  gap: clamp(28px, 5vw, 64px);
  justify-items: center;
}

.tab-states {
  display: grid;
}

.tab-states img {
  position: relative; /* so the script can put the incoming state on top */
  grid-area: 1 / 1;
  width: 100%;
  height: auto;
}

.tab-states img + img {
  opacity: 0;
}

.tab-states.bar {
  width: min(64%, 640px);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
}

.tab-states.pill {
  width: min(62%, 620px);
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.35));
}

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

@media (max-width: 699px) {
  .hero-screen { width: 64%; }
  .iter-row { grid-template-columns: repeat(2, 1fr); row-gap: 24px; }
  .iter-row .phone:nth-child(even) { margin-top: 18%; }
  .sleep { width: 100%; }
  .ds-buttons { width: 100%; }
  .tab-states.bar,
  .tab-states.pill { width: 100%; }
}
