/* Example Ui · stage.css
 * The Studio-like window that hosts the live demo: device screen on the left, Explorer and Properties
 * docked on the right (where Roblox Studio keeps them), status and Luau below.
 * It is a dark tool window on any page theme; tune it with the --st-* variables. */

.stage {
  --st-bg: #15171c;
  --st-panel: #1b1e25;
  --st-well: #0f1115;
  --st-line: #2b2f3a;
  --st-text: #dfe3ec;
  --st-muted: #8d94a3;
  --st-select: #2f9bff;
  --st-accent: var(--accent, #ffc21a);
  --st-accent-ink: var(--accent-ink, #17130a);
  --st-radius: 16px;
  --st-font: var(--font-ui, system-ui, sans-serif);
  --st-mono: var(--font-mono, "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace);

  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: var(--st-radius);
  background: var(--st-bg);
  color: var(--st-text);
  font: 500 12.5px/1.3 var(--st-font);
  box-shadow: 0 0 0 1px var(--st-line);
  overflow: hidden;
  text-align: left;
}

/* ---------------------------------------------------------------- top bar */
.stage-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 10px 6px 14px;
  background: var(--st-panel);
  border-bottom: 1px solid var(--st-line);
}

.stage-dots { display: inline-flex; gap: 6px; flex: none; }
.stage-dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--st-line); }
.stage-dots i:first-child { background: var(--st-accent); }

.stage-file {
  display: inline-flex; align-items: center; gap: 7px;
  min-width: 0;
  font: 500 12px/1 var(--st-mono);
  color: var(--st-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage-file b { color: var(--st-text); font-weight: 500; }

.stage-devices {
  display: inline-flex;
  margin-left: auto;
  padding: 3px;
  gap: 2px;
  border-radius: 9px;
  background: var(--st-well);
  box-shadow: inset 0 0 0 1px var(--st-line);
}
.stage-devices button {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 10px;
  border-radius: 6px;
  background: transparent; color: var(--st-muted);
  font: 600 12px/1 var(--st-font);
}
.stage-devices button svg { width: 15px; height: 15px; flex: none; }
.stage-devices button:hover { color: var(--st-text); }
.stage-devices button[aria-pressed="true"] { background: var(--st-line); color: var(--st-text); }

/* ---------------------------------------------------------------- body */
.stage-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  min-height: 0;
}

.stage-view {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  min-width: 0;
  padding: 0;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, .025) 25%, transparent 25% 75%, rgba(255, 255, 255, .025) 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, rgba(255, 255, 255, .025) 25%, transparent 25% 75%, rgba(255, 255, 255, .025) 75%) 8px 8px / 16px 16px,
    var(--st-well);
  overflow: hidden;
}

.stage-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  transition: width .5s cubic-bezier(.2, .8, .2, 1), height .5s cubic-bezier(.2, .8, .2, 1);
}
[data-device-current="tablet"] .stage-screen,
[data-device-current="phone"] .stage-screen { border-radius: 10px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 0 0 5px #05060a; }

/* ---------------------------------------------------------------- draft | built
 * The blueprint layer covers the screen from the left edge to the build line (--split, set by stage.js). */
.stage-draft {
  --st-draft: #0c3b4d;
  --rbx-wire: #d9f0ff;
  position: absolute; inset: 0; z-index: 2;
  background:
    linear-gradient(rgba(217, 240, 255, .16) 1px, transparent 1px) 0 0 / 100% 120px,
    linear-gradient(90deg, rgba(217, 240, 255, .16) 1px, transparent 1px) 0 0 / 120px 100%,
    linear-gradient(rgba(217, 240, 255, .07) 1px, transparent 1px) 0 0 / 100% 24px,
    linear-gradient(90deg, rgba(217, 240, 255, .07) 1px, transparent 1px) 0 0 / 24px 100%,
    var(--st-draft);
  clip-path: inset(0 calc(100% - var(--split, 0%)) 0 0);
}

.stage-split {
  appearance: none; border: 0; padding: 0; background: none;
  position: absolute; top: 0; bottom: 0; left: var(--split, 0%); z-index: 1001;
  width: 44px; margin-left: -22px;
  display: grid; place-items: center;
  cursor: ew-resize;
  touch-action: none;
  color: var(--st-accent-ink);
}
.stage-split::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px;
  background: var(--st-accent);
}
.stage-split-knob {
  position: relative;
  display: grid; place-items: center;
  width: 30px; height: 38px; border-radius: 9px;
  background: var(--st-accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .28);
  transition: transform .15s ease;
}
.stage-split-knob svg { width: 16px; height: 16px; }
.stage-split:hover .stage-split-knob,
[data-dragging] .stage-split-knob { transform: scale(1.08); }
.stage-split:focus-visible { outline: none; }
.stage-split:focus-visible .stage-split-knob { outline: 2px solid #fff; outline-offset: 3px; }
.stage-split-tag {
  position: absolute; top: 12px;
  padding: 5px 8px;
  font: 600 10.5px/1 var(--st-mono); letter-spacing: .08em;
  white-space: nowrap;
}
.stage-split-tag--draft { right: calc(50% + 1px); color: var(--st-accent); background: var(--st-bg); box-shadow: inset 0 0 0 1px var(--st-accent); border-radius: 4px 0 0 4px; }
.stage-split-tag--built { left: calc(50% + 1px); color: var(--st-accent-ink); background: var(--st-accent); border-radius: 0 4px 4px 0; }

/* With the 3D world live (js/hero3d.js) the drawing of the world is on the canvas, left of the build line:
   the draft layer turns into a thin veil over it, and the built UI is cut at the line instead of covered. */
.stage--3d .stage-draft { background: color-mix(in srgb, var(--st-draft) 34%, transparent); }
.stage--3d[data-split-view] .stage-screen > .rbx-root { clip-path: inset(0 0 0 var(--split, 0%)); }

/* the selection box belongs to the built side only */
[data-split-view] .stage-screen > .rbx-overlay { clip-path: inset(-40px -40px -40px var(--split, 0%)); }

/* dimension call-outs drawn on the draft */
.draft-notes {
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none;
  color: #d9f0ff;
  font: 500 10.5px/1 var(--st-mono);
}
.dim { position: absolute; box-sizing: border-box; }
.dim::before { content: ""; position: absolute; }
.dim span {
  position: absolute; left: 50%; top: 50%;
  padding: 2px 6px;
  background: var(--st-draft, #0c3b4d);
  white-space: nowrap;
  transform: translate(-50%, -50%);
}
.dim--h { height: 9px; border-left: 1px solid; border-right: 1px solid; }
.dim--h::before { left: 0; right: 0; top: 50%; border-top: 1px solid; }
.dim--v { width: 9px; border-top: 1px solid; border-bottom: 1px solid; }
.dim--v::before { top: 0; bottom: 0; left: 50%; border-left: 1px solid; }
.dim--v span { transform: translate(-50%, -50%) rotate(-90deg); }
.dim-note { position: absolute; white-space: nowrap; opacity: .8; }

/* the travelling "AI cursor" */
.stage-cursor {
  position: absolute; left: 0; top: 0; z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .2s;
}
.stage-cursor[data-on] { opacity: 1; }
.stage-cursor svg { display: block; width: 18px; height: 20px; }
.stage-cursor b {
  position: absolute; left: 14px; top: 15px;
  padding: 4px 7px; border-radius: 5px;
  background: var(--st-accent); color: var(--st-accent-ink);
  font: 600 10.5px/1 var(--st-mono);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- right dock */
.stage-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1.55fr) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--st-line);
  background: var(--st-panel);
  /* the dock never dictates the window height: it is as tall as the 16:9 view next to it */
  contain: size;
}

.dock-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.dock-panel + .dock-panel { border-top: 1px solid var(--st-line); }
.dock-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0; padding: 8px 12px 7px;
  font: 600 11px/1 var(--st-font);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--st-muted);
}
.dock-title span { font: 500 11px/1 var(--st-mono); letter-spacing: 0; text-transform: none; }

.explorer {
  flex: 1; min-height: 0;
  margin: 0; padding: 0 0 6px;
  list-style: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--st-line) transparent;
  outline-offset: -2px;
}
.ex-row {
  display: flex; align-items: center; gap: 6px;
  height: 22px;
  padding: 0 10px 0 calc(8px + var(--depth, 0) * 11px);
  white-space: nowrap;
  cursor: default;
  color: var(--st-text);
}
.ex-row--mod { color: var(--st-muted); }
.ex-row.is-hover { background: rgba(255, 255, 255, .06); }
.ex-row[aria-selected="true"] { background: color-mix(in srgb, var(--st-select) 34%, transparent); color: #fff; }
.ex-twist { width: 8px; flex: none; display: inline-flex; color: var(--st-muted); }
.ex-ico { flex: none; width: 14px; height: 14px; }
.ex-ico--gui { color: #7fd0ff; }
.ex-ico--box { color: #a9b6c9; }
.ex-ico--text { color: #ffd166; }
.ex-ico--image { color: #7fe0a8; }
.ex-ico--mod { color: #c9a5ff; }
.ex-name { overflow: hidden; text-overflow: ellipsis; }

.props {
  flex: 1; min-height: 0;
  margin: 0; padding: 0 0 6px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--st-line) transparent;
  font: 500 11.5px/1.2 var(--st-mono);
}
.prop {
  display: grid; grid-template-columns: 46% 1fr; align-items: center;
  min-height: 21px;
  border-top: 1px solid rgba(255, 255, 255, .045);
}
.prop dt { padding: 0 6px 0 12px; color: var(--st-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--st-font); font-size: 12px; }
.prop dd { margin: 0; padding: 0 10px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop--computed dd { color: var(--st-muted); }
.prop-swatch { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); vertical-align: -1px; }

/* ---------------------------------------------------------------- foot */
.stage-foot {
  display: flex; align-items: center; gap: 14px;
  min-height: 42px;
  padding: 6px 8px 6px 14px;
  background: var(--st-panel);
  border-top: 1px solid var(--st-line);
  font: 500 12px/1.2 var(--st-mono);
}
.stage-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--st-muted); }
.stage-status::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%;
  background: #47d58a; vertical-align: 1px;
}
[data-busy] .stage-status { color: var(--st-text); }
[data-busy] .stage-status::before { background: var(--st-accent); animation: st-pulse .7s ease-in-out infinite alternate; }
@keyframes st-pulse { from { opacity: .35; } to { opacity: 1; } }

.stage-button {
  appearance: none; border: 0; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 30px; padding: 0 12px;
  border-radius: 8px;
  background: var(--st-line); color: var(--st-text);
  font: 600 12px/1 var(--st-font);
  text-decoration: none;
}
.stage-button:hover { background: #363b48; }
.stage-button--primary { background: var(--st-accent); color: var(--st-accent-ink); }
.stage-button--primary:hover { background: var(--st-accent); filter: brightness(1.08); }
.stage-button svg { width: 14px; height: 14px; }
.stage-button[data-copied="yes"] .when-idle,
.stage-button:not([data-copied="yes"]) .when-copied { display: none; }

/* ---------------------------------------------------------------- Luau panel */
.luau {
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--st-line) transparent;
  background: var(--st-well);
  color: #c8cedb;
  font: 400 12.5px/1.6 var(--st-mono);
  tab-size: 2;
  counter-reset: none;
}
.luau code { display: block; padding: 14px 16px; font: inherit; white-space: pre; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 860px) {
  .stage-body { grid-template-columns: minmax(0, 1fr); }
  .stage-dock {
    contain: none;
    grid-template-rows: none;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    height: 168px;
    border-left: 0; border-top: 1px solid var(--st-line);
  }
  .dock-panel + .dock-panel { border-top: 0; border-left: 1px solid var(--st-line); }
}
@media (max-width: 560px) {
  .stage { --st-radius: 12px; }
  .stage-bar { gap: 8px; padding-left: 10px; }
  .stage-devices button { padding: 0 8px; }
  .stage-devices button span { display: none; }
  .stage-dock { grid-template-columns: minmax(0, 1fr); height: 150px; }
  .dock-props { display: none; }
  .stage-foot { flex-wrap: wrap; row-gap: 6px; }
  .stage-status { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-screen, .stage-cursor { transition: none; }
  [data-busy] .stage-status::before { animation: none; }
}
