/* -------------------------------------------------------------
 * Drafting Blueprint & Square Box Design System (Gray Slate)
 * ------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;800&family=Space+Mono:wght@400;700&display=swap');

:root {
  /* Blueprint Colors */
  --bg-slate: #0b0c0f;
  --bg-baseplate: #07080a;
  --bg-hud: rgba(10, 11, 14, 0.85);
  --bg-hud-hover: rgba(15, 16, 20, 0.95);
  
  --border-steel: rgba(255, 255, 255, 0.08);
  --border-steel-hover: rgba(255, 255, 255, 0.2);
  --border-blueprint-major: rgba(255, 255, 255, 0.025);
  --border-blueprint-minor: rgba(255, 255, 255, 0.008);
  
  --text-main: #d1d5db;
  --text-muted: #6b7280;
  --text-white: #ffffff;
  
  /* Gray themed accents & glows (strictly square/slate) */
  --accent-slate-gray: #8e95a0;
  --accent-gray-glow: rgba(142, 149, 160, 0.15);
  --accent-iron: #e5e7eb;
  
  /* Fonts */
  --font-sans: 'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'Space Mono', monospace;
  
  /* Transitions */
  --transition-fast: all 0.15s ease;
  --transition-normal: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(135deg, #040507, #0f1115, #06070a, #0b0c10);
  background-size: 400% 400%;
  animation: bgGradientShift 18s ease infinite;
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

@keyframes bgGradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Blueprint / Baseplate Grid Background */
.blueprint-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: 
    linear-gradient(var(--border-blueprint-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-blueprint-major) 1px, transparent 1px),
    linear-gradient(var(--border-blueprint-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-blueprint-minor) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  background-position: center;
  z-index: 0;
  pointer-events: none;
}

/* -------------------------------------------------------------
 * Viewport Layer
 * ------------------------------------------------------------- */
.network-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  overflow: hidden;
  cursor: grab;
}

.network-viewport:active {
  cursor: grabbing;
}

.network-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.network-space {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  z-index: 2;
  transform-origin: 0 0;
  pointer-events: none;
}

/* -------------------------------------------------------------
 * Floating HUD Panels (Square box themed)
 * ------------------------------------------------------------- */
.hud-panel {
  position: absolute;
  background: var(--bg-hud);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-steel);
  border-radius: 0 !important; /* STRICTLY SQUARE */
  padding: 1.1rem;
  z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.hud-panel:hover {
  background: var(--bg-hud-hover);
  border-color: var(--border-steel-hover);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
}

/* Top-Left Console HUD */
.console-hud {
  top: 1.5rem;
  left: 1.5rem;
  width: 330px;
  height: auto;
  max-height: 380px;
}

.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.hud-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-slate-gray);
}

.chatbox-status {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-radius: 0 !important; /* STRICTLY SQUARE */
}

.chatbox-status.connected {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-white);
}

.chatbox-body {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.25rem;
  margin-bottom: 0.75rem;
}

.chat-line {
  line-height: 1.4;
  word-break: break-all;
  white-space: pre-wrap;
}

.chat-line.system { color: #6e7682; }
.chat-line.peer { color: #a1a8b8; }
.chat-line.success { color: #93c5fd; } /* Blue/cyan slate copy success */
.chat-line.info { color: #cbd5e1; }

.terminal-link {
  color: var(--text-white);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  transition: var(--transition-fast);
}

.terminal-link:hover {
  color: var(--accent-slate-gray);
}

.hud-telemetry {
  display: flex;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 0.5rem;
  gap: 0.5rem;
  justify-content: space-between;
}

/* Bottom-Left Action HUD (Copy button) */
.action-hud {
  bottom: 1.5rem;
  left: 1.5rem;
  width: 200px;
  padding: 0;
  overflow: hidden;
}

.action-btn {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.9rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-normal);
  color: var(--text-main);
  border-radius: 0 !important; /* STRICTLY SQUARE */
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.action-title {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.btn-primary-text {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-white);
}

.btn-sub-text {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.action-icon {
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.action-btn:hover .action-icon {
  color: var(--text-white);
  transform: scale(1.1);
}

/* Bottom-Right Zoom Controls */
.network-controls {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-hud);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-steel);
  border-radius: 0 !important; /* STRICTLY SQUARE */
  padding: 0.35rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.ctrl-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0 !important; /* STRICTLY SQUARE */
  color: var(--text-white);
  padding: 0.15rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.ctrl-btn:hover {
  background: var(--text-white);
  color: var(--bg-baseplate);
  border-color: var(--text-white);
}

/* -------------------------------------------------------------
 * Square Node Styles
 * ------------------------------------------------------------- */
.network-node {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0 !important; /* STRICTLY SQUARE */
  cursor: grab;
  z-index: 5;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, opacity 0.3s ease;
  user-select: none;
  transform: translate(-50%, -50%);
}

.network-node:hover {
  transform: translate(-50%, -50%) scale(1.06);
}

.network-node.dragging {
  cursor: grabbing;
  z-index: 100;
}

.node-avatar-box {
  width: 100%;
  height: 100%;
  border-radius: 0 !important; /* STRICTLY SQUARE */
  padding: 2px;
  background: #2b2e35;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: var(--transition-fast);
}

.network-node:hover .node-avatar-box {
  border-color: var(--text-white);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

.node-avatar {
  width: 100%;
  height: 100%;
  border-radius: 0 !important; /* STRICTLY SQUARE */
  object-fit: cover;
  background-color: var(--bg-slate);
}

.node-label {
  position: absolute;
  bottom: -22px;
  white-space: nowrap;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-white);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.node-desc {
  position: absolute;
  bottom: -32px;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* 1. Host Node */
.host-node {
  width: 76px;
  height: 76px;
}

.host-node .node-avatar-box {
  background: linear-gradient(135deg, var(--text-white), #4b5563);
  padding: 3px;
  border: 1px solid var(--text-white);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.08);
}

.host-node:hover .node-avatar-box {
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.2);
}

/* 2. Category Nodes (Interests, Donations, Friends) */
.category-node {
  width: 58px;
  height: 58px;
}

.node-icon-box {
  width: 100%;
  height: 100%;
  border-radius: 0 !important; /* STRICTLY SQUARE */
  background: rgba(35, 38, 43, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transition: var(--transition-fast);
}

.category-node:hover .node-icon-box {
  border-color: var(--text-white);
  background: rgba(50, 54, 61, 0.95);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.15);
}

/* 3. Friend Nodes */
.friend-node {
  width: 54px;
  height: 54px;
}

.friend-node .node-avatar-box {
  background: #23252a;
  border-color: rgba(255, 255, 255, 0.08);
}

.friend-node:hover .node-avatar-box {
  border-color: var(--accent-slate-gray);
  box-shadow: 0 0 12px rgba(142, 149, 160, 0.35);
}

/* 4. Interest Nodes */
.interest-node {
  width: 46px;
  height: 46px;
}

.node-badge {
  width: 100%;
  height: 100%;
  border-radius: 0 !important; /* STRICTLY SQUARE */
  background: rgba(32, 35, 41, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: var(--transition-fast);
}

.interest-node:hover .node-badge {
  background: #31353f;
  border-color: var(--text-white);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* 5. Crypto/Donation Nodes (Slate square boxes) */
.crypto-node {
  width: 50px;
  height: 50px;
}

.crypto-icon-box {
  width: 100%;
  height: 100%;
  border-radius: 0 !important; /* STRICTLY SQUARE */
  background: #1d1e22;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.72rem;
  color: var(--text-muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transition: var(--transition-fast);
}

.crypto-node:hover .crypto-icon-box {
  background: #2b2c33;
  color: var(--text-white);
  border-color: var(--accent-slate-gray);
  box-shadow: 0 0 12px rgba(142, 149, 160, 0.3);
}

.node-icon-box svg, .node-badge svg {
  display: block;
  stroke: currentColor;
}

/* -------------------------------------------------------------
 * Custom Scrollbars & Helpers
 * ------------------------------------------------------------- */
.font-mono {
  font-family: var(--font-mono);
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(0.9); }
}

.chatbox-body::-webkit-scrollbar {
  width: 4px;
}

.chatbox-body::-webkit-scrollbar-track {
  background: transparent;
}

.chatbox-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
}

.chatbox-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* -------------------------------------------------------------
 * Responsive Layout / Media Queries
 * ------------------------------------------------------------- */
@media (max-width: 640px) {
  .console-hud {
    width: calc(100% - 3rem);
    max-height: 200px;
  }
  
  .action-hud {
    width: calc(100% - 3rem);
  }
  
  .network-controls {
    display: none; /* hide zoom controls on mobile to avoid overlapping action-hud */
  }
}
