@import url("./phone-shell.css");

/* Preview contract v2
 *
 * PhoneShell owns hardware chrome. DevicePreview owns only media behavior:
 * screen media fills the 390 x 844 viewport edge-to-edge and explicit artboards
 * use contain. Cases never implement a second device shell here.
 */

:root {
  --library-device-width: 390;
  --library-device-height: 844;
  --library-detail-device-width: 300px;
}

/* A mobile preview must never add a synthetic desktop mouse pointer on top of
 * authored screens or videos. Interaction is conveyed by the UI itself. */
#previewCursor {
  display: none !important;
}

/* Preview image navigation uses one reusable chevron glyph instead of text
 * arrows. Previous reuses the same icon by rotating it 180deg. */
.preview-image-navigation {
  inset-inline: 10px !important;
  grid-template-columns: 36px minmax(0, 1fr) 36px !important;
}

.preview-image-navigation p {
  right: 40px !important;
  left: 40px !important;
  max-width: calc(100% - 80px) !important;
}

.preview-image-step {
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  border: 1px solid rgba(28, 27, 24, .10) !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, .88) !important;
  color: rgba(24, 24, 24, .88) !important;
  font-size: 0 !important;
  line-height: 0 !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.preview-image-step::before {
  width: 16px;
  height: 16px;
  background: currentColor;
  content: "";
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7.5 4.5 13 10l-5.5 5.5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7.5 4.5 13 10l-5.5 5.5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.preview-image-previous::before {
  transform: rotate(180deg);
}

.preview-image-step:hover {
  background: rgba(255, 255, 255, .98) !important;
  color: #171713 !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .11) !important;
}

.preview-image-step:active {
  transform: scale(.96);
}

.preview-image-step:focus-visible {
  outline: 2px solid rgba(25, 169, 87, .72) !important;
  outline-offset: 2px !important;
  background: rgba(255, 255, 255, .98) !important;
  color: #171713 !important;
}

/* Canonical phone sources must touch every screen edge. `contain` here was the
 * compatibility behavior that produced visible inner gaps and an apparent
 * second frame around otherwise-correct phone screenshots. */
.phone-frame:not(.is-artboard-preview) .phone-media {
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: top center !important;
  transform: none !important;
  border: 0 !important;
  background: #000;
}

.phone-frame:not(.is-artboard-preview) iframe.phone-media {
  display: block;
  overflow: hidden;
  border: 0 !important;
  background: transparent !important;
}

.phone-frame--card,
.phone-frame--card.has-wide-device-art,
.phone-frame--card.has-fitted-device-art {
  --card-media-scale: 1 !important;
}

.phone-frame--card .phone-media,
.phone-frame--card.has-wide-device-art .phone-media,
.phone-frame--card.has-fitted-device-art .phone-media,
.preview-media-frame .phone-media,
.preview-media-frame.has-wide-device-art .phone-media,
.preview-media-frame .phone-media.preview-video-sequence {
  transform: none !important;
}

/* Image, video sequence, MP4, and live iframe share one desktop footprint.
 * They may shrink on a short viewport, but switching modes never changes size. */
.preview-media-frame:not(.is-artboard-preview) {
  width: min(
    var(--library-detail-device-width),
    calc(100% - 48px),
    calc((100dvh - 180px) * 390 / 844)
  ) !important;
  height: auto !important;
  max-width: calc(100% - 48px) !important;
  max-height: calc(100dvh - 180px) !important;
  aspect-ratio: 390 / 844 !important;
}

/* Non-phone auxiliary media remains a neutral artboard. Its authored source
 * ratio controls the frame and the source is never cropped. */
.phone-frame.is-artboard-preview {
  aspect-ratio: var(--adaptive-media-ratio, 4 / 3) !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 16px !important;
  background: transparent !important;
  box-shadow: 0 12px 30px -18px rgba(0, 0, 0, .42) !important;
}

.phone-frame.is-artboard-preview::before,
.phone-frame.is-artboard-preview::after {
  display: none !important;
}

.phone-frame.is-artboard-preview .phone-screen {
  overflow: hidden;
  border-radius: 14px !important;
  background: transparent !important;
}

.phone-frame.is-artboard-preview .phone-media {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  transform: none !important;
  background: transparent !important;
}

.phone-frame--card.is-artboard-preview {
  width: min(calc(100% - 36px), 440px) !important;
  height: auto !important;
  max-width: calc(100% - 36px);
  max-height: calc(100% - 36px) !important;
}

.preview-media-frame.is-artboard-preview {
  width: min(620px, calc(100% - 40px)) !important;
  height: auto !important;
  max-width: calc(100% - 40px) !important;
  max-height: 100% !important;
}

@media (max-width: 760px) {
  .preview-media-frame:not(.is-artboard-preview) {
    width: min(
      var(--library-detail-device-width),
      calc(100% - 32px),
      calc((100dvh - 150px) * 390 / 844)
    ) !important;
    max-width: calc(100% - 32px) !important;
    max-height: calc(100dvh - 150px) !important;
  }

  .phone-frame--card.is-artboard-preview {
    width: min(calc(100% - 28px), 440px) !important;
    max-width: calc(100% - 28px);
  }

  .preview-media-frame.is-artboard-preview {
    width: min(100%, 520px) !important;
    max-width: 100% !important;
  }
}
