/* style.css — інтерфейс віртуальної хімічної лабораторії */

:root {
  --bg: #0e1622;
  --panel: rgba(16, 26, 38, 0.92);
  --panel-solid: #131f2e;
  --accent: #33c2b0;
  --accent-2: #4aa3df;
  --text: #eaf2f8;
  --muted: #9fb2c2;
  --danger: #ff7a7a;
  --ok: #6fe0a0;
  --warn: #ffce6b;
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.back-to-hub {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 40;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 14px;
  font-family: var(--font);
}
.back-to-hub:hover { background: var(--panel-solid); }

.hidden { display: none !important; }

/* ── HUD ──────────────────────────────────────────────────────────────── */
.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.hud-counter {
  position: fixed;
  top: 16px;
  left: 16px;
  background: var(--panel);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.hud-counter b { color: var(--accent); }

.hud-prompt {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 10px 18px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 80vw;
}
.hud-prompt .pt-title {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.hud-prompt .pt-keys { font-size: 14px; color: var(--muted); }
.hud-prompt .sep { margin: 0 8px; opacity: 0.4; }

.key {
  display: inline-block;
  min-width: 20px;
  padding: 2px 8px;
  margin: 0 2px;
  background: #223247;
  border: 1px solid #35506e;
  border-bottom-width: 2px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #dbe9f7;
}

.hud-held {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
}
.held-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.held-hint { color: var(--muted); font-size: 12px; margin-left: 6px; }

.hud-toasts {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--panel-solid);
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.35s, transform 0.35s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-warn { border-left-color: var(--warn); }
.toast-info { border-left-color: var(--accent-2); }

/* ── Картка результату реакції ──────────────────────────────────────────── */
.card {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  z-index: 12;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  transition: opacity 0.5s;
}
.card.faded { opacity: 0.25; }
.card-head {
  padding: 14px 18px;
  background: linear-gradient(90deg, rgba(74, 163, 223, 0.25), rgba(51, 194, 176, 0.15));
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-head.new { background: linear-gradient(90deg, rgba(111, 224, 160, 0.3), rgba(51, 194, 176, 0.15)); }
.card-head.neutral { background: rgba(255, 255, 255, 0.05); }
.card-title { font-size: 20px; font-weight: 700; }
.badge {
  background: var(--ok);
  color: #062617;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
}
.card-body { padding: 16px 18px; }
.equation {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 14px;
  border-radius: 10px;
  text-align: center;
  margin-bottom: 12px;
}
.obs-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.obs {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
}
.explain { line-height: 1.5; margin: 0 0 10px; color: var(--text); }
.meta { margin-bottom: 8px; }
.rtype {
  display: inline-block;
  font-size: 12px;
  color: var(--accent-2);
  border: 1px solid rgba(74, 163, 223, 0.4);
  padding: 2px 10px;
  border-radius: 20px;
}
.safety { color: var(--warn); font-size: 13px; margin: 0 0 10px; line-height: 1.4; }
.card-hint { color: var(--muted); font-size: 12px; text-align: center; }

/* ── Журнал (оверлей) ───────────────────────────────────────────────────── */
.journal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(6, 12, 20, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.journal {
  width: min(720px, 94vw);
  max-height: 84vh;
  background: var(--panel-solid);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.journal-head {
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.journal-head h2 { margin: 0; font-size: 20px; }
.journal-progress { color: var(--accent); font-weight: 700; }
.journal-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.jr {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
}
.jr-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.jr-eq { color: var(--accent); font-size: 14px; margin-bottom: 6px; }
.jr-ex { color: var(--muted); font-size: 12px; line-height: 1.4; }
.jr.locked {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.55;
  border-style: dashed;
}
.jr-q {
  font-size: 22px;
  font-weight: 800;
  color: var(--muted);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}
.jr-t { color: var(--muted); font-size: 13px; }
.journal-foot { padding: 12px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

/* ── Меню (старт / пауза) ───────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% 20%, rgba(51, 194, 176, 0.12), transparent),
              linear-gradient(180deg, #0b1420, #0e1622);
}
.menu-box {
  width: min(560px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 32px 34px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.menu-box h1 { margin: 0 0 6px; font-size: 28px; }
.subtitle { color: var(--accent); margin: 0 0 16px; font-weight: 600; }
.lead { color: var(--muted); line-height: 1.6; margin: 0 0 20px; }
.controls {
  list-style: none;
  margin: 0 auto 22px;
  padding: 16px;
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  font-size: 14px;
  color: var(--muted);
}
.controls li { display: flex; align-items: center; gap: 8px; }
.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #04201c;
  border: none;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.08); }
.hint-small { color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.hint-small b { color: var(--text); }

@media (max-width: 560px) {
  .controls, .journal-list { grid-template-columns: 1fr; }
}
