/* SMAU FILE
 * Path: css/smau-studio2-playtest.css
 * Owns: Creator Studio 2.0 PLAYTEST surface — the status pill over the running
 *       phone and the control sheet beneath it (js/creator/creator.playtest.js,
 *       pt2- prefix).
 * Invariants:
 *   - Class selectors only. This surface is built at runtime and lives on
 *     document.body, so it can never rely on an id in index.html.
 *   - It sits OVER the real phone, OUTSIDE #studio-root — which is where the
 *     --s2-* tokens are declared. So .pt2-root re-declares that token set for
 *     itself; that is what lets the shared .s2-row / .s2-btn / .s2-badge /
 *     .s2-empty primitives be reused verbatim out here instead of forked.
 *   - Phone-width first: the sheet is a bottom sheet under the phone. Only on
 *     a genuinely wide screen does it become a column beside it.
 *   - State comes from data-attributes the JS owns (data-collapsed,
 *     data-status, data-on, data-done); CSS only presents them.
 */

.pt2-root {
  --s2-accent: #8b7cf8;
  --s2-accent-strong: #7c5cff;
  --s2-accent-soft: rgba(139, 124, 248, 0.14);
  --s2-ok: #3ecf8e;
  --s2-warn: #ffb454;
  --s2-danger: #ff5c5c;
  --s2-ink: rgba(238, 240, 248, 0.94);
  --s2-muted: rgba(238, 240, 248, 0.55);
  --s2-card: rgba(255, 255, 255, 0.04);
  --s2-card-border: rgba(255, 255, 255, 0.08);
  --s2-radius: 16px;

  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  font-family: var(--smau-font-stack, system-ui, -apple-system, "Segoe UI", sans-serif);
  color: var(--s2-ink);
}

/* ── Status pill — the honest "this is a test" marker ─────────────── */

.pt2-pill {
  pointer-events: auto;
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 16px);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(13, 15, 24, 0.92);
  border: 1px solid rgba(62, 207, 142, 0.5);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
}

.pt2-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--s2-ok);
}

.pt2-pill-label { color: var(--s2-ok); }

.pt2-pill-meta {
  font-weight: 600;
  letter-spacing: 0;
  color: var(--s2-muted);
  max-width: 30vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pt2-pill-t {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0;
  color: rgba(238, 240, 248, 0.8);
}

.pt2-pill-state { color: rgba(238, 240, 248, 0.7); }

.pt2-pill[data-status="paused"] { border-color: rgba(255, 180, 84, 0.55); }
.pt2-pill[data-status="paused"] .pt2-dot,
.pt2-pill[data-status="paused"] .pt2-pill-label { background: none; color: var(--s2-warn); }
.pt2-pill[data-status="paused"] .pt2-dot { background: var(--s2-warn); }

.pt2-pill[data-status="halted"] { border-color: rgba(255, 92, 92, 0.6); }
.pt2-pill[data-status="halted"] .pt2-dot { background: var(--s2-danger); }
.pt2-pill[data-status="halted"] .pt2-pill-label { color: var(--s2-danger); }

.pt2-pill[data-status="idle"] { border-color: var(--s2-card-border); }
.pt2-pill[data-status="idle"] .pt2-dot { background: var(--s2-muted); }
.pt2-pill[data-status="idle"] .pt2-pill-label { color: var(--s2-muted); }

/* ── Control sheet ───────────────────────────────────────────────── */

.pt2-sheet {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(560px, 100vw);
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  padding: 0 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: rgba(11, 13, 21, 0.97);
  border: 1px solid var(--s2-card-border);
  border-bottom: none;
  box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.pt2-handle {
  align-self: center;
  width: 100%;
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 0 6px;
}

.pt2-handle span {
  display: block;
  width: 92px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.pt2-handle:hover span { background: rgba(255, 255, 255, 0.34); }
.pt2-handle:focus-visible { outline: 2px solid var(--s2-accent); outline-offset: -4px; border-radius: 12px; }

.pt2-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 10px;
}

.pt2-headings { min-width: 0; }

.pt2-title {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.pt2-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--s2-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt2-badge {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--s2-ok);
  border: 1px solid rgba(62, 207, 142, 0.5);
  background: rgba(62, 207, 142, 0.1);
}

.pt2-root[data-status="paused"] .pt2-badge {
  color: var(--s2-warn);
  border-color: rgba(255, 180, 84, 0.5);
  background: rgba(255, 180, 84, 0.1);
}

.pt2-root[data-status="halted"] .pt2-badge {
  color: var(--s2-danger);
  border-color: rgba(255, 92, 92, 0.55);
  background: rgba(255, 92, 92, 0.1);
}

.pt2-root[data-status="idle"] .pt2-badge {
  color: var(--s2-muted);
  border-color: var(--s2-card-border);
  background: rgba(255, 255, 255, 0.04);
}

.pt2-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 4px;
}

/* The body is the only thing that scrolls; nothing inside it may be squeezed
   to a sliver to make room (the ticker lost 100px of itself that way). */
.pt2-body > * { flex: 0 0 auto; }

/* Collapsed: the pill and the grab handle stay, everything else folds away,
   so the sheet never sits on top of the phone you are trying to watch. */
.pt2-root[data-collapsed="1"] .pt2-body,
.pt2-root[data-collapsed="1"] .pt2-head,
.pt2-root[data-collapsed="1"] .pt2-foot { display: none; }

.pt2-root[data-collapsed="1"] .pt2-sheet {
  max-height: none;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}

/* ── Rows ────────────────────────────────────────────────────────── */

.pt2-row { text-align: left; width: 100%; }
.pt2-row .s2-row-body span { line-height: 1.35; }

.pt2-chev {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 18px;
  color: var(--s2-muted);
}

.pt2-tail {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--s2-accent);
}

.pt2-tail--halt { color: var(--s2-danger); }
.pt2-tail + .pt2-chev { margin-left: 8px; }

.pt2-row[data-done="1"] .s2-row-icon { color: var(--s2-muted); opacity: 0.65; }
.pt2-bp[data-on="1"] .s2-row-icon { color: var(--s2-danger); border-color: rgba(255, 92, 92, 0.45); background: rgba(255, 92, 92, 0.12); }

.pt2-row .s2-row-icon {
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.pt2-back { align-self: flex-start; }
.pt2-clear { align-self: flex-start; color: var(--s2-danger); }
.pt2-exit { margin-top: 4px; }

/* ── Section headings, ticker, key/value ─────────────────────────── */

.pt2-section {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--s2-muted);
  padding-top: 2px;
}

.pt2-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--s2-muted);
}

.pt2-ticker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 62px;
  max-height: 132px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--s2-card-border);
  font-size: 12px;
}

.pt2-ticker--empty {
  color: var(--s2-muted);
  font-style: italic;
}

.pt2-tick {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding: 2px 0;
}

.pt2-tick-t {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--s2-muted);
}

.pt2-tick-type {
  flex: 0 0 auto;
  font-weight: 800;
  color: var(--s2-accent);
}

.pt2-tick[data-kind="flag"] .pt2-tick-type { color: var(--s2-warn); }

.pt2-tick-id {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(238, 240, 248, 0.8);
}

.pt2-kvs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--s2-card);
  border: 1px solid var(--s2-card-border);
}

.pt2-kv {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 3px 0;
  font-size: 12.5px;
}

.pt2-kv span {
  color: var(--s2-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt2-kv b {
  margin-left: auto;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.pt2-foot {
  flex: 0 0 auto;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--s2-ink);
  background: var(--s2-accent-soft);
  border: 1px solid rgba(139, 124, 248, 0.3);
}

/* ── Wide screens: a column beside the phone, not on top of it ───── */

@media (min-width: 1100px) {
  .pt2-sheet {
    left: auto;
    right: 24px;
    bottom: 24px;
    top: 80px;
    transform: none;
    width: 384px;
    max-height: none;
    border-radius: 20px;
    border-bottom: 1px solid var(--s2-card-border);
    padding-bottom: 14px;
  }

  .pt2-root[data-collapsed="1"] .pt2-sheet {
    top: auto;
    padding-bottom: 6px;
  }

  .pt2-ticker { max-height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  .pt2-root * { transition: none !important; animation: none !important; }
}
