/* Quiet resize affordances, outside the actual theme viewport. */
.stage[data-device]:not([data-device='desktop']) .frame-shell {
    overflow: visible;
    border: 1px solid #dedee5;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgb(28 28 45 / 4%);
}

.stage:not([data-device='desktop']) iframe {
    border-radius: 7px;
}

/* Soft glass grips share one surface, stroke and hover treatment. */
.resize-handle {
    position: absolute;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgb(137 145 163 / 17%);
    border-radius: 6px;
    background: rgb(255 255 255 / 68%);
    color: #a3a7b2;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 85%),
        0 1px 3px rgb(35 45 65 / 3%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    touch-action: none;
    transition: background-color 180ms ease, border-color 180ms ease,
        color 180ms ease, box-shadow 180ms ease;
}

/* Invisible padding makes the small visible grip easier to catch. */
.resize-handle::after {
    position: absolute;
    inset: -6px;
    content: '';
}

.resize-handle::before {
    display: block;
    box-sizing: border-box;
    pointer-events: none;
    content: '';
}

.resize-handle:hover,
.resize-handle:focus-visible,
.resize-handle.is-active {
    border-color: rgb(94 153 224 / 32%);
    background: rgb(218 236 255 / 72%);
    color: #6391c1;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 95%),
        0 2px 7px rgb(73 127 187 / 10%);
}

.resize-handle:focus-visible {
    outline: 2px solid rgb(80 145 220 / 55%);
    outline-offset: 3px;
}

.resize-handle--width {
    top: calc(50% - 20px);
    right: -20px;
    width: 12px;
    height: 40px;
    cursor: ew-resize;
}

.resize-handle--width::before {
    width: 4px;
    height: 14px;
    border-right: 1px solid currentColor;
    border-left: 1px solid currentColor;
    border-radius: 1px;
}

.resize-handle--height {
    bottom: -20px;
    left: calc(50% - 20px);
    width: 40px;
    height: 12px;
    cursor: ns-resize;
}

.resize-handle--height::before {
    width: 14px;
    height: 4px;
    border-top: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    border-radius: 1px;
}

.resize-handle--both {
    right: -20px;
    bottom: -20px;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
}

.resize-handle--both::before {
    width: 8px;
    height: 8px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    border-radius: 0 0 3px;
}

.viewport-size {
    position: absolute;
    top: -30px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 9px;
    width: max-content;
    transform: translateX(-50%);
    color: #777784;
    font: 11px system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

.viewport-size strong {
    color: #42424e;
    font-weight: 550;
}

.viewport-size span::before {
    margin-right: 9px;
    color: #bebec8;
    content: '·';
}

.resize-help {
    position: absolute;
    right: 12px;
    bottom: 12px;
    left: 12px;
    margin: 0;
    color: #858592;
    text-align: center;
    font: 11px system-ui, sans-serif;
}

.stage[data-device='desktop'] .resize-handle,
.stage[data-device='desktop'] .viewport-size,
.stage[data-device='desktop'] .resize-help {
    display: none;
}

.stage.is-resizing iframe {
    pointer-events: none;
}

.stage.is-resizing {
    user-select: none;
}

@media (prefers-reduced-motion: reduce) {
    .resize-handle {
        transition: none;
    }
}

/* Natural entry uses the actual window, without a scaled device inside it. */
.stage[data-view='natural'][data-device] .frame-shell {
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.stage[data-view='natural'] iframe {
    border-radius: 0;
}

.stage[data-view='natural'] .resize-handle,
.stage[data-view='natural'] .viewport-size,
.stage[data-view='natural'] .resize-help {
    display: none;
}
