/*
 * Usage:
 * <div class="rq-phone">
 *   <div class="rq-phone__body"><img src="..." alt="..."></div>
 * </div>
 *
 * Set only the width of .rq-phone. The descendant body resolves every cqw
 * measurement against that outer size container.
 */
.rq-phone {
  width: 100%;
  aspect-ratio: 100 / 216.8444;
  container-type: inline-size;
}

.rq-phone__body {
  --rq-bezel: 2.5cqw;
  --rq-frame-radius: 9.2cqw;
  --rq-screen-radius: 6.7cqw;
  --rq-shadow-contact: 0 1.8cqw 3.2cqw rgba(14, 21, 48, 0.24);
  --rq-shadow-ambient: 0 7cqw 14cqw rgba(14, 21, 48, 0.18);
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  isolation: isolate;
  border-radius: var(--rq-frame-radius);
  background: linear-gradient(90deg, #11151c 0%, #1c2129 7%, #181d24 50%, #1c2129 93%, #11151c 100%);
  box-shadow:
    inset 0 0 0 0.34cqw rgba(255, 255, 255, 0.28),
    inset 0 0 0 0.72cqw rgba(7, 10, 15, 0.86),
    inset -0.55cqw 0 0 rgba(255, 255, 255, 0.07),
    var(--rq-shadow-contact),
    var(--rq-shadow-ambient);
  transform: translateZ(0);
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.rq-phone__body > img {
  position: absolute;
  z-index: 1;
  inset: var(--rq-bezel);
  display: block;
  width: calc(100% - (2 * var(--rq-bezel)));
  height: calc(100% - (2 * var(--rq-bezel)));
  margin: 0;
  border: 0;
  border-radius: var(--rq-screen-radius);
  object-fit: cover;
  object-position: 50% 0;
  background: #080a0f;
  box-shadow: 0 0 0 0.34cqw rgba(4, 6, 10, 0.9);
  user-select: none;
}

/* One physical rocker and one power key, attached to the physical right edge. */
.rq-phone__body::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset-block-start: 27cqw;
  right: -0.65cqw;
  width: 0.8cqw;
  height: 14.5cqw;
  border-radius: 0 0.55cqw 0.55cqw 0;
  background: linear-gradient(90deg, #161a21, #343a45 68%, #202630);
  box-shadow: 0 20cqw 0 #252b35;
}

/* Lens plus a restrained top-left glass sheen. */
.rq-phone__body::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: var(--rq-bezel);
  border-radius: var(--rq-screen-radius);
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 2.9cqw,
      rgba(151, 170, 196, 0.55) 0 0.23cqw,
      #080b10 0.32cqw 0.98cqw,
      rgba(0, 0, 0, 0.82) 1.02cqw 1.27cqw,
      transparent 1.32cqw),
    linear-gradient(132deg,
      rgba(255, 255, 255, 0.055) 0%,
      rgba(255, 255, 255, 0.018) 17%,
      transparent 31%);
}

.rq-phone--tilt .rq-phone__body {
  --rq-shadow-contact: 1.15cqw 1.8cqw 3.2cqw rgba(14, 21, 48, 0.24);
  --rq-shadow-ambient: 2.2cqw 7cqw 14cqw rgba(14, 21, 48, 0.18);
  box-shadow:
    inset 0 0 0 0.34cqw rgba(255, 255, 255, 0.28),
    inset 0 0 0 0.72cqw rgba(7, 10, 15, 0.86),
    inset -1.25cqw 0 0 #10151c,
    inset -1.6cqw 0 0 rgba(255, 255, 255, 0.08),
    var(--rq-shadow-contact),
    var(--rq-shadow-ambient);
  transform: perspective(420cqw) rotateY(-8deg) rotateX(0.35deg) translateZ(0);
  transform-origin: 50% 50%;
}

.rq-phone--flat .rq-phone__body {
  --rq-shadow-contact: 0 0 transparent;
  --rq-shadow-ambient: 0 0 transparent;
}

.rq-phone--dark-bg .rq-phone__body {
  box-shadow:
    inset 0 0 0 1px rgba(211, 222, 238, 0.42),
    inset 0 0 0 0.72cqw rgba(7, 10, 16, 0.88),
    inset -0.55cqw 0 0 rgba(255, 255, 255, 0.1),
    var(--rq-shadow-contact),
    var(--rq-shadow-ambient);
}

@media (prefers-reduced-motion: reduce) {
  .rq-phone--tilt .rq-phone__body {
    transform: perspective(420cqw) rotateY(-8deg) rotateX(0.35deg);
  }
}
