/**
 * Dark Factory Theme
 * Dashboard-oriented design system borrowing the zine's palette and typography.
 * No CRT/glitch effects — those stay zine-exclusive.
 */

/* === FONTS === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Orbitron:wght@400;500;600;700;800&family=Share+Tech+Mono&display=swap');

/* === COLOR PALETTE === */
:root {
  /* Neons (from zine) */
  --f-cyan: #25E1ED;
  --f-cyan-rgb: 37, 225, 237;
  --f-magenta: #ED1E79;
  --f-magenta-rgb: 237, 30, 121;
  --f-yellow: #FFEB0B;
  --f-pink: #FF6EC7;
  --f-orange: #FF6B35;

  /* Semantic */
  --f-accent: #667eea;
  --f-rising: #22c55e;
  --f-falling: #ef4444;
  --f-emerging: #fbbf24;
  --f-papers: #9333ea;
  --f-funding: #22c55e;
  --f-market: #fbbf24;
  --f-signals: #06b6d4;
  --f-comics: #ec4899;

  /* Light mode defaults */
  --f-bg: linear-gradient(135deg, #f0f2f8 0%, #dfe3ee 100%);
  --f-text: #1a1a2e;
  --f-text-dim: rgba(26, 26, 46, 0.65);
  --f-card-bg: rgba(255, 255, 255, 0.88);
  --f-card-border: rgba(0, 0, 0, 0.08);
  --f-card-hover-border: rgba(102, 126, 234, 0.3);
  --f-topbar-bg: rgba(255, 255, 255, 0.7);
  --f-topbar-border: rgba(0, 0, 0, 0.06);
}

/* Dark mode */
body.dark-mode {
  --f-bg: linear-gradient(160deg, #000000 0%, #00060E 40%, #0a0a1a 100%);
  --f-text: #ffffff;
  --f-text-dim: rgba(255, 255, 255, 0.55);
  --f-card-bg: rgba(0, 6, 14, 0.75);
  --f-card-border: rgba(37, 225, 237, 0.12);
  --f-card-hover-border: rgba(37, 225, 237, 0.35);
  --f-topbar-bg: rgba(0, 6, 14, 0.85);
  --f-topbar-border: rgba(37, 225, 237, 0.1);
}

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

body.factory-page {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--f-bg);
  color: var(--f-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === FACTORY TOP BAR === */
.factory-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 2rem;
  background: var(--f-topbar-bg);
  border-bottom: 1px solid var(--f-topbar-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow-x: auto;
  scrollbar-width: none;
}
.factory-topbar::-webkit-scrollbar { display: none; }

.factory-topbar-brand {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--f-cyan);
  margin-right: 1.5rem;
  white-space: nowrap;
  text-decoration: none;
}

.factory-topbar a {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  color: var(--f-text-dim);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
  position: relative;
}
.factory-topbar a:hover {
  color: var(--f-text);
  background: rgba(37, 225, 237, 0.06);
}
.factory-topbar a.active {
  color: var(--f-cyan);
  background: rgba(37, 225, 237, 0.08);
}
.factory-topbar a.active::after {
  content: '';
  position: absolute;
  bottom: -0.6rem;
  left: 0.85rem;
  right: 0.85rem;
  height: 2px;
  background: var(--f-cyan);
  border-radius: 1px;
}

/* === LAYOUT === */
.factory-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* === TYPOGRAPHY === */
.factory-title {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

body.dark-mode .factory-title {
  background: linear-gradient(135deg, var(--f-cyan), var(--f-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.factory-subtitle {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.9rem;
  color: var(--f-text-dim);
  margin-bottom: 2rem;
}

.factory-section-title {
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--f-text-dim);
  margin: 2.5rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.factory-section-title::before {
  content: '';
  width: 3px;
  height: 1em;
  background: var(--f-cyan);
  border-radius: 2px;
}

/* === CARDS === */
.f-card {
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  background: var(--f-card-bg);
  border: 1px solid var(--f-card-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  animation: f-fadeIn 0.4s ease both;
}
.f-card:hover {
  transform: translateY(-3px);
  border-color: var(--f-card-hover-border);
}
body.dark-mode .f-card:hover {
  box-shadow: 0 4px 24px rgba(37, 225, 237, 0.08);
}

.f-card-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

/* === GRID === */
.f-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.f-grid-sm {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.f-grid-wide {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* === BADGES & TAGS === */
.f-badge {
  display: inline-block;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.f-badge-papers { background: rgba(147,51,234,0.15); color: var(--f-papers); }
.f-badge-funding { background: rgba(34,197,94,0.15); color: var(--f-funding); }
.f-badge-market { background: rgba(251,191,36,0.15); color: var(--f-market); }
.f-badge-signals { background: rgba(6,182,212,0.15); color: var(--f-signals); }
.f-badge-comics { background: rgba(236,72,153,0.15); color: var(--f-comics); }
.f-badge-blog { background: rgba(102,126,234,0.15); color: var(--f-accent); }
.f-badge-connections { background: rgba(251,191,36,0.15); color: var(--f-market); }
.f-badge-digest { background: rgba(102,126,234,0.15); color: var(--f-accent); }
.f-badge-trends { background: rgba(6,182,212,0.15); color: var(--f-signals); }

/* === SCORE BARS === */
.f-score-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.f-score-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  min-width: 130px;
  color: var(--f-text-dim);
}
.f-score-track {
  flex: 1;
  height: 6px;
  background: rgba(128,128,128,0.15);
  border-radius: 3px;
  overflow: hidden;
}
.f-score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.f-score-value {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  min-width: 40px;
  text-align: right;
  font-weight: 600;
}

/* === LISTS === */
.f-list { list-style: none; padding: 0; }

.f-list-item {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  background: var(--f-card-bg);
  border: 1px solid var(--f-card-border);
  backdrop-filter: blur(12px);
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s, transform 0.2s;
  animation: f-fadeIn 0.4s ease both;
}
.f-list-item:hover {
  border-color: var(--f-card-hover-border);
  transform: translateX(2px);
}

/* === STATUS INDICATORS === */
.f-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.f-status-dot.healthy { background: var(--f-rising); box-shadow: 0 0 8px var(--f-rising); }
.f-status-dot.warning { background: var(--f-emerging); box-shadow: 0 0 8px var(--f-emerging); }
.f-status-dot.error { background: var(--f-falling); box-shadow: 0 0 8px var(--f-falling); }
.f-status-dot.unknown { background: #6b7280; }

.f-status-dot-lg {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.f-status-dot-lg.healthy { background: var(--f-rising); box-shadow: 0 0 14px var(--f-rising); }
.f-status-dot-lg.warning { background: var(--f-emerging); box-shadow: 0 0 14px var(--f-emerging); }
.f-status-dot-lg.error { background: var(--f-falling); box-shadow: 0 0 14px var(--f-falling); }
.f-status-dot-lg.unknown { background: #6b7280; }

/* === DATA VALUES === */
.f-mono {
  font-family: 'Share Tech Mono', monospace;
}
.f-value-lg {
  font-family: 'Orbitron', monospace;
  font-size: 1.6rem;
  font-weight: 700;
}
.f-value-up { color: var(--f-rising); }
.f-value-down { color: var(--f-falling); }
.f-value-new { color: var(--f-emerging); }
.f-value-accent { color: var(--f-accent); }
.f-value-cyan { color: var(--f-cyan); }

/* === INPUTS === */
.f-input {
  font-family: 'Inter', sans-serif;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: var(--f-card-bg);
  border: 1px solid var(--f-card-border);
  color: var(--f-text);
  font-size: 0.95rem;
  backdrop-filter: blur(10px);
  transition: border-color 0.2s;
}
.f-input:focus {
  outline: none;
  border-color: rgba(37, 225, 237, 0.4);
}
.f-input::placeholder { color: var(--f-text-dim); }

.f-btn {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--f-card-bg);
  border: 1px solid var(--f-card-border);
  color: var(--f-text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.f-btn:hover {
  border-color: var(--f-card-hover-border);
  color: var(--f-text);
}
.f-btn.active {
  background: rgba(37, 225, 237, 0.1);
  border-color: var(--f-cyan);
  color: var(--f-cyan);
}

/* === STAT CARDS === */
.f-stat {
  text-align: center;
  padding: 1rem;
  border-radius: 10px;
  background: var(--f-card-bg);
  border: 1px solid var(--f-card-border);
  backdrop-filter: blur(12px);
}
.f-stat-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--f-cyan);
}
.f-stat-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: var(--f-text-dim);
  margin-top: 0.25rem;
  letter-spacing: 0.05em;
}

/* === GRAPH CONTAINER === */
.f-graph {
  width: 100%;
  height: 500px;
  border-radius: 14px;
  background: var(--f-card-bg);
  border: 1px solid var(--f-card-border);
  backdrop-filter: blur(12px);
  margin-bottom: 2rem;
  overflow: hidden;
}

/* === LEGEND === */
.f-legend {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.f-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  color: var(--f-text-dim);
}
.f-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* === FOOTER === */
.f-timestamp {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  color: var(--f-text-dim);
  text-align: center;
  margin-top: 3rem;
  letter-spacing: 0.05em;
}

/* === LOADING === */
.f-loading {
  text-align: center;
  padding: 4rem;
  font-family: 'Share Tech Mono', monospace;
  color: var(--f-text-dim);
}

/* === OVERALL STATUS BANNER === */
.f-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: 14px;
  background: var(--f-card-bg);
  border: 1px solid var(--f-card-border);
  backdrop-filter: blur(12px);
  margin-bottom: 2rem;
}

/* === PRIORITY BADGES === */
.f-priority {
  display: inline-block;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-right: 0.5rem;
}
.f-priority.high { background: rgba(239,68,68,0.15); color: var(--f-falling); }
.f-priority.medium { background: rgba(251,191,36,0.15); color: var(--f-emerging); }
.f-priority.low { background: rgba(107,114,128,0.15); color: var(--f-text-dim); }

/* === LINK STYLES === */
.f-link {
  color: var(--f-text);
  text-decoration: none;
  transition: color 0.2s;
}
.f-link:hover { color: var(--f-cyan); }

/* === ANIMATIONS === */
@keyframes f-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stagger children */
.f-grid > *:nth-child(1) { animation-delay: 0s; }
.f-grid > *:nth-child(2) { animation-delay: 0.05s; }
.f-grid > *:nth-child(3) { animation-delay: 0.1s; }
.f-grid > *:nth-child(4) { animation-delay: 0.15s; }
.f-grid > *:nth-child(5) { animation-delay: 0.2s; }
.f-grid > *:nth-child(6) { animation-delay: 0.25s; }

.f-list > *:nth-child(1) { animation-delay: 0s; }
.f-list > *:nth-child(2) { animation-delay: 0.04s; }
.f-list > *:nth-child(3) { animation-delay: 0.08s; }
.f-list > *:nth-child(4) { animation-delay: 0.12s; }
.f-list > *:nth-child(5) { animation-delay: 0.16s; }
.f-list > *:nth-child(6) { animation-delay: 0.2s; }
.f-list > *:nth-child(7) { animation-delay: 0.24s; }
.f-list > *:nth-child(8) { animation-delay: 0.28s; }
.f-list > *:nth-child(9) { animation-delay: 0.32s; }
.f-list > *:nth-child(10) { animation-delay: 0.36s; }

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  .f-card, .f-list-item { animation: none; transition: none; }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .factory-topbar { padding: 0.5rem 1rem; }
  .factory-topbar-brand { margin-right: 0.75rem; }
  .factory-container { padding: 1.25rem 1rem 3rem; }
  .f-grid { grid-template-columns: 1fr; }
  .f-grid-sm { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .f-grid-sm { grid-template-columns: 1fr; }
}
