/* The display and the Expo viewport share a 390 × 844 coordinate system. */
#device {
  --screen-width: clamp(235px, 17.6vw, 257px);
  --screen-radius: calc(var(--screen-width) * .128);
  position: relative;
  isolation: isolate;
  box-sizing: content-box;
  width: var(--screen-width);
  height: auto;
  aspect-ratio: 390 / 844;
  padding: 0;
  border: 3.5px solid #11151c;
  border-radius: calc(var(--screen-radius) + 3.5px);
  overflow: visible;
  background: #11151c;
  box-shadow:
    0 0 0 4px #59697b,
    0 3px 3px 4px #26364b40,
    0 24px 32px -4px #20374747,
    0 8px 13px -5px #17243f55;
}

/* Brushed titanium rail with different highlights along its four edges. */
#device::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: -6.5px;
  padding: 3px;
  border-radius: calc(var(--screen-radius) + 6.5px);
  pointer-events: none;
  background: conic-gradient(from 23deg,
    #809db7 0deg, #f4faff 39deg, #a0b7c9 60deg, #5e7387 96deg,
    #bccbd7 123deg, #5f7183 151deg, #d2dfe5 182deg, #8c9dac 204deg,
    #4b6277 237deg, #c9dbe7 270deg, #fcfeff 309deg, #8da7bb 342deg,
    #809db7 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

/* Side buttons sit outside the display and never receive touch events. */
#device::after {
  --key: linear-gradient(90deg, #667787, #cbd6df 55%, #627789);
  content: "";
  position: absolute;
  inset: 0 -9px;
  z-index: -1;
  pointer-events: none;
  background:
    var(--key) left 0 top 17% / 2.5px 2.7% no-repeat,
    var(--key) left 0 top 23% / 2.5px 6% no-repeat,
    var(--key) left 0 top 31% / 2.5px 6% no-repeat,
    var(--key) right 0 top 28% / 2.5px 9.5% no-repeat;
}

#device .handset-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  border-radius: var(--screen-radius);
  background: #175d8a;
  /* Keep the iframe inside the curved glass in WebKit as well. */
  transform: translateZ(0);
}

#device #app-frame {
  position: absolute;
  inset: 0 auto auto 0;
  width: 390px;
  height: 844px;
  display: block;
  border: 0;
  transform-origin: top left;
}

#device .handset-status {
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  height: calc(var(--screen-width) * 54 / 390);
  pointer-events: none;
  user-select: none;
  color: white;
}
#device[data-dark-ink] .handset-status { color: #26374c; }

#device .handset-status::before {
  content: "9:41";
  position: absolute;
  top: 50%;
  left: 10%;
  transform: translateY(-50%);
  font: 620 calc(var(--screen-width) * 15 / 390)/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 .5px 1.5px #1736526b;
}

#device .handset-status::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 9%;
  width: calc(var(--screen-width) * 42 / 390);
  height: calc(var(--screen-width) * 10 / 390);
  transform: translateY(-50%);
  background:
    linear-gradient(currentColor 0 0) 0 100% / 7% 35%,
    linear-gradient(currentColor 0 0) 11% 100% / 7% 54%,
    linear-gradient(currentColor 0 0) 22% 100% / 7% 77%,
    linear-gradient(currentColor 0 0) 33% 100% / 7% 100%,
    linear-gradient(currentColor 0 0) 91% 50% / 44% 77%,
    linear-gradient(currentColor 0 0) 100% 50% / 4% 36%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 .5px 1px #17365263);
}

#device .dynamic-island {
  position: absolute;
  left: 50%;
  top: calc(var(--screen-width) * 11 / 390);
  width: calc(var(--screen-width) * 110 / 390);
  aspect-ratio: 110 / 32;
  transform: translateX(-50%);
  border-radius: 100px;
  background: #050609;
}

#device .dynamic-island::after {
  content: "";
  position: absolute;
  right: 10%;
  top: 38%;
  height: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #273648, #101421 44%, #06070a 82%);
}

@media (min-width: 681px) and (max-width: 1000px) {
  #device { --screen-width: clamp(216px, 25.8vw, 232px); }
}

@media (max-width: 680px) {
  #device { --screen-width: clamp(198px, 51.5vw, 215px); }
}
