/* ==========================================================================
   Band compositions — homepage project cards + project hero.
   Coordinates come straight from Figma, in "content px": x = 0 is the left
   edge of the 1280px content column. --k converts one design px to screen px,
   so the whole composition scales with the grid, and bands bleed to the edge.
   On mobile the same composition is cropped to the devices (--cx0..--cy1).
   ========================================================================== */

.card {
  position: relative;
  display: block;
  container-type: inline-size;
  --k: calc((100cqw - 2 * var(--m)) / 1280);
  --ox: var(--m);
  --oy: 0px;
}
.card__art { position: relative; height: calc(660 * var(--k)); overflow: hidden; }
.card__art > * { position: absolute; }

/* positioned in content px, relative to the art */
.pos {
  left: calc(var(--ox) + var(--x) * var(--k));
  top: calc(var(--oy) + var(--y) * var(--k));
  width: calc(var(--w) * var(--k));
  height: calc(var(--h) * var(--k));
}
/* positioned in design px, relative to its parent device */
.in {
  position: absolute;
  left: calc(var(--x) * var(--k));
  top: calc(var(--y) * var(--k));
  width: calc(var(--w) * var(--k));
  height: calc(var(--h) * var(--k));
  overflow: hidden;
}
.in > img { position: absolute; }
.in > img.cover { inset: 0; width: 100%; height: 100%; object-fit: cover; }

.card__band { top: 0; bottom: 0; background: var(--band); }
.card__deco { pointer-events: none; }
.card__deco img { width: 100%; height: 100%; }

/* White device frames */
.dev { border-radius: calc(var(--r) * var(--k)); }
.dev::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  border: 1px solid #fff; pointer-events: none;
}
.dev .screen { background: #fff; }
.dev .notch { position: absolute; background: var(--ink); }

.card__title {
  position: absolute;
  z-index: 3;
  left: calc(var(--ox) + var(--tx) * var(--k));
  top: calc(var(--oy) + var(--ty) * var(--k));
  width: calc(var(--tw) * var(--k));
  font-size: clamp(30px, calc(56 * var(--k)), 56px);
  line-height: 1.1786;
  font-weight: 500;
  color: var(--tc, #fff);
}

a.card { cursor: pointer; }

/* Homepage: devices swipe in once when the card scrolls into view, then stay put.
   Desktop and tablet only — on mobile they're static. */
@media (prefers-reduced-motion: no-preference) and (min-width: 900px) {
  .js a.card .dev {
    opacity: 0;
    transform: translate3d(calc(220 * var(--k)), 0, 0);
  }
  .js a.card.is-in .dev {
    opacity: 1;
    transform: none;
    transition: transform 1.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.7s ease-out;
  }
  .js a.card.is-in .dev + .dev { transition-delay: 0.14s; }
}

/* --- Card 1 · bank accounts (block starts at content x 0) --- */
.card--p1 { --band: var(--yellow); --tc: var(--ink); --tx: 0; --ty: 44; --tw: 541;
  --cx0: 413; --cx1: 1320; --cy0: 123; --cy1: 656; }
.card--p1 .card__band { left: calc(var(--ox) + 147 * var(--k)); right: 0; }
.card--p1 .card__texture { left: calc(var(--ox) + 147 * var(--k)); right: 0; top: 0; bottom: 0; }
.card--p1 .card__texture img { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: color-burn; opacity: 0.7; }

/* --- Card 2 · ordering (block starts at content x -200) --- */
.card--p2 { --band: var(--blue); --tx: 0; --ty: 198; --tw: 374;
  --cx0: 412; --cx1: 1251; --cy0: 65; --cy1: 595; }
.card--p2 .card__band { left: 0; right: var(--m); }

/* --- Card 3 · streaming (block starts at content x -100) --- */
.card--p3 { --band: var(--red); --tx: 0; --ty: 92; --tw: 600;
  --cx0: 632; --cx1: 1480; --cy0: 64; --cy1: 597; }
.card--p3 .card__band { left: calc(var(--ox) - 40 * var(--k)); right: 0; }

.works { display: flex; flex-direction: column; gap: 40px; }

@media (max-width: 899px) {
  /* Mobile: the crop box (--cx0..--cy1, tight around the devices) is scaled to the
     content width minus an inset on each side, so the devices sit well inside the
     page margins. --pl / --pr / --pt / --pb are the insets around that box. */
  .card {
    --pl: calc(var(--m) * 1.75);
    --pr: var(--pl);
    --pt: 24px;
    --pb: var(--pl);
    --k: calc((100cqw - var(--pl) - var(--pr)) / (var(--cx1) - var(--cx0)));
    --ox: calc(var(--pl) - var(--cx0) * var(--k));
    --oy: calc(var(--pt) - var(--cy0) * var(--k));
    background: var(--band);
    overflow: hidden;              /* decorations may run up behind the title */
  }
  .card__art { height: calc((var(--cy1) - var(--cy0)) * var(--k) + var(--pt) + var(--pb)); overflow: visible; }
  .card .card__band, .card .card__texture { display: none; }   /* the card itself carries the band colour */
  .card__title {
    position: relative; left: 0; top: 0;
    width: auto;
    padding: 36px var(--m) 4px;
    font-size: 30px; line-height: 38px;
  }
  .works { gap: 16px; }

  /* crop boxes = the devices' outer bounds (project 3's desktop bleeds off the right, as in Figma) */
  .card--p1 { --cx0: 453; --cx1: 1280; --cy0: 163; --cy1: 616; }
  .card--p2 { --cx0: 452; --cx1: 1211; --cy0: 105; --cy1: 555; }
  .card--p3 { --cx0: 672; --cx1: 1480; --cy0: 104; --cy1: 557; --pr: 0px; }

  /* the dotted map: drawn larger than the band so the dots read at phone size */
  .card--p1, .hero--p1 {
    background: url("../assets/home/p1-map-texture.png") 50% 40% / max(720px, 190%) auto no-repeat, var(--band);
    background-blend-mode: color-burn, normal;
  }
}
@media (max-width: 599px) {
  .card__title { font-size: 26px; line-height: 34px; padding-top: 28px; }
}

/* ==========================================================================
   Project hero — band + devices; doubles as the video summary player
   ========================================================================== */
.hero { --band: var(--red); --cx0: 25; --cx1: 1255; --cy0: 64; --cy1: 597; }
.hero .card__band { left: 0; right: 0; }
.hero__devices { transition: opacity 0.4s ease; }
.hero__devices > * { position: absolute; }

.hero__play {
  position: absolute;
  z-index: 4;
  left: 50%; top: 50%;
  width: clamp(64px, calc(112 * var(--k)), 112px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 30px rgba(34, 34, 34, 0.18);
  display: grid; place-items: center;
  transform: translate(-50%, -50%);
  transition: transform 0.35s var(--ease-out), opacity 0.3s ease;
}
.hero__play:hover { transform: translate(-50%, -50%) scale(1.06); }
.hero__play svg { width: 34%; height: 34%; margin-left: 6%; }

.hero__player {
  position: absolute; z-index: 5;
  left: 50%; top: 50%;
  height: calc(600 * var(--k));
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%) scale(0.96);
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s ease, transform 0.5s var(--ease-out), visibility 0s linear 0.5s;
}
.hero__player video, .hero__placeholder {
  width: 100%; height: 100%; border-radius: calc(24 * var(--k)); background: #000; display: block;
}
.hero__placeholder {
  display: none; place-items: center; text-align: center;
  background: rgba(34, 34, 34, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.6);
  color: #fff; font-size: 18px; line-height: 28px; font-weight: 500; padding: 24px;
}
.hero__player.is-missing video { display: none; }
.hero__player.is-missing .hero__placeholder { display: grid; }
.hero__close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.94); display: grid; place-items: center;
}
.hero.is-playing .hero__devices, .hero.is-playing .hero__play { opacity: 0; pointer-events: none; }
.hero.is-playing .hero__player {
  opacity: 1; visibility: visible; transform: translate(-50%, -50%);
  transition: opacity 0.4s ease 0.15s, transform 0.5s var(--ease-out) 0.15s, visibility 0s;
}

@media (max-width: 899px) {
  /* Every hero is the height of the open video player (16:9 inside the page margins),
     playing or not; the devices are scaled to fit inside it with room around them. */
  .hero {
    /* player width: the content width, but never so wide that the 16:9 video is taller
       than the screen minus the margins (a phone in landscape) */
    --pw: min(100cqw - 2 * var(--m), (100vh - 2 * var(--m)) * 16 / 9);
    --pw: min(100cqw - 2 * var(--m), (100svh - 2 * var(--m)) * 16 / 9);
    --H: calc(var(--pw) * 9 / 16 + 2 * var(--m));
    --pad: calc(var(--m) * 1.75);
    --k: min((100cqw - 2 * var(--pad)) / (var(--cx1) - var(--cx0)),
             (var(--H) - 2 * var(--pad)) / (var(--cy1) - var(--cy0)));
    --ox: calc((100cqw - (var(--cx1) - var(--cx0)) * var(--k)) / 2 - var(--cx0) * var(--k));
    --oy: calc((var(--H) - (var(--cy1) - var(--cy0)) * var(--k)) / 2 - var(--cy0) * var(--k));
  }
  .hero .card__art { height: var(--H); overflow: hidden; }
  .hero__player { height: auto; width: var(--pw); }
}

/* Video summaries are on hold until they're ready: hide the play button and player.
   To bring them back, delete this rule (and set each hero's data-src). */
.hero__play, .hero__player { display: none !important; }
