/* animations.css — Asymptote Engine Game styles & animations */

/* ─── CSS Variables ─────────────────────────────────────────────── */
:root {
  --color-bg: #111;
  --color-surface: #1a1a1a;
  --color-surface-2: #222;
  --color-border: #2f2f2f;
  --color-accent: #5ee87d;
  --color-accent-dim: #2d8f4a;
  --color-text: #f0f0f0;
  --color-text-muted: #777;
  --color-target: #5ee87d;
  --color-target-glow: rgba(94, 232, 125, 0.55);
  --color-reward: #ffd700;
  --color-pseudo: #8ef4a8;
  --color-bar-early: #2d6e40;
  --color-bar-mid: #5ee87d;
  --color-bar-late: #8ef4a8;
  --color-bar-max: #c0ffd4;
  --color-danger: #ff4466;
  --color-weed: #4ade80;
  --color-adderall: #60a5fa;
  --color-alcohol: #f59e0b;
  --font-main: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  --font-mono: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.6);
}

/* ─── Base Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: filter 0.3s ease, background 0.4s ease;
}

/* ─── Substance Visual Effects ──────────────────────────────────── */
body.weed-active {
  filter: hue-rotate(60deg) saturate(1.4);
  animation: weed-pulse 3s ease-in-out infinite;
}
body.adderall-active {
  filter: contrast(1.15) brightness(1.1);
  animation: adderall-sharpen 2s ease-in-out infinite;
}
body.alcohol-active {
  animation: alcohol-wobble 0.8s ease-in-out infinite;
}

@keyframes weed-pulse {
  0%, 100% { filter: hue-rotate(60deg) saturate(1.4); }
  50% { filter: hue-rotate(110deg) saturate(1.7) brightness(1.05); }
}
@keyframes adderall-sharpen {
  0%, 100% { filter: contrast(1.15) brightness(1.1); }
  50% { filter: contrast(1.25) brightness(1.15) saturate(1.1); }
}
@keyframes alcohol-wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(0.5deg); }
  75% { transform: rotate(-0.5deg); }
}

/* ─── Layout ────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: 1fr 320px;
  grid-template-areas:
    "header  header"
    "effects effects"
    "game    sidebar";
  min-height: 100vh;
  gap: 0;
}

/* ─── Header ────────────────────────────────────────────────────── */
#header {
  grid-area: header;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

#header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.88rem;
}
.stat-chip .label {
  color: var(--color-text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-chip .value {
  font-weight: 700;
  color: var(--color-text);
}
.stat-chip.pseudo-chip {
  border-color: var(--color-pseudo);
}
.stat-chip.pseudo-chip .value {
  color: var(--color-pseudo);
}

/* Progress bar */
.progress-container {
  flex: 1;
  min-width: 160px;
}
.progress-label {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}
.progress-bar {
  height: 6px;
  background: var(--color-surface-2);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
#progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--color-bar-early);
  border-radius: 3px;
  transition: width 0.5s ease, background 0.5s ease;
}

/* ─── Active Effects Bar ────────────────────────────────────────── */
#active-effects-bar {
  grid-area: effects;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 6px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

#active-effects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.active-effect-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-accent);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.82rem;
  animation: badge-in 0.3s ease;
}
.active-effect-badge.fading {
  animation: badge-out 0.3s ease forwards;
}
.effect-label { color: var(--color-text); }
.effect-timer { color: var(--color-accent); font-family: var(--font-mono); font-weight: 700; }

@keyframes badge-in {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes badge-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.8); }
}

/* ─── Game Area ─────────────────────────────────────────────────── */
#game-area {
  grid-area: game;
  position: relative;
  background: radial-gradient(ellipse at 50% 50%, rgba(94,232,125,0.03) 0%, transparent 70%),
    var(--color-bg);
  overflow: hidden;
  cursor: default;
  min-height: 400px;
}

/* Engine background canvas — drawn by main.js; sits behind all targets */
#engine-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ─── Targets ───────────────────────────────────────────────────── */
.target {
  position: absolute;
  width: 44px;
  height: 44px;
  background: radial-gradient(circle at 35% 35%, #8ef4a8, var(--color-accent));
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  cursor: pointer;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 20px var(--color-target-glow), 0 0 4px rgba(255,255,255,0.15);
  animation: target-spawn 0.2s ease-out, target-lifetime linear forwards;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  user-select: none;
  will-change: transform, opacity;
  z-index: 1;
}

.target:hover {
  transform: translate(-50%, -50%) scale(1.18);
  box-shadow: 0 0 32px var(--color-target-glow), 0 0 8px rgba(255,255,255,0.3);
}

/* Shrink and fade during lifetime */
@keyframes target-lifetime {
  0%   { opacity: 1; }
  70%  { opacity: 0.9; }
  100% { opacity: 0.1; transform: translate(-50%, -50%) scale(0.7); }
}

@keyframes target-spawn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.target.clicked {
  animation: target-click 0.2s ease forwards;
  pointer-events: none;
}
@keyframes target-click {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.4); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

.target.expired {
  animation: target-expire 0.4s ease forwards;
  pointer-events: none;
}
@keyframes target-expire {
  0%   { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); filter: grayscale(1); }
}

/* ─── Floating Reward Text ──────────────────────────────────────── */
.floating-reward {
  position: absolute;
  color: var(--color-reward);
  font-weight: 700;
  font-size: 1rem;
  font-family: var(--font-mono);
  pointer-events: none;
  transform: translate(-50%, -100%);
  animation: float-up 1s ease forwards;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.7);
  z-index: 10;
  white-space: nowrap;
}
@keyframes float-up {
  0%   { opacity: 1; transform: translate(-50%, -100%); }
  80%  { opacity: 0.9; }
  100% { opacity: 0; transform: translate(-50%, -260%); }
}

/* ─── Hint Message ──────────────────────────────────────────────── */
.hint-message {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-text-muted);
  font-size: 0.88rem;
  pointer-events: none;
  transition: opacity 1s ease;
  z-index: 5;
}
.hint-message.fade-out { opacity: 0; }

/* ─── Sidebar ───────────────────────────────────────────────────── */
#sidebar {
  grid-area: sidebar;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-section:last-child { border-bottom: none; }

.section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
}

/* ─── Upgrade Buttons ───────────────────────────────────────────── */
.upgrade-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  font-family: var(--font-main);
  font-size: 0.82rem;
}
.upgrade-btn:last-child { margin-bottom: 0; }

.upgrade-btn:hover:not(:disabled) {
  border-color: var(--color-accent);
  background: rgba(94, 232, 125, 0.08);
  transform: translateY(-1px);
}
.upgrade-btn:active:not(:disabled) {
  transform: translateY(0);
}
.upgrade-btn.affordable {
  border-color: rgba(94, 232, 125, 0.5);
}
.upgrade-btn.maxed {
  opacity: 0.45;
  cursor: default;
}
.upgrade-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.upgrade-btn.active-substance {
  border-color: var(--color-accent);
  background: rgba(94, 232, 125, 0.1);
}
.upgrade-btn.alcohol-only {
  border-color: var(--color-alcohol);
}
.upgrade-btn.alcohol-only:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.12);
}

.upgrade-name {
  grid-column: 1;
  grid-row: 1;
  font-weight: 600;
  font-size: 0.85rem;
}
.upgrade-desc {
  grid-column: 1 / 3;
  grid-row: 2;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}
.upgrade-cost {
  grid-column: 2;
  grid-row: 1;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.upgrade-level {
  display: none;
}
.upgrade-btn.affordable .upgrade-cost {
  color: var(--color-accent);
}

/* Stats small text */
#stats-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

/* ─── Fact Popup Overlay ─────────────────────────────────────────── */
.fact-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: overlay-in 0.3s ease;
}
@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fact-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 0 48px rgba(94, 232, 125, 0.25), var(--shadow);
  animation: modal-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.8) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.fact-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 18px;
  text-align: center;
}

.fact-body {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 22px;
  padding: 14px 16px;
  background: var(--color-surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  font-style: italic;
}

.fact-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fact-note {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

#fact-close-btn {
  background: var(--color-accent);
  border: none;
  color: var(--color-bg);
  padding: 8px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  transition: background 0.2s, opacity 0.2s;
  font-family: var(--font-main);
}
#fact-close-btn:disabled {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}
#fact-close-btn:not(:disabled):hover {
  background: var(--color-accent-dim);
  color: #fff;
}

/* ─── Wear Off Message ───────────────────────────────────────────── */
.wear-off-message {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 0.88rem;
  color: var(--color-text);
  z-index: 500;
  max-width: 500px;
  text-align: center;
  animation: wear-off-anim 4s ease forwards;
  box-shadow: 0 0 20px rgba(255, 68, 102, 0.3);
}
@keyframes wear-off-anim {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

/* ─── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-accent-dim); }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 700px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "effects"
      "game"
      "sidebar";
  }
  #sidebar {
    border-left: none;
    border-top: 1px solid var(--color-border);
  }
  #game-area { min-height: 300px; }
}
