/* The iPhone Duo, shared by the hero shot (shot.js) and the tours (redesign/hero/): one box the size
   of the open phone, 30 × 21 em, so the page sizes it with font-size. Like a book: the right half
   stays put and the left half swings shut over it on the hinge (it comes later in the markup, or
   WebKit draws it underneath). Each half has a screen face, a metal edge for its thickness and, on
   the left one, the cover screen on its back. While it folds, the inner screen stays flat and the halves
   only show it where they are (see .hd-pts below). */
.hd-duo { position: absolute; width: 30em; height: 21em; }   /* (no perspective here: the halves carry their own, and two doubled it) */
.hd-duo, .hd-duo *, .hd-duo *::before, .hd-duo *::after { box-sizing: border-box; }

.hd-fold { position: absolute; inset: 0; transform-style: preserve-3d; }
.hd-half { position: absolute; top: 0; width: 50%; height: 100%; transform-style: preserve-3d; }
/* Where the halves rest; duo.js turns them on the hinge frame by frame (pose()). Always a rotateY
   (never "none"), so a turn never blends matrices. Each carries its own perspective, and the left
   half shows its cover side only while it's past edge-on (.turned): browsers flatten nested 3D
   here, so neither the parent's perspective nor backface-visibility can be relied on. */
.hd-half.left { left: 0; transform-origin: 100% 50%; transform: perspective(80em) rotateY(0deg); }
.hd-half.left > .hd-face.back, .hd-half.left.turned > .hd-face.screen { visibility: hidden; }
.hd-half.left.turned > .hd-face.back { visibility: visible; }
.hd-half.right { left: 50%; transform-origin: 0 50%; transform: perspective(80em) rotateY(0deg); }
[data-posture=closed] .hd-half.left { transform: perspective(80em) rotateY(180deg); }
[data-posture=book] .hd-half.left { transform: perspective(80em) rotateY(62deg); }
.hd-face {
	position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
	background: linear-gradient(135deg, #1c1c21, #050506 60%); border: 0.14em solid #b9bbc1;
}
/* Corners: round on the outside, nearly square on the hinge side (shut, that's the folded edge). */
.left > .hd-face.screen { border-radius: 1.8em 0.36em 0.36em 1.8em; border-right: 0; }
.right > .hd-face.screen { border-radius: 0.36em 1.8em 1.8em 0.36em; border-left: 0; box-shadow: inset 0.05em 0 0 #2c2c30; }
/* One shadow under the whole phone: both halves open, the right one shut (duo.js moves it as it folds). */
.hd-shadow { position: absolute; top: 0; bottom: 0; right: 0; left: 0; border-radius: 1.8em; box-shadow: 0 1.4em 3em rgba(20, 16, 50, 0.28); pointer-events: none; }
[data-posture=closed] > .hd-shadow { left: 50%; }
[data-posture=book] > .hd-shadow { left: 26.5%; }   /* (50% × (1 − cos 62°)) */
/* The cover sits on the far side of the half's thickness, so when shut it's on top. (It's turned
   round on the half, so the hinge is on its own left.) */
.hd-face.back { transform: translateZ(-0.7em) rotateY(180deg); border-radius: 0.36em 1.8em 1.8em 0.36em; background: #050506; }
/* Folding, every screen is a window onto one flat picture (duo.js pose()), cut to the screen's
   outline as it turns, traced by these points: 0.37em in from the phone's edge (less the face's
   0.14em border) on the inner screens, the cover screen's own inset on the cover. The turning half
   and the cover get .hd-pane windows: three copies of their flat picture, two of them blurred. */
.hd-pts { position: absolute; inset: 0.23em 0 0.23em 0.23em; pointer-events: none; }
.right .hd-pts { inset: 0.23em 0.23em 0.23em 0; }
.hd-cover > .hd-pts { inset: 0.25em; }   /* (the cover screen is 0.25em inside its border, like .hd-shot) */
.hd-pts > i { position: absolute; }
/* A pane reaches 4em past the picture, so a screen turned towards you (so bigger than the picture)
   sees past its edge into the dark room it sits in, as in Apple's, not a hole. Each copy is a layer
   with the room in it, so a blurred one blurs the picture's edge too. */
.hd-pane { position: absolute; inset: -3.63em; pointer-events: none; }
.hd-pane > i { position: absolute; inset: 0; background: #000; }
.hd-pane > .hd-dark { background: none; }
.hd-pane > i > .hd-inner { inset: 4em; opacity: 1; border-radius: 0; transition: none; }
/* The cover's picture sits flat where the shut cover is: a hair bigger (shut, it's on the far side of
   the half's thickness, nearer you), and without its black glass, so the fill carries its edge on. */
.hd-pane > i > .hd-cover { inset: 3.63em 3.63em 3.63em 18.63em; transform-origin: 0 50%; transform: scale(1.0088); background: none; border-color: transparent; }
/* Where the real cover's camera is: a 36 pt hole centred 49 pt from the right and 47 pt down its
   466 × 678 pt screen (the simulator's mask). The inner screen has none. */
.hd-cam { position: absolute; top: 0.97em; right: 1.08em; width: 1.12em; height: 1.12em; border-radius: 50%; background: #000; z-index: 3; }

/* Inner screen. */
.hd-inner { position: absolute; inset: 0.37em; border-radius: 1.5em; overflow: hidden; background: #fff; opacity: 0; }
.hd-duo[data-posture=open].shown > .hd-inner { opacity: 1; }

/* A screenshot for a screen (the hero shot's). */
.hd-shot { display: block; width: 100%; height: 100%; object-fit: cover; }
.hd-duo picture { display: contents; }   /* (a dark-mode shot's <picture> doesn't change the layout) */
.hd-cover .hd-shot { position: absolute; inset: 0.25em; width: calc(100% - 0.5em); height: calc(100% - 0.5em); border-radius: 0.15em 1.55em 1.55em 0.15em; }
