/*!
 * live-viz.css — the live assembly layer's chrome (console side).
 *
 * Blueprint/CAD aesthetic: electric-blue hairlines, mono labels, saturated
 * agent colours. Everything here is scoped under `.lv-*` so it cannot leak into
 * the console itself, and nothing here is ever exported with a site.
 */

.lv {
  --lv-accent: #4da3ff;
  --lv-accent-soft: rgba(77, 163, 255, 0.16);
  --lv-scan: #ff4d5e;
  --lv-ink: #050b18;
  --lv-chrome: #0b1220;
  --lv-chrome-2: #101a2b;
  --lv-line: rgba(77, 163, 255, 0.28);
  --lv-text: #d8e6ff;
  --lv-muted: #7d8db0;
  --lv-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--lv-chrome);
  box-shadow: 0 24px 60px -32px rgba(2, 11, 26, 0.7), inset 0 0 0 1px rgba(77, 163, 255, 0.18);
}

.lv.is-off { box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.3); }

/* ------------------------------------------------------------ browser bar */

.lv-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: linear-gradient(180deg, #0e1727, #0a111e);
  border-bottom: 1px solid var(--lv-line);
  font-family: var(--lv-mono);
  font-size: 11px;
  color: var(--lv-muted);
  user-select: none;
}

.lv-dots { display: inline-flex; gap: 5px; }
.lv-dots i {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22304a; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.lv-dots i:nth-child(1) { background: #ff5f57; }
.lv-dots i:nth-child(2) { background: #febc2e; }
.lv-dots i:nth-child(3) { background: #28c840; }

.lv-address {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: #070d18;
  box-shadow: inset 0 0 0 1px rgba(77, 163, 255, 0.18);
  color: var(--lv-text);
}

.lv-address__lock { color: var(--lv-accent); flex: none; }
.lv-address__url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lv-address__path { color: var(--lv-muted); }

.lv-badge {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  color: var(--lv-accent);
  background: var(--lv-accent-soft);
  box-shadow: inset 0 0 0 1px rgba(77, 163, 255, 0.35);
  flex: none;
}
.lv-badge[data-state="complete"] { color: #29d98c; background: rgba(41, 217, 140, 0.12); box-shadow: inset 0 0 0 1px rgba(41, 217, 140, 0.4); }
.lv-badge[data-state="error"] { color: #ff6b7a; background: rgba(255, 77, 94, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 77, 94, 0.42); }
.lv-badge[data-state="paused"] { color: #febc2e; background: rgba(254, 188, 46, 0.12); box-shadow: inset 0 0 0 1px rgba(254, 188, 46, 0.36); }

/* ----------------------------------------------------------------- stage */

.lv-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #060b14;
}

.lv-viewport {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(77, 163, 255, 0.35) transparent;
}

.lv-frame {
  display: block;
  width: 100%;
  border: 0;
  background: #fbfaf7;
  min-height: 100%;
}

.lv-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.lv-scroll-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  font-family: var(--lv-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--lv-muted);
  background: rgba(5, 11, 24, 0.72);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(77, 163, 255, 0.2);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.lv-scroll-hint.is-visible { opacity: 1; }

/* --------------------------------------------------------------- controls */

.lv-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(5, 11, 24, 0.82);
  box-shadow: inset 0 0 0 1px rgba(77, 163, 255, 0.24);
  backdrop-filter: blur(6px);
}

.lv-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--lv-text);
  font-family: var(--lv-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 0.32rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1;
}
.lv-btn:hover { background: rgba(77, 163, 255, 0.14); }
.lv-btn:focus-visible { outline: 1.5px solid var(--lv-accent); outline-offset: 1px; }
.lv-btn[aria-pressed="true"] { background: var(--lv-accent-soft); color: #bfe0ff; }
.lv-btn--icon { padding-inline: 0.45rem; }

/* ------------------------------------------------------------- status bar */

.lv-controls--bar {
  position: static;
  inset: auto;
  padding: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.lv-status {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.9rem;
  padding: 0.45rem 0.75rem;
  background: linear-gradient(180deg, #0a1220, #070d18);
  border-top: 1px solid var(--lv-line);
  font-family: var(--lv-mono);
  font-size: 10.5px;
  color: var(--lv-muted);
  user-select: none;
  overflow: hidden;
}

.lv-stat { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.lv-stat b { color: var(--lv-text); font-weight: 600; font-variant-numeric: tabular-nums; }

.lv-pip { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.lv-pip[data-kind="working"] { background: #29d98c; box-shadow: 0 0 6px rgba(41, 217, 140, 0.7); }
.lv-pip[data-kind="queued"] { background: #4da3ff; }
.lv-pip[data-kind="done"] { background: #7d8db0; }
.lv-pip[data-kind="error"] { background: #ff4d5e; }

.lv-phase {
  color: var(--lv-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.16rem 0.42rem;
  border-radius: 4px;
  background: rgba(77, 163, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(77, 163, 255, 0.24);
}

.lv-progress {
  position: relative;
  flex: 1 1 120px;
  min-width: 90px;
  height: 4px;
  border-radius: 999px;
  background: rgba(125, 141, 176, 0.22);
  overflow: hidden;
}
.lv-progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f7bff, #7fd3ff);
  transition: width 240ms ease;
}
.lv-progress[data-state="complete"] > span { background: linear-gradient(90deg, #14b877, #29d98c); }
.lv-progress[data-state="error"] > span { background: #ff4d5e; }

.lv-agents {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}
.lv-agent-chip {
  appearance: none;
  border: 0;
  padding: 0.14rem 0.4rem;
  border-radius: 999px;
  font-family: var(--lv-mono);
  font-size: 9.5px;
  white-space: nowrap;
  color: #d8e6ff;
  background: rgba(125, 141, 176, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
.lv-agent-chip i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.lv-agent-chip[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--lv-accent); background: var(--lv-accent-soft); }

.lv-hint {
  color: rgba(125, 141, 176, 0.85);
  font-size: 9.5px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- off mode */

/* Off removes the visualization (wireframes, guides, scan lines, cursors) and
   applies events instantly. The frame and the toggle stay, so it is never a
   one-way door. */
.lv.is-off .lv-overlay { display: none; }
.lv.is-off .lv-agent-chip { opacity: 0.5; }

/* --------------------------------------------------------------- narrow */

@media (max-width: 720px) {
  .lv-status { gap: 0.6rem; }
  .lv-hint { display: none; }
}

/* ---------------------------------------------- host: console live card */

/* The console's `.build-preview` is a 16/10 scaled screenshot box; the live
   stage needs a real, scrollable viewport instead. */
.build-preview--live {
  aspect-ratio: auto;
  height: clamp(420px, 66vh, 760px);
  background: #060b14;
}

.build-preview--live > .lv {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

.build-preview--live .lv-frame {
  position: static;
  inset: auto;
  width: 100%;
  height: auto;
  min-height: 100%;
  transform: none;
  background: #fbfaf7;
}

@media (max-width: 900px) {
  .build-preview--live { height: clamp(380px, 60vh, 560px); }
}

/* The real page is hidden until the live layer has marked its elements as
   pending, so the first paint of the iframe never flashes the finished site. */
.lv-frame { opacity: 0; transition: opacity 220ms ease; }
.lv.is-stage-ready .lv-frame { opacity: 1; }
