:root {
  color-scheme: dark;
  background: #101214;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 32%, #30343a 0%, #101214 70%);
}

main { position: relative; }

.phone-view {
  --padding: 16px;
  --available-height: calc(100svh - 2 * var(--padding));

  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: var(--padding);
}

[hidden] { display: none !important; }

.phone-view:not(.razr) .razr-display {
  width: min(100%, 400px);
}

iframe {
  --corner-radius: 24px;

  display: block;
  width: 100%;
  height: min(var(--available-height), 850px);
  border: 0;
  border-radius: var(--corner-radius);
  clip-path: inset(0 round var(--corner-radius));
  background: #121212;
}

.razr {
  --razr-width: 352px;
  --case-blue: #215487;
  --case-highlight: #407ab1;
  --case-shadow: #142e4b;
  --control-height: 40px;
  --control-gap: 12px;

  grid-template-rows: 1fr var(--control-height);
  gap: var(--control-gap);
}

.phone-view button {
  color: #f1f3f5;
  cursor: pointer;
}

.phone-view svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edge {
  position: fixed;
  z-index: 1;
  inset-block: 0;
  display: grid;
  place-items: center;
  width: 48px;
  padding: 0;
  border: 0;
  background: transparent;
}

.edge-left { left: 0; padding-left: 12px; }
.edge-right { right: 0; padding-right: 12px; }

.edge svg, .flip {
  border: 1px solid #51575e;
  border-radius: 999px;
  background: #22262b;
  opacity: 0;
}

.edge svg {
  width: 32px;
  height: 36px;
  padding: 5px;
}

.edge:hover svg, .edge:focus-visible svg,
.flip-zone:hover .flip, .flip:focus-visible { opacity: 1; }
.edge:focus-visible { outline: none; }
.edge:focus-visible svg, .flip:focus-visible { outline: 2px solid #9bcbff; }

@media (hover: none) {
  .edge svg, .flip { opacity: 1; }
}

.flip-zone {
  display: grid;
  justify-items: center;
  align-self: start;
  width: 100%;
  height: calc(var(--control-height) + var(--padding));
}

.flip {
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
}

.flip:hover { background: #333a42; }
.razr.is-open .unfold, .razr:not(.is-open) .fold { display: none; }

.razr .razr-display {
  position: relative;
  /* Motorola Razr 60 external display: 1056 × 1066 physical pixels. */
  width: min(100%, var(--razr-width));
  aspect-ratio: 1056 / 1066;
}

.razr.is-open .razr-display {
  /* Keep the 22:9 display in the full layout, even in a short browser window. */
  --open-height: clamp(685px, var(--available-height) - var(--control-height) - var(--control-gap), var(--razr-width) * 22 / 9);

  width: min(100%, calc(var(--open-height) * 9 / 22));
  aspect-ratio: 9 / 22;
}

.razr .razr-display iframe {
  width: 100%;
  height: 100%;
}

.razr:not(.is-open) .razr-display {
  --case-side: clamp(10px, calc((100vw - 384px) / 2), 24px);

  isolation: isolate;
}

.razr:not(.is-open) .razr-display::before,
.razr:not(.is-open) .razr-display::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.razr:not(.is-open) .razr-display::before {
  z-index: -1;
  inset: -60px calc(-1 * var(--case-side)) -25px;
  border-radius: 26px 26px 40px 40px;
  background: linear-gradient(100deg, var(--case-highlight), var(--case-blue) 9%, #1c4775 82%, var(--case-shadow));
  box-shadow:
    inset 0 2px 1px #ffffff29,
    inset 3px 0 5px #80b1df4d,
    inset -4px -5px 8px #0b1a2f99,
    0 14px 28px #070d1680;
}

.razr:not(.is-open) .razr-display::after {
  z-index: -1;
  inset: -4px;
  border: 4px solid #0b1420;
  border-radius: 28px;
  background: #121212;
  box-shadow: 0 0 0 1px #6095c680, 0 -5px 9px #0f2d4d66;
}

.razr-cameras { display: none; }

.razr:not(.is-open) .razr-cameras {
  position: absolute;
  /* The compact patrol's 88px progress ring sits 4px above the bottom. */
  inset: auto 4.5% 4px auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6%;
  width: 47%;
  height: 88px;
  pointer-events: none;
}

.razr-lens {
  width: 38%;
  aspect-ratio: 1;
  border: 2px solid #26303b;
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 42%, #5d9baf 0%, transparent 13%),
    radial-gradient(circle at 52% 50%, #15345b 0%, #0e1d30 29%, #070b12 42%, #333f50 46%, #080b12 52%, #151a22 63%, transparent 64%),
    conic-gradient(from 30deg, #121822, #424d5b 18%, #0c131d 32%, #4b5c72 54%, #bbcedf 68%, #2c3848 81%, #121822);
  box-shadow: 0 0 0 1px #05070b, 0 2px 4px #05070bb3, inset 0 0 0 2px #151b25;
}

.razr-flash {
  width: 7%;
  aspect-ratio: 1;
  margin-right: 4%;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 35%, #fff8d5, #d6c395 58%, #8b805e);
  box-shadow: 0 0 0 1px #3b3f43;
}

.razr-lid {
  display: none;
  position: absolute;
  inset: 0 0 50%;
  transform-origin: center bottom;
  transform-style: preserve-3d;
  pointer-events: none;
}

.razr.is-folding iframe {
  pointer-events: none;
}

.razr.is-preparing-open .razr-display { transform: var(--closed-pose); }
.razr.is-preparing-open .razr-lid { transform: rotateX(-180deg); }

.razr.is-preparing-open iframe, .razr.is-hinge-active:not(.has-screen-fold) iframe {
  clip-path: inset(50% 0 0 round 0 0 24px 24px);
}

.razr.has-screen-fold iframe { background: transparent; }
.razr.has-screen-fold .razr-lid-front { visibility: hidden; }
.razr.is-preparing-open .razr-lid, .razr.is-hinge-active .razr-lid { display: block; }

.razr-lid-front, .razr-lid-back {
  position: absolute;
  inset: 0;
  border: 1px solid #3a5378;
  backface-visibility: hidden;
}

.razr-lid-front {
  border-radius: 24px 24px 2px 2px;
  background: linear-gradient(145deg, #273c59, #121c2d 45%, #1b2940);
}

.razr-lid-back {
  transform: rotateX(180deg);
  border-radius: 24px;
  background: linear-gradient(155deg, var(--case-highlight), var(--case-blue) 35%, var(--case-shadow));
}

.razr-lid-back::after {
  content: '';
  position: absolute;
  right: 24px;
  bottom: 20px;
  width: 18px;
  height: 18px;
  border: 2px solid #505964;
  border-radius: 50%;
  background: #11151a;
  box-shadow: -28px 0 0 -2px #11151a, -28px 0 0 #505964;
}
