/* ================================================================
   HUNTFRAMEWORK — CSS
   Tema 1 (default): HuntKB dark — teal, fondo #111318
   Tema 2: body.light-Mode  — blanco, negro, teal HuntKB
   [REFERENCIA] body.matrix-Mode — verde matrix (desactivado)
   Fuente: Hack (cdn.jsdelivr.net)
   ================================================================ */

/* ---- TEMA DEFAULT: HuntKB (teal) ---- */
:root {
  --bg-primary:        #111318;
  --bg-secondary:      #1a1d24;
  --bg-legend:         #1a1d24f0;
  --text-primary:      #e2e4e9;
  --text-secondary:    #4ecdc4;
  --text-muted:        #b0b4c0;
  --text-dim:          #606470;
  --node-fill:         #111318;
  --node-stroke:       #4ecdc4;
  --node-collapsed:    #2e8b85;
  --link-stroke:       #2e3240;
  --border-color:      #2e3240;
  --header-rule:       #4ecdc4;
  --button-bg:         #1a1d24;
  --button-border:     #4ecdc4;
  --button-text:       #4ecdc4;
  --button-hover-bg:   #4ecdc4;
  --button-hover-text: #111318;
  --glow-accent:       0 0 8px #4ecdc4, 0 0 20px rgba(78,205,196,0.3);
  --glow-secondary:    0 0 6px rgba(78,205,196,0.4);
  --font-mono:         'Hack', 'Courier New', 'Lucida Console', monospace;
}

/* ---- [REFERENCIA] Matrix verde — desactivado del ciclo, disponible si se reactiva ---- */
/*
body.matrix-Mode {
  --bg-primary:        #0d0d0d;
  --bg-secondary:      #111111;
  --bg-legend:         #0d0d0df0;
  --text-primary:      #00ff41;
  --text-secondary:    #00e5ff;
  --text-muted:        #4a9e6b;
  --text-dim:          #1e5c35;
  --node-fill:         #0d0d0d;
  --node-stroke:       #00ff41;
  --node-collapsed:    #00e5ff;
  --link-stroke:       #1a4a2e;
  --border-color:      #1e5c35;
  --header-rule:       #00ff41;
  --button-bg:         #0d0d0d;
  --button-border:     #00ff41;
  --button-text:       #00ff41;
  --button-hover-bg:   #00ff41;
  --button-hover-text: #0d0d0d;
  --glow-accent:       0 0 8px #00ff41, 0 0 20px rgba(0,255,65,0.3);
  --glow-secondary:    0 0 8px #00e5ff, 0 0 20px rgba(0,229,255,0.3);
}
*/

/* ---- TEMA 2: Light — blanco, negro, teal HuntKB ---- */
body.light-Mode {
  --bg-primary:        #ffffff;
  --bg-secondary:      #f4f5f7;
  --bg-legend:         #f4f5f7f5;
  --text-primary:      #343131;
  --text-secondary:    #2e8b85;
  --text-muted:        #343131;
  --text-dim:          #8a8f9e;
  --node-fill:         #ffffff;
  --node-stroke:       #2e8b85;
  --node-collapsed:    #1a6b66;
  --link-stroke:       #9ba3b8;
  --border-color:      #d0d3dc;
  --header-rule:       #2e8b85;
  --button-bg:         #ffffff;
  --button-border:     #2e8b85;
  --button-text:       #2e8b85;
  --button-hover-bg:   #2e8b85;
  --button-hover-text: #ffffff;
  --glow-accent:       none;
  --glow-secondary:    none;
}

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

/* ---- BASE ---- */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scanlines CRT solo en tema Matrix */
body.matrix-Mode {
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 65, 0.012) 2px,
    rgba(0, 255, 65, 0.012) 4px
  );
}

/* ---- CABECERA ---- */
#header {
  font-size: 33px;
  font-weight: bold;
  text-align: center;
  padding: 26px 0 6px;
  letter-spacing: 4px;
  color: var(--text-primary);
  user-select: none;
}

.title-bracket {
  color: var(--text-secondary);
  text-shadow: var(--glow-secondary);
  transition: color 0.3s ease;
}

.title-hunt {
  color: var(--text-secondary);
  text-shadow: var(--glow-accent);
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.title-accent {
  color: var(--text-primary);
  transition: color 0.3s ease;
}

.subtitle {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 3px;
  text-align: center;
  margin-top: 4px;
  margin-bottom: 2px;
  transition: color 0.3s ease;
}

.header-rule {
  border: none;
  border-top: 1px solid var(--header-rule);
  box-shadow: 0 0 5px var(--header-rule);
  margin: 8px 40px 0;
  opacity: 0.4;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

body.light-Mode .header-rule {
  box-shadow: none;
  opacity: 0.6;
}

/* ---- LEYENDA — popover hover ---- */
/* ---- ICONO GITHUB ---- */
#github-link {
  position: fixed;
  top: 14px;
  right: 86px;
  z-index: 200;
  color: var(--button-text);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: color 0.2s ease, opacity 0.2s ease;
}

#github-link:hover {
  color: var(--text-secondary);
  opacity: 0.8;
}

.legend-trigger {
  position: fixed;
  top: 14px;
  right: 50px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.legend-icon {
  background: transparent;
  border: none;
  color: var(--button-text);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, opacity 0.2s ease;
  outline: none;
  user-select: none;
}

.legend-icon:hover {
  color: var(--text-secondary);
  opacity: 0.8;
}

.legend {
  position: absolute;
  top: 36px;
  right: 0;
  width: 215px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-legend);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  z-index: 100;
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease,
              background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  pointer-events: none;
}

.legend-trigger:hover .legend {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.legend-title {
  color: var(--text-secondary);
  font-size: 11px;
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-shadow: var(--glow-secondary);
  transition: color 0.3s ease;
}

.legend div {
  line-height: 1.75;
}

.tag {
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

/* ---- BOTÓN TOGGLE TEMA ---- */
#theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  background: transparent;
  color: var(--button-text);
  border: none;
  padding: 4px;
  cursor: pointer;
  transition: color 0.2s ease, opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  outline: none;
  z-index: 200;
}

#theme-toggle:hover {
  color: var(--text-secondary);
  opacity: 0.8;
}

#theme-toggle svg {
  display: block;
  flex-shrink: 0;
}

/* ---- ANIMACIONES ---- */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ---- CONTENEDOR D3 ---- */
#body {
  margin: 0 auto;
  position: relative;
}

/* ---- NODOS D3 ---- */
.node {
  cursor: pointer;
}

.node circle {
  fill: var(--node-fill);
  stroke: var(--node-stroke);
  stroke-width: 1.5px;
  transition: fill 0.25s ease, stroke 0.25s ease;
  filter: drop-shadow(0 0 3px var(--node-stroke));
}

body.light-Mode .node circle {
  filter: none;
}

/* Nodo colapsado */
.node circle.collapsed {
  fill: var(--node-collapsed);
  stroke: var(--node-collapsed);
  filter: drop-shadow(0 0 5px var(--node-collapsed));
}

body.light-Mode .node circle.collapsed {
  filter: none;
}

.node text {
  font-family: var(--font-mono);
  font-size: 13px;
  fill: var(--text-primary);
  transition: fill 0.2s ease;
}

.root-node text {
  font-size: 15px;
}

/* Hover */
.node:hover > text,
.node:hover a text {
  fill: var(--text-secondary);
  filter: drop-shadow(0 0 4px var(--text-secondary));
}

body.light-Mode .node:hover > text,
body.light-Mode .node:hover a text {
  filter: none;
}

/* Nodos hoja URL */
.node.url-node > a text {
  fill: var(--text-primary);
}

.node.url-node:hover > a text {
  fill: var(--text-secondary);
  text-decoration: underline;
}

/* ---- LINKS ---- */
path.link {
  fill: none;
  stroke: var(--link-stroke);
  stroke-width: 1px;
  transition: stroke 0.3s ease;
}

/* ---- NOSCRIPT ---- */
noscript p {
  text-align: center;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  margin: 80px auto 0;
  width: 80vw;
  max-width: 600px;
  padding: 28px 20px;
  font-family: var(--font-mono);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--bg-primary); }
::-webkit-scrollbar-thumb  { background: var(--text-dim); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- SELECCIÓN ---- */
::selection {
  background: var(--text-secondary);
  color: var(--bg-primary);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  #header {
    font-size: 23px;
    letter-spacing: 2px;
    padding: 16px 0 4px;
  }

  .header-rule {
    margin: 6px 16px 0;
  }
}
