/* ============================================================
   AGENT FACTORY — "Coke Zero Arcade, midnight"
   carbon black · red neon · rising carbonation · chrome HUD
   ============================================================ */

:root {
  /* plain (ICE) palette — the default below is overridden by .theme-coke */
  --carbon: #07070c;
  --panel: rgba(20, 20, 30, 0.72);
  --panel-solid: #12121b;
  --ink: #f3f4fb;
  --muted: #9192ad;
  --line: rgba(255, 255, 255, 0.09);
  --neon: #4fe3ff;
  --neon-2: #9af6ff;
  --neon-rgb: 79, 227, 255;
  --term-bg: #06060c;

  --f-sign: 'Monoton', cursive;
  --f-head: 'Anton', sans-serif;
  --f-body: 'Sora', sans-serif;
  --f-mono: 'Space Mono', monospace;
}

body.theme-coke {
  --neon: #ff1f2d;
  --neon-2: #ff626b;
  --neon-rgb: 255, 31, 45;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--f-body);
  color: var(--ink);
  background: var(--carbon);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ---------- atmosphere ---------- */
#bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.glow-a {
  width: 60vw; height: 60vw; top: -22vw; left: 50%; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(var(--neon-rgb), 0.55), transparent 68%);
  animation: pulse 7s ease-in-out infinite;
}
.glow-b {
  width: 42vw; height: 42vw; bottom: -16vw; right: -8vw;
  background: radial-gradient(circle, rgba(var(--neon-rgb), 0.28), transparent 70%);
  animation: pulse 9s ease-in-out infinite reverse;
}
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.62; } }

#bubbles { position: absolute; inset: 0; }
.fizz {
  position: absolute; bottom: -40px; left: var(--x);
  width: var(--s); height: var(--s); border-radius: 50%;
  border: 1px solid rgba(var(--neon-rgb), 0.4);
  box-shadow: 0 0 10px rgba(var(--neon-rgb), 0.3), inset 0 0 6px rgba(var(--neon-rgb), 0.15);
  animation: rise var(--d) linear var(--delay) infinite;
  opacity: 0;
}
@keyframes rise {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  12% { opacity: 0.8; }
  88% { opacity: 0.45; }
  100% { transform: translateY(-112vh) scale(1); opacity: 0; }
}

.grain {
  position: absolute; inset: 0; opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.scanlines {
  position: absolute; inset: 0; opacity: 0.4; mix-blend-mode: overlay;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.25) 0 1px, transparent 1px 3px);
}

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 22px;
  background: linear-gradient(180deg, rgba(8,8,14,0.92), rgba(8,8,14,0.55));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(var(--neon-rgb), 0.18);
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-sign {
  font-family: var(--f-sign); font-size: 22px; color: var(--neon); letter-spacing: 1px;
  text-shadow: 0 0 7px rgba(var(--neon-rgb), 0.9), 0 0 18px rgba(var(--neon-rgb), 0.6);
  animation: flicker 5s infinite;
}
@keyframes flicker {
  0%, 19%, 21%, 50%, 55%, 100% { opacity: 1; }
  20%, 52% { opacity: 0.55; }
}
.brand-word { font-family: var(--f-head); font-size: 22px; letter-spacing: 1.5px; }
.brand-tag { font-family: var(--f-mono); font-size: 10px; color: var(--muted); letter-spacing: 0.5px; }

.hud { display: flex; align-items: center; gap: 10px; }
.pill {
  font-family: var(--f-mono); font-size: 13px; font-weight: 700;
  padding: 6px 11px; border-radius: 999px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); color: var(--ink);
}
.flavor-btn {
  font-family: var(--f-head); font-size: 13px; letter-spacing: 1px;
  padding: 8px 15px; border-radius: 10px; cursor: pointer;
  color: var(--neon); background: transparent;
  border: 1.5px solid rgba(var(--neon-rgb), 0.6);
  box-shadow: 0 0 12px rgba(var(--neon-rgb), 0.25), inset 0 0 12px rgba(var(--neon-rgb), 0.12);
  transition: all 0.15s ease;
}
.flavor-btn:hover { background: rgba(var(--neon-rgb), 0.14); box-shadow: 0 0 20px rgba(var(--neon-rgb), 0.5); }

/* ---------- layout ---------- */
#app { position: relative; z-index: 1; flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 30px 18px 70px; }
#footnote { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: 11px; font-family: var(--f-mono); padding: 16px; }
#footnote em { color: rgba(var(--neon-rgb), 0.85); font-style: normal; }

/* ---------- the map ---------- */
.fridge-wrap { text-align: center; margin-bottom: 30px; }
.fridge-label { font-family: var(--f-mono); font-size: 11px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; }
.fridge-shelf { font-size: 28px; margin-top: 4px; filter: drop-shadow(0 0 8px rgba(var(--neon-rgb), 0.5)); }
.fridge-empty { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }

.chapter { margin-bottom: 30px; }
.chapter h2 {
  font-family: var(--f-head); font-size: 14px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--neon); margin: 0 0 14px; opacity: 0.9;
  text-shadow: 0 0 10px rgba(var(--neon-rgb), 0.35);
}
.nodes { display: flex; flex-direction: column; gap: 12px; }
.node {
  display: flex; align-items: center; gap: 15px;
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-left: 3px solid rgba(var(--neon-rgb), 0.5);
  border-radius: 14px; padding: 15px 17px; cursor: pointer;
  animation: slideUp 0.4s ease both;
  transition: transform 0.08s ease, box-shadow 0.2s ease;
}
.nodes .node:nth-child(2) { animation-delay: 0.04s; }
.nodes .node:nth-child(3) { animation-delay: 0.08s; }
.nodes .node:nth-child(4) { animation-delay: 0.12s; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.node:hover { transform: translateY(-2px); box-shadow: -4px 0 22px rgba(var(--neon-rgb), 0.22); }
.node[data-state="locked"] { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); border-left-color: var(--line); }
.node[data-state="done"] { border-left-color: var(--neon); box-shadow: inset 3px 0 14px rgba(var(--neon-rgb), 0.12); }
.node .bubble {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 11px;
  display: grid; place-items: center; font-size: 18px; font-weight: 800;
  background: rgba(var(--neon-rgb), 0.1); color: var(--neon);
  border: 1px solid rgba(var(--neon-rgb), 0.4);
}
.node[data-state="done"] .bubble {
  background: var(--neon); color: #07070c;
  box-shadow: 0 0 16px rgba(var(--neon-rgb), 0.6);
}
.node .label { font-family: var(--f-head); font-size: 17px; letter-spacing: 0.4px; }
.node .sub { color: var(--muted); font-size: 12px; font-family: var(--f-mono); }

/* ---------- card ---------- */
.card {
  position: relative;
  background: var(--panel); backdrop-filter: blur(12px);
  border: 1px solid rgba(var(--neon-rgb), 0.22);
  border-radius: 18px; padding: 26px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 18px 50px rgba(0,0,0,0.55), 0 0 40px rgba(var(--neon-rgb), 0.1);
  animation: cardIn 0.22s ease;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 22px; right: 22px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
  box-shadow: 0 0 12px rgba(var(--neon-rgb), 0.7); opacity: 0.8;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.kicker { font-family: var(--f-mono); color: var(--neon); font-size: 11px; text-transform: uppercase; letter-spacing: 2px; }
.card h1 { font-family: var(--f-head); font-size: 30px; margin: 8px 0 16px; letter-spacing: 0.5px; line-height: 1.05; }
.story { font-size: 17px; line-height: 1.6; color: #e7e7f2; }
.concept {
  background: rgba(var(--neon-rgb), 0.08); border: 1px solid rgba(var(--neon-rgb), 0.2);
  border-radius: 12px; padding: 15px 17px; font-size: 16px; line-height: 1.55; margin-top: 6px;
}

/* ---------- exercises ---------- */
.prompt { font-family: var(--f-head); font-size: 20px; font-weight: 400; margin-bottom: 18px; line-height: 1.3; letter-spacing: 0.3px; }
.options { display: flex; flex-direction: column; gap: 11px; }
.opt {
  text-align: left; font-family: var(--f-body); font-size: 16px; font-weight: 600; color: var(--ink);
  background: rgba(255,255,255,0.03); border: 1.5px solid var(--line);
  border-radius: 13px; padding: 15px 16px; cursor: pointer; transition: all 0.12s ease;
}
.opt:hover { border-color: rgba(var(--neon-rgb), 0.6); background: rgba(var(--neon-rgb), 0.07); }
.opt.correct { border-color: var(--neon); background: rgba(var(--neon-rgb), 0.16); box-shadow: 0 0 16px rgba(var(--neon-rgb), 0.3); }
.opt.wrong { border-color: #ff4b4b; background: rgba(255,75,75,0.12); }
.opt:disabled { cursor: default; }

.bank { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.tile {
  font-family: var(--f-body); font-size: 15px; font-weight: 700; color: var(--ink);
  background: rgba(255,255,255,0.04); border: 1.5px solid var(--line);
  border-radius: 11px; padding: 11px 14px; cursor: pointer; transition: all 0.12s ease;
}
.tile:hover { border-color: rgba(var(--neon-rgb), 0.6); }
.tile.used { opacity: 0.3; pointer-events: none; }
.tile.lit, .tile.done { border-color: var(--neon); background: rgba(var(--neon-rgb), 0.16); box-shadow: 0 0 12px rgba(var(--neon-rgb), 0.3); }
.tile.miss { border-color: #ff4b4b; background: rgba(255,75,75,0.14); }
.answer-row {
  min-height: 52px; border: 1.5px dashed rgba(var(--neon-rgb), 0.3); border-radius: 12px;
  padding: 8px; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;
}
.answer-row .tile { cursor: default; }
.answer-row .tile .ord { color: var(--neon); margin-right: 6px; font-size: 12px; font-family: var(--f-mono); }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-grid .col { display: flex; flex-direction: column; gap: 10px; }

.explain { margin-top: 16px; padding: 14px 16px; border-radius: 12px; font-size: 15px; line-height: 1.5; display: none; }
.explain.show { display: block; }
.explain.ok { background: rgba(var(--neon-rgb), 0.12); border: 1px solid rgba(var(--neon-rgb), 0.3); }
.explain.no { background: rgba(255,75,75,0.12); border: 1px solid rgba(255,75,75,0.3); }

/* ---------- footer / buttons ---------- */
.actions { margin-top: 24px; display: flex; gap: 12px; align-items: center; }
.btn {
  font-family: var(--f-head); font-size: 16px; letter-spacing: 0.8px;
  border: none; cursor: pointer; padding: 13px 24px; border-radius: 12px;
  color: #08080c; background: linear-gradient(180deg, var(--neon-2), var(--neon));
  box-shadow: 0 0 20px rgba(var(--neon-rgb), 0.45), 0 4px 0 rgba(0,0,0,0.4);
  transition: transform 0.06s ease, box-shadow 0.2s ease;
}
.btn:hover { box-shadow: 0 0 30px rgba(var(--neon-rgb), 0.7), 0 4px 0 rgba(0,0,0,0.4); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 20px rgba(var(--neon-rgb), 0.45), 0 2px 0 rgba(0,0,0,0.4); }
.btn:disabled { background: rgba(255,255,255,0.08); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; border: 1.5px solid var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--muted); }
.dots { margin-left: auto; color: var(--muted); font-size: 12px; font-family: var(--f-mono); }

/* ---------- terminal hero ---------- */
.term-intro { font-family: var(--f-mono); font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.terminal {
  background: var(--term-bg); border: 1px solid rgba(var(--neon-rgb), 0.25);
  border-top: 2px solid var(--neon); border-radius: 12px;
  padding: 16px 18px; font-family: var(--f-mono); font-size: 13px; line-height: 1.75;
  min-height: 200px; white-space: pre-wrap; color: #d7d7e2;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.6), 0 0 20px rgba(var(--neon-rgb), 0.12);
}
.terminal .ln { opacity: 0; animation: fade 0.25s forwards; }
@keyframes fade { to { opacity: 1; } }
.terminal .prompt { color: var(--neon-2); font-family: var(--f-mono); font-size: 13px; font-weight: 700; }
.terminal .tool { color: #7cc7ff; }
.terminal .output { color: #9a9ab0; }
.terminal .done { color: #5ee6a8; font-weight: 700; }
.terminal .note { color: #7a7a90; font-style: italic; }
body.theme-coke .terminal .tool { color: #ff9aa0; }

/* ---------- crack / reward ---------- */
.center { text-align: center; }
.reward { text-align: center; padding: 16px 0; }
.linkish { font-family: var(--f-mono); color: var(--muted); font-size: 12px; background: none; border: none; cursor: pointer; text-decoration: underline; }
.linkish:hover { color: var(--neon); }
.glow-can { filter: drop-shadow(0 0 18px rgba(var(--neon-rgb), 0.75)); }

/* ---------- Coke Zero can asset ---------- */
.can-img { display: inline-block; vertical-align: middle; }
.can-hud { height: 19px; }
.can-shelf { height: 36px; margin: 0 1px; filter: drop-shadow(0 0 7px rgba(var(--neon-rgb), 0.55)); }
.can-big { height: 132px; }
.psssht { font-family: var(--f-mono); font-size: 12px; color: var(--neon); margin-top: 8px; letter-spacing: 1px; }

/* ---------- source link ---------- */
.source-link { display: block; margin-top: 16px; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.source-link a { color: var(--neon); text-decoration: none; border-bottom: 1px dotted rgba(var(--neon-rgb), 0.5); }
.source-link a:hover { text-shadow: 0 0 10px rgba(var(--neon-rgb), 0.5); }

/* ---------- verification loop ---------- */
.task-card {
  background: rgba(var(--neon-rgb), 0.07); border: 1px solid rgba(var(--neon-rgb), 0.28);
  border-radius: 14px; padding: 16px 18px; margin: 4px 0 14px;
}
.task-label { font-family: var(--f-mono); font-size: 10px; letter-spacing: 2px; color: var(--neon); text-transform: uppercase; }
.task-text { font-size: 16px; line-height: 1.5; margin-top: 8px; }
.tool-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 13px; }
.chip {
  font-family: var(--f-mono); font-size: 12px; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line);
}
textarea.paste {
  width: 100%; min-height: 92px; resize: vertical; margin-top: 4px;
  background: var(--term-bg); color: var(--ink);
  border: 1px solid rgba(var(--neon-rgb), 0.3); border-radius: 12px;
  padding: 12px 14px; font-family: var(--f-mono); font-size: 13px; line-height: 1.55;
}
textarea.paste:focus { outline: none; border-color: var(--neon); box-shadow: 0 0 16px rgba(var(--neon-rgb), 0.25); }
.checks { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.check-row { font-size: 14px; padding: 9px 13px; border-radius: 10px; }
.check-row.ok { background: rgba(var(--neon-rgb), 0.16); }
.check-row.no { background: rgba(255,255,255,0.04); color: var(--muted); }
.reveal {
  margin-top: 14px; padding: 14px 16px; border-radius: 12px;
  background: rgba(var(--neon-rgb), 0.1); border: 1px solid rgba(var(--neon-rgb), 0.3);
}
.reveal-h { font-family: var(--f-head); font-size: 16px; margin-bottom: 6px; }
.reveal-b { font-size: 15px; line-height: 1.5; color: #e7e7f2; }

/* ---------- example block ---------- */
.example {
  background: rgba(255,255,255,0.04); border-left: 3px solid var(--neon);
  border-radius: 0 12px 12px 0; padding: 15px 18px;
}
.example-label { font-family: var(--f-mono); font-size: 11px; letter-spacing: 1.5px; color: var(--neon); text-transform: uppercase; margin-bottom: 8px; }
.example-text { font-size: 16px; line-height: 1.6; color: #e7e7f2; }

/* ---------- diagram (mermaid) ---------- */
.mermaid-wrap {
  background: rgba(0,0,0,0.35); border: 1px solid rgba(var(--neon-rgb), 0.22);
  border-radius: 14px; padding: 18px; overflow-x: auto; text-align: center;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}
.mermaid-wrap svg { max-width: 100%; height: auto; }
.loading-mono { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }

/* ---------- code example ---------- */
.code-label { font-family: var(--f-mono); font-size: 11px; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }
.code-pre {
  background: var(--term-bg); border: 1px solid rgba(var(--neon-rgb), 0.25);
  border-top: 2px solid var(--neon); border-radius: 12px;
  padding: 16px 18px; overflow-x: auto; margin: 0;
  font-family: var(--f-mono); font-size: 13px; line-height: 1.65; color: #d7d7e2;
  box-shadow: inset 0 0 26px rgba(0,0,0,0.55);
}
