/* ═══════════════════════════════════════════
   SCAN — Systematic Curation & Analysis Network
   Aesthetic: Net Art × Algorithmic Art × Terminal
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg-primary: #050508;
  --bg-secondary: #0a0a10;
  --bg-tertiary: #0f0f18;
  --bg-card: #0c0c14;
  --bg-hover: #12121e;
  --text-primary: #e0e0e8;
  --text-secondary: #8888a0;
  --text-muted: #555566;
  --border: #1a1a2e;
  --border-active: #2a2a44;
  --glow: rgba(255, 255, 255, 0.03);

  /* Domain colors */
  --neuroscience: #00f0ff;
  --ai: #ff00aa;
  --cybernetics: #ffaa00;
  --cognition: #00ff88;
  --biomimetics: #aa44ff;

  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-sans: 'Space Grotesk', system-ui, sans-serif;

  --panel-width: 480px;
  --header-height: 56px;
  --sidebar-width: 260px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ─── SCANLINE OVERLAY ─── */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 10000;
}

/* ─── LAYOUT ─── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  height: 100vh;
  width: 100vw;
}

/* ─── HEADER ─── */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  backdrop-filter: blur(20px);
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__logo-text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 6px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--neuroscience), var(--ai), var(--biomimetics));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__logo-cursor {
  display: inline-block;
  width: 2px;
  height: 18px;
  background: var(--ai);
  animation: blink 1s step-end infinite;
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

.header__subtitle {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.header__search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
  margin: 0 32px;
}

.header__search input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.header__search input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.header__search input:focus {
  border-color: var(--ai);
  box-shadow: 0 0 12px rgba(255, 0, 170, 0.15);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__stats {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 16px;
}

.header__stats span {
  color: var(--text-secondary);
}

/* ─── BUTTONS ─── */
.btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
  color: var(--text-primary);
}

.btn--accent {
  border-color: var(--ai);
  color: var(--ai);
}

.btn--accent:hover {
  background: rgba(255, 0, 170, 0.1);
  box-shadow: 0 0 12px rgba(255, 0, 170, 0.2);
}

.btn--active {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn--icon {
  padding: 6px 8px;
  font-size: 14px;
}

/* ─── SIDEBAR ─── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar__section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar__section-title {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Domain filters */
.domain-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.domain-filter:hover {
  background: var(--bg-hover);
}

.domain-filter.active {
  background: var(--bg-tertiary);
}

.domain-filter__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.domain-filter__label {
  font-size: 13px;
  flex: 1;
}

.domain-filter__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Overlap indicator */
.overlap-indicator {
  display: none;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--cognition);
  padding: 6px 10px;
  margin-top: 8px;
  background: rgba(0, 255, 136, 0.06);
  border: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: 3px;
  letter-spacing: 0.5px;
}

/* Tag cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.tag-pill:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
  background: var(--bg-hover);
}

.tag-pill.active {
  color: var(--ai);
  border-color: var(--ai);
}

/* View toggles */
.view-toggles {
  display: flex;
  gap: 4px;
}

.view-toggles .btn {
  flex: 1;
  text-align: center;
}

/* Queue section */
.queue-list {
  list-style: none;
}

.queue-item {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 2px;
}

.queue-item:hover {
  background: var(--bg-hover);
}

.queue-item__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.queue-item__title {
  font-size: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.queue-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

/* ─── MAIN AREA ─── */
.main {
  grid-area: main;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ─── GRAPH CANVAS ─── */
#graph-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#graph-container svg {
  width: 100%;
  height: 100%;
}

/* Graph nodes */
.node-group { cursor: pointer; }

.node-circle {
  stroke-width: 1.5;
  transition: r 0.2s, stroke-width 0.2s;
}

.node-group:hover .node-circle {
  stroke-width: 3;
  filter: url(#glow);
}

.node-label {
  font-family: var(--font-mono);
  font-size: 8px;
  fill: var(--text-muted);
  pointer-events: none;
  text-anchor: middle;
  opacity: 0;
  transition: opacity 0.2s;
}

.node-group:hover .node-label {
  opacity: 1;
  fill: var(--text-primary);
}

.node-group.selected .node-label {
  opacity: 1;
  fill: var(--text-primary);
  font-size: 9px;
  font-weight: 600;
}

.node-group.selected .node-circle {
  stroke-width: 3;
  filter: url(#glow);
}

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

.node-group.highlighted .node-circle {
  stroke-width: 2.5;
}

.graph-link {
  stroke-linecap: round;
}

.graph-link.dimmed {
  opacity: 0.03;
}

/* ─── LIST VIEW ─── */
#list-container {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#list-container.active {
  display: block;
}

.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

.paper-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.paper-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  transition: width 0.2s;
}

.paper-card:hover {
  border-color: var(--border-active);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.paper-card:hover::before {
  width: 4px;
}

.paper-card__domains {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.paper-card__domain-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: 0 0 4px currentColor;
}

.paper-card__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-card__authors {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-card__abstract {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.paper-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.paper-card__tag {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 2px;
  color: var(--text-muted);
}

.paper-card__actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.paper-card:hover .paper-card__actions {
  opacity: 1;
}

/* ─── DETAIL PANEL ─── */
.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-panel.open {
  transform: translateX(0);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
}

.detail-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.detail-panel__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  transition: color 0.15s;
}

.detail-panel__close:hover { color: var(--text-primary); }

.detail-panel__actions {
  display: flex;
  gap: 6px;
}

.detail-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.detail-panel__domain-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-panel__domain-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 2px;
  border: 1px solid;
}

.detail-panel__title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 12px;
}

.detail-panel__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-panel__meta a {
  color: var(--ai);
  text-decoration: none;
}

.detail-panel__meta a:hover {
  text-decoration: underline;
}

.detail-panel__authors {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.detail-panel__section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 20px;
}

.detail-panel__abstract {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.detail-panel__abstract::selection {
  background: rgba(255, 0, 170, 0.3);
}

.detail-panel__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.detail-panel__tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.detail-panel__tag:hover {
  border-color: var(--ai);
  color: var(--ai);
}

.detail-panel__categories {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.detail-panel__notes {
  margin-top: 16px;
}

.detail-panel__notes textarea {
  width: 100%;
  min-height: 80px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.detail-panel__notes textarea:focus {
  border-color: var(--cognition);
}

.detail-panel__connected {
  margin-top: 16px;
}

.connected-paper {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.connected-paper:hover {
  background: var(--bg-hover);
}

.connected-paper__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.connected-paper__title {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.connected-paper__weight {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

/* ─── TOOLTIP ─── */
.graph-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  max-width: 420px;
  min-width: 280px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.graph-tooltip.visible { opacity: 1; }

.graph-tooltip__title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
}

.graph-tooltip__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: pre-line;
  line-height: 1.5;
}

/* Concept node styles */
.concept-node .concept-label { pointer-events: none; }
.concept-node.dimmed .concept-label { opacity: 0.15; }
.concept-node.highlighted .concept-label { opacity: 1; }

/* Upload button accent */
#btn-upload {
  color: var(--cognition);
  border-color: rgba(0, 255, 136, 0.3);
}
#btn-upload:hover {
  background: rgba(0, 255, 136, 0.1);
}

/* Graph mode toggle */
.btn--subtle {
  font-size: 10px;
  opacity: 0.6;
  letter-spacing: 1px;
}
.btn--subtle:hover { opacity: 1; }

/* ─── CONCEPT PANEL ─── */
.panel-concept__header {
  margin-bottom: 20px;
}

.panel-concept__domains {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.panel-concept__title {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.panel-concept__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.panel-concept__section-title {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.panel-concept__paper {
  padding: 10px 12px;
  border-left: 3px solid;
  margin-bottom: 6px;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: background 0.15s;
  background: var(--bg-tertiary);
}

.panel-concept__paper:hover {
  background: var(--bg-hover);
}

.panel-concept__paper-title {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 3px;
}

.panel-concept__paper-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── LOADING ─── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-top: 24px;
}

.loading-bar {
  width: 200px;
  height: 2px;
  background: var(--border);
  margin-top: 16px;
  border-radius: 1px;
  overflow: hidden;
}

.loading-bar__fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--neuroscience), var(--ai), var(--biomimetics));
  animation: loadSlide 2s ease-in-out infinite;
}

@keyframes loadSlide {
  0% { width: 0%; margin-left: 0%; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* ─── GENERATIVE BACKGROUND ─── */
#bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.4;
  pointer-events: none;
}

/* ─── NOTIFICATION ─── */
.notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification--success { border-left: 3px solid var(--cognition); }
.notification--info { border-left: 3px solid var(--neuroscience); }
.notification--warning { border-left: 3px solid var(--cybernetics); }

/* ─── MODAL (Export) ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
}

.modal__title {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.modal__content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal__actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ─── GLITCH EFFECT ─── */
@keyframes glitch-1 {
  0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
  20% { clip-path: inset(20% 0 60% 0); transform: translate(-2px, 1px); }
  40% { clip-path: inset(60% 0 10% 0); transform: translate(2px, -1px); }
  60% { clip-path: inset(40% 0 30% 0); transform: translate(-1px, 2px); }
}

.glitch-hover:hover {
  animation: glitch-1 0.3s linear;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }
  .sidebar { display: none; }
  .detail-panel { width: 100%; }
  :root { --panel-width: 100%; }
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

/* ─── SELECTION ─── */
::selection {
  background: rgba(255, 0, 170, 0.25);
  color: #fff;
}
