/* DANA Wallet v3: page one-offs only.
   Everything shared (type scale, rhythm, rail, chapter, frames, ledger,
   findings, compare, anatomy, scrubbed video, climax, reflection, modal)
   comes from ../case-study.css; see DESIGN.md. What stays here is the
   wallet's own idea, listed under DO NOT REPEAT:
     - the hero: five shipped section slices fanned beside the Wallet home,
       squaring into one column on scroll (wallet.js)
     - the perforated voucher skin on the research findings
     - the numbered four bets, the exploration groups, the asset gallery
     - the pocket-wave climax edges (inline SVG, filled by the system)

   dana-wallet-v3.css stays in place for the pages that still load it. */

.case-page { position: relative; padding-bottom: 24px; }

/* ---------- hero: the stack beside the phone ---------- */

.dw-hero {
  --phone-h: clamp(460px, calc(100svh - 300px), 620px);
  position: relative;
  z-index: 1;
  width: var(--cs-edge);
  margin: 0 auto;
  min-height: calc(100svh - 112px);
  padding: 72px 0 40px;
  display: grid;
  grid-template-columns: clamp(230px, 20vw, 290px) auto minmax(0, 1fr);
  grid-template-rows: 1fr auto auto 1fr;
  grid-template-areas:
    "stack phone ."
    "stack phone title"
    "stack phone copy"
    "stack phone .";
  column-gap: clamp(32px, 3.4vw, 52px);
  align-items: center;
}

/* Each slice is placed so the last one ends level with the bottom of the
   phone: top = i * (phone height - last slice height) / 4. The last slice
   (Financial, 375x248) is 66.2% as tall as it is wide; cqw reads the
   stack's own width. */
.dw-hero__stack { grid-area: stack; margin: 0; align-self: center; }
.dw-stack {
  container-type: inline-size;
  position: relative;
  height: var(--phone-h);
}
.dw-stack img {
  position: absolute;
  left: 0;
  top: calc(var(--i) * (var(--phone-h) - 66.2cqw) / 4);
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--cs-shot-shadow);
  transform: translateX(var(--x, 0)) rotate(var(--r, 0deg));
}
/* fanned: five products that do not line up */
.dw-stack img:nth-child(1) { --x: -16px; --r: -6deg; }
.dw-stack img:nth-child(2) { --x: 20px;  --r: 4deg; }
.dw-stack img:nth-child(3) { --x: -8px;  --r: -2.5deg; }
.dw-stack img:nth-child(4) { --x: 24px;  --r: 5deg; }
.dw-stack img:nth-child(5) { --x: -10px; --r: -3deg; }
/* assembled: one column, one wallet */
.dw-stack.is-assembled img { --x: 0px; --r: 0deg; }
/* the page's one motion: 420ms each, staggered 40ms, inside 580ms */
@media (prefers-reduced-motion: no-preference) {
  .dw-stack img {
    transition: transform 420ms cubic-bezier(0.2, 0.75, 0.2, 1);
    transition-delay: calc(var(--i) * 40ms);
  }
}

.dw-hero__stack figcaption,
.dw-hero__phone figcaption {
  margin-top: 18px;
  font-size: var(--cs-type-caption);
  line-height: 1.5;
  color: var(--ink-muted);
}
.dw-hero__phone { grid-area: phone; margin: 0; }

/* the same render and crop the home page's wallet folder flies in from */
.dw-phone {
  position: relative;
  height: var(--phone-h);
  width: calc(var(--phone-h) * 394 / 645);
  overflow: hidden;
}
.dw-phone img {
  position: absolute;
  left: -64.56%;
  top: -17.17%;
  width: 228.8%;
  height: 124.84%;
  max-width: none;
  object-fit: cover;
}
.dw-hero__phone figcaption { max-width: calc(var(--phone-h) * 394 / 645); }

/* ---------- research: the voucher skin on the findings ---------- */

.dw .dw-ticket__heard {
  -webkit-mask: radial-gradient(circle 11px at 0 100%, #0000 10.5px, #000 11px),
                radial-gradient(circle 11px at 100% 100%, #0000 10.5px, #000 11px);
  -webkit-mask-composite: source-in;
          mask: radial-gradient(circle 11px at 0 100%, #0000 10.5px, #000 11px),
                radial-gradient(circle 11px at 100% 100%, #0000 10.5px, #000 11px);
          mask-composite: intersect;
}
.dw .dw-ticket__stub {
  background:
    radial-gradient(circle, color-mix(in oklab, var(--ink) 30%, transparent) 1.6px, transparent 2.1px)
      14px 0 / 11px 5px repeat-x,
    var(--cs-surface-deep) !important;
  -webkit-mask: radial-gradient(circle 11px at 0 0, #0000 10.5px, #000 11px),
                radial-gradient(circle 11px at 100% 0, #0000 10.5px, #000 11px);
  -webkit-mask-composite: source-in;
          mask: radial-gradient(circle 11px at 0 0, #0000 10.5px, #000 11px),
                radial-gradient(circle 11px at 100% 0, #0000 10.5px, #000 11px);
          mask-composite: intersect;
}
.cs-chapter > .dw-answer { margin: 44px 0 20px; }

/* ---------- evolution: the four bets and the explorations ---------- */

.dw-bets {
  list-style: none;
  counter-reset: bet;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 40px;
}
.dw-bets li {
  counter-increment: bet;
  position: relative;
  padding-left: 46px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--ink);
}
.dw-bets li::before {
  content: counter(bet);
  position: absolute;
  left: 0;
  top: -6px;
  font-family: "Tanker", system-ui, sans-serif;
  font-size: 40px;
  line-height: 1;
  color: var(--ink-faint);
}

.dw-explore { display: grid; gap: 16px; margin: 32px 0 0; }
.dw-explore__group {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 18px 18px 18px 26px;
  border-radius: var(--cs-radius);
  background: var(--cs-surface);
}
.dw-explore__group figcaption { margin: 0; padding: 0; font-size: var(--cs-type-label); line-height: 1.5; color: var(--ink-muted); }
.dw-explore__group figcaption strong { display: block; margin-bottom: 4px; font-size: 16px; color: var(--ink); }
.dw-explore__shots { display: flex; gap: 12px; justify-content: flex-start; }
.dw-explore__shots img {
  display: block;
  height: 270px;
  width: auto;
  border-radius: 12px;
  cursor: zoom-in;
}

/* ---------- pattern: the gallery around the anatomy ---------- */

.dw-gallery {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--cs-grid-gap);
  margin: 64px 0 0;
  align-items: stretch;
}
.dw-gallery .cs-frame { display: flex; flex-direction: column; }
.dw-frame--section { grid-column: span 6; }
.dw-frame--screen { grid-column: span 6; }
.dw-gallery .dw-frame--screen img { width: auto; max-width: 100%; height: 500px; margin: 0 auto; }
.dw-frame--assets { grid-column: span 12; }
.dw-assets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; padding: 4px; }
.dw-assets img { width: 100%; border-radius: 12px; cursor: default; }

/* ---------- view transition: the folder flies into the hero phone ---------- */

@media (prefers-reduced-motion: no-preference) {
  img[data-project-transition="dana-wallet-v3"] { view-transition-name: vt-hero-wallet; }
  .dana-wallet-v3-page .cs-hero__title { view-transition-name: vt-title-wallet; }
  .dana-wallet-v3-page .cs-hero__pitch { view-transition-name: vt-sub-wallet; }
}
html:active-view-transition .dw-phone img { filter: none; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .dw-explore__shots img { height: 220px; }
}

@media (max-width: 1023px) {
  .dw-hero {
    --phone-h: clamp(330px, calc(42vw + 160px), 560px);
    min-height: 0;
    padding-top: 68px;
    grid-template-columns: minmax(0, 340px) auto;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "title title"
      "stack phone"
      "copy copy";
    justify-content: center;
    column-gap: clamp(18px, 4vw, 40px);
    align-items: start;
  }
  .dw-hero__stack figcaption { margin-top: 14px; }
}

@media (max-width: 760px) {
  .dw-bets { grid-template-columns: 1fr; }

  .dw-explore__group { grid-template-columns: 1fr; gap: 14px; padding: 18px; }
  .dw-explore__shots { overflow-x: auto; padding-bottom: 4px; }
  .dw-explore__shots img { height: 240px; }

  .dw-gallery .dw-frame--screen img { height: 320px; }
  .dw-assets { gap: 6px; }
  .dw-frame--section { grid-column: span 12; }
  .dw-frame--screen { grid-column: span 6; }
  .dw-frame--assets { grid-column: span 12; }
  .dw-gallery { gap: 12px; }
}

@media (max-width: 420px) {
  .dw-hero { column-gap: 16px; }
  .dw-stack img { border-radius: 9px; }
  .dw-stack img:nth-child(1) { --x: -6px; }
  .dw-stack img:nth-child(2) { --x: 8px; }
  .dw-stack img:nth-child(4) { --x: 10px; }
  .dw-stack img:nth-child(5) { --x: -4px; }
}
