/* A physical iPhone (15 Pro proportions) around the app screenshot.
   Shared by Night, Bold and Third; everything scales from --pw, the
   phone's width. Loaded last, and doubled up (.iphone.iphone) so it
   wins over each page's older, flat phone rules.

   Finish: matte black.

   Real numbers, from Apple's spec sheet, as fractions of the width:
     body 70.6 x 146.6 x 8.25 mm      -> height 2.077w, depth 0.117w
     titanium band ~0.9 mm            -> 1.3%
     black border ~1.4 mm             -> 2.0%
     screen corners 55 pt of 393 pt   -> 14% of the screen's width
     Dynamic Island 126 x 37 pt, 11 pt from the top
   The screenshot is an iPhone screen (1170 x 2532), so the screen keeps
   that ratio and the body follows from it. */

.iphone.iphone {
  --band: calc(var(--pw) * .013);
  --border: calc(var(--pw) * .02);
  --sw: calc(var(--pw) - 2 * (var(--band) + var(--border)));   /* screen width */
  --depth: 0px;                                                 /* > 0 where the phone is shown in 3D */
  position: relative; width: var(--pw); aspect-ratio: auto; transform-style: preserve-3d;
  padding: calc(var(--band) + var(--border));
  border-radius: calc(var(--sw) * .14 + var(--band) + var(--border));
  /* Brushed titanium: a soft sheen that travels round the band. */
  /* Matte black: a near-flat finish with only a soft sheen on the band. */
  background: linear-gradient(135deg, #2a2a2d 0%, #111113 30%, #1b1b1e 55%, #0d0d0f 80%, #232326 100%);
  box-shadow:
    inset 0 0 0 calc(var(--band) * .35) rgba(255, 255, 255, .09),  /* a faint chamfer on the outer edge */
    inset 0 0 0 var(--band) rgba(0, 0, 0, .15),
    0 calc(var(--pw) * .09) calc(var(--pw) * .2) rgba(0, 0, 0, .45),
    0 calc(var(--pw) * .02) calc(var(--pw) * .04) rgba(0, 0, 0, .35);
}
.iphone.iphone::before { content: none; }   /* the old flat island; the real one is on the screen */

.iphone.iphone .screen {
  position: relative; overflow: hidden; height: auto; padding: 0;
  aspect-ratio: 1170 / 2532;
  border-radius: calc(var(--sw) * .14);
  background: #1C2433;
  /* The black border between glass edge and pixels. */
  box-shadow: 0 0 0 var(--border) #050506, 0 0 0 calc(var(--border) + 1px) rgba(255, 255, 255, .06);
}
.iphone.iphone .screen > img { width: 100%; height: 100%; object-fit: cover; }
/* Dynamic Island, on the glass: a real element, not a pseudo-element,
   so every browser composites it above the screenshot. */
.iphone.iphone .island {
  position: absolute; z-index: 4; left: 50%; transform: translate3d(-50%, 0, 0);
  top: calc(var(--sw) * .028); width: calc(var(--sw) * .32); height: calc(var(--sw) * .094);
  border-radius: 999px;
  /* the front camera: a small lens near the right end */
  background: radial-gradient(circle at 80% 50%, #2a3350 0, #121626 calc(var(--sw) * .016), #000 calc(var(--sw) * .02));
}
/* The glass: a faint diagonal reflection over everything. */
.iphone.iphone .screen::after {
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, rgba(255, 255, 255, .13) 0%, rgba(255, 255, 255, .04) 22%, transparent 38%, transparent 70%, rgba(255, 255, 255, .05) 100%);
}
/* Status bar: the time centred in the left ear, the icons in the right. */
.iphone.iphone .statusbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3; height: calc(var(--sw) * .15);
  display: grid; grid-template-columns: 1fr calc(var(--sw) * .36) 1fr; align-items: center; padding: 0;
  color: #fff; font: 600 calc(var(--sw) * .043)/1 system-ui, -apple-system, "SF Pro Text", sans-serif; letter-spacing: -0.01em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .35); background: none; backdrop-filter: none; -webkit-backdrop-filter: none; -webkit-mask-image: none; mask-image: none;
}
.iphone.iphone .statusbar > span:first-child { justify-self: center; padding-left: calc(var(--sw) * .03); }
.iphone.iphone .statusbar .sb { grid-column: 3; justify-self: center; display: flex; align-items: center; gap: calc(var(--sw) * .014); padding-right: calc(var(--sw) * .02); }
.iphone.iphone .statusbar svg { height: calc(var(--sw) * .031); width: auto; }
.iphone.iphone .statusbar svg.batt { height: calc(var(--sw) * .036); }
.iphone.iphone .ios-note { top: calc(var(--sw) * .145); }

/* Side buttons, in the band's titanium. Left: Action, volume up and down.
   Right: side button. Positions from the top, as fractions of height. */
.iphone .hw {
  position: absolute; width: calc(var(--pw) * .011); border-radius: 2px;
  background: linear-gradient(90deg, #0e0e10, #2c2c30 50%, #0e0e10);
  transform: translateZ(calc(var(--depth) * -.5));
}
.iphone .hw-action { left: calc(var(--pw) * -.009); top: 17.5%; height: 5.4%; }
.iphone .hw-up { left: calc(var(--pw) * -.009); top: 25.5%; height: 10%; }
.iphone .hw-down { left: calc(var(--pw) * -.009); top: 37.5%; height: 10%; }
.iphone .hw-power { right: calc(var(--pw) * -.009); top: 28%; height: 15.5%; }

/* Depth, where the phone is tilted: the body's edge is built from thin
   rounded slices stacked behind the front, so the side of the phone shows
   as a solid band of metal. */
.iphone .slab { position: absolute; inset: 0; border-radius: inherit; transform-style: preserve-3d; pointer-events: none; }
.iphone .slab i { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, #2a2a2e, #141416 45%, #1f1f22 70%, #0e0e10); transform: translateZ(calc(var(--depth) * var(--k) * -1)); }
.iphone .slab i:nth-child(odd) { filter: brightness(.92); }
.iphone .slab i:last-child { background: #0a0a0b; box-shadow: 0 calc(var(--pw) * .08) calc(var(--pw) * .18) rgba(0, 0, 0, .5); }
.hero-b .iphone.iphone { --depth: calc(var(--pw) * .117); box-shadow: inset 0 0 0 calc(var(--band) * .35) rgba(255, 255, 255, .09), inset 0 0 0 var(--band) rgba(0, 0, 0, .15); }

/* Safari drops backdrop blur inside a 3D scene, so the notification
   carries enough of its own colour to read without it. */
.iphone.iphone .ios-note { background: rgba(238, 238, 243, .985); }


/* Safari: inside a 3D-transformed phone it can paint the screenshot's
   layer over its absolutely positioned siblings, hiding the clock, the
   island and the notification. The screen is made one isolated layer,
   and each overlay gets a layer of its own above the image. */
.iphone.iphone .screen { isolation: isolate; transform: translateZ(0); -webkit-transform: translateZ(0); }
.iphone.iphone .screen > img { position: relative; z-index: 0; transform: translateZ(0); }
.iphone.iphone .statusbar { transform: translateZ(0); will-change: transform; }
.iphone.iphone .ios-note { will-change: transform, opacity; }
