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

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

/* ---------------------------------------------------------------------------
   1. VIEWPORT SIMULATOR
   data-vp carries the RESOLVED width bucket. Every responsive rule keys off it,
   so a 390 render is identical regardless of the real window 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"] {
  margin-block: var(--s-10) var(--s-16);
  min-height: calc(100vh - var(--s-20));
  box-shadow: 0 0 0 1px rgba(198, 168, 102, 0.24), 0 40px 120px -50px rgba(0, 0, 0, 0.72);
}

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

/* ---------------------------------------------------------------------------
   2. OVERLAY HOST — bounded to the simulated frame
   ------------------------------------------------------------------------ */

.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; }

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: rgba(5, 12, 23, 0.44);
  backdrop-filter: blur(1px);
  animation: fade var(--dur) var(--ease) both;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.overlay-panel {
  position: absolute;
  z-index: calc(var(--z-overlay) + 1);
  display: flex;
  flex-direction: column;
  background: var(--paper-050);
  box-shadow: var(--shadow-panel);
  animation: panelIn var(--dur) var(--ease) both;
}

@keyframes panelIn { from { opacity: 0; } to { opacity: 1; } }

.overlay-drawer {
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 94%);
  border-left: 1px solid var(--line-strong);
}

.overlay-sheet {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88%;
  border-top: 1px solid var(--line-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.overlay-modal {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100% - 2.5rem));
  max-height: 86%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}

.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-5);
  padding: var(--s-6) var(--s-6) var(--s-5);
  border-bottom: 1px solid var(--line);
}

.overlay-kicker { font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--gilt-700); margin-bottom: var(--s-2); }
.overlay-title { font-family: var(--font-display); font-size: 1.375rem; color: var(--ink-900); line-height: 1.25; }
.overlay-body { padding: var(--s-6); overflow-y: auto; flex: 1; }
.overlay-foot { padding: var(--s-5) var(--s-6); border-top: 1px solid var(--line); background: var(--paper-100); display: flex; align-items: center; justify-content: flex-end; gap: var(--s-3); }
.overlay-close { border: 0; background: transparent; padding: var(--s-2); color: var(--ink-500); border-radius: var(--radius-xs); }
.overlay-close:hover { background: rgba(13, 22, 34, 0.06); color: var(--ink-900); }
.overlay-grip { width: 38px; height: 4px; border-radius: var(--radius-pill); background: var(--line-strong); margin: var(--s-3) auto 0; }

/* ---------------------------------------------------------------------------
   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 {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: var(--s-3);
  align-items: start;
  width: min(460px, calc(100% - 2rem));
  padding: var(--s-4) var(--s-5);
  background: var(--navy-950);
  color: var(--paper-050);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-panel);
  font-size: var(--fs-sm);
  line-height: 1.5;
  animation: fade var(--dur) var(--ease) both;
  pointer-events: auto;
}

.toast svg { margin-top: 2px; color: var(--gilt-400); }
.toast-title { font-weight: 600; }
.toast-body { font-size: var(--fs-micro); color: rgba(250, 248, 244, 0.7); margin-top: 2px; }

/* ---------------------------------------------------------------------------
   4. PRODUCT INDEX (development / QA only)
   Visually separate: 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-1000);
  color: var(--paper-050);
  border: 1px solid rgba(198, 168, 102, 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-panel);
}

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

.lab-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(420px, 94vw);
  z-index: calc(var(--z-lab) + 1);
  background: #08111d;
  color: #d7dee7;
  border-right: 1px solid rgba(198, 168, 102, 0.24);
  box-shadow: 24px 0 60px -30px rgba(0, 0, 0, 0.85);
  overflow-y: auto;
}

.lab-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-4);
  background: #08111d;
  border-bottom: 1px solid rgba(198, 168, 102, 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-family: var(--font-mono); font-size: 0.6875rem; color: #7d8b9c; margin-top: 3px; }
.lab-close { border: 0; background: transparent; color: #8b98a8; padding: var(--s-2); }
.lab-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-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.lab-note { font-size: 0.6875rem; line-height: 1.55; color: #7d8b9c; margin-top: var(--s-3); }

.lab-chip {
  padding: 0.3125rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  color: #c3ccd8;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.04em;
}
.lab-chip:hover { border-color: rgba(198, 168, 102, 0.5); color: #fff; }
.lab-chip.is-active { background: var(--gilt-600); border-color: var(--gilt-400); color: #16110a; }
.lab-chip[disabled] { opacity: 0.4; cursor: not-allowed; }

.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;
  gap: 1px;
  padding: var(--s-3);
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
}
.lab-surface:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); }
.lab-surface.is-active { background: rgba(198, 168, 102, 0.12); border-color: rgba(198, 168, 102, 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-code {
  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;
  line-height: 1.5;
  color: #b9c6d4;
  word-break: break-all;
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------------------
   5. RUNTIME STATES
   ------------------------------------------------------------------------ */

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