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

:root {
  --cyan: #00d4ff;
  --cyan-dim: rgba(0, 212, 255, 0.15);
  --cyan-glow: rgba(0, 212, 255, 0.4);
  --navy: #030d1a;
  --navy-mid: #071828;
  --navy-card: #0a1e30;
  --navy-border: rgba(0, 212, 255, 0.18);
  --text: #c8e8f8;
  --text-dim: rgba(200, 232, 248, 0.55);
  --read-color: rgba(200, 232, 248, 0.28);
}

html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background-color: var(--navy);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== ELECTRIC BLUE TILE BACKGROUND ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: var(--navy);
  background-image:
    linear-gradient(rgba(0,212,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.06) 1px, transparent 1px),
    linear-gradient(rgba(0,212,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.025) 1px, transparent 1px);
  background-size: 60px 60px, 60px 60px, 12px 12px, 12px 12px;
  animation: grid-pulse 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes grid-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* Radial glow blob */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse 60% 45% at 50% 0%, rgba(0,212,255,0.08) 0%, transparent 70%);
  pointer-events: none;
  animation: glow-breathe 8s ease-in-out infinite;
}

@keyframes glow-breathe {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1; }
}

/* ===== SCANLINES ===== */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.07) 3px,
    rgba(0, 0, 0, 0.07) 4px
  );
  animation: scanline-drift 12s linear infinite;
}

@keyframes scanline-drift {
  from { background-position: 0 0; }
  to   { background-position: 0 120px; }
}

/* ===== LAYOUT ===== */
.topbar,
main {
  position: relative;
  z-index: 2;
}

/* ===== TOP BAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.6rem;
  background: rgba(3, 13, 26, 0.85);
  border-bottom: 1px solid var(--navy-border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.07);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

.topbar-brand h1 .highlight {
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(0, 212, 255, 0.8);
}

.subtitle {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-left: 1px solid var(--navy-border);
  padding-left: 0.75rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan), 0 0 20px rgba(0,212,255,0.5);
  animation: dot-pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.cache-status {
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  transition: opacity 0.4s ease;
}
.cache-status:empty { display: none; }
.cache-hit {
  color: rgba(0, 212, 255, 0.6);
  background: rgba(0, 212, 255, 0.07);
  border: 1px solid rgba(0, 212, 255, 0.2);
}
.cache-miss {
  color: rgba(100, 255, 160, 0.7);
  background: rgba(100, 255, 160, 0.07);
  border: 1px solid rgba(100, 255, 160, 0.25);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 4px;
  border: 1px solid;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}
.btn-primary:hover {
  background: rgba(0,212,255,0.28);
  box-shadow: 0 0 16px rgba(0,212,255,0.35);
}

.btn-secondary {
  background: rgba(255,255,255,0.04);
  border-color: rgba(200,232,248,0.3);
  color: var(--text-dim);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(200,232,248,0.6);
  color: var(--text);
}

.btn-read {
  padding: 0.22rem 0.55rem;
  border-radius: 3px;
  border: 1px solid rgba(0,212,255,0.3);
  background: transparent;
  color: rgba(0,212,255,0.7);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.btn-read:hover {
  background: rgba(0,212,255,0.1);
  border-color: var(--cyan);
  color: var(--cyan);
}
.btn-read.is-read {
  border-color: rgba(200,232,248,0.15);
  color: rgba(200,232,248,0.25);
}
.btn-read.is-read:hover {
  border-color: rgba(200,232,248,0.3);
  color: rgba(200,232,248,0.5);
  background: rgba(255,255,255,0.04);
}

/* ===== MAIN FEED GRID ===== */
main {
  padding: 1.4rem 1.6rem 2.5rem;
}

.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.2rem;
}

/* ===== SOURCE PANEL ===== */
.source-panel {
  background: rgba(7, 24, 40, 0.75);
  border: 1px solid var(--navy-border);
  border-radius: 8px;
  overflow: hidden;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s;
}
.source-panel:hover {
  border-color: rgba(0,212,255,0.35);
}

.source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: rgba(0, 212, 255, 0.05);
  border-bottom: 1px solid var(--navy-border);
}

.source-name {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0,212,255,0.5);
}

.source-count {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

/* ===== HEADLINE ITEM ===== */
.headline-list {
  list-style: none;
}

.headline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(0,212,255,0.05);
  transition: background 0.15s;
}
.headline-item:last-child { border-bottom: none; }
.headline-item:hover { background: rgba(0,212,255,0.04); }

.headline-item.is-read .headline-link {
  color: var(--read-color);
  text-decoration: line-through;
  text-decoration-color: rgba(200,232,248,0.2);
}

.headline-link {
  flex: 1;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}
.headline-link:hover { color: var(--cyan); }

.ai-badge {
  font-size: 0.58rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: rgba(0,212,255,0.12);
  border: 1px solid rgba(0,212,255,0.3);
  color: var(--cyan);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-top: 0.1rem;
  align-self: flex-start;
}

/* ===== LOADING STATE ===== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 5rem 2rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(0,212,255,0.15);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 12px rgba(0,212,255,0.3);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== ERROR STATE ===== */
.error-state {
  text-align: center;
  padding: 4rem 2rem;
  color: rgba(255, 100, 100, 0.7);
  font-size: 0.85rem;
}

/* ===== EMPTY SOURCE ===== */
.empty-source {
  padding: 1.2rem 1rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
}

/* ===== REFRESH ANIMATION ===== */
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.source-panel {
  animation: panel-in 0.3s ease both;
}
.source-panel:nth-child(1) { animation-delay: 0.05s; }
.source-panel:nth-child(2) { animation-delay: 0.10s; }
.source-panel:nth-child(3) { animation-delay: 0.15s; }
.source-panel:nth-child(4) { animation-delay: 0.20s; }
.source-panel:nth-child(5) { animation-delay: 0.25s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .topbar { flex-direction: column; gap: 0.7rem; align-items: flex-start; }
  .subtitle { display: none; }
  main { padding: 1rem; }
  .feed-grid { grid-template-columns: 1fr; }
}
