/* ═══════════════════════════════════════════════════════════════════════════
   MISINFORMED.US — "Signals Intelligence" Design System
   A political news spectrum aggregator.
   Dark command-center aesthetic with phosphor-glow data accents.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Fonts ──────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Instrument+Serif:ital@0;1&display=swap');

/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg-deep:       #0a0a0f;
  --bg-surface:    #12121a;
  --bg-raised:     #1a1a26;
  --bg-hover:      #22222f;
  --border:        #2a2a3a;
  --border-dim:    #1e1e2c;
  --text-primary:  #d4d4dc;
  --text-muted:    #6e6e82;
  --text-dim:      #44445a;
  --accent-blue:   #1565C0;
  --accent-purple: #9C27B0;
  --accent-red:    #C62828;
  --glow-blue:     rgba(21, 101, 192, 0.25);
  --glow-purple:   rgba(156, 39, 176, 0.2);
  --glow-red:      rgba(198, 40, 40, 0.25);
  --font-mono:     'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  --font-serif:    'Instrument Serif', 'Georgia', serif;
  --scanline:      rgba(156, 39, 176, 0.04);
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-mono);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Scanline overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    var(--scanline) 2px,
    var(--scanline) 4px
  );
  pointer-events: none;
  z-index: 9999;
  opacity: 0.3;
}

/* Subtle vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 9998;
}

a { color: inherit; text-decoration: none; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.header {
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}

.brand-name .dot {
  color: var(--accent-purple);
  text-shadow: 0 0 20px var(--glow-purple);
}

.brand-name .tld {
  font-family: var(--font-mono);
  font-size: 0.55em;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  vertical-align: baseline;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 300;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Controls Bar ───────────────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.filter-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-right: 8px;
}

.filter-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  padding: 5px 14px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:first-of-type { border-radius: 3px 0 0 3px; }
.filter-btn:last-of-type  { border-radius: 0 3px 3px 0; }

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

.filter-btn.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
  box-shadow: 0 0 12px var(--glow-purple);
}

/* ─── Spectrum Legend ────────────────────────────────────────────────────── */
.spectrum-legend {
  display: flex;
  align-items: stretch;
  height: 28px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-dim);
  flex: 1;
  max-width: 600px;
}

.legend-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  position: relative;
  transition: flex 0.3s;
}

.legend-zone:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 20%;
  bottom: 20%;
  width: 1px;
  background: rgba(255,255,255,0.15);
}

.legend-zone.zone-left      { background: var(--accent-blue); }
.legend-zone.zone-lean-left  { background: rgb(66, 133, 200); }
.legend-zone.zone-center     { background: var(--accent-purple); }
.legend-zone.zone-lean-right { background: rgb(211, 74, 74); }
.legend-zone.zone-right      { background: var(--accent-red); }

/* ─── Stories Container ──────────────────────────────────────────────────── */
#stories-container {
  padding: 10px 0 40px;
}

/* ─── Story Row ──────────────────────────────────────────────────────────── */
.story-row {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  margin-bottom: 8px;
  overflow: hidden;
  animation: row-enter 0.4s ease-out both;
  transition: border-color 0.2s;
}

.story-row:hover {
  border-color: var(--border);
}

.story-row.importance-high {
  border-left: 3px solid var(--accent-purple);
  box-shadow: inset 3px 0 12px -4px var(--glow-purple);
}

.story-row.importance-mid {
  border-left: 2px solid var(--border);
}

@keyframes row-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Story Header ───────────────────────────────────────────────────────── */
.story-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.story-header:hover {
  background: var(--bg-hover);
}

.story-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 36px;
  gap: 1px;
}

.story-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-purple);
  line-height: 1;
  text-shadow: 0 0 10px var(--glow-purple);
}

.story-sources {
  font-size: 0.5rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.story-headline {
  flex: 1;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text-primary);
  line-height: 1.3;
}

.importance-high .story-headline {
  font-size: 1.25rem;
}

.story-indicators {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.expand-toggle {
  font-size: 0.65rem;
  color: var(--text-dim);
  transition: color 0.2s;
}

.story-header:hover .expand-toggle {
  color: var(--text-muted);
}

/* ─── Coverage Gap Tags ──────────────────────────────────────────────────── */
.coverage-gaps {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.gap-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 152, 0, 0.08);
  border: 1px solid rgba(255, 152, 0, 0.2);
  color: #ff9800;
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  white-space: nowrap;
}

.gap-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ff9800;
  opacity: 0.7;
}

/* ─── Spectrum Track ─────────────────────────────────────────────────────── */
.spectrum-track {
  position: relative;
  height: 64px;
  margin: 0 16px 12px;
  border-radius: 3px;
  overflow: visible;
}

.spectrum-zones {
  position: absolute;
  inset: 0;
  display: flex;
  border-radius: 3px;
  overflow: hidden;
}

.zone {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: 0.08;
  transition: opacity 0.2s;
}

.zone-left      { background: var(--accent-blue); }
.zone-lean_left { background: rgb(66, 133, 200); }
.zone-center    { background: var(--accent-purple); }
.zone-lean_right{ background: rgb(211, 74, 74); }
.zone-right     { background: var(--accent-red); }

.story-row:hover .zone { opacity: 0.12; }

.spectrum-cards {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ─── Article Card (on spectrum) ─────────────────────────────────────────── */
.article-card {
  position: absolute;
  top: 6px;
  bottom: 6px;
  transform: translateX(-50%);
  width: clamp(70px, 9vw, 130px);
  background: var(--bg-raised);
  border: 1px solid var(--card-color, var(--border));
  border-top: 2px solid var(--card-color);
  border-radius: 3px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
  pointer-events: all;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 0 var(--card-glow);
  z-index: 1;
}

.article-card:hover {
  background: var(--bg-hover);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 20px var(--card-glow);
  z-index: 10;
  transform: translateX(-50%) translateY(-2px);
  border-color: var(--card-color);
}

.card-source {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--card-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-title {
  font-size: 0.58rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card:hover .card-title {
  color: var(--text-primary);
}

/* ─── Expanded Detail View ───────────────────────────────────────────────── */
.story-detail {
  border-top: 1px solid var(--border-dim);
  background: var(--bg-deep);
  animation: detail-enter 0.25s ease-out;
}

@keyframes detail-enter {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 600px; }
}

.detail-header {
  padding: 10px 16px 6px;
}

.detail-header-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.detail-list {
  padding: 0 8px 12px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 3px;
  transition: background 0.15s;
  cursor: pointer;
}

.detail-row:hover {
  background: var(--bg-raised);
}

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

.detail-source {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 110px;
  letter-spacing: 0.05em;
}

.detail-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  min-width: 70px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-title {
  flex: 1;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.detail-time {
  font-size: 0.6rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ─── Tooltip ────────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  max-width: 320px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.tooltip.visible {
  opacity: 1;
}

.tooltip-source {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-purple);
  margin-bottom: 4px;
}

.tooltip-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
}

.tooltip-excerpt {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── Empty / Loading / Error States ─────────────────────────────────────── */
.loading-state, .empty-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-dim);
  text-align: center;
}

.loading-pulse {
  width: 40px;
  height: 40px;
  border: 2px solid var(--accent-purple);
  border-radius: 50%;
  animation: radar-ping 1.5s ease-out infinite;
  margin-bottom: 20px;
}

@keyframes radar-ping {
  0% { transform: scale(0.8); opacity: 1; box-shadow: 0 0 0 0 var(--glow-purple); }
  100% { transform: scale(2); opacity: 0; box-shadow: 0 0 40px var(--glow-purple); }
}

.loading-text, .empty-text {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.empty-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-sub {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 6px;
  letter-spacing: 0.1em;
}

.error-state {
  color: var(--accent-red);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border-dim);
  padding: 20px 0 30px;
  text-align: center;
}

.footer-disclaimer {
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  line-height: 1.8;
  max-width: 600px;
  margin: 0 auto;
}

.footer-disclaimer a {
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-dim);
  transition: color 0.2s;
}

.footer-disclaimer a:hover {
  color: var(--text-primary);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .spectrum-track {
    height: auto;
    min-height: 80px;
  }

  .spectrum-cards {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0;
  }

  .article-card {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: calc(50% - 3px);
    flex-shrink: 0;
  }

  .article-card:hover {
    transform: none !important;
  }

  .spectrum-zones {
    display: none;
  }

  .detail-row {
    flex-wrap: wrap;
  }

  .detail-title {
    flex-basis: 100%;
    order: 10;
    white-space: normal;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .spectrum-legend {
    max-width: none;
  }
}

@media (max-width: 600px) {
  html { font-size: 13px; }

  .brand-name { font-size: 1.5rem; }
  .brand-tagline { display: none; }

  .story-headline { font-size: 0.95rem !important; }

  .article-card {
    width: 100%;
  }

  .legend-zone {
    font-size: 0.5rem;
    letter-spacing: 0.05em;
  }

  .gap-tag { font-size: 0.5rem; }
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ─── Selection ──────────────────────────────────────────────────────────── */
::selection {
  background: var(--accent-purple);
  color: #fff;
}
