/* ============================================================================
   Ube News Radar — styling
   Brand palette: deep aubergine + lighter purple accents (matches the deck)
   ============================================================================ */

:root {
  --primary:        #4A1E5C;
  --primary-dark:   #3A1648;
  --accent:         #8E4FA8;
  --bg:             #FAFAFB;
  --bg-light:       #F7F4FA;
  --card:           #FFFFFF;
  --border:         #E5E5EA;
  --text:           #2D2D2D;
  --text-muted:     #6B7280;
  --text-soft:      #9CA3AF;
  --star:           #F59E0B;
  --rule:           #D9D2E0;

  /* Category accents */
  --cat-business:   #2563EB;
  --cat-research:   #059669;
  --cat-food:       #D97706;
  --cat-agri:       #65A30D;
  --cat-culture:    #DB2777;
  --cat-ip:         #DC2626;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(to bottom, rgba(247, 244, 250, 0.6), var(--bg));
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ============= HEADER ============= */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: white;
  border-bottom: 1px solid var(--bg-light);
  backdrop-filter: blur(6px);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: inherit; text-decoration: none; min-width: 0;
}
.brand-mark {
  width: 40px; height: 40px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 14px;
  background: white; border-radius: 50%;
}
.brand-text { min-width: 0; }
.brand-eyebrow {
  display: block;
  font-size: 10px; font-weight: 700;
  color: var(--primary); letter-spacing: 2px;
}
.brand-title {
  margin: 1px 0 0;
  font-size: 18px; font-weight: 700;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.updated-label { font-size: 12px; color: var(--text-muted); }
@media (max-width: 600px) { .updated-label { display: none; } }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1px solid var(--border);
  background: white; color: var(--primary);
  font-weight: 700; font-style: italic; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-light); }

.primary-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 0;
  background: var(--primary); color: white;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background-color 0.15s ease;
}
.primary-btn:hover { background: var(--primary-dark); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.refresh-icon { font-size: 16px; display: inline-block; }
.primary-btn.loading .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.info-panel {
  background: var(--bg-light); border-top: 1px solid var(--rule);
  padding: 14px 0; font-size: 13px; color: var(--primary-dark);
}
.info-panel p { margin: 0; max-width: 900px; }

/* ============= FILTERS ============= */
.main-content { padding: 24px 24px 60px; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px;
  background: white; padding: 12px;
  border: 1px solid var(--border); border-radius: 12px;
  margin-bottom: 16px;
}
.search-wrap {
  flex: 1 1 240px; min-width: 200px; position: relative;
}
.search-wrap input {
  width: 100%; padding: 8px 32px 8px 32px;
  font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: white; color: var(--text);
}
.search-wrap input:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(142, 79, 168, 0.15);
}
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-soft); pointer-events: none;
}
.clear-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 18px; line-height: 1;
}
.clear-btn:hover { color: var(--text); }

.filters select {
  padding: 8px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: white; color: var(--text); cursor: pointer;
}
.filters select:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(142, 79, 168, 0.15);
}

.filter-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: white;
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
}
.filter-toggle.active {
  background: #FEF3C7; color: #92400E; border-color: #FCD34D;
}
.filter-toggle.active .star-icon { color: var(--star); }
.star-icon { font-size: 16px; }

/* ============= STATS BAR ============= */
.stats-bar {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 12px; padding: 0 4px;
}
.link-btn {
  border: 0; background: none; cursor: pointer;
  color: var(--primary); font-weight: 600; font-size: 12px;
}
.link-btn:hover { color: var(--primary-dark); }

/* ============= ERROR + EMPTY + LOADING ============= */
.error-box {
  background: #FEF2F2; border: 1px solid #FECACA;
  border-radius: 12px; padding: 16px;
  color: #991B1B; font-size: 14px; margin-bottom: 16px;
}
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 24px; text-align: center;
}
.loader-orb {
  position: relative;
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(74, 30, 92, 0.25);
}
.loader-orb::before {
  content: ""; position: absolute; inset: -10px;
  background: var(--accent); border-radius: 50%;
  opacity: 0.25; animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.25; }
  70% { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(0.9); opacity: 0; }
}
.loader-spinner {
  position: relative;
  width: 38px; height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.loading-screen h3 { margin: 24px 0 6px; color: var(--primary); font-size: 18px; }
.loading-screen p { margin: 0; color: var(--text-muted); font-size: 13px; min-height: 20px; }

/* ============= ARTICLE GRID ============= */
.article-grid {
  display: grid; gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px)  { .article-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .article-grid { grid-template-columns: 1fr 1fr 1fr; } }

.article-card {
  background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px;
  display: flex; flex-direction: column;
  transition: all 0.15s ease;
}
.article-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(74, 30, 92, 0.08);
  transform: translateY(-1px);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
  font-size: 12px; color: var(--text-muted);
}
.card-source { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-date { white-space: nowrap; color: var(--text-soft); }
.card-meta { display: flex; align-items: center; gap: 6px; min-width: 0; }

.card-star {
  border: 0; background: none; cursor: pointer;
  padding: 2px; color: var(--text-soft);
  font-size: 18px; line-height: 1;
}
.card-star:hover, .card-star.starred { color: var(--star); }

.card-title {
  margin: 0 0 8px;
  font-size: 16px; font-weight: 700; line-height: 1.35;
  color: var(--text);
}
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--primary); }

.card-summary {
  font-size: 13.5px; color: var(--text-muted); line-height: 1.5;
  margin: 0 0 10px;
  flex: 1;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
}
.tag-cat { background: #F3F4F6; color: var(--text); }
.tag-cat[data-category="business"]          { background: #DBEAFE; color: var(--cat-business); }
.tag-cat[data-category="research"]          { background: #D1FAE5; color: var(--cat-research); }
.tag-cat[data-category="food_trends"]       { background: #FED7AA; color: var(--cat-food); }
.tag-cat[data-category="agriculture"]       { background: #D9F99D; color: var(--cat-agri); }
.tag-cat[data-category="culture"]           { background: #FBCFE8; color: var(--cat-culture); }
.tag-cat[data-category="ip_authentication"] { background: #FECACA; color: var(--cat-ip); }
.tag-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.tag-region { background: #F3E8FF; color: var(--primary); }
.tag-relevance { background: #F3F4F6; color: var(--text-muted); }

.card-keywords { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.keyword {
  font-size: 11px; color: var(--text-muted);
  background: #F9FAFB; border: 1px solid #F3F4F6;
  padding: 2px 6px; border-radius: 4px;
}

.card-link {
  margin-top: auto;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--primary); font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.card-link:hover { color: var(--primary-dark); }

/* ============= LOAD MORE ============= */
.load-more { text-align: center; padding: 30px 0; }
.secondary-btn {
  padding: 10px 24px; border-radius: 8px;
  border: 1px solid var(--border); background: white;
  color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer;
}
.secondary-btn:hover { background: var(--bg-light); border-color: var(--accent); }

/* ============= FOOTER ============= */
.site-footer {
  margin-top: 40px; padding: 24px 0;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted); text-align: center;
}
.site-footer p { margin: 2px 0; }
.site-footer .muted { color: var(--text-soft); }
