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

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #21262d;
  --border:      #30363d;
  --accent:      #58a6ff;
  --accent-glow: rgba(88,166,255,.15);
  --danger:      #f85149;
  --success:     #3fb950;
  --warning:     #d29922;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,.4);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial,
               sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ─── Header ────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.logo-icon { font-size: 2rem; line-height: 1; }

.logo-title {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.logo-sub {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
}

.badge.live {
  background: rgba(63,185,80,.12);
  color: var(--success);
  border: 1px solid rgba(63,185,80,.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { color: var(--text); border-color: var(--accent); }
.btn-icon.spinning { animation: spin .6s linear infinite; }

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

/* ─── Controls bar ──────────────────────────────────────────────────────── */
.controls-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.controls-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  padding: 8px 12px 8px 34px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

#search-input::placeholder { color: var(--text-muted); }
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filter-wrap label { font-size: .8rem; color: var(--text-muted); }

.filter-wrap select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
  padding: 7px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}

.filter-wrap select:focus { border-color: var(--accent); }

/* A select sizes itself to its longest option, and long source names pushed it
   past the screen edge on phones. Let it shrink, and fill the row on narrow screens. */
.filter-wrap { min-width: 0; max-width: 100%; }
.filter-wrap select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }

@media (max-width: 600px) {
  .filter-wrap { flex: 1 1 100%; }
  .filter-wrap select { flex: 1; }
}

/* ─── Main layout ───────────────────────────────────────────────────────── */
.main-layout {
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 20px 40px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; top: auto; }
}

/* ─── Feed ──────────────────────────────────────────────────────────────── */
.feed-section { min-width: 0; }

.feed-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.feed-header h2 { font-size: 1.1rem; font-weight: 600; }

.count-badge {
  font-size: .75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 20px;
}

.feed { display: flex; flex-direction: column; gap: 12px; }

/* ─── Article card ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow), var(--shadow);
  transform: translateY(-1px);
}

.card-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-source {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(88,166,255,.2);
  border-radius: 4px;
  padding: 2px 7px;
}

.card-date {
  font-size: .75rem;
  color: var(--text-muted);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
}

.card-link { color: var(--text); }
.card-link:hover { color: var(--accent); text-decoration: none; }

.card-summary {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-read-more {
  font-size: .8rem;
  font-weight: 500;
  color: var(--accent);
}

/* ─── Skeleton loader ───────────────────────────────────────────────────── */
.skeleton { pointer-events: none; }

.sk-line {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  height: 14px;
  margin-bottom: 10px;
}

.sk-title  { height: 18px; width: 80%; }
.sk-meta   { height: 11px; width: 40%; }
.sk-body   { width: 100%; }
.sk-body.short { width: 65%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Empty / error state ───────────────────────────────────────────────── */
.state-msg {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.state-msg .state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.state-msg h3 { color: var(--text); margin-bottom: 6px; }

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: .85rem;
  cursor: pointer;
  transition: all .15s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

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

.page-btn:disabled { opacity: .35; cursor: default; }

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 110px; }

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.sidebar-card h3 {
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar-card p { font-size: .85rem; color: var(--text-muted); line-height: 1.55; }

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

.tag {
  font-size: .75rem;
  font-weight: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}

.tag:hover, .tag.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* Source list */
.source-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.source-list li {
  font-size: .8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* Stats card */
.stat-card {
  display: flex;
  gap: 8px;
}

.stat {
  flex: 1;
  text-align: center;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 10px 6px;
}

.stat span {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.stat small {
  display: block;
  font-size: .68rem;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
