/* ============================================= */
/* THE NETWORK - Power Structure Visualization   */
/* evil1.org/network/                            */
/* ============================================= */

:root {
  --bg: #0d0d0f;
  --surface: #141418;
  --surface-2: #1a1a1f;
  --border: #2a2a2e;
  --text: #ccc;
  --dim: #888;
  --accent: #d4a843;
  --accent-dim: rgba(212, 168, 67, 0.3);
  --pink: #ff3399;
  --blue: #4a9eff;
  --green: #2ecc71;
  --purple: #9b59b6;
  --neutral: #666;
  --panel-width: 360px;
  --header-height: 48px;
  --controls-height: 52px;
  --timeline-height: 80px;
}

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

body {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================= */
/* COMPONENT: Platform Header    */
/* ============================= */

.net-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.net-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  width: 100%;
}

.net-logo {
  font-size: 14px;
  font-weight: 700;
  color: var(--pink);
  letter-spacing: 1px;
}
.net-logo:hover { text-decoration: none; color: #fff; }

.net-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
}

.net-subtitle {
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* ============================= */
/* COMPONENT: Controls Bar       */
/* ============================= */

.net-controls {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  height: var(--controls-height);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.net-controls-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  width: 100%;
}

/* Filter buttons */
.net-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.net-filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  padding: 4px 12px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.net-filter-btn:hover {
  border-color: var(--cat-color, var(--dim));
  color: var(--cat-color, #fff);
}

.net-filter-btn.active {
  background: var(--cat-color, var(--accent));
  border-color: var(--cat-color, var(--accent));
  color: #000;
  font-weight: 600;
}

/* Search */
.net-search-wrap {
  position: relative;
  margin-left: auto;
}

.net-search {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 16px;
  font-family: inherit;
  font-size: 12px;
  width: 200px;
  outline: none;
  transition: border-color 0.15s;
}

.net-search:focus {
  border-color: var(--accent);
}

.net-search::placeholder { color: var(--dim); }

.net-search-results {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 260px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  z-index: 200;
}

.net-search-results.visible { display: block; }

.net-search-result {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.net-search-result:last-child { border-bottom: none; }
.net-search-result:hover { background: var(--surface-2); }

.net-search-result-name { color: #fff; font-weight: 600; }
.net-search-result-type {
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 6px;
}

/* Layout toggle */
.net-layout-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 6px;
  padding: 2px;
}

.net-layout-btn {
  background: transparent;
  border: none;
  color: var(--dim);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.net-layout-btn:hover { color: #fff; }

.net-layout-btn.active {
  background: var(--accent);
  color: #000;
}

/* ============================= */
/* COMPONENT: Main Graph Area    */
/* ============================= */

.net-main {
  position: fixed;
  top: calc(var(--header-height) + var(--controls-height));
  left: 0;
  right: 0;
  bottom: var(--timeline-height);
  background: var(--bg);
}

.net-graph {
  width: 100%;
  height: 100%;
}

.net-graph svg {
  width: 100%;
  height: 100%;
}

/* ============================= */
/* COMPONENT: Tooltip            */
/* ============================= */

.net-tooltip {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  pointer-events: none;
  z-index: 300;
  max-width: 220px;
}

.net-tooltip.visible { display: block; }

.net-tooltip-name {
  color: #fff;
  font-weight: 600;
  margin-bottom: 2px;
}

.net-tooltip-type {
  color: var(--dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================= */
/* COMPONENT: Side Panel         */
/* ============================= */

.net-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 50;
  overflow-y: auto;
}

.net-panel.open { transform: translateX(0); }

.net-panel-close {
  position: sticky;
  top: 0;
  float: right;
  background: var(--surface);
  border: none;
  color: var(--dim);
  font-size: 24px;
  cursor: pointer;
  padding: 12px 16px;
  z-index: 10;
}
.net-panel-close:hover { color: #fff; }

.net-panel-content {
  padding: 16px 20px 20px;
}

.net-panel-empty {
  color: var(--dim);
  font-size: 13px;
  text-align: center;
  padding: 40px 0;
}

.net-panel-node-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.net-panel-node-category {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.net-panel-section {
  margin-bottom: 16px;
}

.net-panel-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--dim);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.net-panel-description {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

.net-panel-connection {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(42, 42, 46, 0.5);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.1s;
}
.net-panel-connection:hover { color: #fff; }

.net-panel-connection-name { font-weight: 600; }

.net-panel-connection-type {
  color: var(--dim);
  font-size: 10px;
}

.net-panel-dossier {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}
.net-panel-dossier:hover {
  background: var(--accent);
  color: #000;
  text-decoration: none;
}

/* Tolkien ring indicator */
.net-panel-tolkien {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  color: var(--accent);
  opacity: 0.8;
}

/* ============================= */
/* COMPONENT: Timeline Bar       */
/* ============================= */

.net-timeline {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--timeline-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  overflow-x: auto;
  overflow-y: hidden;
}

.net-timeline::-webkit-scrollbar { height: 4px; }
.net-timeline::-webkit-scrollbar-track { background: var(--surface); }
.net-timeline::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.net-timeline-inner {
  display: flex;
  align-items: stretch;
  height: 100%;
  min-width: max-content;
  padding: 0 20px;
  gap: 0;
}

.net-timeline-event {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 140px;
  padding: 8px 16px;
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background 0.15s;
  text-align: center;
  position: relative;
}

.net-timeline-event:hover { background: var(--surface-2); }
.net-timeline-event.active { background: var(--surface-2); }

.net-timeline-event::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.15s;
}

.net-timeline-event:hover::before,
.net-timeline-event.active::before { background: var(--accent); }

.net-timeline-year {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 8px;
}

.net-timeline-label {
  font-size: 10px;
  color: var(--dim);
  line-height: 1.3;
  max-width: 130px;
}

/* ============================= */
/* COMPONENT: Footer             */
/* ============================= */

.net-footer {
  display: none; /* Hidden when graph is active, shown on mobile */
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--dim);
}
.net-footer a { color: var(--dim); }
.net-footer-dim { color: #555; }

/* ============================= */
/* COMPONENT: Mobile Fallback    */
/* ============================= */

.net-mobile-msg {
  display: none;
}

/* ============================= */
/* D3 Graph Styles               */
/* ============================= */

.node-circle {
  cursor: pointer;
  transition: filter 0.15s;
}

.node-circle:hover { filter: brightness(1.3); }

.node-circle.selected {
  filter: drop-shadow(0 0 8px currentColor) drop-shadow(0 0 16px currentColor);
}

.node-circle.dimmed { opacity: 0.15; }

.node-label {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 10px;
  fill: var(--dim);
  pointer-events: none;
  text-anchor: middle;
}

.node-label.highlighted { fill: #fff; font-weight: 600; }
.node-label.dimmed { opacity: 0.1; }

.edge-line {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-linecap: round;
  transition: opacity 0.15s;
}

.edge-line.highlighted {
  stroke: rgba(255, 255, 255, 0.5);
}

.edge-line.dimmed { opacity: 0.03; }

.edge-label {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 9px;
  fill: var(--dim);
  opacity: 0;
  pointer-events: none;
  text-anchor: middle;
}

.edge-label.visible { opacity: 1; }

/* Tolkien ring glow on node */
.tolkien-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.4;
  animation: ring-pulse 3s ease-in-out infinite;
}

@keyframes ring-pulse {
  0%, 100% { opacity: 0.2; stroke-width: 1.5; }
  50% { opacity: 0.6; stroke-width: 3; }
}

/* ============================= */
/* RESPONSIVE                    */
/* ============================= */

@media (max-width: 768px) {
  .net-header,
  .net-controls,
  .net-main,
  .net-timeline { display: none; }

  .net-mobile-msg {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
  }

  .net-mobile-inner {
    max-width: 400px;
    text-align: center;
  }

  .net-mobile-inner h2 {
    font-size: 24px;
    color: var(--accent);
    margin-bottom: 12px;
  }

  .net-mobile-inner p {
    color: var(--text);
    margin-bottom: 8px;
    font-size: 14px;
  }

  .net-mobile-dim {
    color: var(--dim) !important;
    font-size: 12px !important;
  }

  .net-mobile-list {
    text-align: left;
    margin: 24px 0;
    max-height: 60vh;
    overflow-y: auto;
  }

  .net-mobile-node {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }

  .net-mobile-node-name { color: #fff; font-weight: 600; }
  .net-mobile-node-type { color: var(--dim); font-size: 11px; margin-left: 6px; }

  .net-mobile-back {
    display: inline-block;
    margin-top: 16px;
    color: var(--accent);
    font-size: 13px;
  }

  .net-footer {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }
}
