/* ── iPhone Mockup Widget v1.5 ── */

/* Scene: provides the 3D perspective context */
.imw-scene {
    perspective: 900px;
    display: inline-flex;
    justify-content: center;
    width: 100%;
}

/* Phone wrapper: receives 3D transform */
.imw-phone-wrap {
    position: relative;
    display: inline-block;
    transform-style: preserve-3d;
    transition: transform 0.08s linear;
    will-change: transform;
    width: 320px;
    max-width: 100%;
    cursor: default;
    user-select: none;
}

/* Phone PNG sits on top, full width */
.imw-phone-img {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 2;
    pointer-events: none;
}

/* ── Screen overlay ──
   top/left/right/bottom set in pixels by JS (applyScreenBounds).
   CSS fallback percentages used only if JS hasn't run yet.        */
.imw-screen {
    position: absolute;
    top: 11%;
    left: 6%;
    right: 6%;
    bottom: 5%;
    z-index: 1;
    overflow: hidden;
    background-color: #000;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    /* Hidden until JS positions it — prevents visible jump on load */
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* ── App icon grid ── */
.imw-app-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 4px;
    padding: 24px 6px 6px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

/* ── Single app item ── */
.imw-app-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: default;
    /* Neutralize <a> element defaults when item is rendered as a link */
    text-decoration: none;
    color: inherit;
    -webkit-user-drag: none;
}

.imw-app-item.has-url {
    cursor: pointer;
    /* Tells iOS to treat tap as a click immediately — no 300ms delay,
       no suppression from the preserve-3d transform context above */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Icon image */
.imw-app-icon {
    /* JS sets width + height to iconSize px. This wrapper gives the img
       a reliable containing block so 100%/100% always resolves correctly. */
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 22%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.45);
}

.imw-app-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* aspect-ratio ensures square even if a CSS constraint fights the JS size */
    aspect-ratio: 1 / 1;
    border-radius: 0; /* radius lives on the wrapper now */
    box-shadow: none;
    pointer-events: none;
}

/* Placeholder for missing icon — same shape as wrapper */
.imw-app-icon-placeholder {
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    box-sizing: border-box;
}

/* App label */
.imw-app-label {
    display: block;
    font-size: 10px;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    line-height: 1.2;
}

/* ── QR Popup ──
   Lives inside .imw-phone-wrap (preserve-3d) — tilts with the phone.
   translateZ(20px) lifts it off the screen surface in 3D space.
   JS calculates top/left in layout space (offsetTop walk) so position
   is immune to the tilt transform. Dynamic shadow set via JS on mousemove. */
.imw-qr-popup {
    position: absolute;
    z-index: 200;
    /* Frosted glass — visually reads as floating above the screen */
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    /* padding-bottom includes the arrow height so ::after lives inside the
       layout box — prevents 3D paint-order flicker of out-of-box pseudo-elements */
    padding: 10px 10px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.32), 0 2px 8px rgba(0,0,0,0.18);
    min-width: 140px;
    max-width: 190px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    /* translateZ(20px): float above the glass; scale for pop-in animation */
    transform: translateZ(20px) scale(0.88);
    transform-origin: bottom center;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.imw-qr-popup.imw-qr-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateZ(20px) scale(1);
}

.imw-qr-popup img {
    display: block;
    width: 120px !important;
    height: 120px !important;
    object-fit: contain;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 auto;
}

.imw-qr-popup .imw-qr-label {
    margin: 6px 0 0;
    font-size: 11px;
    color: #333;
    line-height: 1.3;
}

/* Arrow — sits at bottom: 2px so it's inside the popup's layout box.
   Out-of-box pseudo-elements (negative bottom) flicker in 3D preserve-3d
   contexts as the tilt shifts paint order. Keeping it inside prevents that. */
.imw-qr-popup::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #fff;
    border-bottom: none;
}

/* When popup flips below the icon */
.imw-qr-popup.imw-popup-below {
    transform-origin: top center;
}
.imw-qr-popup.imw-popup-below::after {
    bottom: auto;
    top: 2px;
    border-top-color: transparent;
    border-bottom: 8px solid #fff;
}

/* ── Responsive: disable tilt on touch-primary devices ── */
@media (hover: none) {
    .imw-phone-wrap {
        transform: none !important;
        transition: none;
    }
}

/* ── Elementor editor helpers ── */
.elementor-editor-active .imw-qr-popup {
    pointer-events: none;
}
