/* Clean Size case study: the hero, the tape-measure scroll, the preset rack, the listing strip and the before/after.
   Markup: src/_includes/e2/cleansize/*.njk. Real UI (Figma exports) stays crisp images; the worlds, the 3D garments and the
   tools are Higgsfield renders. Palette: coral #EB5F58 (#DE5A53, #EB7973, blush #F2CBC9), mint #B9EBEC, deep teal #1E5C5C,
   sky #9CCBF5. The --a modifiers are the Atelier look (the user's pick; the Ruler skies look b was removed).
   Sizes inside the stage use cqw (the stage is an inline-size container) with a vw fallback written first. */

/* ---------- Hero ---------- */
.cz-hero {
  position: relative; margin: 0; overflow: hidden; isolation: isolate;
  aspect-ratio: 16 / 9; width: 100%; border-radius: 32px; background: #B9EBEC;
}
.cz-hero__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
/* A light vignette keeps the floating window the brightest thing in the frame. */
.cz-hero__shade { position: absolute; inset: 0; z-index: -1; background: radial-gradient(120% 90% at 50% 45%, transparent 50%, rgba(30,92,92,.28) 100%); }
.cz-hero__scene { position: absolute; inset: 0; --px: 0; --py: 0; perspective: 1800px; }

/* The real Add Size Chart screen, tilted towards the reader; the pointer leans it a few degrees more. */
.cz-window {
  position: absolute; left: 50%; top: 50%; width: 50%; border-radius: 14px; overflow: hidden; z-index: 1;
  transform: translate(-50%, -50%) rotateX(calc(7deg - var(--py) * 4deg)) rotateY(calc(var(--px) * 6deg));
  box-shadow: 0 0 0 1px rgba(30,92,92,.14), 0 50px 100px -20px rgba(30,92,92,.4), 0 30px 60px rgba(30,60,60,.22);
  transition: transform .2s linear;
}
.cz-window img { display: block; width: 100%; height: auto; }

/* Floating garments: the span carries the pointer parallax (deeper ones move more), the img the slow float. */
.cz-float {
  position: absolute; left: var(--x); top: var(--y); width: var(--w); z-index: 2;
  translate: calc(var(--px) * var(--z) * 36px) calc(var(--py) * var(--z) * 24px);
  filter: drop-shadow(0 18px 28px rgba(30,92,92,.34));
}
.cz-float img { display: block; width: 100%; height: auto; animation: cz-bob var(--d) ease-in-out var(--delay) infinite alternate; }
.cz-float--far { z-index: 0; filter: drop-shadow(0 10px 18px rgba(30,92,92,.3)) blur(.6px); opacity: .92; }
@keyframes cz-bob {
  from { transform: translateY(-4%) rotate(calc(var(--r) * -1)); }
  to { transform: translateY(4%) rotate(var(--r)); }
}

/* ---------- Section headings (same scale as the story title) ---------- */
.cz-h { font-weight: 600; font-size: clamp(36px, 4vw, 56px); line-height: 1; letter-spacing: -.05em; }

/* ---------- Measure: the tape unrolls, one inch per preset ---------- */
.cz-measure { position: relative; height: 360vh; height: 360svh; }
.cz-measure__sticky {
  position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); height: calc(100svh - var(--header-h));
  display: flex; align-items: center; justify-content: center;
}
.cz-stage {
  position: relative; overflow: hidden; isolation: isolate; border-radius: 32px; background: #B9EBEC;
  aspect-ratio: 16 / 9; width: min(100%, calc((100svh - var(--header-h) - 48px) * 16 / 9));
  container-type: inline-size;
}
.cz-stage__bg, .cz-finale { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cz-finale { z-index: 3; opacity: 0; transition: opacity .5s ease; }
.cz-finale.is-on { opacity: 1; }
.cz-stage__glow {
  position: absolute; left: 50%; top: calc(var(--pt) + var(--ph) / 2); height: calc(var(--ph) * 1.7); aspect-ratio: 1; translate: -50% -50%;
  border-radius: 50%; z-index: 1; pointer-events: none; opacity: .55; mix-blend-mode: screen;
  background: radial-gradient(closest-side, rgba(255,255,255,.75), rgba(255,236,230,.28) 55%, transparent 72%);
}

/* Pieces: one per preset (and the diamond tag as the 13th), placed exactly where the finale clip's first frame has the tag.
   Only .is-on shows; the one leaving shrinks away quickly, the one arriving pops with a small wobble. */
.cz-piece {
  position: absolute; left: 50%; top: var(--pt); height: var(--ph); width: auto; z-index: 2;
  translate: -50% 0; transform-origin: 50% 100%; transform: scale(.55); rotate: -9deg; opacity: 0;
  transition: transform .18s ease-in, rotate .18s ease-in, opacity .16s ease;
  filter: drop-shadow(0 24px 30px rgba(30,92,92,.34));
}
.cz-piece.is-on {
  opacity: 1; transform: scale(1); rotate: 0deg;
  transition: transform .62s cubic-bezier(.34, 1.56, .64, 1), rotate .62s cubic-bezier(.34, 1.56, .64, 1), opacity .2s ease;
  animation: cz-hover 3.2s ease-in-out .7s infinite alternate;
}
@keyframes cz-hover { from { translate: -50% 0; } to { translate: -50% -2.2%; } }
.cz-stage.is-burst .cz-piece.is-on { animation: cz-flash .9s ease-out, cz-hover 3.2s ease-in-out .7s infinite alternate; }
@keyframes cz-flash { 0% { filter: brightness(1.7) drop-shadow(0 0 36px rgba(255,255,255,.95)); } 100% { filter: brightness(1) drop-shadow(0 24px 30px rgba(30,92,92,.34)); } }
.cz-stage.is-burst .cz-stage__glow { animation: cz-glow .9s ease-out; }
@keyframes cz-glow { 0% { opacity: 1; scale: 1.25; } 100% { opacity: .55; scale: 1; } }

/* Burst: a ring and ten four-point sparkles (coral, mint, white) thrown out from the piece on every step. */
.cz-burst {
  position: absolute; left: 50%; top: calc(var(--pt) + var(--ph) / 2); height: calc(var(--ph) * 1.1); aspect-ratio: 1;
  translate: -50% -50%; z-index: 2; pointer-events: none;
}
.cz-burst::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; opacity: 0;
  box-shadow: 0 0 0 2px rgba(235,95,88,.9), 0 0 36px 6px rgba(255,255,255,.7), inset 0 0 36px 6px rgba(185,235,236,.6);
}
.cz-burst i {
  position: absolute; left: 50%; top: 50%; width: 9%; aspect-ratio: 1; opacity: 0; translate: -50% -50%; background: #fff;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 5px rgba(30,92,92,.55));
}
.cz-burst i:nth-child(3n + 1) { background: #EB5F58; }
.cz-burst i:nth-child(3n + 2) { background: #B9EBEC; }
.cz-stage.is-burst .cz-burst::before { animation: cz-ring .9s cubic-bezier(.2,.8,.2,1); }
.cz-stage.is-burst .cz-burst i { animation: cz-spark 1s cubic-bezier(.2,.8,.2,1); }
.cz-stage.is-burst .cz-burst i:nth-child(odd) { animation-duration: 1.2s; }
@keyframes cz-ring { 0% { opacity: .9; scale: .4; } 100% { opacity: 0; scale: 1.7; } }
@keyframes cz-spark {
  0% { opacity: 0; transform: rotate(var(--a)) translateY(0) scale(.4); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--dist) * -1)) scale(1); }
}

/* Readout: the app's own words, then the inch and the preset it lands on. */
.cz-read { position: absolute; left: 4%; top: 6%; z-index: 4; display: flex; flex-direction: column; gap: 8px; margin: 0; color: #1E5C5C; }
.cz-read__label { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.cz-read__big { display: flex; align-items: baseline; gap: .1em; }
.cz-read__num {
  font-weight: 600; font-size: clamp(56px, 8vw, 128px); font-size: clamp(56px, 9cqw, 128px); line-height: .85; letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
}
.cz-read__in { font-weight: 500; font-size: clamp(22px, 2.6vw, 40px); font-size: clamp(22px, 3cqw, 44px); letter-spacing: -.03em; }
.cz-read__name { font-weight: 600; font-size: clamp(20px, 2.4vw, 36px); font-size: clamp(20px, 2.8cqw, 40px); line-height: 1.05; letter-spacing: -.04em; }
.cz-stage.is-finale .cz-read__in { display: none; }

/* The tape: coral band, white ticks, unrolled left to right by the scroll (--fill). The coil sits at its left end. */
.cz-tape { position: absolute; left: 6%; right: 6%; bottom: 5%; height: 11%; z-index: 4; display: flex; align-items: flex-end; }
.cz-tape__coil {
  flex: none; position: relative; z-index: 1; height: 238%; width: auto; margin-right: -.6%; translate: 0 3.5%;
  filter: drop-shadow(0 14px 18px rgba(30,92,92,.3));
}
.cz-tape__track { position: relative; flex: 1; min-width: 0; height: 100%; }
.cz-tape__band {
  position: absolute; inset: 0; border-radius: 3px 8px 8px 3px; clip-path: inset(0 calc(100% - var(--fill)) 0 0);
  background:
    repeating-linear-gradient(90deg, #fff 0 1px, transparent 1px calc(100% / 48)) left bottom / 100% 16% no-repeat,
    repeating-linear-gradient(90deg, #fff 0 1.5px, transparent 1.5px calc(100% / 24)) left bottom / 100% 26% no-repeat,
    repeating-linear-gradient(90deg, #fff 0 2px, transparent 2px calc(100% / 12)) left bottom / 100% 38% no-repeat,
    linear-gradient(180deg, #EE6F68, #EB5F58 42%, #DE5A53);
  box-shadow: 0 10px 24px rgba(30,92,92,.28);
}
/* Number i sits just right of its tick, above the ticks. */
.cz-tape__n {
  position: absolute; left: calc(var(--k) * 100% / 12 + 6px); top: 11%; color: #fff; line-height: 1; font-weight: 600; letter-spacing: -.02em;
  font-family: var(--mono); font-size: clamp(9px, 1.1vw, 14px); font-size: clamp(9px, 1.5cqw, 20px);
}
/* The loose end of the tape, riding the front of the reveal. */
.cz-tape__tip {
  position: absolute; left: var(--fill); bottom: -5%; height: 110%; width: clamp(5px, .7cqw, 10px); translate: -100% 0;
  border-radius: 3px; background: #C9453F; box-shadow: 0 4px 10px rgba(30,60,60,.3); pointer-events: none;
}

/* Collected tokens: a small garment hops onto each inch the tape reaches, like earned badges. */
.cz-tokens { position: absolute; left: 0; right: 0; bottom: calc(100% + 5%); height: 55%; pointer-events: none; }
.cz-token {
  position: absolute; bottom: 0; left: calc((var(--k) + .3) * 100% / 12); height: 100%; width: auto; translate: -50% 0; opacity: 0;
  filter: drop-shadow(0 6px 8px rgba(30,92,92,.28));
}
.cz-token.is-got { opacity: 1; animation: cz-hop .6s var(--ease-out) both; }
@keyframes cz-hop {
  0% { opacity: 0; transform: translateY(-170%) scale(.5); }
  35% { opacity: 1; }
  62% { transform: translateY(6%) scale(1.12, .92); }
  100% { transform: none; }
}

/* ---------- Rack: the twelve presets hang from a rail and swing when brushed ---------- */
.cz-rail { display: flex; flex-direction: column; gap: 32px; }
.cz-rail__panel {
  --pp: clamp(16px, 3vw, 40px);
  position: relative; isolation: isolate; overflow: hidden; border-radius: 32px; background: #B9EBEC; padding: 28px var(--pp) 14px;
}
.cz-rail__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; }

.cz-rail__list {
  --gh: clamp(90px, 11vw, 150px); --str: clamp(26px, 3.2vw, 44px); --row: calc(var(--str) + var(--gh) + 72px); --row2: var(--row);
  list-style: none; margin: 0 calc(var(--pp) * -1); padding: 0 var(--pp); display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: var(--row);
  background-repeat: no-repeat;
}
/* Look a: a brushed brass bar (and its shadow) at the top of each row. */
.cz-rail--a .cz-rail__list {
  --string: linear-gradient(90deg, #6fc6bf, #c8f2ef);
  --brass: linear-gradient(180deg, #fbf0c9 0%, #e6c872 28%, #b98a2f 62%, #8a6420 82%, #d6b765 100%);
  --drop: linear-gradient(180deg, rgba(30,92,92,.2), transparent);
  background-image: var(--brass), var(--drop), var(--brass), var(--drop);
  background-size: 100% 12px, 100% 16px, 100% 12px, 100% 16px;
  background-position: 0 0, 0 12px, 0 var(--row2), 0 calc(var(--row2) + 12px);
}

.cz-hang {
  position: relative; display: flex; justify-content: center; padding-top: 6px; min-width: 0;
  opacity: 0; translate: 0 -34px;
  transition: opacity .5s ease calc(var(--k) * .06s), translate .9s cubic-bezier(.34, 1.56, .64, 1) calc(var(--k) * .06s);
}
.cz-rail.is-in .cz-hang { opacity: 1; translate: 0 0; }
/* The pendulum: JS turns the element about the top of the string; the idle sway is the individual `rotate` property on top. */
.cz-hang__swing {
  display: flex; flex-direction: column; align-items: center; max-width: 100%; transform-origin: 50% 0; will-change: transform;
  animation: cz-sway calc(4.6s + var(--k) * .17s) ease-in-out calc(var(--k) * -.7s) infinite alternate;
}
@keyframes cz-sway { from { rotate: -.9deg; } to { rotate: .9deg; } }
.cz-hang__string { flex: none; width: 2px; height: var(--str); border-radius: 1px; background: var(--string, #B9EBEC); }
.cz-hang__peg {
  flex: none; position: relative; z-index: 1; width: 11px; height: 16px; margin-top: -2px; border-radius: 3px;
  background: linear-gradient(90deg, #EB5F58, #DE5A53); box-shadow: 0 2px 4px rgba(30,60,60,.25);
}
.cz-hang__img {
  display: block; height: var(--gh); width: auto; max-width: 100%; object-fit: contain; margin-top: -6px;
  filter: drop-shadow(0 12px 12px rgba(30,92,92,.28));
}
/* The swing tag with the preset's name: real text, white on a deep coral so 12px type passes contrast. */
.cz-hang__tag {
  position: relative; margin-top: 10px; max-width: 100%; padding: 13px 10px 6px; border-radius: 6px; text-align: center; text-wrap: balance;
  font-family: var(--mono); font-size: 12px; font-weight: 500; line-height: 1.25; letter-spacing: .01em; color: #fff; background: #C9453F;
  box-shadow: 0 6px 14px rgba(30,60,60,.2);
}
.cz-hang__tag::before { content: ""; position: absolute; left: 50%; top: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: rgba(255,255,255,.85); }

/* ---------- Listing: a tailor's tape over the App Store images ---------- */
.cz-listing { display: flex; flex-direction: column; gap: 32px; }
.cz-nav { display: flex; gap: 10px; }
.cz-nav__btn {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border-radius: 50%;
  font: inherit; color: #fff; background: var(--surface-1); border: 1px solid var(--border-strong); cursor: pointer;
  transition: background-color .2s ease, color .2s ease, opacity .2s ease;
}
.cz-nav__btn:hover:not(:disabled) { background: #fff; color: #000; }
.cz-nav__btn:disabled { opacity: .35; cursor: default; }
.cz-strip {
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
  border-radius: 20px; -webkit-overflow-scrolling: touch;
}
.cz-strip::-webkit-scrollbar { display: none; }
.cz-strip:focus-visible { outline: 2px solid var(--blue-light); outline-offset: 4px; }
@media (pointer: fine) { .cz-strip { cursor: grab; } }
.cz-strip.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.cz-track { position: relative; display: flex; flex-direction: column; gap: 14px; width: max-content; min-width: 100%; }
/* 1 unit (cm) = 8px: a tick every unit, a taller one every 5, the tallest and a number every 10. */
.cz-ruler {
  position: relative; flex: none; height: 42px; border-radius: 6px; overflow: hidden;
  background:
    repeating-linear-gradient(90deg, #1E5C5C 0 1px, transparent 1px 8px) left top / 100% 8px no-repeat,
    repeating-linear-gradient(90deg, #1E5C5C 0 1.5px, transparent 1.5px 40px) left top / 100% 14px no-repeat,
    repeating-linear-gradient(90deg, #1E5C5C 0 2px, transparent 2px 80px) left top / 100% 22px no-repeat,
    linear-gradient(180deg, #FBF3E4, #F3E5C9);
}
.cz-ruler__n {
  position: absolute; left: calc(var(--n) * 80px + 5px); top: 22px; font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 1;
  color: #C9453F; font-variant-numeric: tabular-nums;
}
.cz-cards { list-style: none; margin: 0; padding: 0; display: flex; gap: 16px; }
.cz-card { flex: none; width: min(720px, 82vw); aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; scroll-snap-align: start; background: var(--surface-1); }
.cz-card img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }

/* ---------- Before and after ---------- */
.cz-ba { display: flex; flex-direction: column; gap: 32px; }
.cz-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-1); border: 1px solid var(--border); }
.cz-tab {
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text-3); background: none; border: 0; cursor: pointer;
  padding: 9px 16px; border-radius: 999px; transition: background-color .2s ease, color .2s ease;
}
.cz-tab:hover { color: #fff; }
.cz-tab[aria-selected="true"] { background: #fff; color: #000; }
.cz-ba__stage { display: flex; justify-content: center; padding: clamp(16px, 4vw, 48px); border-radius: 32px; background: var(--surface-1); }
.cz-ba .e2-slider { aspect-ratio: 1200 / 747; width: min(100%, 920px); }
.cz-ba .e2-slider__img { transition: opacity .25s ease; }
.cz-ba.is-swapping .e2-slider__img { opacity: .2; }

/* ---------- Phones and narrow windows ---------- */
@media (max-width: 699px) {
  .cz-hero { aspect-ratio: 4 / 5; border-radius: 20px; }
  .cz-window { width: 88%; top: 48%; }
  /* On a 4:5 phone frame the screen fills the middle band, so the garments sit above and below it. */
  .cz-float { width: calc(var(--w) * 1.9); }
  .cz-float[data-k="1"] { left: 5%; top: 4%; }
  .cz-float[data-k="2"] { left: 74%; top: 3%; }
  .cz-float[data-k="3"] { left: 6%; top: 77%; width: 20%; }
  .cz-float[data-k="4"] { left: 66%; top: 77%; width: 24%; }

  .cz-stage { aspect-ratio: 4 / 5; width: 100%; border-radius: 20px; }
  .cz-read { left: 6%; top: 5%; gap: 4px; }
  .cz-read__label { font-size: 10px; }
  .cz-read__num { font-size: clamp(44px, 17cqw, 72px); }
  .cz-read__in { font-size: clamp(16px, 5.4cqw, 26px); }
  .cz-read__name { font-size: clamp(16px, 5.4cqw, 24px); }
  .cz-tape { left: 4%; right: 4%; bottom: 4%; height: 9%; }
  .cz-tape__coil { height: 190%; }
  .cz-tape__band {
    background:
      repeating-linear-gradient(90deg, #fff 0 1.5px, transparent 1.5px calc(100% / 24)) left bottom / 100% 24% no-repeat,
      repeating-linear-gradient(90deg, #fff 0 2px, transparent 2px calc(100% / 12)) left bottom / 100% 36% no-repeat,
      linear-gradient(180deg, #EE6F68, #EB5F58 42%, #DE5A53);
  }
  .cz-tape__n { left: calc(var(--k) * 100% / 12 + 3px); top: 10%; font-size: 9px; }
  .cz-tokens { height: 50%; bottom: calc(100% + 6%); }
  .cz-token:nth-child(even) { translate: -50% -62%; }

  .cz-rail__panel { padding: 22px 0 10px; border-radius: 20px; }
  /* One row in a rack that scrolls sideways; the rail scrolls with it (background-attachment: local). */
  .cz-rail__list {
    --row2: -200px; display: flex; margin: 0; padding: 0 16px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    overscroll-behavior-x: contain; background-attachment: local; -webkit-overflow-scrolling: touch;
  }
  .cz-rail__list::-webkit-scrollbar { display: none; }
  .cz-hang { flex: 0 0 148px; scroll-snap-align: center; height: var(--row); }
  .cz-ruler__n { font-size: 10px; }
  .cz-card { border-radius: 12px; }
  .cz-strip { border-radius: 14px; }
  .cz-tabs { border-radius: 20px; }
  .cz-ba__stage { border-radius: 20px; }
}

/* ---------- Reduced motion: no float, no tilt, no sway; the measure shows its last state (tape out, tag on the stand) ---------- */
@media (prefers-reduced-motion: reduce) {
  .cz-float img, .cz-piece.is-on, .cz-hang__swing, .cz-token.is-got { animation: none !important; }
  .cz-window { transform: translate(-50%, -50%); transition: none; }
  .cz-float { translate: none; }
  .cz-piece, .cz-piece.is-on { transition: none; }
  .cz-hang { opacity: 1; translate: none; transition: none; }
  .cz-measure { height: auto; }
  .cz-measure__sticky { position: static; height: auto; padding: 24px 0; }
  .cz-strip { scroll-behavior: auto; }
}
