/* ==========================================================================
   DESIGN TOKENS & CSS VARIABLES
   ========================================================================== */
:root {
  /* Color Palette - Ink Noir Minimalist */
  --bg-dark: #030305;      /* Absolute black */
  --bg-onyx: #08080c;      /* Dark smoke */
  --text-primary: #f5f5f7;  /* Ivory off-white */
  --text-muted: #a1a1aa;    /* Ash gray (increased contrast for WCAG 2.1 compliance) */
  --text-dark: #08080c;
  
  /* Node Specific Accent Colors (Highly desaturated, elegant ink washes) */
  --color-you: #f5f5f7;
  --color-github: #cbd5e1;    /* Slate ink */
  --color-space: #e2e8f0;     /* Mist ink */
  --color-bikku: #fed7aa;     /* Warm sand */
  --color-bitacora: #d1fae5;  /* Sage ink */
  --color-pinterest: #fee2e2; /* Ash rose */
  --color-itch: #f3e8ff;      /* Lavender mist */
  
  /* Translucent overlays & lines */
  --line-color: rgba(245, 245, 247, 0.18);
  --line-active-glow: rgba(245, 245, 247, 0.2);
  --glass-bg: rgba(8, 8, 12, 0.75);
  --glass-border: rgba(245, 245, 247, 0.05);
  --glass-border-hover: rgba(245, 245, 247, 0.12);
  
  /* Fonts */
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-tech: 'Space Grotesk', monospace;
  
  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-medium: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-slow: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100%;
  width: 100%;
}

body {
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Screen reader only helper */
.sr-only-focusable {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.sr-only-focusable:focus {
  z-index: 9999;
  width: auto;
  height: auto;
  clip: auto;
  padding: 1rem;
  background: var(--bg-onyx);
  color: var(--text-primary);
  outline: 2px solid var(--text-primary);
}

/* ==========================================================================
   AMBIENT BACKGROUND EFFECTS (Ink Noir vignette and film grain)
   ========================================================================== */
#ambient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Vignette: warm/cool white spotlight in center, fading to absolute black at edges */
  background: radial-gradient(circle at 50% 50%, rgba(245, 245, 247, 0.05) 0%, rgba(3, 3, 5, 0.6) 50%, rgba(3, 3, 5, 1) 100%);
  pointer-events: none;
  z-index: 1;
}

#ambient-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Procedural film grain via SVG fractal noise */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 250 250' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  opacity: 0.035; /* Subtle noise density */
  pointer-events: none;
  mix-blend-mode: overlay;
}

#particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.6;
}

/* ==========================================================================
   APP LAYOUT & CONTAINERS
   ========================================================================== */
.app-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
}

.scene-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.scene-container.active {
  opacity: 1;
  pointer-events: all;
}

.scene-container.hidden {
  display: none !important;
}

/* ==========================================================================
   AUDIO CONTROLS (MUTE)
   ========================================================================== */
.audio-toggle-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.audio-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
  transform: scale(1.05);
}

.audio-toggle-btn:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 4px;
}

.audio-toggle-btn.unmuted {
  color: var(--text-primary);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   PHASE 1: INTRODUCTION STYLES
   ========================================================================== */
.intro-content {
  max-width: 600px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  text-align: center;
  padding: 2rem;
}

.intro-text-wrapper {
  min-height: 120px; /* Prevent layout shift during typing */
  display: flex;
  align-items: center;
  justify-content: center;
}

.typewriter-text {
  font-family: var(--font-body);
  font-size: 1.25rem;
  line-height: 1.8;
  font-weight: 300;
  color: var(--text-muted);
}

.typewriter-text strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* Emerge animation for typewriter lines (drawing from the void) */
.typewriter-line {
  margin-bottom: 1.5rem;
  opacity: 0;
  filter: blur(4px);
  animation: emerge-text 0.8s forwards cubic-bezier(0.25, 0.8, 0.25, 1);
}

.typewriter-line:first-child {
  font-size: 1.7rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

@keyframes emerge-text {
  to {
    opacity: 1;
    filter: blur(0);
  }
}

.typewriter-cursor::after {
  content: '|';
  color: var(--text-primary);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  from, to { color: transparent }
  50% { color: var(--text-primary); }
}

/* Premium Button Styling */
.btn-primary {
  position: relative;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  font-family: var(--font-tech);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 1rem 2.25rem;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition-medium);
  opacity: 1;
  transform: translateY(0);
}

.btn-primary.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.btn-primary:hover {
  border-color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.2em;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 4px;
}

/* ==========================================================================
   PHASE 2 & 3: CONSTELLATION STYLES
   ========================================================================== */
#connections-svg,
.connections-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.connections-layer line {
  stroke: var(--line-color);
  stroke-width: 1.5px;
  transition: stroke var(--transition-medium), stroke-width var(--transition-medium);
}

.connections-layer line.active {
  stroke: var(--line-active-glow);
  stroke-width: 2px;
}

/* Glowing connections */
.constellation-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw-line 2s forwards ease-out;
}

@keyframes draw-line {
  to {
    stroke-dashoffset: 0;
  }
}

.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none; /* Let background events pass through, individual nodes override this */
}

.constellation-node {
  position: absolute;
  pointer-events: all;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  outline: none;
  
  /* Anticipation hover state for undiscovered nodes */
  opacity: 0.04;
  transition: opacity var(--transition-slow), transform var(--transition-medium);

  /* RESETEO AGRESIVO DE BOTÓN HTML */
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  outline: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
}

.constellation-node:hover {
  opacity: 0.15;
}

.constellation-node.discovered {
  opacity: 1;
}

.constellation-node.discovered:hover {
  opacity: 1;
}

/* Node Outer Pulse and Inner Dot */
.node-orb {
  position: relative;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 2px solid var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all var(--transition-medium);
}

.node-orb::after {
  content: '';
  position: absolute;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition-medium);
}

/* Pulsing rings around YOU node */
.node-orb.you-node {
  width: 1.5rem;
  height: 1.5rem;
  border-color: var(--color-you);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.node-orb.you-node::after {
  background: var(--color-you);
  width: 0.5rem;
  height: 0.5rem;
}

/* Base node text label */
.node-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-tech);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 0.5rem;
  transition: all var(--transition-medium);
  white-space: nowrap;
}

/* Node state modifiers */
.constellation-node.discovered .node-orb {
  border-color: var(--text-primary);
}

.constellation-node.discovered .node-orb::after {
  background: var(--text-primary);
}

.constellation-node.discovered .node-label {
  color: var(--text-primary);
}

/* Dynamic colors based on configuration */
.constellation-node.active-portal .node-orb {
  border-color: var(--node-accent-color);
  /* Subtly desaturated ink-wash glow */
  box-shadow: 0 0 20px rgba(245, 245, 247, 0.08), 0 0 40px rgba(245, 245, 247, 0.03);
}

.constellation-node.active-portal .node-orb::after {
  background: var(--node-accent-color);
}

.constellation-node.active-portal .node-label {
  color: var(--text-primary);
  font-weight: 500;
  text-shadow: 0 0 8px rgba(245, 245, 247, 0.15);
}

/* Selected state (Ink drop expansion) */
.constellation-node.selected .node-orb {
  transform: scale(1.2);
  border-color: var(--node-accent-color, var(--text-primary));
  border-width: 3px;
  box-shadow: 0 0 30px var(--node-accent-glow, rgba(245, 245, 247, 0.3)), 0 0 60px var(--node-accent-glow, rgba(245, 245, 247, 0.1));
  animation: pulse-selected 2s infinite alternate ease-in-out;
}

.constellation-node.selected .node-label {
  color: var(--text-primary);
  font-weight: 500;
}

@keyframes pulse-selected {
  from {
    box-shadow: 0 0 20px var(--node-accent-glow, rgba(245, 245, 247, 0.2)), 0 0 40px var(--node-accent-glow, rgba(245, 245, 247, 0.05));
    transform: scale(1.15);
  }
  to {
    box-shadow: 0 0 35px var(--node-accent-glow, rgba(245, 245, 247, 0.4)), 0 0 70px var(--node-accent-glow, rgba(245, 245, 247, 0.15));
    transform: scale(1.25);
  }
}

/* Hover effects for discovered nodes (Ink bleed spread) */
.constellation-node.discovered:hover .node-orb {
  transform: scale(1.15);
  border-color: var(--text-primary);
  /* Expanded ink bleed shadow: wide blur, low opacity white/gray */
  box-shadow: 0 0 25px rgba(245, 245, 247, 0.12), 0 0 50px rgba(245, 245, 247, 0.04);
}

.constellation-node.discovered:hover .node-orb::after {
  background: var(--node-accent-color, var(--text-primary));
}

.constellation-node.discovered:hover .node-label {
  color: var(--text-primary);
  transform: translateX(-50%) translateY(2px);
}

/* Custom interactive keyboard focus */
.constellation-node:focus-visible .node-orb {
  outline: 2px solid var(--text-primary);
  outline-offset: 4px;
}

/* ==========================================================================
   INFO & CARD PANEL
   ========================================================================== */
.info-panel {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 1.25rem 1.75rem;
  border-radius: 8px;
  max-width: 420px;
  width: 90%;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all var(--transition-medium);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Close button for Info Panel */
.info-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent !important;
  border: none !important;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), transform var(--transition-fast);
  border-radius: 50%;
  z-index: 21;
}

.info-close-btn:hover {
  color: var(--text-primary);
  transform: scale(1.1);
}

.info-close-btn:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.info-panel.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.info-title {
  font-family: var(--font-tech);
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--node-accent-color, var(--text-primary));
  padding-right: 1.5rem;
}

.info-desc {
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.info-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: var(--text-primary);
  background: rgba(8, 8, 12, 0.3);
  border: 1px solid var(--node-accent-color, var(--text-primary));
  font-family: var(--font-tech);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  margin-top: 0.5rem;
  transition: all var(--transition-fast);
}

.info-link-btn:hover {
  background: var(--node-accent-glow, rgba(245, 245, 247, 0.1));
  color: var(--text-primary);
  box-shadow: 0 0 15px var(--node-accent-glow, rgba(245, 245, 247, 0.2));
  border-color: var(--node-accent-color, var(--text-primary));
}

.info-link-btn:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 4px;
}

/* ==========================================================================
   FINAL MESSAGE OVERLAY
   ========================================================================== */
.final-message-layer {
  position: absolute;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  transition: opacity var(--transition-slow);
}

.final-message-layer.hidden {
  opacity: 0;
}

.final-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  animation: fade-glow 3s infinite alternate ease-in-out;
}

@keyframes fade-glow {
  from {
    text-shadow: 0 0 5px rgba(255, 255, 255, 0);
    opacity: 0.7;
  }
  to {
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    opacity: 1;
  }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  .intro-content {
    gap: 2rem;
  }
  
  .typewriter-text {
    font-size: 1.15rem;
  }
  
  .info-panel {
    bottom: 1rem;
    padding: 1rem 1.25rem;
  }
  
  .node-orb {
    width: 1.1rem;
    height: 1.1rem;
  }
  
  .node-orb.you-node {
    width: 1.35rem;
    height: 1.35rem;
  }
  
  .node-label {
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   MOUSE PARTICLE DUST/ASH TRAIL
   ========================================================================== */
.mouse-particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(245, 245, 247, 0.35);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: drift 3.2s forwards cubic-bezier(0.1, 0.8, 0.25, 1);
  z-index: 3;
}

@keyframes drift {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  15% {
    opacity: 0.45;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.25;
    transform: translate(calc(-50% + var(--dx) * 0.7), calc(-50% + var(--dy) * 0.4)) scale(0.8);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2);
  }
}
