/* ===========================
   Outbreak Watch - dark warm palette, mirrors Energy
   =========================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0e0d;
  --bg2:       #1a1816;
  --bg3:       #242220;
  --border:    #2e2b28;
  --text:      #e8e4de;
  --text2:     #a09890;
  --text3:     #6a6460;
  --accent:    #c88a2a;
  --watch:     #7a9e3f;
  --concern:   #c88a2a;
  --alert:     #e27952;
  --emergency: #c14a27;
  --radius:    12px;
  --radius-sm: 8px;
  --topbar-h:  56px;
  --stats-h:   56px;
  font-size: 16px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* TOPBAR */
.topbar {
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  height: var(--topbar-h);
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__brand { display: flex; flex-direction: column; line-height: 1.05; }
.topbar__label {
  color: var(--accent);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  font-weight: 500;
}
.topbar__title {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 300;
}

.topbar__nav { display: flex; gap: 0.25rem; }
.topbar__nav-item {
  background: none;
  border: 1px solid transparent;
  border-radius: 20px;
  color: var(--text3);
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.9rem;
  text-transform: uppercase;
  transition: color 0.2s, border-color 0.2s;
}
.topbar__nav-item:hover { color: var(--text); }
.topbar__nav-item.active { color: var(--accent); border-color: var(--accent); }

/* STATS BAR */
.stats-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--stats-h);
}
.stat {
  align-items: center;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.4rem;
}
.stat:last-child { border-right: none; }
.stat__value {
  color: var(--text);
  font-family: 'Fraunces', serif;
  font-size: 1.35rem;
  font-weight: 300;
}
.stat__label {
  color: var(--text3);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* VIEW */
.view { flex: 1; display: flex; flex-direction: column; }
.loading, .error {
  color: var(--text3);
  font-size: 0.9rem;
  padding: 3rem 1rem;
  text-align: center;
}
.error { color: var(--emergency); }

/* FOOTER */
.footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  color: var(--text3);
  font-size: 0.7rem;
  padding: 0.5rem 1.25rem;
  text-align: center;
}

/* ===========================
   MAP VIEW
   =========================== */

.map-wrap {
  display: grid;
  grid-template-columns: 1fr 360px;
  flex: 1;
  min-height: calc(100dvh - var(--topbar-h) - var(--stats-h) - 32px);
}
.map {
  background: var(--bg);
  height: 100%;
  min-height: 500px;
}
.leaflet-container {
  background: var(--bg);
  font-family: 'Outfit', sans-serif;
}
.leaflet-control-attribution {
  background: rgba(15,14,13,0.7) !important;
  color: var(--text3) !important;
  font-size: 0.65rem !important;
}

.map-panel {
  background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem 1.25rem;
}
.map-panel__head {
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}
.map-panel__head h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 400;
}
.map-panel__count {
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.map-panel__empty {
  color: var(--text3);
  font-size: 0.85rem;
  padding: 1rem 0;
}
.map-panel__list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }

.ev-item {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  display: flex;
  overflow: hidden;
}
.ev-item__bar { width: 4px; flex-shrink: 0; }
.ev-item__body { flex: 1; padding: 0.65rem 0.85rem; }
.ev-item__head {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
}
.ev-item__disease { font-size: 0.95rem; font-weight: 400; }
.ev-item__meta {
  color: var(--text3);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  margin-top: 0.1rem;
  text-transform: uppercase;
}
.ev-item__counts {
  color: var(--text);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}
.ev-item__growth { color: var(--text2); font-size: 0.75rem; margin-top: 0.15rem; }
.ev-item__narrative {
  color: var(--text2);
  font-size: 0.8rem;
  line-height: 1.45;
  margin-top: 0.4rem;
}
.ev-item__source {
  border-top: 1px solid var(--border);
  color: var(--text3);
  font-size: 0.7rem;
  margin-top: 0.5rem;
  padding-top: 0.3rem;
}

.badge {
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.4rem;
  text-transform: uppercase;
}
.badge--pheic { background: rgba(193,74,39,0.25); color: #f0a48a; }

/* ===========================
   FEED VIEW
   =========================== */

.feed { padding: 1rem 1.25rem 2rem; max-width: 900px; width: 100%; margin: 0 auto; }
.feed__filters {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.feed__filter {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  outline: none;
  padding: 0.4rem 0.6rem;
}
.feed__count {
  color: var(--text3);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  margin-left: auto;
  text-transform: uppercase;
}
.feed__list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.feed-item {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
}
.feed-item__head {
  align-items: baseline;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}
.feed-item__source {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.feed-item__time { color: var(--text3); font-size: 0.7rem; }
.feed-item__title {
  color: var(--text);
  display: block;
  font-size: 0.95rem;
  margin: 0.15rem 0 0.35rem;
  text-decoration: none;
}
.feed-item__title:hover { color: var(--accent); }
.feed-item__summary { color: var(--text2); font-size: 0.8rem; line-height: 1.5; }
.feed-item__tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }

.chip {
  border-radius: 3px;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  text-transform: uppercase;
}
.chip--disease { background: rgba(200,138,42,0.18); color: #e2b97a; }
.chip--country { background: rgba(74,111,165,0.18); color: #9ab2d7; }
.chip--linked  { background: rgba(122,158,63,0.18); color: #b6cc8a; }

/* ===========================
   SOURCES VIEW
   =========================== */

.sources { padding: 1.25rem; max-width: 1100px; width: 100%; margin: 0 auto; }
.sources__intro {
  color: var(--text2);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 1.25rem;
  max-width: 60ch;
}
.sources__grid {
  display: grid;
  gap: 0.875rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.src-card {
  background: var(--bg2);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
}
.src-card__header {
  align-items: flex-start;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
}
.src-card__name {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 400;
}
.src-card__type {
  background: var(--bg3);
  border-radius: 4px;
  color: var(--text3);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.4rem;
  text-transform: uppercase;
  white-space: nowrap;
}
.src-card__type--WHO { color: #9ab2d7; }
.src-card__type--government { color: #d7c9a9; }
.src-card__type--academic { color: #b6cc8a; }
.src-card__type--NGO { color: #e2b97a; }
.src-card__type--private { color: #d79aab; }
.src-card__type--community { color: #a8b8b8; }

.src-card__funder { color: var(--text2); font-size: 0.8rem; line-height: 1.5; }
.src-card__funder strong { color: var(--text); font-weight: 500; }

.src-card__scores { display: flex; flex-direction: column; gap: 0.3rem; }
.score-row {
  align-items: center;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 6.5rem 1fr 2.2rem;
}
.score-row__label { color: var(--text3); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
.score-row__dots { display: flex; gap: 3px; }
.dot {
  background: var(--bg3);
  border-radius: 50%;
  height: 8px;
  width: 8px;
}
.dot--on { background: var(--accent); }
.score-row__num { color: var(--text2); font-size: 0.75rem; text-align: right; }

.src-card__meta {
  border-top: 1px solid var(--border);
  display: grid;
  font-size: 0.75rem;
  gap: 0.2rem 0.5rem;
  grid-template-columns: auto 1fr;
  margin-top: 0.4rem;
  padding-top: 0.6rem;
}
.src-card__meta dt { color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.65rem; padding-top: 0.1rem; }
.src-card__meta dd { color: var(--text2); }

.src-card__link {
  color: var(--accent);
  font-size: 0.8rem;
  margin-top: auto;
  padding-top: 0.5rem;
  text-decoration: none;
}
.src-card__link:hover { text-decoration: underline; }

/* ===========================
   TRENDS VIEW
   =========================== */

.trends { padding: 1.25rem; max-width: 1100px; width: 100%; margin: 0 auto; }
.trends__intro {
  color: var(--text2);
  font-size: 0.85rem;
  line-height: 1.55;
  margin-bottom: 1rem;
  max-width: 70ch;
}
.trends__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.trend-control {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}
.trend-control select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  outline: none;
  padding: 0.4rem 0.6rem;
  text-transform: none;
  letter-spacing: normal;
  min-width: 140px;
}
.trend-control--filter select { min-width: 220px; }

.trends__chart-wrap {
  background: var(--bg2);
  border-radius: var(--radius);
  height: 380px;
  padding: 1rem;
  position: relative;
}

.trends__legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}
.trend-stat {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.8rem;
}
.trend-stat__label { color: var(--text); font-size: 0.85rem; }
.trend-stat__total { color: var(--text3); font-size: 0.75rem; }
.trend-stat__growth { font-size: 0.75rem; }

.growth--up   { color: var(--alert); }
.growth--down { color: var(--watch); }
.growth--flat { color: var(--text3); }
.growth--new  { color: var(--accent); }

/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 800px) {
  .map-wrap { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .map { min-height: 0; }
  .map-panel { border-left: none; border-top: 1px solid var(--border); max-height: none; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); height: auto; }
  .stat { border-bottom: 1px solid var(--border); padding: 0.5rem; }
  .topbar { flex-direction: column; height: auto; padding: 0.5rem; gap: 0.4rem; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
