/* The two full-width layers share one coordinate system and studio surface.
   The interactive reveal must clip the top layer without changing its width. */
.comparison-stage {
  container-type: inline-size;
  isolation: isolate;
  --studio-reference-width: 1000px;
  --studio-cover-width: 49%;
  --studio-fallback-image: 70%;
  --studio-surface: radial-gradient(ellipse at 38% 30%, #fbedd8, #f1dfc4 57%, #dfc5a1 100%);
  background: #eedbc0 var(--studio-surface);
}
.comparison-stage .comparison-plate {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #eedbc0 var(--studio-surface);
  pointer-events: none;
}
.comparison-plate::before {
  content: '';
  position: absolute;
  left: calc(50% - var(--studio-cover-width) / 2 + .7%);
  top: 50%;
  width: var(--studio-cover-width);
  aspect-ratio: 490 / 644;
  transform: translateY(-48.8%);
  border-radius: 2.7%;
  background: #59391955;
  filter: blur(.85cqw);
}
.comparison-stage .comparison-plate img {
  position: absolute;
  display: block;
  left: 50%;
  top: 50%;
  max-width: none;
  max-height: none;
  width: var(--studio-fallback-image);
  height: auto;
  object-fit: fill;
  margin: 0;
  border: 0;
  opacity: 1;
  filter: none;
  user-select: none;
  -webkit-user-drag: none;
}
.comparison-stage .is-before img {
  transform: translate(-50%, -54.1%);
  clip-path: polygon(14.75% 29.08%, 16.12% 27.85%, 18.85% 27.23%, 24.59% 26.92%, 66.67% 26.46%, 75.14% 26.31%, 77.32% 26.62%, 78.42% 27.38%, 79.51% 29.38%, 80.60% 32.77%, 84.43% 60.92%, 86.07% 69.08%, 86.89% 72.77%, 87.98% 79.38%, 86.61% 80.62%, 81.42% 81.08%, 17.76% 82.00%, 12.84% 81.54%, 12.30% 80.92%, 12.57% 79.38%, 13.66% 77.08%, 14.48% 41.54%, 14.75% 32.62%);
}
.comparison-stage .is-after img {
  transform: translate(-49.3%, -49.7%);
  clip-path: polygon(12.50% 12.46%, 13.65% 12.31%, 15.58% 11.85%, 19.04% 11.85%, 79.23% 11.38%, 80.77% 11.69%, 82.31% 12.31%, 83.46% 13.38%, 84.04% 14.92%, 84.42% 83.85%, 84.23% 85.23%, 83.46% 86.62%, 81.92% 87.38%, 80.00% 87.69%, 15.19% 88.15%, 14.23% 87.85%, 13.46% 87.23%, 13.08% 86.15%, 12.69% 84.00%, 12.69% 78.15%, 13.08% 74.77%, 14.04% 73.08%, 15.19% 72.15%, 14.62% 14.15%, 13.65% 13.69%);
}
/* Four corners of each physical cover are mapped to a 490 x 644 rectangle,
   centred in a 1000-unit-wide frame. The final scale follows the actual stage.
   atan2 divides two lengths without requiring newer CSS typed division. */
@supports (width: 1cqw) and (transform: scale(tan(atan2(100cqw, 1000px)))) {
  .comparison-stage .comparison-plate img {
    width: var(--source-width);
    height: 650px;
    transform-origin: 0 0;
    transform: scale(tan(atan2(100cqw, var(--studio-reference-width)))) var(--align-cover);
  }
  .comparison-stage .is-before img {
    --source-width: 366px;
    --align-cover: matrix3d(
      2.31820551, .06465451, 0, .00002052,
      -.08817475, 2.18731436, 0, .00057359,
      0, 0, 1, 0,
      -379.77369248, -748.06593333, 0, 1
    );
  }
  .comparison-stage .is-after img {
    --source-width: 520px;
    --align-cover: matrix(1.35729515, .01081136, -.00548402, 1.30096642, -347.73216154, -422.99607725);
  }
}

@media (max-width: 600px) {
  .comparison-stage.is-interactive {
    aspect-ratio: 1;
    --studio-reference-width: 755px;
    --studio-cover-width: 64.9%;
    --studio-fallback-image: 92.7%;
  }
}
