/* ===================================
   DEVICE PREVIEW (organism)
   ===================================

   What a guest's device shows, over the page (TLP-1238): the guest app on a phone,
   or the signage menu on a table tablet. The root is a .modal-overlay, so Modal.css
   owns its position, backdrop and stacking; this file owns the stage, the optional
   device switch and the device itself. Colours are the platform device tokens -- one
   set of device chrome, shared with the signage screen preview.

   The device is drawn at its REAL size -- its screen is the device's CSS viewport --
   and shrunk to fit the window by DevicePreview.fit(), which sets --device-scale and
   the size of the fit box. Without a fit (no layout yet) it shows at full size.
*/

/* The stage owns all the air, so the overlay's own padding goes. */
.modal-overlay.device-preview {
    padding: 0;
}

/* The whole window, less a margin: the switch and caption on top, then the room the
   device may take. The top margin clears the environment banner that dev, test and
   stage pin across the window; side padding leaves space for the X. It covers the
   backdrop, so it lets clicks through to it -- a click beside the device is a click on
   the backdrop, which closes the preview -- and only the switch and the device take them. */
.device-preview-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    height: 100%;
    padding: var(--space-12) var(--space-16) var(--space-6);
    box-sizing: border-box;
    pointer-events: none;
}

.device-preview-bar,
.device-preview-fit {
    pointer-events: auto;
}

.device-preview-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.device-preview-caption {
    margin: 0;
    color: var(--text-inverse);
    font-size: var(--text-sm);
}

/* The room the device is fitted into. Its size comes from the stage, never from the
   device, so measuring it cannot feed back into it. */
.device-preview-area {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Exactly the size of the shrunk device, so it centres on what is drawn. */
.device-preview-fit {
    position: relative;
    width: var(--device-fit-width, auto);
    height: var(--device-fit-height, auto);
}

/* Beside the device's top corner, not in the window's: a window corner sits under the
   environment banner on dev, test and stage, and is a long way from what is being read. */
.device-preview .device-preview-close {
    position: absolute;
    top: 0;
    left: calc(100% + var(--space-3));
    color: var(--text-inverse);
}

.device-preview-device {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    padding: var(--space-3);
    background: var(--bg-device-frame);
    box-shadow:
        0 0 0 var(--border-width-2) var(--bg-device-bezel),
        var(--shadow-device),
        inset 0 0 0 var(--border-width-1) var(--bg-device-bezel);
    transform: scale(var(--device-scale, 1));
    transform-origin: top left;
}

/* Dark while the app loads, so the frame never flashes white. */
.device-preview-screen {
    overflow: hidden;
    background: var(--bg-device-frame);
}

.device-preview-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-device-frame);
}

/* ---- Phone: the guest app ---- */

.device-preview--phone .device-preview-device {
    border-radius: var(--radius-device-phone);
}

.device-preview--phone .device-preview-screen {
    width: var(--device-phone-viewport-width);
    height: var(--device-phone-viewport-height);
    border-radius: var(--border-radius-sm);
}

.device-preview-notch,
.device-preview-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.device-preview-notch {
    height: var(--space-8);
}

.device-preview-nav {
    height: var(--space-6);
}

.device-preview-notch::after,
.device-preview-nav::after {
    content: '';
    border-radius: var(--radius-pill);
}

.device-preview-notch::after {
    width: var(--device-phone-notch-width);
    height: var(--device-phone-notch-height);
    background: var(--bg-device-bezel);
}

.device-preview-nav::after {
    width: var(--device-phone-home-width);
    height: var(--device-phone-home-height);
    background: var(--bg-device-nav);
}

/* ---- Table tablet: the signage menu, held upright as it stands on a table ---- */

.device-preview--tablet .device-preview-device {
    padding: var(--space-4);
    border-radius: var(--radius-device-tablet);
}

.device-preview--tablet .device-preview-notch,
.device-preview--tablet .device-preview-nav {
    display: none;
}

.device-preview--tablet .device-preview-screen {
    width: var(--device-tablet-viewport-width);
    height: var(--device-tablet-viewport-height);
    border-radius: var(--border-radius-md);
}

/* ---- TV: the guest app on the in-room set (TLP-1265). Its screen is 1920x1080, the size
   the guest app draws its TV layout at, shrunk to fit like the others. A thin bezel. ---- */

.device-preview--tv .device-preview-device {
    padding: var(--space-3);
    border-radius: var(--radius-device-tv);
}

.device-preview--tv .device-preview-notch,
.device-preview--tv .device-preview-nav {
    display: none;
}

.device-preview--tv .device-preview-screen {
    width: var(--device-tv-viewport-width);
    height: var(--device-tv-viewport-height);
    border-radius: var(--border-radius-sm);
}
