/* Device mockups: a MacBook Pro 14" and a studio monitor, drawn with CSS only.
   Built by js/lib/devices.js. Every size is in cqw (a percentage of the device's own
   width), so a device scales as one piece wherever it is placed: give its wrapper a
   width and the rest follows. No brand logos on purpose.
   The colours here are materials (aluminium, black glass) and stay the same in both
   themes, so they are written here instead of in tokens.css. */

/* ---------- Shared parts ---------- */

.device {
  container-type: inline-size;
  position: relative;
  isolation: isolate;
  width: 100%;
}

/* A blurred copy of the wallpaper behind the device, so its colours spill out like
   light from the screen. Every wallpaper gives the device its own mood. */
.device-glow {
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.device-glow img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: var(--device-glow-opacity);
  filter: blur(6cqw) saturate(1.6);
  transform: scale(1.06);
}

/* The lit display. It is also a .skeleton: grey with a shine until the wallpaper is in.
   Selecting, dragging and "Save image as…" are switched off. That only stops casual
   copying, not a screenshot: the real protection is that the image is a small preview
   (see docs/protecting-wallpapers.md). */
.device-screen {
  position: relative;
  overflow: hidden;
  background: #111111;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* The <picture> around the wallpaper takes no box of its own: the image fills the screen. */
.device-picture {
  display: contents;
}

/* While the sharp wallpaper loads: the small preview, blurred, so the screen already shows
   the colours of the picture (--placeholder is set by js/lib/devices.js). */
.device-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--placeholder, none) center / cover;
  filter: blur(14px);
  transform: scale(1.08);
}

.device-screen.is-loaded::before {
  content: none;
}

.device-screen .device-wallpaper {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* The watermark on every shop preview, in two layers. Shown when the device has the
   "has-watermark" class. Why it looks like this (docs/protecting-wallpapers.md):
   - a clear copyright notice: the big AI image tools usually refuse to remove a
     watermark that says it is copyrighted, and removing it is against the law;
   - a faint repeated pattern over the whole screen: cropping a corner is not enough,
     and painting it out everywhere damages the picture.
   The SVG tile has the text twice, side by side and never on top of each other: once dark
   (seen on light parts, such as snow) and once light (seen on dark parts). On top of each
   other, the light one would wipe out the dark one on a white wallpaper. */
.device-watermark-pattern {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='150'%3E%3Cg font-family='Helvetica, Arial, sans-serif' font-size='22' font-weight='600' text-anchor='middle'%3E%3Ctext x='70' y='45' fill='black' fill-opacity='0.24' transform='rotate(-24 70 45)'%3E%C2%A9 feelpixels%3C/text%3E%3Ctext x='195' y='115' fill='white' fill-opacity='0.24' transform='rotate(-24 195 115)'%3E%C2%A9 feelpixels%3C/text%3E%3C/g%3E%3C/svg%3E");
  background-size: 26cqw auto;
}

/* The copyright notice sits on a small dark label, so it can be read on white snow too. */
.device-watermark {
  position: absolute;
  right: 2.5%;
  bottom: 3.5%;
  z-index: 2;
  display: none;
  padding: 0.25cqw 0.7cqw;
  border-radius: 1cqw;
  background: rgb(0 0 0 / 0.38);
  color: rgb(255 255 255 / 0.85);
  font-family: var(--font-sans);
  font-size: 1.05cqw;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.has-watermark .device-watermark,
.has-watermark .device-watermark-pattern {
  display: block;
}

/* A faint diagonal reflection on the glass. */
.device-glass {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(118deg, rgb(255 255 255 / 0.08) 0%, rgb(255 255 255 / 0.02) 38%, transparent 38.2%);
}

/* The macOS menu bar, shown when the device has the "has-menu-bar" class. */
.device-menu-bar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: none;
  justify-content: space-between;
  align-items: center;
  padding-inline: 1.8cqw 1.6cqw;
  background: rgb(0 0 0 / 0.16);
  backdrop-filter: blur(0.8cqw);
  -webkit-backdrop-filter: blur(0.8cqw);
  color: rgb(255 255 255 / 0.95);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1;
  white-space: nowrap;
}

.has-menu-bar .device-menu-bar {
  display: flex;
}

.device-menu-items,
.device-menu-status {
  display: flex;
  align-items: center;
}

.device-menu-items b {
  font-weight: 600;
}

.device-menu-status svg {
  fill: currentColor;
}

.device-battery {
  border: 0.08cqw solid rgb(255 255 255 / 0.8);
  background: currentColor content-box;
}

/* ---------- MacBook Pro 14" ---------- */

.macbook .device-glow {
  inset: 2% 8% 12%;
}

/* The lid: a thin aluminium rim around the black glass. */
.macbook-lid {
  width: 88%;
  margin-inline: auto;
  padding: 0.24cqw;
  border-radius: 2.3cqw 2.3cqw 0.4cqw 0.4cqw;
  background: linear-gradient(180deg, #eceef1, #c3c6cb 45%, #9fa3a9);
  box-shadow:
    inset 0 0.08cqw 0 rgb(255 255 255 / 0.85),
    0 2.5cqw 6cqw -1.5cqw rgb(0 0 0 / 0.55);
}

.macbook-bezel {
  position: relative;
  padding: 0.95cqw 0.95cqw 1.5cqw;
  border-radius: 2.1cqw 2.1cqw 0.3cqw 0.3cqw;
  background: #060608;
  box-shadow: inset 0 0 0 0.08cqw #2a2a2f;
}

/* The thicker black strip under the screen, where the lid meets the hinge. */
.macbook-bezel::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 0.35cqw;
  border-radius: 0 0 0.3cqw 0.3cqw;
  background: linear-gradient(180deg, #060608, #1c1c20);
}

/* Real panel: 3024 x 1964 pixels. */
.macbook .device-screen {
  aspect-ratio: 3024 / 1964;
  border-radius: 1.2cqw 1.2cqw 0.15cqw 0.15cqw;
}

.macbook .device-menu-bar {
  height: 2.3cqw;
  font-size: 1.05cqw;
}

.macbook .device-menu-items {
  gap: 1.3cqw;
}

.macbook .device-menu-status {
  gap: 1.1cqw;
}

.macbook .device-menu-status svg {
  width: 1.15cqw;
}

.macbook .device-battery {
  width: 2cqw;
  height: 0.95cqw;
  padding: 0.12cqw;
  border-radius: 0.28cqw;
}

/* The camera notch. It hangs from the top of the bezel down to the bottom of the menu
   bar: 0.95cqw (bezel padding above the screen) + 2.3cqw (menu bar height). */
.macbook-notch {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 4;
  width: 8.2cqw;
  height: 3.25cqw;
  border-radius: 0 0 0.8cqw 0.8cqw;
  background: #060608;
  transform: translateX(-50%);
}

.macbook-notch::after {
  content: "";
  position: absolute;
  top: 1.4cqw;
  left: 50%;
  width: 0.6cqw;
  height: 0.6cqw;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3d4c6c, #0b0e16 62%);
  transform: translateX(-50%);
}

/* The base seen from the front: a thin aluminium slab, a little wider than the lid,
   with the opening groove in the middle. */
.macbook-base {
  position: relative;
  height: 1.3cqw;
  border-radius: 0.2cqw 0.2cqw 1.3cqw 1.3cqw / 0.2cqw 0.2cqw 1cqw 1cqw;
  background: linear-gradient(180deg, #f5f6f8 0%, #d9dbdf 28%, #aaadb3 72%, #75787e 100%);
  box-shadow: inset 0 0.07cqw 0 rgb(255 255 255 / 0.95);
}

.macbook-base::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 13cqw;
  height: 0.5cqw;
  border-radius: 0 0 0.8cqw 0.8cqw;
  background: linear-gradient(180deg, #8b8e94, #c8cace);
  transform: translateX(-50%);
}

/* Soft shadow where it touches the table. */
.macbook-base::after {
  content: "";
  position: absolute;
  inset: 100% 4% auto;
  height: 1.8cqw;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--device-floor-shadow), transparent);
}

/* ---------- Studio monitor (27", 16:9) ---------- */

.monitor .device-glow {
  inset: 0 4% 30%;
}

/* The panel: aluminium edge, an even black border, the screen. */
.monitor-panel {
  position: relative;
  z-index: 1;
  padding: 0.4cqw;
  border-radius: 1.6cqw;
  background: linear-gradient(180deg, #eef0f3, #c4c7cc 50%, #a3a7ad);
  box-shadow:
    inset 0 0.1cqw 0 rgb(255 255 255 / 0.9),
    0 3cqw 7cqw -2cqw rgb(0 0 0 / 0.5);
}

.monitor-bezel {
  padding: 2.1cqw;
  border-radius: 1.25cqw;
  background: #060608;
  box-shadow: inset 0 0 0 0.1cqw #2a2a2f;
}

/* Real panel: 5120 x 2880 pixels. */
.monitor .device-screen {
  aspect-ratio: 16 / 9;
  border-radius: 0.2cqw;
}

.monitor .device-menu-bar {
  height: 1.9cqw;
  font-size: 0.95cqw;
}

.monitor .device-menu-items {
  gap: 1.15cqw;
}

.monitor .device-menu-status {
  gap: 1cqw;
}

.monitor .device-menu-status svg {
  width: 1.05cqw;
}

.monitor .device-battery {
  display: none; /* a desktop has no battery */
}

/* The stand: a flat arm that narrows a little towards the foot. */
.monitor-neck {
  width: 17%;
  height: 15cqw;
  margin: -1cqw auto 0;
  clip-path: polygon(4% 0, 96% 0, 100% 100%, 0 100%);
  background:
    linear-gradient(180deg, rgb(0 0 0 / 0.35), transparent 30%),
    linear-gradient(90deg, #8f9399, #dfe1e5 22%, #f2f3f5 50%, #dfe1e5 78%, #8f9399);
}

.monitor-foot {
  position: relative;
  width: 30%;
  height: 1.3cqw;
  margin-inline: auto;
  border-radius: 0.3cqw 0.3cqw 0.9cqw 0.9cqw;
  background: linear-gradient(180deg, #f5f6f8, #c9ccd0 45%, #85888e);
  box-shadow: inset 0 0.07cqw 0 rgb(255 255 255 / 0.95);
}

.monitor-foot::after {
  content: "";
  position: absolute;
  inset: 100% -6% auto;
  height: 1.8cqw;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--device-floor-shadow), transparent);
}
