/* playground.css - the fourth-wall layer over the Stage IX research site.
   Uses theme.css tokens only, so light and dark mode follow the site. */

#pg-voice {
  position: fixed; left: 16px; bottom: calc(16px + var(--pg-lift, 0px)); z-index: 2147483000;
  max-width: min(360px, calc(100vw - 32px));
  font: 400 12px/1.6 var(--mono); color: var(--text-primary);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  border: 1px solid var(--border-col); border-left: 2px solid var(--brand-l);
  padding: 10px 14px 10px 12px; backdrop-filter: blur(6px);
  opacity: 0; transform: translateY(8px); transition: opacity .4s, transform .4s;
  pointer-events: none;
}
#pg-voice.on { opacity: 1; transform: none; }
#pg-voice .who { display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-l); margin-bottom: 2px; }
#pg-voice .caret { display: inline-block; width: 7px; height: 12px; background: var(--brand-l); vertical-align: -1px; margin-left: 2px; animation: pg-blink 1s steps(1) infinite; }
@keyframes pg-blink { 50% { opacity: 0; } }

/* the one cue (no menu, Sep msg 1078): wordless, two rings pulsing like a double-tap, after ~4 s idle */
#pg-cue { position: fixed; left: 50%; bottom: calc(44px + var(--pg-lift, 0px)); width: 44px; height: 44px; margin-left: -22px;
  z-index: 2147483001; pointer-events: none; opacity: 0; transition: opacity .6s; }
#pg-cue.on, #pg-cue.mute { opacity: .55; }
#pg-cue i { position: absolute; inset: 0; border: 1px solid var(--brand-l); border-radius: 50%; transform: scale(.3); opacity: 0; }
#pg-cue.on i { animation: pg-cue 2.4s cubic-bezier(.2,.7,.3,1) infinite; }
#pg-cue.on i + i { animation-delay: .22s; }
@keyframes pg-cue { 0% { transform: scale(.3); opacity: 0; } 8% { opacity: 1; } 40% { transform: scale(1); opacity: 0; } 100% { opacity: 0; } }
/* the sound toggle answers with one blink of the same mark: rings for sound, a flat line for mute */
#pg-cue.mute i { animation: pg-cue .9s cubic-bezier(.2,.7,.3,1) 1; }
html.pg-muted #pg-cue.mute i { border-radius: 0; border-width: 1px 0 0; top: 50%; animation-name: pg-flat; }
@keyframes pg-flat { 0% { transform: scaleX(.2); opacity: 0; } 20% { opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
html.pg-broken #pg-voice { display: none; }   /* broken, the rig has the screen */

/* the visitor's own trace: where the cursor has been */
#pg-trace { position: fixed; inset: 0; z-index: 8000; pointer-events: none; }

/* play mode: blocks become props */
html.pg-play .pg-prop { cursor: grab; position: relative; z-index: 10; transition: box-shadow .2s; }
html.pg-play .pg-prop:hover { box-shadow: 0 0 0 1px var(--brand); }
.pg-prop.pg-held { position: relative; cursor: grabbing; z-index: 50; box-shadow: 0 12px 40px rgba(0,0,0,.45), 0 0 0 1px var(--brand-l); }
.pg-prop.pg-pinned::after {
  content: "pinned"; position: absolute; top: 6px; right: 8px;
  font: 400 9px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--brand-l);
}
html.pg-play .pg-prop a { pointer-events: none; }
html.pg-play body { touch-action: pan-y; }
html.pg-play .pg-prop, html.pg-play .pg-prop * { touch-action: none; }
.pg-wobble { animation: pg-wobble .5s; }
@keyframes pg-wobble { 25% { rotate: -1.2deg; } 75% { rotate: 1.2deg; } }

/* backstage: the scaffolding shows */
html.pg-back body * { outline: 1px dashed color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: -1px; }
html.pg-back section { position: relative; }
html.pg-back .pg-tag {
  position: absolute; top: 0; left: 0; z-index: 60; pointer-events: none;
  font: 400 9px/1.4 var(--mono); color: var(--black); background: var(--brand-l); padding: 1px 5px;
}
html.pg-back img, html.pg-back svg { filter: grayscale(1) contrast(.8); }
html.pg-back body { background-image:
  linear-gradient(var(--grey-2) 1px, transparent 1px),
  linear-gradient(90deg, var(--grey-2) 1px, transparent 1px);
  background-size: 24px 24px; }

#pg-back {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 2147482999; width: min(380px, 100vw);
  background: var(--surface-1); border-left: 1px solid var(--border-col);
  font: 400 11px/1.6 var(--mono); color: var(--text-primary);
  padding: 20px 18px 80px; overflow-y: auto; transform: translateX(100%); transition: transform .35s;
}
html.pg-back #pg-back { transform: none; }
#pg-back h3 { font: 500 10px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--brand-l); margin: 18px 0 6px; }
#pg-back h3:first-child { margin-top: 0; }
#pg-back dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
#pg-back dt { color: var(--text-dim); }
#pg-back dd { margin: 0; text-align: right; }
#pg-back .sw { display: flex; flex-wrap: wrap; gap: 4px; }
#pg-back .sw span { width: 26px; height: 26px; border: 1px solid var(--border-col); }
#pg-back ol { margin: 0; padding-left: 18px; color: var(--text-dim); max-height: 220px; overflow: hidden; }
#pg-back ol li:first-child { color: var(--text-primary); }
#pg-back p { color: var(--text-dim); margin: 0; }

@media (max-width: 640px) {
  #pg-back { width: 100vw; }
}
@media (prefers-reduced-motion: reduce) {
  #pg-voice, #pg-back { transition: none; }
  .pg-wobble { animation: none; }
}

/* a moved block gets its own ground, so it never prints over the text it now covers */
.pg-prop[style*="translate"], .pg-prop.pg-pinned { position: relative; z-index: 10; background: var(--surface-bg); }
html.pg-back #pg-back, html.pg-back #pg-back *, html.pg-back #pg-voice, html.pg-back #pg-voice * { outline: none; }

/* a level change: fracture lines race out from the struck point (playground.js fracture()) */
.pg-fracture { position: fixed; inset: 0; z-index: 2147483003; pointer-events: none; animation: pg-fr-out 1.5s ease-in forwards; }
.pg-fracture svg { display: block; overflow: visible; }
.pg-fracture path { fill: none; stroke: var(--brand-l); stroke-width: 1.4; stroke-dasharray: 1; stroke-dashoffset: 1; animation: pg-fr .38s cubic-bezier(.1,.8,.2,1) forwards;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--brand-l) 70%, transparent)); }
.pg-fracture circle { fill: color-mix(in srgb, var(--white, #fff) 85%, transparent); transform-box: fill-box; transform-origin: center; animation: pg-fr-flash .45s ease-out forwards; }
@keyframes pg-fr { to { stroke-dashoffset: 0; } }
@keyframes pg-fr-flash { from { transform: scale(.2); opacity: 1; } to { transform: scale(9); opacity: 0; } }
@keyframes pg-fr-out { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pg-fracture { display: none; } }
