/* Playground interior (dark, calm). Tokens come from styles.css with fallbacks. */

.playground { container-type: inline-size; container-name: pgbox; }

.pg {
  --pg-bg: var(--bg, #0d1014);
  --pg-bg-2: var(--bg-2, #141920);
  --pg-surface: var(--surface, #181e26);
  --pg-line: var(--line, #2a323d);
  --pg-line-2: #3a4452; /* control borders: a touch stronger than the hairline */
  --pg-text: var(--text, #e6ebf0);
  --pg-muted: var(--text-muted, #9aa6b4);
  --pg-mint: var(--mint, #7fe0c0);
  --pg-mint-ink: var(--mint-ink, #7fe0c0);
  --pg-focus: var(--focus, #8cc8ff);
  --pg-slate: #6b7a90;
  --pg-slate-hi: #8795a9;
  color: var(--pg-text);
  font-family: var(--font-body, system-ui, "Segoe UI", Arial, sans-serif);
  font-size: 1rem;
  line-height: 1.45;
  background: var(--pg-surface);
  /* no border/radius here: the single outer frame is .playground in styles.css */
  border: 0;
  border-radius: 0;
  overflow: hidden;
  min-width: 0;
}
.pg *, .pg *::before, .pg *::after { box-sizing: border-box; }
:where(.pg) :where(p, dl, dd, dt, figure, ol) { margin: 0; padding: 0; }
.pg code { font: inherit; background: none; border: 0; padding: 0; margin: 0; color: inherit; border-radius: 0; box-shadow: none; white-space: inherit; }

/* ---- header ---- */
.pg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--pg-line);
}
.pg-tag {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--pg-mint-ink);
  border: 1px solid currentColor;
  border-radius: var(--radius-pill, 999px);
  padding: 0.1rem 0.7rem;
}
.pg-sub { font-size: 1rem; color: var(--pg-muted); }

/* ---- layout ---- */
.pg-body { display: grid; grid-template-columns: minmax(0, 1fr); }
.pg-scene, .pg-side { min-width: 0; }
@container pgbox (min-width: 40rem) {
  .pg-body { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: stretch; }
  .pg-side { border-left: 1px solid var(--pg-line); }
}

/* ---- scene ---- */
.pg-scene {
  position: relative;
  display: flex;
  align-items: center;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, rgb(127 224 192 / 0.07), transparent 70%), var(--pg-bg-2);
  cursor: pointer;
  touch-action: pan-y; /* vertical swipes still scroll the page */
  user-select: none;
  -webkit-user-select: none;
}
.pg-scene svg { display: block; width: 100%; height: auto; max-height: 24rem; margin: 0 auto; }
.pg-scene:focus-visible { outline: 3px solid var(--pg-focus); outline-offset: -3px; }

.pg-tile { fill: #1a212a; stroke: var(--pg-text); stroke-opacity: 0.1; stroke-width: 0.75; stroke-linejoin: round; }
.pg-tile.is-alt { fill: #161c24; }
.pg-slab { stroke: var(--pg-text); stroke-opacity: 0.14; stroke-width: 0.75; stroke-linejoin: round; }
.pg-slab-l { fill: #10151b; }
.pg-slab-r { fill: #0a0e12; }

.pg-cube polygon { stroke: var(--pg-text); stroke-opacity: 0.38; stroke-width: 0.9; stroke-linejoin: round; }
.pg-sh-l { fill: #000; fill-opacity: 0.18; }
.pg-sh-r { fill: #000; fill-opacity: 0.4; }
.pg-shadow { fill: #000; fill-opacity: 0.32; stroke: none; }

.pg-block-box .pg-l, .pg-block-box .pg-r { fill: var(--pg-slate); }
.pg-block-box .pg-t { fill: var(--pg-slate-hi); }
.pg-strap { fill: none; stroke: var(--pg-text); stroke-opacity: 0.5; stroke-width: 1.2; stroke-linecap: round; }

.pg-plate .pg-l, .pg-plate .pg-r { fill: #232c37; }
.pg-plate .pg-t { fill: #39465a; }
.pg-plate.is-pressed .pg-t { fill: var(--pg-mint); }

.pg-door-box .pg-l, .pg-door-box .pg-r { fill: #3a465a; }
.pg-door-box .pg-t { fill: #55637a; }
.pg-ped .pg-l, .pg-ped .pg-r { fill: #2c3541; }
.pg-ped .pg-t { fill: #3d495a; }

.pg-wire { fill: none; stroke: var(--pg-muted); stroke-opacity: 0.55; stroke-width: 1.6; stroke-dasharray: 2 5; stroke-linejoin: round; stroke-linecap: round; }
.pg-wire.is-live { stroke: var(--pg-mint); stroke-opacity: 1; stroke-dasharray: none; stroke-width: 2; }

.pg-lamp circle { fill: #232c37; stroke: var(--pg-text); stroke-opacity: 0.45; stroke-width: 1; }
.pg-lamp .pg-glow { fill: var(--pg-mint); fill-opacity: 0.16; stroke: none; }
.pg-lamp line { stroke: var(--pg-mint); stroke-width: 1.6; stroke-linecap: round; }
.pg-lamp.is-on circle:not(.pg-glow) { fill: var(--pg-mint); stroke: var(--pg-mint); stroke-opacity: 1; }

/* ---- side column ---- */
.pg-side { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; }
.pg-controls { display: grid; gap: 0.85rem; }
.pg-label { font-size: 0.9375rem; color: var(--pg-muted); margin-bottom: 0.4rem; }
.pg-pad, .pg-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

.pg-btn {
  appearance: none;
  min-height: 2.75rem;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--pg-text);
  background: var(--pg-bg-2);
  border: 1px solid var(--pg-line-2);
  border-radius: var(--radius-pill, 999px);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.pg-btn:hover { border-color: var(--pg-muted); background: #1c232d; }
.pg-btn:focus-visible { outline: 3px solid var(--pg-focus); outline-offset: 2px; }
.pg-primary { border-color: var(--pg-mint); color: var(--pg-mint-ink); }
.pg-primary[aria-pressed="true"] { background: var(--pg-mint); color: #0d1014; border-color: var(--pg-mint); }
.pg-primary[aria-pressed="true"]:hover { background: var(--pg-mint); }
.pg-codetoggle { align-self: flex-start; }
.pg-codetoggle[aria-expanded="true"] { border-color: var(--pg-mint); }

/* ---- readout ---- */
.pg-read { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem 1rem; border-top: 1px solid var(--pg-line); padding: 0.85rem 0 0; }
.pg-wide { grid-column: 1 / -1; }
.pg-read dt { font-size: 0.875rem; color: var(--pg-muted); }
.pg-read dd { font-size: 1rem; font-weight: 600; }
.pg-read dd[data-on="true"], .pg-event.is-set { color: var(--pg-mint-ink); }

/* ---- code (collapsed by default) ---- */
.pg-code { border-top: 1px solid var(--pg-line); }
.pg-code[hidden] { display: none; }
.pg-code figcaption { padding: 0.7rem 1rem; font-size: 0.9375rem; color: var(--pg-muted); border-bottom: 1px solid var(--pg-line); }
.pg-scroll { overflow-x: auto; padding: 0.5rem 0; background: var(--pg-bg); }
.pg-scroll:focus-visible { outline: 3px solid var(--pg-focus); outline-offset: -3px; }
.pg-lines {
  list-style: none;
  counter-reset: ln;
  font-family: var(--font-mono, ui-monospace, "Cascadia Code", Menlo, Consolas, monospace);
  font-size: 0.9375rem;
  line-height: 1.65;
  width: max-content;
  min-width: 100%;
}
.pg-lines li {
  counter-increment: ln;
  position: relative;
  min-height: 1.65em;
  padding: 0 1rem 0 3rem;
  border-left: 3px solid transparent;
  white-space: pre;
}
.pg-lines li::before {
  content: counter(ln);
  position: absolute;
  left: 0;
  width: 2.1rem;
  text-align: right;
  color: var(--pg-muted);
}
.pg-lines li.is-hot { border-left-color: var(--pg-mint); background: rgb(127 224 192 / 0.12); }
.pg-lines li.is-called { border-left-color: var(--pg-slate-hi); background: rgb(135 149 169 / 0.1); }
.pg-c { color: var(--pg-muted); font-style: italic; }
.pg-k { color: #9cc4ff; }
.pg-s { color: #f0cf9a; }

/* ---- status + live ---- */
.pg-status { padding: 0.7rem 1rem; font-size: 1rem; color: var(--pg-muted); border-top: 1px solid var(--pg-line); min-height: 2.8rem; }
.pg-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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