/* The phone: one self-contained component.
   Markup: .phone-wrap > .phone (see index.html). Script: js/phone.js.
   Size comes from --u on any ancestor: one "design pixel" of a 300 x 628 phone.
   State comes from custom properties set by MooivaPhone.set():
     --rx, --ry  rotation          --pos  which screen the strip shows (0 to 3)
     --dim       shadow on the lower half    --lp, --gl  where the light sits
   Everything here is CSS: sixteen stacked slices make the metal band, real side
   faces make the buttons. It could be swapped for a canvas with a 3D model. */

.phone-wrap { position: absolute; inset: 0; perspective: calc(1900 * var(--u)); }
.phone, .phone__edge { transform-style: preserve-3d; }
.phone {
  --rx: 0deg; --ry: 0deg; --pos: 0; --dim: 0.1; --lp: 22%; --gl: 30%;
  position: absolute; inset: 0;
  transform: rotateX(var(--rx)) rotateY(var(--ry)) translateZ(calc(16 * var(--u)));
}
.phone__edge, .phone__edge i, .phone__face { position: absolute; inset: 0; border-radius: calc(50 * var(--u)); }

/* The band. Only the rim of each slice is ever seen, so its colour along the
   rim is the band's shading: a light that sits at --lp and falls into shadow
   below, antenna lines, and a darker right-hand side. --b is how bright this
   depth of the band is (bright chamfers, dark flat middle). */
.phone__edge i {
  --b: 0.2;
  background:
    linear-gradient(180deg, transparent 13.1%, rgba(255, 255, 255, 0.16) 13.1%, rgba(255, 255, 255, 0.16) 13.45%, transparent 13.45%, transparent 86.55%, rgba(255, 255, 255, 0.12) 86.55%, rgba(255, 255, 255, 0.12) 86.9%, transparent 86.9%),
    linear-gradient(90deg, transparent 23%, rgba(255, 255, 255, 0.16) 23%, rgba(255, 255, 255, 0.16) 23.7%, transparent 23.7%, transparent 76.3%, rgba(255, 255, 255, 0.16) 76.3%, rgba(255, 255, 255, 0.16) 77%, transparent 77%),
    linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(180deg,
      hsl(225 6% calc(var(--b) * 30%)) 0%,
      hsl(222 7% calc(var(--b) * 96%)) calc(var(--lp) - 5%),
      hsl(222 7% calc(var(--b) * 100%)) var(--lp),
      hsl(225 6% calc(var(--b) * 42%)) calc(var(--lp) + 24%),
      hsl(228 8% calc(var(--b) * 12%)) calc(var(--lp) + 62%),
      hsl(228 8% calc(var(--b) * 7%)) 100%);
}
.phone__edge i:nth-child(1)  { --b: 0.98; transform: translateZ(calc(-2 * var(--u))); }
.phone__edge i:nth-child(2)  { --b: 0.62; transform: translateZ(calc(-4 * var(--u))); }
.phone__edge i:nth-child(3)  { --b: 0.34; transform: translateZ(calc(-6 * var(--u))); }
.phone__edge i:nth-child(4)  { --b: 0.24; transform: translateZ(calc(-8 * var(--u))); }
.phone__edge i:nth-child(5)  { --b: 0.2;  transform: translateZ(calc(-10 * var(--u))); }
.phone__edge i:nth-child(6)  { --b: 0.2;  transform: translateZ(calc(-12 * var(--u))); }
.phone__edge i:nth-child(7)  { --b: 0.25; transform: translateZ(calc(-14 * var(--u))); }
.phone__edge i:nth-child(8)  { --b: 0.36; transform: translateZ(calc(-16 * var(--u))); }
.phone__edge i:nth-child(9)  { --b: 0.42; transform: translateZ(calc(-18 * var(--u))); }
.phone__edge i:nth-child(10) { --b: 0.34; transform: translateZ(calc(-20 * var(--u))); }
.phone__edge i:nth-child(11) { --b: 0.24; transform: translateZ(calc(-22 * var(--u))); }
.phone__edge i:nth-child(12) { --b: 0.19; transform: translateZ(calc(-24 * var(--u))); }
.phone__edge i:nth-child(13) { --b: 0.19; transform: translateZ(calc(-26 * var(--u))); }
.phone__edge i:nth-child(14) { --b: 0.28; transform: translateZ(calc(-28 * var(--u))); }
.phone__edge i:nth-child(15) { --b: 0.55; transform: translateZ(calc(-30 * var(--u))); }
.phone__edge i:nth-child(16) { --b: 0.85; transform: translateZ(calc(-32 * var(--u))); }

/* Buttons: real faces standing on the band, turned 90 degrees. */
.side {
  position: absolute; width: calc(12 * var(--u)); border-radius: calc(3 * var(--u));
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #8b8e95 0%, #3b3d42 16%, #1d1e21 55%, #2c2e32 84%, #6b6e75 100%);
  box-shadow: inset 0 calc(1 * var(--u)) 0 rgba(255, 255, 255, 0.28), inset 0 calc(-1 * var(--u)) 0 rgba(0, 0, 0, 0.6);
}
.side--l { left: 0; transform: translateX(calc(-1.5 * var(--u))) translateZ(calc(-11 * var(--u))) rotateY(90deg); }
.side--r { left: 100%; transform: translateX(calc(1.5 * var(--u))) translateZ(calc(-11 * var(--u))) rotateY(90deg); }
.side--action { top: calc(112 * var(--u)); height: calc(22 * var(--u)); }
.side--up     { top: calc(156 * var(--u)); height: calc(42 * var(--u)); }
.side--down   { top: calc(208 * var(--u)); height: calc(42 * var(--u)); }
.side--power  { top: calc(178 * var(--u)); height: calc(70 * var(--u)); }
.side--camera {
  top: calc(392 * var(--u)); height: calc(46 * var(--u));
  transform: translateX(calc(0.3 * var(--u))) translateZ(calc(-11 * var(--u))) rotateY(90deg);
  background: linear-gradient(90deg, #26272a, #0b0b0c 40%, #0b0b0c 60%, #303236);
  box-shadow: inset 0 0 0 calc(0.6 * var(--u)) rgba(255, 255, 255, 0.14);
}

/* Front: a hair of lit chamfer, then black glass, then the screen. */
.phone__face {
  background: linear-gradient(128deg, #f4f6fa 0%, #9da1a9 9%, #3d3f44 26%, #131416 52%, #0a0a0b 74%, #4a4d53 100%);
}
.phone__glass {
  position: absolute; inset: calc(1.2 * var(--u)); border-radius: calc(48.8 * var(--u));
  background: #020203; overflow: hidden;
  box-shadow: inset 0 0 0 calc(0.7 * var(--u)) rgba(255, 255, 255, 0.07), inset 0 0 calc(5 * var(--u)) rgba(0, 0, 0, 0.9);
}
.phone__screen {
  position: absolute; inset: calc(8 * var(--u)); border-radius: calc(40.6 * var(--u));
  overflow: hidden; background: #05070c;
}
/* The four screens in one vertical strip; --pos slides it. */
.strip { position: absolute; inset: 0; transform: translateY(calc(var(--pos) * -104%)); }
.shot { position: absolute; left: 0; width: 100%; height: 100%; background: #FFF8EC; }
.shot:nth-child(1) { top: 0; }
.shot:nth-child(2) { top: 104%; }
.shot:nth-child(3) { top: 208%; }
.shot:nth-child(4) { top: 312%; }
/* Screenshots are 390 x 772; the 52pt above them is the status bar area. */
.shot img { position: absolute; left: 0; top: calc(37.6 * var(--u)); width: 100%; height: calc(558.2 * var(--u)); display: block; }
.shot--sea::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: calc(39 * var(--u)); background: #8FD0F7; }
.status { position: absolute; left: 0; right: 0; top: 0; height: calc(37.6 * var(--u)); color: #1B2A49; }
.status__time {
  position: absolute; left: calc(20 * var(--u)); width: calc(52 * var(--u)); top: calc(13.6 * var(--u)); text-align: center;
  font: 600 calc(11.8 * var(--u)) / 1.3 -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif; letter-spacing: -0.01em;
}
.status__icons { position: absolute; right: calc(20 * var(--u)); top: calc(16.4 * var(--u)); width: calc(50 * var(--u)); height: auto; fill: currentColor; }
.phone__island {
  position: absolute; left: 50%; top: calc(8 * var(--u));
  width: calc(90 * var(--u)); height: calc(26.6 * var(--u)); margin-left: calc(-45 * var(--u));
  border-radius: calc(13.3 * var(--u));
  background: radial-gradient(circle at 79% 50%, #1b2233 0, #0a0d16 calc(2.6 * var(--u)), #000 calc(4.4 * var(--u)));
}
.phone__home {
  position: absolute; left: 50%; bottom: calc(5.6 * var(--u));
  width: calc(97 * var(--u)); height: calc(3.7 * var(--u)); margin-left: calc(-48.5 * var(--u));
  border-radius: calc(2 * var(--u)); background: #1B2A49;
}
.phone__shade, .phone__glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
/* The lower part of the body falls into shadow. */
.phone__shade { background: linear-gradient(180deg, transparent 38%, rgba(0, 0, 0, var(--dim)) 100%); }
/* Glass: one hard-edged sheen and a soft band that travels as the phone turns. */
.phone__glare {
  background:
    linear-gradient(104deg, transparent calc(var(--gl) - 16%), rgba(255, 255, 255, 0.11) var(--gl), transparent calc(var(--gl) + 12%)),
    linear-gradient(121deg, rgba(255, 255, 255, 0.075) 0%, rgba(255, 255, 255, 0.02) 27%, transparent 27.15%);
}

/* The mirrored copy on the floor (added by MooivaPhone.mount). */
.phone-reflect {
  position: absolute; left: -40%; right: -40%;
  top: calc(100% + 14 * var(--u)); height: 100%;
  transform: scaleY(-1);
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.1) 20%, transparent 40%);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.1) 20%, transparent 40%);
  filter: blur(calc(1.4 * var(--u)));
  pointer-events: none;
}
.phone-reflect .phone-wrap { left: 22.22%; right: 22.22%; }
