/* Wandering Waveforms — Clean Prototype Viewer + Agent-Driven Optical Layers */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f2efe9;
  color: #1b1a18;
  font-family: 'Apercu', 'WWMathSym', 'WWSubSup', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html[data-theme="dark"],
html[data-theme="dark"] body {
  background: #151514;
  color: #ebe8e1;
}

/* Full-Bleed Live Website Stage */
#live-stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.ww-prog {
  container-type: inline-size;
}

/* Agent-Driven Inspection Filters (Used programmatically by agent_workbench.py) */
body.ww-squint-active #live-stage {
  filter: grayscale(1) blur(16px) contrast(1.06);
}

.ww-ruder-lock,
.ww-ruder-lock * {
  font-family: 'Unica', sans-serif !important;
  font-size: 12.5px !important;
  font-weight: 400 !important;
  font-style: normal !important;
  letter-spacing: 0.005em !important;
  line-height: 1.32 !important;
}

#telemetry-svg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 40;
  display: none;
}
body.ww-grid-overlay #telemetry-svg {
  display: block;
}

/* Hide agent gizmos in live prototype view */
.ww-rail-gizmo {
  display: none !important;
}

/* Live Relational Hover Choreography */
.ww-prog:not(.ww-no-dim).ww-hovering .ww-item {
  opacity: var(--ww-hover-dim, 0.32);
  transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1), transform 180ms cubic-bezier(0.23, 1, 0.32, 1);
}
.ww-prog .ww-item {
  transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1), transform 180ms cubic-bezier(0.23, 1, 0.32, 1);
}
.ww-prog.ww-hovering .ww-item.is-hovered {
  opacity: 1 !important;
}
.ww-prog.ww-hovering .ww-item.is-hovered:not([data-keep-transform]) {
  transform: translateX(2px);
}
.ww-prog.ww-hovering .ww-item.is-related {
  opacity: 0.92 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Quiet Bottom-Right Prototype Switcher Pill */
#proto-switcher {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(16, 18, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  opacity: 0.72;
  transition: opacity 160ms ease;
}
#proto-switcher:hover {
  opacity: 1;
}
body.ww-agent-capture #proto-switcher,
body.ww-focus-mode #proto-switcher {
  display: none !important;
}
@media (max-width: 959px), (max-height: 559px), (pointer: coarse), (max-aspect-ratio: 10/11) {
  body:not(.ww-studio-pill) #proto-switcher {
    display: none !important;
  }
}

.ps-label {
  font-size: 11px;
  color: rgba(235, 240, 248, 0.65);
  padding: 0 6px 0 5px;
  user-select: none;
}

.ps-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(240, 243, 250, 0.8);
  font-family: inherit;
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}
.ps-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}
.ps-btn.is-active {
  background: #f3f5fa;
  color: #101217;
  font-weight: 600;
}

.ps-sep {
  width: 1px;
  height: 13px;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 2px;
}

/* Optional Overview Grid of Pinned Prototypes */
#grid-view {
  position: fixed;
  inset: 0;
  z-index: 75;
  background: #0f1116;
  overflow-y: auto;
  padding: 28px 30px 64px;
  display: none;
}
#grid-view.is-open {
  display: block;
}

.pg-inner {
  max-width: 1420px;
  margin: 0 auto;
}
.pg-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
}
.pg-title {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  color: #f3f5fa;
}
.pg-sub {
  font-size: 12.5px;
  color: #8f99ad;
}

.pg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  gap: 20px;
}

.pg-card {
  background: #161922;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease;
}
.pg-card:hover {
  border-color: rgba(255, 255, 255, 0.36);
  transform: translateY(-2px);
}
.pg-card.is-current {
  border-color: #f3f5fa;
}

.pg-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0b0d12;
}
.pg-thumb-inner {
  position: absolute;
  left: 0;
  top: 0;
  width: 1440px;
  height: 900px;
  transform-origin: 0 0;
  pointer-events: none;
}
.pg-meta {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  font-size: 12.5px;
  color: #e6eaf3;
}
.pg-meta span {
  font-size: 11px;
  color: #8f99ad;
}

/* Inline Entry Reader Modal */
.wb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 92;
  background: rgba(8, 10, 14, 0.76);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.wb-backdrop.is-open {
  display: flex;
}

#ww-reader-sheet {
  width: min(720px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 26px 30px;
  border-radius: 8px;
  background: #141720;
  color: #f2f4f8;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
}

.wb-sm-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #e4e8f2;
  font-family: inherit;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.wb-sm-btn:hover {
  background: rgba(255, 255, 255, 0.13);
  color: #ffffff;
}

@media print {
  html, body, #live-stage {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #111318 !important;
  }
  #proto-switcher, #telemetry-svg, #grid-view, .wb-backdrop {
    display: none !important;
  }
}
