/*
 * Tang Luck Builder: the phone preview (web/js/widgets/preview.mjs): the
 * floating button, the drawer (docked on the right from 1100 px, the page
 * making room; full screen below), its controls, and the phone (bezel,
 * screen, splash, lobby frame). The screen's size and scale are set by the
 * widget through the CSSOM; data-phase on the screen says what shows.
 */

/*
 * the floating button: in the gap of the wizard's footer, between Back and
 * Continue, on their line (the footer's 14 px padding); on a phone that gap
 * is too narrow for the words, so it is a round phone icon there (its name
 * stays for screen readers and as a tooltip)
 */
.pv-fab {
  position: fixed; z-index: 30; left: 50%; bottom: 14px; transform: translateX(-50%); gap: 8px; padding: 9px 16px 9px 13px; border-radius: 99px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 213, 74, .35), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.pv-fab::before { content: ''; flex: none; width: 9px; height: 15px; border: 2px solid currentColor; border-radius: 3px; }
.pv-fab:active { transform: translateX(-50%) translateY(1px); }

/* the drawer: --pv-dock is its docked width, and the room the page gives it */
:root { --pv-dock: 420px; }
:root.pv-land { --pv-dock: clamp(420px, calc(100vw - 720px), 880px); }
.pv-drawer {
  position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: var(--pv-dock); display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 10px;
  background: linear-gradient(180deg, #1b0e40, #0d0624); border-left: 1px solid var(--line2); box-shadow: -12px 0 40px rgba(0, 0, 0, .45);
}
html.pv-docked body { padding-right: var(--pv-dock); }
html.pv-full, html.pv-full body { overflow: hidden; }
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pv-head h3 { margin: 0; }
.pv-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pv-seg button { padding: 5px 11px; font-size: .86rem; }
.pv-size { width: auto; padding: 6px 9px; font-size: .86rem; }
.pv-caption { margin: 0; text-align: center; font-size: .8rem; color: var(--dim); }

/* the phone: a bezel sized to the scaled screen; the screen keeps its real CSS size under a scale */
.pv-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pv-device {
  position: relative; flex: none; border: 8px solid #05030c; border-radius: 34px; overflow: hidden; background: #000;
  box-shadow: 0 0 0 2px #2c2450, 0 14px 40px rgba(0, 0, 0, .55);
}
.pv-screen { position: absolute; left: 0; top: 0; overflow: hidden; transform-origin: 0 0; background: #000; }
.pv-splash, .pv-lobby, .pv-status { position: absolute; inset: 0; }
.pv-lobby { z-index: 1; }
.pv-status { z-index: 2; display: flex; align-items: center; justify-content: center; padding: 24px; pointer-events: none; }
.pv-status > * { pointer-events: auto; }
.pv-splash { z-index: 3; transition: opacity .3s ease; }
.pv-screen[data-phase="lobby"] .pv-splash { visibility: hidden; }
.pv-screen[data-phase="splash"] .pv-lobby, .pv-screen[data-phase="splash"] .pv-status { visibility: hidden; }
.pv-screen[data-phase="fade"] .pv-splash { opacity: 0; }
.pv-frame { display: block; border: 0; background: #000; }
.pv-capture { position: absolute; inset: 0; background: #0b0620; }
.pv-capture img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pv-capture .pv-note { position: absolute; left: 12px; right: 12px; bottom: 12px; }
.pv-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.4;
  color: var(--muted); background: rgba(8, 4, 26, .86); border: 1px solid var(--line);
}
.pv-note.alert.bad { color: var(--text); border-color: var(--bad); }
.pv-splash > .pv-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap; }

/* the splash mock at the phone's real size (its own sizes are shares of its short side) */
.pv-splash .mock { width: 100%; height: 100%; aspect-ratio: auto; border: 0; border-radius: 0; }

@media (max-width: 1099px) {
  .pv-drawer { left: 0; width: auto; padding: 10px 12px; border-left: 0; }
}
@media (max-width: 520px) {
  .pv-fab { width: 42px; height: 42px; padding: 0; border-radius: 50%; }
  .pv-fab::before { width: 12px; height: 20px; }
  .pv-fab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .pv-splash { transition: none; }
}
