/* ============================================================
   DESKTOP-OS — lab.css   (v5: THE PIPES)
   Fullscreen generative tunnel. The camera travels deeper into
   glass pipework; liquid streams past, fog drifts, the cursor
   steers. Works float free as lab glassware.
   ============================================================ */

.lab-stage {
  --taskbar-h: 46px;
  --phos: #37ff8b;
  --phos-dim: #0f4d2c;

  position: relative;

  /* FULL-BLEED FULLSCREEN.
     The classic `width:100vw; margin-left:calc(50% - 50vw)` trick is
     unreliable here: 100vw INCLUDES the scrollbar, and inside a padded
     theme container on a phone it pushes the stage past the viewport,
     causing horizontal overflow and dumping the icons off-screen. So the
     CSS below is only a safe fallback — lab.js measures the real viewport
     and sets width + margin-left in pixels (see fullBleed()). */
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;

  overflow: hidden;
  box-sizing: border-box;
  background: #020704;
  font-family: 'Courier New', ui-monospace, monospace;
  cursor: crosshair;
}

.lab-field, .lab-overlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.lab-field { z-index: 1; }
.lab-overlay { z-index: 2; }

/* CRT scanlines + vignette */
.lab-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.22) 2px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 42%, rgba(0,0,0,0.6) 100%);
}

/* ---------- floating glassware ---------- */
.lab-nodes { position: absolute; inset: 0; z-index: 4; }

.node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--phos);
  will-change: left, top;
  touch-action: manipulation;   /* kills the 300ms tap delay + double-tap zoom */
  -webkit-tap-highlight-color: transparent;
}

.node-vessel {
  width: 62px;
  height: 72px;
  filter: drop-shadow(0 0 6px rgba(55,255,139,0.25));
  transition: filter 0.25s ease, transform 0.25s ease;
}
.node-vessel svg { width: 100%; height: 100%; display: block; }

.node-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(55,255,139,0.5);
}

/* Blurb: driven by a JS class (.hot), not :hover — so it also works on
   keyboard focus. On touch there IS no hover, so .lab-stage.touch shows
   every blurb permanently (see below) and a single tap launches. */
.node-blurb {
  max-width: 170px;
  font-size: 10px;
  line-height: 1.45;
  letter-spacing: 0.3px;
  text-align: center;
  color: #a5ffd0;
  background: rgba(2, 10, 5, 0.85);
  border: 1px solid var(--phos-dim);
  border-radius: 3px;
  padding: 5px 8px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.node.hot .node-vessel,
.node:focus-visible .node-vessel {
  filter: drop-shadow(0 0 16px rgba(55,255,139,0.75));
  transform: scale(1.1);
}
.node.hot .node-blurb,
.node:focus-visible .node-blurb { opacity: 1; transform: translateY(0); }
.node:focus-visible { outline: none; }

/* TOUCH: no hover exists, so every blurb is simply always legible, and
   the vessel sits at a comfortable thumb size. */
.lab-stage.touch .node-blurb {
  opacity: 1;
  transform: none;
  max-width: 132px;
  font-size: 9.5px;
}
.lab-stage.touch .node-vessel { filter: drop-shadow(0 0 10px rgba(55,255,139,0.45)); }

.lab-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  color: var(--phos);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.7;
}

/* ---------- dock ---------- */
.lab-dock {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--taskbar-h);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  box-sizing: border-box;
  background: linear-gradient(to top, rgba(2,7,4,0.92), rgba(2,7,4,0));
}

.lab-sig {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--phos);
  opacity: 0.55;
}

.lab-dock .task-area {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.lab-stage .task-btn,
.lab-snd {
  height: 24px;
  min-width: 0;
  max-width: 180px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--phos);
  background: rgba(55,255,139,0.06);
  border: 1px solid var(--phos-dim);
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-stage .task-btn.active { background: rgba(55,255,139,0.16); border-color: var(--phos); font-weight: bold; }
.lab-snd { flex: 0 0 auto; }
.lab-snd.on { border-color: var(--phos); background: rgba(55,255,139,0.14); }
.lab-stage .task-btn:focus-visible, .lab-snd:focus-visible { outline: 1px dotted var(--phos); outline-offset: 2px; }

/* ---------- CRT windows (Lab skin over the shared WM) ---------- */
.lab-stage .os-window {
  background: rgba(4, 12, 7, 0.96);
  border: 1px solid var(--phos-dim);
  box-shadow: 0 0 0 1px rgba(55,255,139,0.06), 0 18px 50px rgba(0,0,0,0.6);
}
.lab-stage .os-window.focused {
  border-color: var(--phos);
  box-shadow: 0 0 0 1px rgba(55,255,139,0.25), 0 0 40px rgba(55,255,139,0.12), 0 18px 50px rgba(0,0,0,0.6);
}
.lab-stage .titlebar {
  height: 28px;
  background: rgba(55,255,139,0.07);
  border-bottom: 1px solid var(--phos-dim);
  color: var(--phos);
  font-family: inherit;
  font-size: 11px;
  font-weight: normal;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.lab-stage .os-window.focused > .titlebar { background: rgba(55,255,139,0.14); }
.lab-stage .tb-btn {
  width: 20px; height: 18px;
  line-height: 16px;
  color: var(--phos);
  background: transparent;
  border: 1px solid var(--phos-dim);
  border-radius: 2px;
  font-family: inherit;
  font-size: 10px;
}
.lab-stage .tb-btn:hover { background: rgba(55,255,139,0.2); border-color: var(--phos); }
.lab-stage .window-body { background: #000; }

/* ---------- window content ---------- */
.app-media { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.game-body { display: flex; align-items: center; justify-content: center; background: #000; }
.fit-canvas { display: block; max-width: 100%; max-height: 100%; image-rendering: pixelated; }
.app-status {
  color: var(--phos, #37ff8b);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 20px;
  text-align: center;
}

@media (max-width: 640px) {
  .lab-stage { cursor: default; }
  /* 58x66 vessel + 12px padding clears the 44px minimum tap target.
     The blurb is NOT hidden any more — on touch it's the only way the
     work explains itself. */
  .node-vessel { width: 58px; height: 66px; }
  .node { padding: 12px; gap: 4px; }
  .node-label { font-size: 10px; letter-spacing: 1px; }
  .lab-sig { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .node-vessel, .node-blurb { transition: none; }
}
