/* Blobsorb site styles.
   The phosphor palette lives in the --crt-* custom properties below - retint
   the whole site from here. (screen.js has matching green()/brightGreen()
   helpers for the canvas-drawn CRT backdrop.) */

:root {
  --crt-green-rgb: 51, 204, 77;       /* main phosphor green */
  --crt-green: rgb(var(--crt-green-rgb));
  --crt-dim-rgb: 120, 220, 140;       /* dimmer body-text green */
  --crt-bright-rgb: 120, 255, 150;    /* hover / glint green */
  --crt-shine: rgba(191, 255, 204, 0.5);
  --bg: #07070c;
}

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg); overflow: hidden;
  font-family: "Courier New", Courier, monospace;
}

/* The game's slime cursors (hotspots match CursorStyles.uss / IconAssetPipeline). */
html, body, canvas {
  cursor: url("../cursors/blobsorb_arrow.png") 2 2, auto;
}
a, button, [role="button"], label, summary {
  cursor: url("../cursors/blobsorb_pointer.png") 12 2, pointer;
}
input, textarea, [contenteditable="true"] {
  cursor: url("../cursors/blobsorb_text.png") 16 16, text;
}
#app { position: fixed; inset: 0; }
canvas { display: block; }

/* Loading overlay: a squirming blob colony while the lab boots up */
#loader {
  position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; transition: opacity 0.7s ease; color: var(--crt-green);
}
#loader.done { opacity: 0; pointer-events: none; }
#loader .blob {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--crt-green); position: relative; display: inline-block;
  animation: squirm 1.4s ease-in-out infinite;
}
#loader .blob::after {
  content: ""; position: absolute; left: 18%; top: 14%;
  width: 42%; height: 42%; border-radius: 50%;
  background: var(--crt-shine);
}
#loader .blob:nth-child(2) { animation-delay: 0.15s; }
#loader .blob:nth-child(3) { animation-delay: 0.3s; }
#loader .blob:nth-child(4) { animation-delay: 0.45s; }
#loader .blob:nth-child(5) { animation-delay: 0.6s; }
#loader .blobs { display: flex; gap: 10px; }
@keyframes squirm {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-9px) scale(1.12, 0.9); }
}
#loader .status { font-size: 14px; letter-spacing: 3px; opacity: 0.8; }

/* Static fallback when WebGL is unavailable (main.js swaps the loader's
   contents for the og-card image + blurb + Steam link). */
#loader.fallback {
  opacity: 1; pointer-events: auto;
  padding: 2rem; text-align: center; overflow-y: auto;
}
#loader.fallback .fallback-card {
  max-width: min(560px, 92vw); height: auto;
  border: 1px solid rgba(var(--crt-green-rgb), 0.35);
}
#loader.fallback .fallback-copy {
  margin: 0; font-size: 15px; line-height: 1.7;
  color: rgba(var(--crt-dim-rgb), 0.9);
}
#loader.fallback .fallback-link {
  padding: 10px 20px; font-weight: 600; letter-spacing: 1px;
  color: var(--crt-green); text-decoration: none;
  border: 2px solid rgba(var(--crt-green-rgb), 0.6);
}
#loader.fallback .fallback-link:hover {
  background: #0c2c14; color: rgb(210, 255, 220);
}

/* --- CSS3D overlay: real, selectable HTML projected onto the CRT glass --- */
#css3d {
  position: fixed; inset: 0; z-index: 2;
  pointer-events: none; /* only the screen surface itself takes input */
}
#screen-ui {
  width: 1024px; height: 768px; /* must match SCREEN.pxW/pxH in assets/js/screen.js */
  pointer-events: auto;
  font-family: "Courier New", Courier, monospace;
  color: rgba(var(--crt-dim-rgb), 0.85);
  cursor: url("../cursors/blobsorb_text.png") 16 16, text;
  overflow: hidden;
}
#screen-ui ::selection, #screen-ui::selection {
  background: rgba(var(--crt-green-rgb), 0.85); color: #06130a;
}
#screen-ui .screen-text {
  /* Fills from just under the blob title down to just above the Steam button,
     and scrolls when the blurb outgrows it. */
  position: absolute; left: 60px; right: 46px; top: 292px; bottom: 146px;
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 14px;
  font-size: 19px; font-weight: 600; line-height: 27px;
  text-shadow: 0 0 6px rgba(var(--crt-green-rgb), 0.35);
  scrollbar-width: thin;                                   /* Firefox */
  scrollbar-color: rgba(var(--crt-green-rgb), 0.6) rgba(0, 26, 10, 0.5);
  /* Faint scanlines on the text panel only (a full-screen overlay would draw
     over 3D props like the post-it, which render beneath the CSS layer). */
  background-image: repeating-linear-gradient(
    to bottom, rgba(0,0,0,0.16) 0 1px, transparent 1px 4px);
}
#screen-ui .screen-text::-webkit-scrollbar { width: 10px; }
#screen-ui .screen-text::-webkit-scrollbar-track {
  background: rgba(0, 26, 10, 0.5);
  border-left: 1px solid rgba(var(--crt-green-rgb), 0.25);
}
#screen-ui .screen-text::-webkit-scrollbar-thumb {
  background: rgba(var(--crt-green-rgb), 0.55);
  border: 2px solid rgba(0, 20, 8, 0.8);
}
#screen-ui .screen-text::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--crt-bright-rgb), 0.8);
}
#screen-ui .screen-text p { margin: 0 0 27px 0; }
#screen-ui .screen-text .head { color: rgba(var(--crt-green-rgb), 0.95); }
#screen-ui .screen-text pre {
  margin: 0 0 27px 0; font: inherit; white-space: pre-wrap;
}

/* --- FIG.1 absorption-cycle diagram (small blob -> nutrients -> big blob) --- */
#screen-ui .evo-diagram {
  display: block; width: 78%; height: auto; margin: 0 auto 27px auto;
  overflow: visible;
  transition: opacity 0.6s ease;
}
#screen-ui .evo-diagram.boot-hidden { opacity: 0; }
#screen-ui .evo-diagram .body { fill: rgba(var(--crt-green-rgb), 0.85); }
#screen-ui .evo-diagram .shine { fill: var(--crt-shine); }
#screen-ui .evo-diagram .arrow { fill: var(--crt-green); }
#screen-ui .evo-diagram .nutrients circle { fill: rgba(var(--crt-dim-rgb), 0.8); }
#screen-ui .evo-diagram .nutrients .husk {
  fill: none; stroke: rgba(var(--crt-dim-rgb), 0.6); stroke-width: 1.5;
}
#screen-ui .evo-diagram .flow {
  stroke: var(--crt-green); stroke-width: 3; stroke-dasharray: 7 7;
  opacity: 0.85;
}
#screen-ui .evo-diagram text {
  font-family: "Courier New", Courier, monospace; font-weight: 600;
  fill: rgba(var(--crt-dim-rgb), 0.85);
}
#screen-ui .evo-diagram .tag { font-size: 17px; letter-spacing: 2px; }
#screen-ui .evo-diagram .fig-label { font-size: 15px; letter-spacing: 2px; opacity: 0.6; }
/* gentle squirm, matching the loader blobs */
#screen-ui .evo-diagram .blob {
  animation: evo-squirm 2.6s ease-in-out infinite;
  transform-box: fill-box; transform-origin: center;
}
#screen-ui .evo-diagram .blob.big { animation-delay: 1.3s; }
@keyframes evo-squirm {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.045, 0.955); }
}

#screen-ui .steam-btn {
  position: absolute; right: 60px; bottom: 66px;
  display: block; padding: 12px 22px;
  font-size: 20px; font-weight: 600; letter-spacing: 1px;
  color: rgba(var(--crt-green-rgb), 0.95); text-decoration: none;
  /* Solid (no alpha) so every engine/composite path renders it the same. */
  background-color: #041209;
  text-shadow: 0 0 8px rgba(var(--crt-green-rgb), 0.45);
  /* NO `border` here on purpose: some engines smear border paint across the
     whole element on 3D-transformed layers. The frame is an inset box-shadow
     on ::before, and the pulse animates its opacity (safest property). */
}
#screen-ui .steam-btn::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--crt-green);
  opacity: 0.55;
  animation: btn-pulse 2.8s ease-in-out infinite;
}
@keyframes btn-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}
#screen-ui .steam-btn:hover, #screen-ui .steam-btn:visited:hover {
  background-color: #0c2c14;
  color: rgb(210, 255, 220);
}
#screen-ui .steam-btn:hover::before {
  box-shadow: inset 0 0 0 2px rgb(var(--crt-bright-rgb));
  opacity: 1;
  animation: none;
}
#screen-ui .steam-btn:visited { color: rgba(var(--crt-green-rgb), 0.95); }

/* --- interactive terminal (driven from terminal.js) --- */
#screen-ui #term-line {
  margin: 0 0 27px 0;
  white-space: pre-wrap; word-break: break-all; /* long input wraps, not clips */
  color: rgba(var(--crt-green-rgb), 0.95);
}
#screen-ui #term-out .echo {
  margin-bottom: 0;                    /* command hugs its response */
  color: rgba(var(--crt-green-rgb), 0.95);
}
#screen-ui #term-mobile-input {
  /* real input for touch keyboards; visually absent but focusable */
  position: absolute; left: -9999px; top: 0;
  width: 1px; height: 1px; opacity: 0; border: 0; padding: 0;
}

/* --- typewriter animation (driven from typewriter.js) --- */
#screen-ui .untyped { visibility: hidden; }   /* keeps layout stable while typing */
#screen-ui .type-cursor {
  display: inline-block; width: 10px; height: 18px; margin-left: 2px;
  background: rgba(var(--crt-green-rgb), 0.9);
  vertical-align: baseline; transform: translateY(2px);
  animation: cursor-blink 0.9s steps(1) infinite;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

/* Visually hidden but exposed to screen readers / crawlers (the h1). */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* prefers-reduced-motion: stop every decorative CSS animation. (screen.js
   gates the canvas-drawn wiggle/flicker/scan band on the same media query,
   and typewriter.js skips the typing animation.) */
@media (prefers-reduced-motion: reduce) {
  #loader .blob,
  #screen-ui .evo-diagram .blob,
  #screen-ui .steam-btn::before,
  #screen-ui .type-cursor {
    animation: none;
  }
  #loader, #screen-ui .evo-diagram { transition: none; }
}

noscript {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); color: var(--crt-green);
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 2rem; font-size: 15px; line-height: 1.7;
}
