/* ==========================================================
   Device mask frames (iMac / iPad / iPhone)
   Used by content-device-frame.php.

   How it works:
   - .device-frame sets the device's shape (aspect-ratio).
   - .device-frame__screen is the window inside the artwork.
     The screenshot <img> sits in it at full width.
   - .device-frame__art (the SVG) sits on top. Its screen area is
     transparent, so the screenshot shows through.
   - The screenshot fills the screen's width (object-fit: cover)
     and scrolls by animating object-position from 0% (top) to
     100% (bottom), so the distance always matches the image.
     No JavaScript, and it works in older Safari too.
   ========================================================== */

.device-frame {
  position: relative;
  width: 100%;
  margin: 0 auto;
}

.device-frame__screen {
  position: absolute;
  overflow: hidden;
  background: #fff;
  z-index: 1;
}

.device-frame__screen img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 0%;
}

.device-frame__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  user-select: none;
}

/* ---- Scrolling ------------------------------------------- */

.device-frame.is-scrolling .device-frame__screen img {
  animation: device-frame-scroll var(--dm-duration, 10s) ease-in-out infinite alternate;
}

.device-frame.is-scrolling:hover .device-frame__screen img {
  animation-play-state: paused;
}

@keyframes device-frame-scroll {
  0%, 8%    { object-position: 50% 0%; }
  92%, 100% { object-position: 50% 100%; }
}

/* Screenshot shorter than the screen: it just fills the screen, no scroll */

@media (prefers-reduced-motion: reduce) {
  .device-frame.is-scrolling .device-frame__screen img { animation: none; }
}

/* ---- Devices: artwork size and screen opening ------------- */
/* Screen positions are measured from the SVG viewBoxes.        */

/* iMac / desktop: desktop.svg, viewBox 620 x 515 */
.device-frame--desktop { aspect-ratio: 620 / 515; }
.device-frame--desktop .device-frame__screen {
  left: 3.71%;   /* 23 / 620 */
  top: 4.56%;    /* 23.5 / 515 */
  width: 92.58%; /* 574 / 620 */
  height: 62.53%;/* 322 / 515 */
}

/* iPad: tablet.svg, viewBox 506 x 715 */
.device-frame--ipad { aspect-ratio: 506 / 715; max-width: 520px; }
.device-frame--ipad .device-frame__screen {
  left: 6.52%;   /* 33 / 506 */
  top: 9.23%;    /* 66 / 715 */
  width: 86.76%; /* 439 / 506 */
  height: 81.82%;/* 585 / 715 */
}

/* iPhone: iphone.svg, viewBox 360 x 722 */
.device-frame--iphone { aspect-ratio: 360 / 722; max-width: 300px; }
.device-frame--iphone .device-frame__screen {
  left: 6.58%;   /* 23.7 / 360 */
  top: 7.34%;    /* 53 / 722 (below the status bar) */
  width: 86.86%; /* 312.7 / 360 */
  height: 89.66%;/* 647.4 / 722 */
  border-radius: 0 0 10% 10% / 0 0 5% 5%;
}

/* ---- Small screens --------------------------------------- */
@media (max-width: 767.98px) {
  .device-frame--ipad   { max-width: 380px; }
  .device-frame--iphone { max-width: 240px; }
  .device-frame--desktop { max-width: 520px; }
}

/* ==========================================================
   Three-device mockup (desktop + tablet + phone)
   Used by content-half-image-intro-w-three-device-mask.php.
   device-mask-half.png (1500 x 1361) sits on top; each screenshot
   sits behind one of its transparent screens. Positions are the
   screen openings in px / image size, plus a hair of bleed.
   ========================================================== */

.three-device-mask {
  position: relative;
  width: 100%;
  aspect-ratio: 1500 / 1361;
}

.three-device-mask .tdm-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
  user-select: none;
}

.three-device-mask .tdm-screen {
  position: absolute;
  overflow: hidden;
  background: #fff;
}

.three-device-mask .tdm-screen img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 0%;
}

.three-device-mask .tdm-screen.is-scrolling img {
  animation: device-frame-scroll var(--dm-duration, 10s) ease-in-out infinite alternate;
}
.three-device-mask:hover .tdm-screen.is-scrolling img {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  .three-device-mask .tdm-screen.is-scrolling img { animation: none; }
}

/* desktop: px 124,118 to 1282,774 */
.three-device-mask .tdm-screen--desktop {
  left: 8.2%; top: 8.6%; width: 77.4%; height: 48.4%;
  z-index: 1;
}
/* tablet: px 1105,643 to 1421,1064 (in front of the desktop) */
.three-device-mask .tdm-screen--tablet {
  left: 73.6%; top: 47.2%; width: 21.3%; height: 31.1%;
  z-index: 2;
}
/* phone: px 118,735 to 288,1037 (in front of the desktop) */
.three-device-mask .tdm-screen--phone {
  left: 7.8%; top: 53.95%; width: 11.55%; height: 22.35%;
  z-index: 2;
}
