/* ==========================================================================
   Sign-in art: the live form playground (markup: app/views/playground.php,
   behaviour: assets/js/playground.js).
   The scene fills the free space of the art panel (a size container) and the
   stage inside it keeps one of a few compositions — tall, wide or phone band —
   scaling as one picture. Everything inside is sized in em from the stage.
   ========================================================================== */

.auth-scene {
  container: pgscene / size;
  position: relative; flex: 1 1 0; width: auto; height: auto; min-height: 320px; max-width: none; aspect-ratio: auto;
  margin: 10px -22px; display: flex; align-items: center; justify-content: center; align-self: stretch;
}
.auth-scene .jelly-stage, .auth-scene .sticker, .jg-bubble { display: none; }
.auth-art { justify-content: flex-start; }

.pg { --pg-ink: #13212c; position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.pg-stage {
  --a: .9; --k: .03;            /* aspect ratio of the composition · font size per stage width */
  position: relative; perspective: 1100px;
  width: min(100cqw, 100cqh * var(--a)); aspect-ratio: var(--a);
  font-size: calc(min(100cqw, 100cqh * var(--a)) * var(--k));
}
.pg-layer { position: absolute; inset: 0; pointer-events: none; transform: translate3d(var(--px, 0), var(--py, 0), 0); will-change: transform; }
.pg-layer > * { pointer-events: auto; }

/* ---------- cards ---------- */
.pg-card {
  position: absolute; background: var(--surface); color: var(--text); border-radius: 1.4em;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: 0 1.6em 3.2em -1.2em rgba(4, 32, 29, .55), 0 .3em .8em rgba(4, 32, 29, .12);
}
.pg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .7em; }
.pg-chip { display: inline-flex; align-items: center; gap: .35em; padding: .3em .75em; border-radius: 99em; background: var(--butter); color: var(--pg-ink); font: 800 .78em/1.2 var(--font-display); letter-spacing: .01em; border: 1.5px solid var(--pg-ink); box-shadow: 2px 2px 0 var(--pg-ink); transform: rotate(-3deg); }
.pg-chip .icon { width: 1.1em; height: 1.1em; }
.pg-head-dots { display: flex; gap: .3em; }
.pg-head-dots i { width: .5em; height: .5em; border-radius: 50%; background: var(--border-strong); }
.pg-head-dots i:first-child { background: var(--coral); }
.pg-q { margin: 0; font: 800 1.42em/1.15 var(--font-display); letter-spacing: -.02em; color: var(--text); }
.pg-hint { margin: .25em 0 .8em; font-size: .86em; color: var(--text-3); min-height: 1.3em; }
.pg-hint.is-thanks { color: var(--accent-fg); font-weight: 700; }

/* ---------- main card (poll / system check) ---------- */
.pg-main {
  left: 0; top: 17%; width: 19.5em; padding: 1.15em 1.2em 1.05em;
  transform: rotateY(var(--ry, 0deg)) rotateX(var(--rx, 0deg)); transform-style: preserve-3d;
}
.pg-main::before { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(115deg, rgba(255, 255, 255, .45), transparent 40%); opacity: var(--glare, 0); mix-blend-mode: soft-light; }
.pg-main::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: .45em; border-radius: 1.4em 1.4em 0 0; background: linear-gradient(90deg, var(--coral), var(--butter), var(--brand)); }
.pg-main.is-swap .pg-q, .pg-main.is-swap .pg-opts, .pg-main.is-swap .pg-hint { animation: pgSwap .5s var(--spring); }
@keyframes pgSwap { 0% { opacity: 0; transform: translateY(.7em); } 100% { opacity: 1; transform: none; } }

.pg-opts, .pg-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45em; }
.pg-opt, .pg-row {
  position: relative; width: 100%; display: flex; align-items: center; gap: .55em; padding: .55em .75em; overflow: hidden; isolation: isolate;
  border-radius: .85em; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text);
  font: 600 .95em/1.2 var(--font); text-align: left; cursor: pointer;
  transition: border-color .2s, transform .25s var(--spring), background .2s;
}
.pg-opt:hover, .pg-row:hover { border-color: var(--accent); transform: translateX(.2em); }
.pg-opt:active, .pg-row:active { transform: scale(.97); }
.pg-bar { position: absolute; inset: 0; z-index: -1; width: var(--p, 0%); background: color-mix(in srgb, var(--accent) 16%, transparent); transition: width .9s cubic-bezier(.2, .9, .25, 1.15); }
.pg-emoji { font-size: 1.15em; line-height: 1; }
.pg-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-pct { font: 800 .85em/1 var(--font-display); color: var(--text-3); opacity: 0; transform: translateX(.5em); transition: opacity .3s, transform .4s var(--spring); font-variant-numeric: tabular-nums; }
.pg-poll.is-voted .pg-pct { opacity: 1; transform: none; }
.pg-poll.is-voted .pg-opt { cursor: default; }
.pg-poll.is-voted .pg-opt:hover { transform: none; border-color: var(--border); }
.pg-opt.is-mine { border-color: var(--accent) !important; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.pg-opt.is-mine .pg-bar { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.pg-opt.is-mine .pg-pct { color: var(--accent-fg); }
.pg-opt.is-mine .pg-label::after { content: ' ✓'; color: var(--accent-fg); font-weight: 800; }
.pg-opt.is-press { transform: scale(.95); border-color: var(--accent); }

.pg-rate { display: flex; align-items: center; justify-content: space-between; gap: .6em; margin-top: .85em; padding-top: .8em; border-top: 1px dashed var(--border); }
.pg-rate-label { font-size: .85em; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-stars { display: flex; gap: .1em; flex: none; }
.pg-star { border: 0; background: none; padding: 0 .08em; font-size: 1.35em; line-height: 1; color: var(--border-strong); cursor: pointer; transition: transform .3s var(--spring), color .15s; }
.pg-star.is-on { color: var(--butter); text-shadow: 0 0 .5em rgba(255, 200, 87, .55); }
.pg-star:hover { transform: scale(1.25) rotate(-8deg); }
.pg-star.is-pop { animation: pgStar .5s var(--spring); }
@keyframes pgStar { 40% { transform: scale(1.55) rotate(12deg); } }

/* admin rows */
.pg-row-ic { display: grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: .6em; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-fg); flex: none; }
.pg-row-ic .icon { width: 1.1em; height: 1.1em; }
.pg-status { display: grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; flex: none; transition: background .2s, transform .35s var(--spring); }
.pg-status .icon { width: .9em; height: .9em; }
.pg-status.is-ok { background: var(--success); color: #fff; }
.pg-status.is-run { background: transparent; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.pg-status.is-run .icon { display: none; }
.pg-status.is-ok.is-pop { animation: pgStar .45s var(--spring); }
.pg-foot { margin-top: .8em; padding-top: .7em; border-top: 1px dashed var(--border); font-size: .85em; font-weight: 700; color: var(--accent-fg); }

/* ---------- live stats ---------- */
.pg-stats { right: 0; top: 0; width: 15em; padding: 1em 1.1em .9em; transform: rotate(2.5deg); }
.pg-stats-top { display: flex; align-items: center; gap: .55em; font-size: .78em; font-weight: 600; color: var(--text-3); white-space: nowrap; overflow: hidden; }
.pg-stats-top span:last-child { overflow: hidden; text-overflow: ellipsis; }
.pg-live { display: inline-flex; align-items: center; gap: .4em; padding: .2em .6em; border-radius: 99em; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .9em; flex: none; }
.pg-live i { width: .55em; height: .55em; border-radius: 50%; background: currentColor; animation: pgPulse 1.6s ease-out infinite; }
@keyframes pgPulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); } 100% { box-shadow: 0 0 0 .7em transparent; } }
.pg-count { display: block; margin-top: .25em; font: 800 2.5em/1.05 var(--font-display); letter-spacing: -.04em; color: var(--text); font-variant-numeric: tabular-nums; }
.pg-count.is-bump, .pg-trio b.is-bump { animation: pgBump .6s var(--spring); }
@keyframes pgBump { 35% { transform: scale(1.12); color: var(--accent-fg); } }
.pg-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5em; margin-top: .55em; }
.pg-trio div { display: flex; flex-direction: column; min-width: 0; }
.pg-trio b { display: inline-block; font: 800 1.55em/1.1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pg-trio span { font-size: .75em; color: var(--text-3); font-weight: 600; }
.pg-today { display: flex; align-items: center; gap: .35em; margin-top: .3em; font-size: .85em; font-weight: 700; color: var(--text-2); }
.pg-up { display: grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: .45em; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-fg); }
.pg-up .icon { width: .95em; height: .95em; }
.pg-today [data-stat] { color: var(--accent-fg); font-variant-numeric: tabular-nums; }
.pg-spark { display: flex; align-items: flex-end; gap: .22em; height: 2.6em; margin-top: .7em; }
.pg-spark i { flex: 1; height: var(--h); border-radius: .25em .25em .1em .1em; background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 35%, transparent)); transform-origin: bottom; animation: pgBar 2.8s ease-in-out infinite alternate; }
.pg-spark i:nth-child(3n) { animation-delay: -.9s; } .pg-spark i:nth-child(3n + 1) { animation-delay: -1.7s; }
.pg-spark i:last-child { background: linear-gradient(180deg, var(--coral), color-mix(in srgb, var(--coral) 35%, transparent)); }
@keyframes pgBar { 0% { transform: scaleY(.72); } 100% { transform: scaleY(1); } }

/* ---------- feature notifications ---------- */
.pg-toasts { position: absolute; right: 0; bottom: 0; width: 17em; height: 9em; }
.pg-toast {
  position: absolute; right: 0; bottom: 0; width: 100%; display: flex; align-items: center; gap: .7em; padding: .7em .85em;
  border-radius: 1.1em; background: var(--surface); color: var(--text); border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: 0 1.2em 2.4em -1em rgba(4, 32, 29, .55);
  transform: translate3d(115%, 0, 0) rotate(4deg); opacity: 0;
  transition: transform .7s var(--spring), opacity .35s ease;
}
.pg-toast.is-in { transform: translate3d(0, 0, 0) rotate(-1.5deg); opacity: 1; }
.pg-toast.is-up { transform: translate3d(-3%, -112%, 0) rotate(1deg) scale(.94); opacity: .9; }
.pg-toast.is-out { transform: translate3d(-6%, -200%, 0) scale(.86); opacity: 0; }
.pg-toast.is-real { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), 0 1.2em 2.4em -1em rgba(4, 32, 29, .55); }
.pg-toast-ic { display: grid; place-items: center; width: 2.2em; height: 2.2em; border-radius: .75em; flex: none; font-size: 1.05em; background: var(--surface-2); }
.pg-toast > div { min-width: 0; }
.pg-toast b { display: block; font: 700 .9em/1.25 var(--font-display); }
.pg-toast small { display: block; margin-top: .1em; font-size: .76em; color: var(--text-3); line-height: 1.3; }

/* ---------- floating stickers ---------- */
.pg-float { position: absolute; animation: pgFloat 6s ease-in-out infinite; }
.pg-float.f1 { left: 40%; top: 8%; font-size: 2.6em; filter: drop-shadow(0 .25em .35em rgba(0, 0, 0, .25)); animation-duration: 5s; }
.pg-float.f2 { right: 4%; top: 45%; animation-delay: -2s; }
.pg-float.f3 { left: 3%; bottom: 1%; animation-delay: -3.6s; }
@keyframes pgFloat { 50% { translate: 0 -.55em; rotate: 3deg; } }
.pg-pill { display: inline-flex; align-items: center; gap: .4em; padding: .45em .85em; border-radius: 99em; background: #fff; color: var(--pg-ink); border: 1.5px solid var(--pg-ink); box-shadow: 2px 2px 0 var(--pg-ink); font: 700 .82em/1.2 var(--font-display); white-space: nowrap; }
.pg-pill .icon { width: 1.1em; height: 1.1em; }
.pg-qr { display: flex; flex-direction: column; align-items: center; gap: .3em; padding: .55em .55em .4em; border-radius: .9em; background: #fff; border: 1.5px solid var(--pg-ink); box-shadow: 3px 3px 0 var(--pg-ink); transform: rotate(6deg); }
.pg-qr svg { width: 3.6em; height: 3.6em; fill: var(--pg-ink); }
.pg-qr span { font: 800 .62em/1 var(--font-display); color: var(--pg-ink); letter-spacing: .02em; }

/* ---------- demo cursor and confetti ---------- */
.pg-cursor { position: absolute; left: 0; top: 0; width: 1.9em; height: 1.9em; z-index: 6; pointer-events: none; opacity: 0; fill: #fff; stroke: var(--pg-ink); stroke-width: 1.6; stroke-linejoin: round; filter: drop-shadow(0 .2em .25em rgba(0, 0, 0, .35)); transform: translate(var(--cx, 0), var(--cy, 0)); transition: transform 1.1s cubic-bezier(.45, .05, .2, 1), opacity .3s; }
.pg-cursor.is-on { opacity: 1; }
.pg-cursor.is-click { animation: pgClick .3s ease; }
@keyframes pgClick { 50% { scale: .8; } }
.pg-confetti { position: absolute; inset: 0; pointer-events: none; z-index: 7; overflow: visible; }
.pg-confetti i { position: absolute; width: .5em; height: .75em; border-radius: .12em; animation: pgBurst .95s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes pgBurst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---------- wide panels (big laptops, desktops): a landscape composition ---------- */
@media (min-width: 961px) {
  @container pgscene (min-aspect-ratio: 21 / 20) {
    .pg-stage { --a: 1.32; --k: .021; }
    .pg-main { left: 3%; top: 11%; width: 20em; }
    .pg-stats { right: 2%; top: 3%; width: 15.5em; }
    .pg-toasts { right: 1%; bottom: 3%; width: 18em; }
    .pg-float.f1 { left: 40%; top: 4%; }
    .pg-float.f2 { left: 52%; right: auto; top: 46%; }
    .pg-float.f3 { left: 6%; bottom: 2%; }
  }
}
@media (min-width: 961px) and (max-height: 700px) { .auth-pitch .auth-points { display: none; } }

/* ---------- phones and tablets: a wide band above the card ---------- */
@media (max-width: 960px) {
  .auth-scene { flex: none; height: 222px; min-height: 0; margin: 2px -8px 0; }
  .pg-stage { --a: 1.7; --k: .034; }
  .pg-main { left: 0; top: 1%; width: 61%; padding: .85em .9em .8em; border-radius: 1.2em; }
  .pg-head, .pg-hint, .pg-rate, .pg-foot { display: none; }
  .pg-q { font-size: 1.15em; margin: .2em 0 .55em; }
  .pg-opts, .pg-rows { gap: .32em; }
  .pg-opt, .pg-row { padding: .4em .6em; font-size: .86em; border-radius: .7em; }
  .pg-row-ic { width: 1.6em; height: 1.6em; }
  .pg-stats { right: 0; top: 5%; width: 36%; padding: .75em .8em .7em; }
  .pg-count { font-size: 1.9em; }
  .pg-trio { grid-template-columns: 1fr; gap: .15em; }
  .pg-trio div { flex-direction: row; align-items: baseline; gap: .35em; }
  .pg-trio b { font-size: 1.15em; }
  .pg-spark { height: 1.6em; margin-top: .45em; }
  .pg-toasts { width: 37%; height: 30%; bottom: 13%; }
  .pg-toast { padding: .5em .6em; gap: .5em; }
  .pg-toast small { display: none; }
  .pg-toast-ic { width: 1.8em; height: 1.8em; }
  .pg-float.f2, .pg-float.f3 { display: none; }
  .pg-float.f1 { left: 55%; top: -4%; font-size: 1.8em; }
}
@media (min-width: 600px) and (max-width: 960px) {
  .auth-scene { height: 290px; }
  .pg-stage { --k: .029; }
  .pg-hint { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-float, .pg-spark i, .pg-live i { animation: none; }
  .pg-toast { transition: opacity .3s; }
  .pg-cursor { display: none; }
}
