/* ═══════════════════════════════════════════════
   FestivalLuts — /playground
   Loaded after style.css and apple-design.css, on this page only. Every colour is
   one of their tokens; nothing here defines a new one.
   ═══════════════════════════════════════════════ */

.pg-section { padding-bottom: 1.5rem; }

/* Tool left, library right; the library is a fixed column so the viewer keeps
   every pixel it can. Below 1024px the library drops under the tool. */
.pg { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.pg-main { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }

/* ── Viewer ── */
.pg-viewer { position: relative; background: #000; border: 1px solid var(--border-light);
  border-radius: 14px; overflow: hidden; aspect-ratio: 16 / 9; display: flex;
  align-items: center; justify-content: center; }
.pg-viewer.is-over { outline: 2px dashed var(--accent); outline-offset: -8px; }
/* Sized by playground.js to the frame's own aspect inside the viewer ("contain"),
   so the split handle and the corner tags sit on the picture, not on the bars. */
.pg-stage { position: relative; width: 100%; height: 100%; touch-action: pan-y; }
.pg-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pg-stage canvas, .pg-poster { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pg-poster { object-fit: contain; }
.pg-stage.is-dragging { cursor: ew-resize; }
.pg-viewer.is-loading .pg-stage::after { content: ""; position: absolute; top: 12px; right: 12px;
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff; animation: pg-spin 700ms linear infinite; }
@keyframes pg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pg-viewer.is-loading .pg-stage::after { animation-duration: 2s; } }

.pg-split { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: rgba(255,255,255,0.9); box-shadow: 0 0 0 1px rgba(0,0,0,0.35); pointer-events: none; }
.pg-split-grip { position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border-radius: 50%; background: rgba(9,9,11,0.85); border: 2px solid #fff; }
.pg-split-grip::before, .pg-split-grip::after { content: ""; position: absolute; top: 50%; margin-top: -4px;
  border: 4px solid transparent; }
.pg-split-grip::before { left: 3px; border-right-color: #fff; }
.pg-split-grip::after { right: 3px; border-left-color: #fff; }

.pg-tag { position: absolute; top: 10px; max-width: 45%; padding: 0.22rem 0.55rem; border-radius: 6px;
  background: rgba(9,9,11,0.72); color: #fff; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.pg-tag--left { left: 10px; }
.pg-tag--right { right: 10px; }

.pg-status { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.6rem 0.9rem; font-size: 0.85rem;
  color: var(--text-secondary); background: linear-gradient(transparent, rgba(0,0,0,0.75)); }
.pg-status:empty { display: none; }
.pg-status.is-error { color: #FFD60A; }

/* ── Toolbar ── */
.pg-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center;
  padding: 0.75rem 0.9rem; background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: 12px; }
.pg-group { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.pg-group--grow { flex: 1 1 220px; }
.pg-group--grow input[type="range"] { flex: 1; min-width: 120px; accent-color: var(--accent); }
.pg-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.pg-strength-out { min-width: 3.2em; text-align: right; font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-primary); }

.pg-btn, .pg-seg-btn, .pg-cat { font: inherit; font-size: 0.82rem; color: var(--text-secondary); background: transparent;
  border: 1px solid var(--border-light); border-radius: 8px; padding: 0.38rem 0.7rem; cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease; }
/* Pressed buttons are excluded from the hover rule: `:hover:not(:disabled)` is (0,3,0)
   and outranked the pressed style, so the active scope went blank under the cursor. */
.pg-btn:hover, .pg-seg-btn:hover:not(:disabled):not([aria-pressed="true"]), .pg-cat:hover:not([aria-pressed="true"]) { color: var(--text-primary); border-color: var(--border-hover); background: rgba(255,255,255,0.04); }
.pg-btn:focus-visible, .pg-seg-btn:focus-visible, .pg-cat:focus-visible, .pg-frame:focus-visible, .pg-lut:focus-visible,
.pg-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pg-btn[aria-pressed="true"] { color: var(--text-primary); border-color: var(--accent); background: var(--accent-soft); }
.pg-seg { display: inline-flex; border: 1px solid var(--border-light); border-radius: 9px; padding: 2px; gap: 2px; }
.pg-seg .pg-seg-btn { border: 0; border-radius: 7px; padding: 0.32rem 0.62rem; }
.pg-seg-btn[aria-pressed="true"] { background: var(--text-primary); color: var(--bg-deep); font-weight: 600; }
.pg-seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Now showing ── */
.pg-now { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem; background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: 12px; }
.pg-now-text { min-width: 0; flex: 1 1 280px; }
.pg-now-kicker { margin: 0; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.pg-now-title { margin: 0.1rem 0 0.15rem; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.pg-now-title a { color: var(--text-primary); text-decoration: none; }
.pg-now-title a:hover { text-decoration: underline; }
.pg-now-meta { margin: 0; font-size: 0.82rem; color: var(--text-secondary); }
.pg-now-pipe { margin: 0.25rem 0 0; font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-muted); }
.pg-now-pipe:empty { display: none; }
.pg-now-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Frames ── */
.pg-panel { padding: 0.9rem 1rem; background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: 12px; }
.pg-frames { display: flex; flex-direction: column; gap: 0.6rem; }
.pg-frame-row { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.2rem; scrollbar-width: thin; }
.pg-frame { flex: 0 0 auto; display: flex; flex-direction: column; gap: 0.3rem; align-items: stretch; width: 112px;
  padding: 6px; background: transparent; border: 1px solid var(--border-light); border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 0.74rem; color: var(--text-secondary); text-align: left; }
.pg-frame img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.pg-frame[aria-pressed="true"] { border-color: var(--accent); color: var(--text-primary); background: var(--accent-soft); }
.pg-frame:hover { border-color: var(--border-hover); color: var(--text-primary); }
.pg-frame--own { justify-content: center; }
.pg-own-icon { display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; border-radius: 6px;
  border: 1px dashed var(--border-hover); font-size: 1.3rem; color: var(--text-secondary); }
.pg-frame--own.has-image .pg-own-icon { background-size: cover; background-position: center; border-style: solid; color: transparent; }
#pg-own-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-source { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.pg-source select { max-width: 100%; }
.pg-note { margin: 0; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }
.pg-note:empty { display: none; }
.pg-note.is-warn { color: #FFD60A; }

/* ── Scopes ── */
.pg-scopes { display: flex; flex-direction: column; gap: 0.7rem; }
.pg-scope-head { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: space-between; }
.pg-scope { width: 100%; height: auto; aspect-ratio: 3 / 1; background: #050506; border-radius: 8px; border: 1px solid var(--border-subtle); display: block; }
.pg-stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; margin: 0; }
.pg-stats div { display: flex; gap: 0.45rem; align-items: baseline; }
.pg-stats dt { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); cursor: help; }
.pg-stats dd { margin: 0; font-family: var(--font-mono); font-size: 0.88rem; color: var(--text-primary); }

/* ── Library ── */
.pg-library { position: sticky; top: 84px; display: flex; flex-direction: column; min-height: 0;
  max-height: calc(100vh - 100px); background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: 14px; overflow: hidden; }
.pg-lib-head { padding: 0.9rem 0.9rem 0.6rem; display: flex; flex-direction: column; gap: 0.6rem; border-bottom: 1px solid var(--border-subtle); }
.pg-lib-title { margin: 0; font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.pg-lib-count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); font-weight: 500;
  border: 1px solid var(--border-light); border-radius: 999px; padding: 0.05rem 0.45rem; }
.pg-search { width: 100%; padding: 0.5rem 0.75rem; font-size: 0.88rem; color: var(--text-primary);
  background: var(--bg-deep); border: 1px solid var(--border-light); border-radius: 9px; }
.pg-search::placeholder { color: var(--text-muted); }
.pg-cats { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.pg-cats .pg-cat { font-size: 0.72rem; padding: 0.22rem 0.55rem; border-radius: 999px; }
.pg-cat[aria-pressed="true"] { background: var(--text-primary); color: var(--bg-deep); border-color: var(--text-primary); font-weight: 600; }
.pg-list { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; flex: 1 1 auto; min-height: 0; scrollbar-width: thin; }
.pg-list li { margin: 0; }
.pg-list li[hidden] { display: none; }
.pg-lut { display: flex; gap: 0.6rem; align-items: center; padding: 0.4rem 0.45rem; border-radius: 9px;
  text-decoration: none; color: var(--text-secondary); border: 1px solid transparent; }
.pg-lut:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.pg-lut[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent-border); color: var(--text-primary); }
.pg-lut-thumb { flex: 0 0 64px; width: 64px; height: 36px; border-radius: 5px; object-fit: cover; background: var(--bg-elevated); display: block; }
.pg-lut-text { display: flex; flex-direction: column; min-width: 0; }
.pg-lut-title { font-size: 0.84rem; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-lut-meta { font-size: 0.7rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-lib-empty { margin: 0; padding: 1rem; font-size: 0.85rem; color: var(--text-muted); }

/* ── Article ── */
.pg-article { padding-top: 1.5rem; }
.pg-prose { max-width: 46rem; }
.pg-prose h2 { font-size: 1.4rem; margin: 2.5rem 0 0.75rem; letter-spacing: -0.01em; }
.pg-prose h2:first-child { margin-top: 0; }
.pg-prose p, .pg-prose ul { color: #D4D4D8; font-size: 1.02rem; line-height: 1.75; margin: 0 0 1.2rem; }
.pg-prose ul { padding-left: 1.3rem; }
.pg-prose li { margin-bottom: 0.55rem; }
.pg-prose strong { color: var(--text-primary); }
.pg-prose a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(255,255,255,0.35); text-underline-offset: 2px; }
.pg-prose a:hover { text-decoration-color: var(--accent); }
.pg-prose code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-elevated); padding: 0.1rem 0.35rem; border-radius: 5px; }
.pg-table-wrap { overflow-x: auto; margin: 0 0 1rem; }
.pg-table { font-size: 0.92rem; min-width: 0; }
.pg-table td:nth-child(n+2), .pg-table th:nth-child(n+2) { font-family: var(--font-mono); text-align: right; }
.pg-footnote { font-size: 0.85rem !important; color: var(--text-muted) !important; }
.pg-dagger { color: var(--text-muted); }
.pg-ad { margin: 2.5rem 0; }
/* 350, not the shared 320: this unit's <ins> reserves 280px rather than 250. */
.pg-ad .apple-ad-card { margin: 0; min-height: 350px; }
.pg-ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }

/* ── Narrow ── */
@media (max-width: 1023px) {
  .pg { grid-template-columns: minmax(0, 1fr); }
  .pg-library { position: static; max-height: 460px; }
}
@media (max-width: 560px) {
  .pg-viewer { border-radius: 10px; }
  .pg-toolbar, .pg-now, .pg-panel { padding: 0.75rem; }
  .pg-group--grow { flex-basis: 100%; }
  .pg-frame { width: 96px; }
  .pg-prose p, .pg-prose ul { font-size: 1rem; }
  /* Full-bleed on a phone for the same reason as the Academy unit: AdSense widens a
     full-width-responsive unit to the screen, and an inset card would crop it. */
  .pg-ad { margin: 2rem calc(50% - 50vw); }
  .pg-ad .apple-ad-card { border-radius: 0; border-left: 0; border-right: 0; padding: 0.75rem 0; }
  .pg-ad .ad-kicker { padding-left: 1rem; }
}
