/* ============================================================
   AIOS Brain Graph V2 — style.css
   FVM Studio — brain.fvm-studio.com
   ============================================================ */

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

:root {
  --bg:          #030508;
  --bg-panel:    rgba(6, 10, 18, 0.88);
  --bg-overlay:  rgba(0, 0, 0, 0.55);
  --border:      rgba(255, 255, 255, 0.07);
  --border-hover:rgba(255, 255, 255, 0.18);
  --text:        #c8d0e0;
  --text-dim:    #6a7488;
  --text-bright: #e8eaf0;
  --accent:      #E54666;
  --glow-soft:   rgba(229, 70, 102, 0.15);

  --font-mono:   'JetBrains Mono', 'Fira Mono', 'Consolas', monospace;
  --font-sans:   'Inter', 'Helvetica Neue', sans-serif;

  --radius-sm:   4px;
  --radius:      8px;
  --radius-lg:   12px;
  --transition:  all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Canvas / Graph ---------------------------------------- */
#graph-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#graph-container canvas {
  display: block;
  outline: none;
}

/* --- Vignette ----------------------------------------------- */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%,
    transparent 38%,
    rgba(0, 0, 0, 0.45) 72%,
    rgba(0, 0, 0, 0.82) 100%
  );
}

/* --- Header bar -------------------------------------------- */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(3,5,8,0.92), transparent);
  pointer-events: none;
}

#header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

#header-logo svg { width: 22px; height: 22px; }

#header-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
}

#header-title span {
  color: var(--accent);
}

/* --- Controls ---------------------------------------------- */
#controls {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 40px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 32px rgba(0,0,0,0.6);
}

.ctrl-btn {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 24px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text-bright);
}

.ctrl-btn:active {
  background: rgba(255,255,255,0.12);
  transform: scale(0.96);
}

.ctrl-btn svg {
  width: 13px; height: 13px;
  flex-shrink: 0;
}

.ctrl-sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 2px;
}

/* --- Region Legend ------------------------------------------ */
#legend {
  position: fixed;
  top: 60px; left: 20px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  opacity: 0.7;
}

.legend-item:hover { opacity: 1; background: rgba(255,255,255,0.05); }
.legend-item.active { opacity: 1; }

.legend-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  filter: blur(0.4px);
  box-shadow: 0 0 5px currentColor;
}

.legend-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

/* --- Detail Sidebar ----------------------------------------- */
#sidebar {
  position: fixed;
  top: 0; right: 0;
  width: 300px;
  height: 100vh;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

#sidebar.open {
  transform: translateX(0);
}

#sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sidebar-close {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  float: right;
  padding: 0;
  transition: var(--transition);
  line-height: 1;
}
#sidebar-close:hover { color: var(--text-bright); }
#sidebar-close svg { width: 16px; height: 16px; }

#sidebar-region-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

#sidebar-region-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

#sidebar-name {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

#sidebar-type-tag {
  margin-top: 6px;
  display: inline-block;
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

#sidebar-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

#sidebar-body::-webkit-scrollbar { width: 3px; }
#sidebar-body::-webkit-scrollbar-track { background: transparent; }
#sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.sidebar-section { margin-bottom: 20px; }

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.sidebar-section-content {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}

.sidebar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sidebar-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 6px;
  letter-spacing: 0.05em;
}

.sidebar-file {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  word-break: break-all;
  line-height: 1.5;
}

#sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#sidebar-obsidian-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-hover);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

#sidebar-obsidian-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.28);
  color: var(--text-bright);
}

#sidebar-obsidian-btn svg { width: 13px; height: 13px; }

/* --- Tooltip ----------------------------------------------- */
#tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  padding: 7px 11px;
  background: var(--bg-panel);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: 220px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

#tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

#tooltip-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 2px;
}

#tooltip-region {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

/* --- Loading screen ---------------------------------------- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
  transition: opacity 0.6s ease;
}

#loading.done { opacity: 0; pointer-events: none; }

#loading-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: pulse 1.6s ease-in-out infinite;
}

#loading-bar-wrap {
  width: 160px;
  height: 1px;
  background: rgba(255,255,255,0.06);
  border-radius: 1px;
  overflow: hidden;
}

#loading-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--accent);
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* --- Stats overlay ------------------------------------------ */
#stats {
  position: fixed;
  bottom: 72px; left: 20px;
  z-index: 10;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  pointer-events: none;
  line-height: 1.8;
  opacity: 0.6;
}

/* --- Utility ------------------------------------------------ */
.hidden { display: none !important; }
