/* THE CONSTRUCT: styles for bait site, CRT interface, panels, overlays */

:root {
  --amber: #C49A6C;
  --teal: #7EBDC2;
  --ichor: #9a7fd0;
  --green: #74e77f;
  --bg: #06060a;
  --panel-bg: #14141c;          /* solid, high contrast */
  --panel-text: #EDE6D6;        /* light on solid dark: readable */
  --parch-bg: #efe6d3;
  --parch-text: #2a2418;
  --red: #e05a4e;
  --mono: "Menlo", "Consolas", "Liberation Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--panel-text);
  font-family: var(--mono);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--teal); }

/* ============================================================
   LAYER 0: THE BAIT. Deliberately beige, competent, boring.
   ============================================================ */
#bait {
  position: fixed; inset: 0; z-index: 50;
  overflow-y: auto;
  background: #f7f5f0;
  color: #333;
  font-family: "Helvetica Neue", Arial, sans-serif;
  transition: filter 0.2s;
}
#bait .container { max-width: 760px; margin: 0 auto; padding: 48px 24px 96px; }
#bait header { border-bottom: 1px solid #ddd; padding-bottom: 24px; margin-bottom: 32px; }
#bait h1 { font-size: 32px; font-weight: 600; color: #222; }
#bait .tagline { color: #777; margin-top: 6px; font-size: 15px; }
#bait nav { margin-top: 16px; display: flex; gap: 18px; flex-wrap: wrap; }
#bait nav a { color: #4a6fa5; text-decoration: none; font-size: 14px; }
#bait nav a:hover { text-decoration: underline; }
#bait h2 { font-size: 20px; font-weight: 600; color: #222; margin: 36px 0 12px; }
#bait p, #bait li { font-size: 15px; line-height: 1.7; color: #444; }
#bait ul { padding-left: 22px; margin: 10px 0; }
#bait .card {
  border: 1px solid #e2ded6; border-radius: 8px; background: #fff;
  padding: 18px 20px; margin: 14px 0;
}
#bait .card h3 { font-size: 16px; color: #222; margin-bottom: 6px; }
#bait .muted { color: #999; font-size: 13px; }
#bait footer { margin-top: 56px; border-top: 1px solid #ddd; padding-top: 20px; color: #999; font-size: 13px; }
#bait .pill { display: inline-block; background: #eef; color: #4a6fa5; border-radius: 999px; padding: 2px 10px; font-size: 12px; margin: 2px 4px 2px 0; }

/* glitch escalation */
#bait.glitch-1 { animation: jitter 4s steps(2) infinite; }
#bait.glitch-2 { animation: jitter 1.6s steps(2) infinite; }
#bait.glitch-2 h1, #bait.glitch-2 h2 { text-shadow: 2px 0 rgba(255,0,60,0.35), -2px 0 rgba(0,255,220,0.35); }
#bait.glitch-3 { animation: jitter 0.5s steps(2) infinite; filter: saturate(1.4) contrast(1.1); }
#bait.glitch-3::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.12) 0 2px, transparent 2px 5px);
}
@keyframes jitter {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(2px, 2px); }
  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  #bait.glitch-1, #bait.glitch-2, #bait.glitch-3 { animation: none; }
}

/* intruding runes during glitch */
.rune-intrusion { color: var(--amber); font-family: var(--mono); }

/* breakout prompt */
#breakout {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  z-index: 60; display: none; text-align: center;
  background: #0a0a0e; border: 1px solid var(--amber); border-radius: 8px;
  padding: 18px 26px; color: var(--panel-text); font-family: var(--mono);
  box-shadow: 0 0 40px rgba(196,154,108,0.4);
}
#breakout.show { display: block; }
#breakout .line1 { color: var(--red); letter-spacing: 2px; font-size: 12px; }
#breakout .line2 { margin: 8px 0 10px; font-size: 14px; }
#breakout .bar {
  width: 260px; height: 10px; border: 1px solid var(--amber);
  border-radius: 5px; overflow: hidden; margin: 0 auto;
}
#breakout .bar > div { height: 100%; width: 0%; background: var(--amber); transition: width 0.1s; }
#breakout .alt { margin-top: 10px; font-size: 11px; color: #8a8478; }
#breakout .alt button {
  background: none; border: 1px solid #555; color: #aaa; border-radius: 4px;
  padding: 4px 10px; font-size: 11px; min-height: 32px;
}

/* white flash on breakout */
#flash {
  position: fixed; inset: 0; z-index: 200; background: #fff; opacity: 0;
  pointer-events: none; transition: opacity 0.12s;
}
#flash.on { opacity: 1; }

/* ============================================================
   LAYER 1: THE STUDY (3D canvas + HUD)
   ============================================================ */
#scene { position: fixed; inset: 0; z-index: 10; display: block; }

#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#hud .hint {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(10,10,14,0.92); border: 1px solid rgba(196,154,108,0.5);
  border-radius: 6px; padding: 9px 16px; font-size: 13px; color: var(--panel-text);
  opacity: 0; transition: opacity 0.25s; max-width: 90vw; text-align: center;
}
#hud .hint.show { opacity: 1; }
#hud #reticle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(196,154,108,0.9); opacity: 0; transition: opacity 0.2s;
}
#hud #reticle.show { opacity: 0.9; }
#hud #reticle.hot { background: var(--teal); box-shadow: 0 0 10px var(--teal); }

#controls-hint {
  position: absolute; top: 16px; left: 16px;
  background: rgba(10,10,14,0.85); border: 1px solid rgba(196,154,108,0.35);
  border-radius: 6px; padding: 10px 14px; font-size: 11px; line-height: 1.8;
  color: #b8b0a0; letter-spacing: 1px;
}
#controls-hint b { color: var(--amber); font-weight: normal; }

/* toasts */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -10px);
  z-index: 300; background: #0f0f16; border: 1px solid var(--amber);
  color: var(--panel-text); border-radius: 8px; padding: 12px 20px;
  font-family: var(--mono); font-size: 13px; opacity: 0;
  transition: all 0.3s; max-width: min(560px, 92vw); text-align: center;
  box-shadow: 0 6px 30px rgba(0,0,0,0.6);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   READABLE PANELS: solid backgrounds, real contrast
   ============================================================ */
#panel-overlay {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(3,3,6,0.72); align-items: center; justify-content: center;
  padding: 20px;
}
#panel-overlay.open { display: flex; }
#panel {
  width: 680px; max-width: 94vw; max-height: 86vh; overflow-y: auto;
  background: var(--panel-bg); color: var(--panel-text);
  border: 1px solid rgba(196,154,108,0.6); border-radius: 10px;
  padding: 28px 30px; font-family: var(--mono);
  box-shadow: 0 0 60px rgba(196,154,108,0.25);
}
body.lit #panel { background: var(--parch-bg); color: var(--parch-text); border-color: #b09a72; }
#panel h2 { color: var(--amber); font-size: 17px; letter-spacing: 2px; margin-bottom: 4px; }
body.lit #panel h2 { color: #7a5a2e; }
#panel .sub { font-size: 11px; letter-spacing: 2px; color: #8a8478; margin-bottom: 18px; }
#panel h3 { color: var(--teal); font-size: 14px; margin: 18px 0 6px; }
body.lit #panel h3 { color: #3e6d72; }
#panel p, #panel li { font-size: 14px; line-height: 1.75; }
#panel ul { padding-left: 20px; margin: 8px 0; }
#panel .close-row { margin-top: 22px; text-align: right; }
#panel .hbtn, .hbtn {
  background: rgba(196,154,108,0.12); color: var(--amber);
  border: 1px solid rgba(196,154,108,0.55); border-radius: 6px;
  padding: 9px 16px; font-size: 12px; letter-spacing: 2px; min-height: 40px;
}
.hbtn:hover { background: rgba(196,154,108,0.25); }
body.lit #panel .hbtn { color: #7a5a2e; border-color: #b09a72; background: rgba(122,90,46,0.08); }
#panel .stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
#panel .stat {
  flex: 1 1 120px; border: 1px solid rgba(196,154,108,0.4); border-radius: 8px;
  padding: 12px; text-align: center;
}
#panel .stat .n { color: var(--amber); font-size: 22px; }
body.lit #panel .stat .n { color: #7a5a2e; }
#panel .stat .l { font-size: 10px; letter-spacing: 1px; color: #8a8478; margin-top: 4px; }
#panel .grimoire-rune { color: var(--ichor); }
#panel .tally-bar { height: 8px; border: 1px solid rgba(196,154,108,0.5); border-radius: 4px; overflow: hidden; margin-top: 8px; }
#panel .tally-bar > div { height: 100%; background: linear-gradient(90deg, var(--amber), #e0b87e); width: 0%; transition: width 1.2s ease; }

/* ============================================================
   THE CRT INTERFACE (full-screen when "sitting down")
   ============================================================ */
#crt {
  position: fixed; inset: 0; z-index: 120; display: none;
  background: #030304; align-items: center; justify-content: center;
}
#crt.open { display: flex; }
#crt .bezel {
  width: min(960px, 96vw); height: min(700px, 92vh);
  background: #101010; border-radius: 26px; padding: 26px;
  box-shadow: inset 0 0 30px #000, 0 0 80px rgba(116,231,127,0.12);
  display: flex; flex-direction: column;
}
#crt .screen {
  flex: 1; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at center, #0c1a0e 0%, #050a06 100%);
  border-radius: 14px; border: 1px solid #1e3322;
  font-family: var(--mono); color: var(--green);
  text-shadow: 0 0 6px rgba(116,231,127,0.55);
  display: flex; flex-direction: column;
}
#crt .screen::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.04) 0 1px, transparent 1px 3px);
}
#crt .screen::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.5) 100%);
}
#crt.amber .screen { color: var(--amber); text-shadow: 0 0 6px rgba(196,154,108,0.55); background: radial-gradient(ellipse at center, #1a130c 0%, #0a0705 100%); border-color: #332a1e; }
#crt-content { flex: 1; overflow-y: auto; padding: 20px 24px; font-size: 14px; line-height: 1.65; position: relative; z-index: 2; }
#crt-content::-webkit-scrollbar { width: 6px; }
#crt-content::-webkit-scrollbar-thumb { background: #2a4a30; }
#crt-input-row { display: flex; gap: 8px; padding: 10px 24px 16px; position: relative; z-index: 2; }
#crt-input-row .prompt { opacity: 0.9; }
#crt-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: inherit; font-family: inherit; font-size: 14px; text-shadow: inherit;
  min-height: 32px;
}
#crt .standup {
  margin-top: 14px; text-align: center;
}
#crt .standup button {
  background: none; border: 1px solid #333; color: #888; border-radius: 6px;
  padding: 8px 18px; font-size: 11px; letter-spacing: 2px; min-height: 40px;
}
#crt .standup button:hover { color: var(--amber); border-color: var(--amber); }

/* CRT text categories */
.c-title { color: inherit; font-weight: bold; letter-spacing: 1px; }
.c-dim { opacity: 0.65; }
.c-cmd { opacity: 0.85; font-style: italic; }
.c-err { color: #ff6b5e; text-shadow: 0 0 6px rgba(255,107,94,0.5); }
.c-item { color: #b8e6c0; }
.c-npc { color: #ffd9a0; }
.c-hint { opacity: 0.75; font-style: italic; }
.c-room { font-weight: bold; text-decoration: underline; }
.c-menu-row { display: block; padding: 2px 0; }

/* arcade canvas inside CRT */
#casks-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }

/* ============================================================
   ESCAPE FX: watcher loop, reality crash, reboot
   ============================================================ */
#reality-crash {
  position: fixed; inset: 0; z-index: 400; display: none;
  background: #0827a0; color: #fff; font-family: var(--mono);
  align-items: center; justify-content: center; text-align: center; padding: 24px;
}
#reality-crash.on { display: flex; }
#reality-crash .inner { max-width: 62ch; font-size: 14px; line-height: 2; }
#reality-crash h2 { font-size: 18px; letter-spacing: 2px; margin-bottom: 18px; }

#magnus {
  position: fixed; inset: 0; z-index: 350; display: none;
  background: rgba(2,2,4,0.96); align-items: center; justify-content: center; padding: 30px;
}
#magnus.open { display: flex; }
#magnus .statement {
  max-width: 68ch; font-size: 14px; line-height: 2; color: #cfc7b4;
  white-space: pre-wrap; font-family: var(--mono);
}

/* cheat console */
#cheat-console {
  position: fixed; top: 0; left: 0; right: 0; z-index: 380;
  background: rgba(8,8,12,0.97); border-bottom: 1px solid var(--amber);
  transform: translateY(-100%); transition: transform 0.25s;
  font-family: var(--mono); padding: 14px 20px;
}
#cheat-console.open { transform: translateY(0); }
#cheat-log { max-height: 200px; overflow-y: auto; font-size: 12px; line-height: 1.8; color: #cfc7b4; white-space: pre-wrap; }
#cheat-input-row { display: flex; gap: 8px; margin-top: 8px; color: var(--amber); }
#cheat-input { flex: 1; background: none; border: none; outline: none; color: var(--amber); font-family: inherit; font-size: 13px; min-height: 32px; }

/* wild wasteland */
.ufo, .abductee { position: fixed; z-index: 390; font-size: 34px; pointer-events: none; top: 0; left: 0; }
.abductee { font-size: 26px; }

/* no-JS and fallback notice */
.nojs-note { background: #fffbe6; border: 1px solid #e0d290; padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; font-size: 13px; color: #6a5d20; }

@media (max-width: 720px) {
  #controls-hint { display: none; }
  #crt .bezel { padding: 12px; border-radius: 14px; }
  #panel { padding: 20px 18px; }
}

/* ============================================================
   v2 additions: zoom-out breakout, nano bars
   ============================================================ */
#bait.zoom-out {
  transform: scale(0.32);
  opacity: 0;
  transition: transform 1.1s cubic-bezier(0.5, 0, 0.75, 0.5), opacity 1.05s ease-in;
  transform-origin: 50% 46%;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  #bait.zoom-out { transition: opacity 0.25s; transform: none; }
}

.c-nano-bar { background: #74e77f; color: #04140a; padding: 1px 6px; }
#crt.amber .c-nano-bar { background: #ffb641; color: #140a02; }
