/*
 * @hraness/product-mockups: a macOS menu bar, window buttons and an iPhone for product pages.
 *
 * Size the menu bar and window buttons with --pm-pt, one macOS point in the page's units. An iPhone sizes
 * itself from its width. Colours follow the visitor's light or dark preference; set the --pm-* properties on
 * an ancestor to use the product's own. Layout rules have zero specificity so a page's positioning wins.
 */

:where(.pm-menubar, .pm-traffic, .pm-iphone, .pm-iphone-status, .pm-iphone-stack, .pm-iphone-screen),
:where(.pm-menubar, .pm-traffic, .pm-iphone, .pm-iphone-status, .pm-iphone-stack, .pm-iphone-screen) * {
  box-sizing: border-box;
}
.pm-glyph {
  display: block;
  flex: none;
  overflow: visible;
}

/* macOS menu bar: 32 points tall with 14-point text, the Apple menu, the app, its menus and status items. */
.pm-menubar {
  display: flex;
  align-items: center;
  gap: calc(19 * var(--pm-pt, 1px));
  block-size: calc(32 * var(--pm-pt, 1px));
  padding-inline: calc(18 * var(--pm-pt, 1px)) calc(14 * var(--pm-pt, 1px));
  background: var(--pm-menubar-background, rgb(255 255 255 / 0.3));
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  backdrop-filter: blur(24px) saturate(1.6);
  color: var(--pm-menubar-ink, #101317);
  font:
    500 calc(14 * var(--pm-pt, 1px)) / 1 -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  white-space: nowrap;
}
.pm-menubar .pm-app {
  font-weight: 700;
}
.pm-menubar .pm-apple {
  inline-size: calc(13.5 * var(--pm-pt, 1px));
  block-size: calc(16 * var(--pm-pt, 1px));
  margin-inline-end: calc(2 * var(--pm-pt, 1px));
}
.pm-status {
  display: flex;
  align-items: center;
  gap: calc(16 * var(--pm-pt, 1px));
  margin-inline-start: auto;
}
.pm-item {
  display: block;
  flex: none;
}
.pm-menubar .pm-battery {
  inline-size: calc(27.5 * var(--pm-pt, 1px));
  block-size: calc(13 * var(--pm-pt, 1px));
}
.pm-menubar .pm-wifi {
  inline-size: calc(17 * var(--pm-pt, 1px));
  block-size: calc(12.3 * var(--pm-pt, 1px));
}
.pm-menubar .pm-spotlight {
  inline-size: calc(14.5 * var(--pm-pt, 1px));
  block-size: calc(14.5 * var(--pm-pt, 1px));
}
.pm-menubar .pm-control {
  inline-size: calc(16.5 * var(--pm-pt, 1px));
  block-size: calc(14.5 * var(--pm-pt, 1px));
}
.pm-time {
  margin-inline-start: calc(-9 * var(--pm-pt, 1px));
}

/* The close, minimize and zoom buttons. */
.pm-traffic {
  display: flex;
  gap: calc(8 * var(--pm-pt, 1px));
}
.pm-traffic i {
  display: block;
  inline-size: calc(12 * var(--pm-pt, 1px));
  block-size: calc(12 * var(--pm-pt, 1px));
  border-radius: 50%;
  background: #ff5f57;
  box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.2);
}
.pm-traffic i + i {
  background: #febc2e;
}
.pm-traffic i + i + i {
  background: #28c840;
}

/*
 * iPhone 17 Pro: a 402 x 874 point screen in a 15-point bezel, 432 x 904 points in all. One point inside is
 * --pm-ipt. The status layer sits over the frame at the same size; screen content goes between them.
 */
:where(.pm-iphone, .pm-iphone-status) {
  position: relative;
}
.pm-iphone,
.pm-iphone-status {
  --pm-ipt: calc(100cqw / 432);
  container-type: inline-size;
  aspect-ratio: 432 / 904;
}
.pm-iphone {
  border-radius: 17.82% / 8.52%;
  background: var(
    --pm-iphone-finish,
    linear-gradient(130deg, #c9c8c1, #77786f 22%, #d6d5ce 48%, #6f706a 76%, #b9b8b0)
  );
  box-shadow: var(--pm-iphone-shadow, 0 0 0 0.5px rgb(0 0 0 / 0.45), 0 14px 32px -10px rgb(10 14 24 / 0.45));
}
.pm-iphone::before,
.pm-iphone::after {
  content: '';
  position: absolute;
}
.pm-iphone::before {
  inset: calc(3 * var(--pm-ipt));
  border-radius: calc(74 * var(--pm-ipt));
  background: #0b0b0c;
}
.pm-iphone::after {
  inset: calc(15 * var(--pm-ipt));
  border-radius: calc(62 * var(--pm-ipt));
  background: var(--pm-iphone-screen, #fff);
}
.pm-iphone-key {
  position: absolute;
  inline-size: calc(4 * var(--pm-ipt));
  border-radius: calc(2 * var(--pm-ipt));
  background: #8d8e86;
}
.pm-iphone-action {
  inset-inline-start: calc(-2.5 * var(--pm-ipt));
  inset-block-start: calc(150 * var(--pm-ipt));
  block-size: calc(34 * var(--pm-ipt));
}
.pm-iphone-volume {
  inset-inline-start: calc(-2.5 * var(--pm-ipt));
  inset-block-start: calc(215 * var(--pm-ipt));
  block-size: calc(120 * var(--pm-ipt));
}
.pm-iphone-power {
  inset-inline-end: calc(-2.5 * var(--pm-ipt));
  inset-block-start: calc(250 * var(--pm-ipt));
  block-size: calc(100 * var(--pm-ipt));
}

/* Status bar positions and sizes follow Textmock's iPhone 17 Pro, offset by the bezel. */
.pm-iphone-status {
  color: var(--pm-iphone-ink, #000);
  pointer-events: none;
}
.pm-iphone-time,
.pm-iphone-indicators {
  position: absolute;
  display: flex;
  align-items: center;
  translate: -50% -50%;
}
.pm-iphone-time {
  inset-inline-start: calc(87.67 * var(--pm-ipt));
  inset-block-start: calc(47.67 * var(--pm-ipt));
  font:
    600 calc(16.75 * var(--pm-ipt)) / 1 -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-feature-settings: 'case';
}
.pm-iphone-indicators {
  inset-inline-start: calc(342.6 * var(--pm-ipt));
  inset-block-start: calc(47.33 * var(--pm-ipt));
}
.pm-iphone-island {
  position: absolute;
  inset-inline-start: calc(50% - 62.5 * var(--pm-ipt));
  inset-block-start: calc(26 * var(--pm-ipt));
  inline-size: calc(125 * var(--pm-ipt));
  block-size: calc(37 * var(--pm-ipt));
  border-radius: calc(19 * var(--pm-ipt));
  background: #000;
}
.pm-iphone-indicators .pm-cellular {
  position: relative;
  inset-block-start: calc(0.33 * var(--pm-ipt));
  inline-size: calc(19.33 * var(--pm-ipt));
  block-size: calc(12.33 * var(--pm-ipt));
  margin-inline-end: calc(7.33 * var(--pm-ipt));
}
.pm-iphone-indicators .pm-wifi {
  inline-size: calc(17 * var(--pm-ipt));
  block-size: calc(12.33 * var(--pm-ipt));
  margin-inline-end: calc(7.33 * var(--pm-ipt));
}
.pm-iphone-indicators .pm-battery {
  inline-size: calc(27.5 * var(--pm-ipt));
  block-size: calc(13 * var(--pm-ipt));
}
.pm-iphone-home {
  position: absolute;
  inset-inline-start: calc(50% - 67 * var(--pm-ipt));
  inset-block-end: calc(23 * var(--pm-ipt));
  inline-size: calc(134 * var(--pm-ipt));
  block-size: calc(5 * var(--pm-ipt));
  border-radius: calc(3 * var(--pm-ipt));
  background: currentColor;
}

/* Optional: stack the frame, screen content and status layer in one box. Give the stack a definite width. */
:where(.pm-iphone-stack) {
  display: grid;
  container-type: inline-size;
}
:where(.pm-iphone-stack) > * {
  grid-area: 1 / 1;
}
:where(.pm-iphone-screen) {
  z-index: 1;
  align-self: start;
  margin: calc(100cqw * 15 / 432);
  aspect-ratio: 402 / 874;
  overflow: hidden;
  border-radius: calc(100cqw * 62 / 432);
}
:where(.pm-iphone-stack > .pm-iphone-status) {
  z-index: 2;
}

@media (prefers-color-scheme: dark) {
  .pm-menubar {
    background: var(--pm-menubar-background, rgb(30 30 32 / 0.42));
    color: var(--pm-menubar-ink, #f5f5f7);
  }
  .pm-iphone::after {
    background: var(--pm-iphone-screen, #000);
  }
  .pm-iphone-status {
    color: var(--pm-iphone-ink, #fff);
  }
}

@media (forced-colors: active) {
  .pm-iphone,
  .pm-menubar {
    border: 1px solid CanvasText;
  }
}
