/* styles.css — Morpheus Building Diorama
 * Layout principal + agents + HUD + panel
 * (les effets CSS vivants sont dans effects.css — Rick, 2026-02-28)
 */

/* ── Reset minimal ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }

/* ── Variables globales ──────────────────────────────────── */
:root {
  --bg:     #09090b;
  --text:   #fafafa;
  --muted:  rgba(255, 255, 255, 0.42);
  --border: rgba(255, 255, 255, 0.05);
  --radius: 10px;
  font-family: 'Inter', system-ui, sans-serif;
  letter-spacing: -0.04em;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Backdrop (canvas city night) ────────────────────────── */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.45;
  pointer-events: none;
}

/* ── Building — conteneur principal ─────────────────────── */
#building {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;   /* app.js insère penthouse en 1er → apparaît en haut */
  z-index: 1;
}

/* ── Floor strip ─────────────────────────────────────────── */
.floor {
  flex: 1;
  display: flex;
  align-items: stretch;
  position: relative;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

/* Teinture couleur par étage via ::before (z-index négatif) */
.floor::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--floor-color) 0%,
    transparent 65%
  );
  opacity: 0.09;
  pointer-events: none;
  z-index: 0;
}

/* Étage penthouse — pas de border-bottom, border-top à la place */
.floor[data-id="penthouse"] {
  border-bottom: none;
  border-top: 1px solid var(--border);
}

/* ── Floor label (colonne gauche) ────────────────────────── */
.floor-label {
  position: relative;
  z-index: 1;
  width: 156px;
  min-width: 156px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  font-size: 8.5px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  letter-spacing: 0.09em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  user-select: none;
  /* Accent gauche coloré */
  border-left: 2px solid var(--accent-color);
}

/* ── Floor area (zone de déambulation) ───────────────────── */
.floor-area {
  position: relative;
  z-index: 1;
  flex: 1;
}

/* ── Agent circle ─────────────────────────────────────────── */
.agent {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  /* Centre sur les coordonnées left/top */
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  letter-spacing: 0;
  color: var(--agent-color);
  background: rgba(9, 9, 11, 0.82);
  border: 1.5px solid var(--agent-color);
  box-shadow: 0 0 7px var(--agent-glow);
  cursor: pointer;
  /* Transition douce des positions (le "mouvement" visible) */
  transition:
    left       0.32s cubic-bezier(0.4, 0, 0.2, 1),
    top        0.32s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.25s ease;
  will-change: left, top;
  z-index: 10;
  user-select: none;
}

.agent:hover {
  box-shadow: 0 0 14px var(--agent-glow), 0 0 28px var(--agent-glow);
  z-index: 20;
}

/* ── Agent states ─────────────────────────────────────────── */
.agent[data-state="working"] {
  animation: agent-pulse 1.4s ease-in-out infinite;
}

.agent[data-state="reacting"] {
  animation: agent-flash 0.45s ease-out;
}

.agent[data-state="walking"] {
  opacity: 0.88;
}

@keyframes agent-pulse {
  0%,100% { box-shadow: 0 0 7px var(--agent-glow); }
  50%     { box-shadow: 0 0 18px var(--agent-glow), 0 0 36px var(--agent-glow); }
}

@keyframes agent-flash {
  0%   { box-shadow: 0 0 30px var(--agent-glow), 0 0 60px var(--agent-glow); opacity: 1; }
  100% { box-shadow: 0 0 7px  var(--agent-glow); opacity: 0.88; }
}

/* ── HUD — coin supérieur droit ──────────────────────────── */
#hud {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

#ws-badge {
  font-size: 9.5px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.07em;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(12px);
  color: var(--muted);
  transition: color 0.3s, border-color 0.3s;
}

#ws-badge[data-status="connected"]    { color: #00ff88; border-color: rgba(0, 255, 136, 0.28); }
#ws-badge[data-status="demo"]         { color: #ffd700; border-color: rgba(255, 215, 0,   0.28); }
#ws-badge[data-status="disconnected"] { color: var(--muted); }

#hud-clock {
  font-size: 10.5px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* ── Agent panel — coin inférieur gauche ─────────────────── */
#agent-panel {
  position: fixed;
  bottom: 22px;
  left: 22px;
  width: 272px;
  background: rgba(9, 9, 11, 0.93);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  z-index: 100;
  /* Hidden par défaut */
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#agent-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#panel-close {
  position: absolute;
  top: 11px;
  right: 11px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 6px;
  line-height: 1;
  border-radius: 4px;
}
#panel-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

#panel-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
  padding-right: 24px;
}

#panel-role {
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

#panel-state-wrap { margin-bottom: 10px; }

#panel-state {
  display: inline-block;
  font-size: 8.5px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.1em;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid currentColor;
  transition: color 0.2s;
}

#panel-state[data-state="idle"]     { color: var(--muted); }
#panel-state[data-state="walking"]  { color: #4488ff; }
#panel-state[data-state="working"]  { color: #00ff88; }
#panel-state[data-state="reacting"] { color: #ff8c00; }

#panel-floor {
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

#panel-catchphrase {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.68);
  font-style: italic;
  line-height: 1.55;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ── FPS counter — coin inférieur droit ──────────────────── */
#fps {
  position: fixed;
  bottom: 14px;
  right: 16px;
  font-size: 9.5px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  z-index: 100;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .agent { transition: none !important; }
  .agent[data-state="working"],
  .agent[data-state="reacting"] { animation: none !important; }
  #agent-panel { transition: none !important; }
}
