/* ============================================================================
   ZKCAP-X · V3 CANDIDATE · SYSTEM LAYER
   Layer 5 of 6 — viewport simulator, overlays, toasts, runtime states, and the
   development-only Product Index. None of this is part of the product design.
   ========================================================================== */

:root {
  --frame-left: 0px;
  --frame-width: 100%;
}

body {
  padding: 0;
}

/* ---------------------------------------------------------------------------
   1. VIEWPORT SIMULATOR
   The product renders inside one frame. data-vp carries the RESOLVED width
   bucket; every responsive rule in responsive.css keys off it. This makes
   rendering identical at 390px whether or not the real window is that size.
   ------------------------------------------------------------------------ */

.viewport-frame {
  position: relative;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper-050);
  overflow-x: clip;
  transition: width var(--dur) var(--ease);
}

.viewport-frame[data-vp-request="390"],
.viewport-frame[data-vp-request="768"],
.viewport-frame[data-vp-request="1440"] {
  box-shadow: 0 0 0 1px rgba(216, 189, 126, 0.28), 0 40px 120px -40px rgba(0, 0, 0, 0.7);
  margin-block: var(--s-10) var(--s-16);
  min-height: calc(100vh - var(--s-20));
}

.viewport-frame[data-vp-request="390"] {
  border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   2. OVERLAY HOST
   Fixed to the viewport, but horizontally bounded to the simulated frame so a
   sheet at 390px behaves like a 390px sheet.
   ------------------------------------------------------------------------ */

.overlay-host {
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--frame-left);
  width: var(--frame-width);
  z-index: var(--z-overlay);
  pointer-events: none;
}

.overlay-host[data-open] {
  pointer-events: auto;
}

.overlay-host .overlay-scrim {
  position: absolute;
}

/* ---------------------------------------------------------------------------
   3. TOASTS
   ------------------------------------------------------------------------ */

.toast-host {
  position: fixed;
  bottom: var(--s-6);
  left: var(--frame-left);
  width: var(--frame-width);
  z-index: var(--z-toast);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
}

.toast-host .toast {
  width: min(440px, calc(100% - 2rem));
}

/* ---------------------------------------------------------------------------
   4. RUNTIME STATES
   ------------------------------------------------------------------------ */

.render-error {
  padding: var(--s-16) var(--s-8);
  background: var(--paper-050);
}

.surface-loading {
  min-height: 60vh;
  display: grid;
  place-items: center;
}

/* ---------------------------------------------------------------------------
   5. PRODUCT RUNTIME INDEX (development / QA only)
   Visually separated from the product: dark chrome, monospace, fixed.
   ------------------------------------------------------------------------ */

.lab-host {
  position: relative;
  z-index: var(--z-lab);
}

.lab-toggle {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: calc(var(--z-lab) + 2);
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0.625rem 0.875rem;
  background: var(--navy-950);
  color: var(--paper-050);
  border: 1px solid rgba(216, 189, 126, 0.42);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: var(--shadow-overlay);
}

.lab-toggle:hover {
  background: var(--navy-800);
}

.lab-toggle-open {
  background: var(--gilt-600);
  color: #16110a;
  border-color: var(--gilt-400);
}

.lab-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(400px, 92vw);
  background: #0a1420;
  color: #d7dee7;
  border-right: 1px solid rgba(216, 189, 126, 0.24);
  transform: translateX(-102%);
  transition: transform var(--dur) var(--ease);
  z-index: calc(var(--z-lab) + 1);
  overflow-y: auto;
  font-family: var(--font-sans);
  box-shadow: 24px 0 60px -30px rgba(0, 0, 0, 0.8);
}

.lab-panel-open {
  transform: none;
}

.lab-head {
  position: sticky;
  top: 0;
  background: #0a1420;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid rgba(216, 189, 126, 0.18);
}

.lab-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gilt-300);
}

.lab-sub {
  font-size: 0.6875rem;
  color: #7d8b9c;
  margin-top: 3px;
  font-family: var(--font-mono);
}

.lab-panel .overlay-close {
  color: #8b98a8;
}

.lab-panel .overlay-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.lab-section {
  padding: var(--s-5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.lab-label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6f7d8e;
  margin-bottom: var(--s-3);
}

.lab-vp {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.lab-panel .chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: #c3ccd8;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
}

.lab-panel .chip:hover {
  border-color: rgba(216, 189, 126, 0.5);
  color: #fff;
}

.lab-panel .chip-active {
  background: var(--gilt-600);
  border-color: var(--gilt-400);
  color: #16110a;
}

.lab-panel .chip[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.lab-note {
  font-size: 0.6875rem;
  line-height: 1.55;
  color: #7d8b9c;
  margin-top: var(--s-3);
}

.lab-group {
  margin-bottom: var(--s-5);
}

.lab-group-title {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gilt-300);
  margin-bottom: var(--s-2);
}

.lab-surface {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  padding: var(--s-3);
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.lab-surface:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.lab-surface-active {
  background: rgba(216, 189, 126, 0.12);
  border-color: rgba(216, 189, 126, 0.4);
}

.lab-surface-id {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--gilt-300);
}

.lab-surface-title {
  font-size: 0.8125rem;
  color: #e4e9ef;
}

.lab-surface-meta {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7d8e;
}

.lab-route {
  display: block;
  padding: var(--s-3);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: #b9c6d4;
  word-break: break-all;
  line-height: 1.5;
}

/* ---------------------------------------------------------------------------
   6. FOCUS / ACCESSIBILITY SUPPORT IN OVERLAYS
   ------------------------------------------------------------------------ */

.overlay-host[data-open] .overlay-panel :focus-visible {
  outline: 2px solid var(--gilt-500);
  outline-offset: 2px;
}
