/* MacBook media frame. Keep pg-desktop so existing articles switch in place.
 * Geometry matches the approved preview: 83.5% lid, 80.8% screen, 16:10 content.
 * The decoration owns the device height; native media and captions stay native. */
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop {
  --pg-macbook-default-width: 640px;
  --pg-macbook-scale: 1;
  position: relative;
  box-sizing: border-box;
  min-width: 0;
}
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop:is(.alignwide, .alignfull) { --pg-macbook-default-width: 100%; }
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop.size_s { --pg-macbook-scale: .84; }
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop.size_xs { --pg-macbook-scale: .68; }
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop:has(img, video, iframe) {
  container-type: inline-size;
  isolation: isolate;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "device" "caption";
  gap: 0;
  max-width: min(100%, calc(var(--pg-macbook-width, var(--pg-macbook-default-width)) * var(--pg-macbook-scale))) !important;
  height: auto !important;
  padding: 0 !important;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  margin-inline: auto;
}
/* Gallery column widths remain owned by Core. */
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop:has(img, video, iframe):not(.wp-block-gallery *) { width: 100% !important; }
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop.alignleft { margin-inline: 0 auto; }
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop.alignright { margin-inline: auto 0; }

/* No decoration on ::after: Gutenberg owns that pseudo-element when selected. */
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop > .pg-macbook-decoration { display: none; }
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop:has(img, video, iframe) > .pg-macbook-decoration {
  display: block;
  grid-area: device;
  align-self: start;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: 0;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-display {
  display: block; position: relative; box-sizing: border-box; width: 83.5%; margin: 0 auto;
  padding: 2cqw 1.1cqw 2cqw; border: .25cqw solid transparent;
  border-radius: 2.2cqw 2.2cqw .9cqw .9cqw;
  background: linear-gradient(128deg, #08090b 0%, #121316 48%, #050608 100%) padding-box,
    linear-gradient(138deg, #b5bfc6 0%, #68747d 7%, #24282d 21%, #9aa4ad 49%, #30373c 68%, #c5cdd3 94%, #59636b 100%) border-box;
  box-shadow: 0 0 0 .12cqw #262c31, 0 .12cqw .3cqw .12cqw #14181d66, inset 0 .13cqw .15cqw #ccd5e022;
}
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-screen { display: block; position: relative; aspect-ratio: 16 / 10; overflow: hidden; border-radius: .45cqw .45cqw .08cqw .08cqw; background: #09090b; box-shadow: 0 0 0 .08cqw #020508, 0 .12cqw .18cqw #ffffff0c; }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-camera { position: absolute; top: .65cqw; left: 50%; width: .6cqw; height: .6cqw; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle at 39% 33%, #65859b 0%, #1d3445 16%, #090f19 36%, #020407 65%); box-shadow: 0 0 0 .14cqw #13171c, .04cqw .05cqw .12cqw #000; }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-display-edge { position: absolute; inset: .1cqw; border-radius: 1.9cqw 1.9cqw .7cqw .7cqw; box-shadow: inset .07cqw .11cqw .1cqw #f4f8ff32, inset -.07cqw -.1cqw .18cqw #0009; pointer-events: none; }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-hinge { display: block; position: relative; width: 77.5%; height: .5cqw; margin: -.18cqw auto -.12cqw; border-radius: .3cqw; background: linear-gradient(90deg, #434a51, #0c1014 4%, #1d2328 48%, #080b0e 95%, #4b535c); box-shadow: 0 -.08cqw .12cqw #c4d1dd40; }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-base {
  display: block; position: relative; box-sizing: border-box; width: 100%; height: 2cqw;
  border-top: .12cqw solid #e1eaf0; border-bottom: .1cqw solid #5c6c78;
  border-radius: .15cqw .15cqw 2cqw 2cqw / .15cqw .15cqw 1.1cqw 1.1cqw;
  background: linear-gradient(90deg, #6c828f 0%, #e2edf2 .8%, #92a8b5 1.5%, #dce5eb 3%, #c5d2da 15%, #dce5eb 45%, #b9c8d1 81%, #e1e9ef 97%, #9bb0bd 98.5%, #e8f0f4 99.2%, #6b808d 100%);
  box-shadow: inset 0 .16cqw .18cqw #ffffffb3, inset 0 -.45cqw .3cqw #42576555, 0 .12cqw .16cqw #0614213b;
}
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-base::after { content: ""; position: absolute; left: 1.7%; right: 1.7%; bottom: .15cqw; height: .18cqw; border-radius: 50%; background: linear-gradient(90deg, transparent, #eff6fa90 8%, #b5c4cf70 50%, #eff6fa90 92%, transparent); }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-recess { position: absolute; top: -.12cqw; left: 41%; width: 18%; height: 1.03cqw; box-sizing: border-box; border: .08cqw solid #80919d; border-top: none; border-radius: 0 0 1cqw 1cqw / 0 0 .8cqw .8cqw; background: linear-gradient(90deg, #637681 0%, #d9e4ea 8%, #edf4f7 22%, #d6e1e8 75%, #eef4f8 91%, #60737f 100%); box-shadow: inset 0 -.12cqw .16cqw #ffffffd9, 0 .08cqw .09cqw #26394652; }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-feet { display: flex; justify-content: space-between; width: 90%; margin: 0 auto; }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-feet span { display: block; width: 6%; height: .28cqw; border-radius: 0 0 .4cqw .4cqw; background: linear-gradient(#242c32, #697984 52%, #303b42); }
.is-style-pg-desktop > .pg-macbook-decoration .pg-mb-shadow { position: absolute; top: calc(100% - .5cqw); left: 2%; width: 96%; height: 2.4cqw; z-index: -1; border-radius: 50%; background: radial-gradient(ellipse, #18222c32 0%, #18222c12 50%, transparent 73%); filter: blur(.5cqw); }

/* A single existing image/video occupies the screen inset; contain never crops
 * a screenshot, portrait image or a differently shaped video. */
:is(.wp-block-image, .wp-block-video).is-style-pg-desktop :is(img, video),
.wp-block-gallery.has-nested-images figure.wp-block-image.is-style-pg-desktop img {
  grid-area: device;
  align-self: start;
  justify-self: center;
  position: relative;
  box-sizing: border-box !important;
  display: block;
  width: 80.8% !important;
  max-width: none !important;
  height: 50.5cqw !important;
  max-height: none !important;
  min-height: 0 !important;
  aspect-ratio: 16 / 10 !important;
  margin: 2.25cqw auto 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: .45cqw .45cqw .08cqw .08cqw !important;
  object-fit: contain !important;
  object-position: center !important;
  background: #09090b;
  box-shadow: none !important;
  clip-path: none !important;
  z-index: 1;
}
.wp-block-image.is-style-pg-desktop > a,
.wp-block-image.is-style-pg-desktop > figure > a,
.wp-block-image.is-style-pg-desktop > picture,
.wp-block-image.is-style-pg-desktop > figure > picture,
:is(.wp-block-image, .wp-block-video).is-style-pg-desktop .components-resizable-box__container {
  grid-area: device;
  align-self: start;
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0;
  z-index: 1;
}
/* Older Core images can have an outer div and an inner figure. */
.wp-block-image.is-style-pg-desktop > figure { display: contents; }

/* Core's responsive wrapper and editor sandbox occupy exactly the same screen.
 * The original iframe, URL, allow attributes and player controls are retained. */
.wp-block-embed.is-style-pg-desktop .wp-block-embed__wrapper:has(iframe) {
  grid-area: device;
  align-self: start;
  justify-self: center;
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 80.8% !important;
  max-width: none !important;
  height: 50.5cqw !important;
  aspect-ratio: 16 / 10 !important;
  margin: 2.25cqw auto 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: .45cqw .45cqw .08cqw .08cqw;
  background: #09090b;
  overflow: hidden;
  z-index: 1;
}
.wp-block-embed.is-style-pg-desktop .wp-block-embed__wrapper:has(iframe)::before { content: none !important; display: none !important; padding: 0 !important; }
.wp-block-embed.is-style-pg-desktop .wp-block-embed__wrapper iframe {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: inherit;
  box-shadow: none !important;
  pointer-events: auto;
}
/* Fullscreen belongs to the player, not the decorative device dimensions. */
:is(.wp-block-video, .wp-block-embed).is-style-pg-desktop :is(video, iframe):fullscreen {
  position: fixed !important; inset: 0 !important; width: 100% !important; height: 100% !important;
  max-width: none !important; max-height: none !important; aspect-ratio: auto !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
}
:is(.wp-block-video, .wp-block-embed).is-style-pg-desktop :is(video, iframe):-webkit-full-screen {
  position: fixed !important; inset: 0 !important; width: 100% !important; height: 100% !important;
  max-width: none !important; max-height: none !important; aspect-ratio: auto !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
}
:is(.wp-block-image, .wp-block-video, .wp-block-embed).is-style-pg-desktop figcaption {
  grid-area: caption;
  position: relative !important;
  inset: auto !important;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  max-height: none;
  margin: .8em 0 0 !important;
  overflow-wrap: anywhere;
  z-index: 1;
}
.wp-block-gallery .wp-block-image.is-style-pg-desktop { flex-grow: 0; align-self: start; }
.wp-block-gallery .wp-block-image.is-style-pg-desktop figcaption { color: inherit; background: none; padding: 0; text-shadow: none; }
