/* WorldPulse — dark tech / salle de veille. Design dials: VARIANCE 7, MOTION 6, DENSITY 5 */

:root {
  --bg: #06090f;
  --bg-2: #0a1018;
  --panel: rgba(12, 18, 28, 0.96);
  --border: rgba(120, 160, 200, 0.14);
  --border-strong: rgba(120, 180, 255, 0.35);
  --text: #dce8f5;
  --text-dim: #7189a3;
  --accent: #37f0c2;
  --accent-warn: #ffb347;
  --accent-hot: #ff5470;
  --font-mono: "JetBrains Mono", monospace;
  --font-display: "Space Grotesk", sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  overflow: hidden;
}

/* Fond radar : grille fine + vignette */
#radar-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(80, 130, 180, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 130, 180, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
}
#radar-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(0,0,0,0.65) 100%);
}

/* --- Top bar -------------------------------------------------------------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(180deg, rgba(6,9,15,0.98), rgba(6,9,15,0.85) 80%, transparent);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 {
  font-family: var(--font-mono); font-size: 19px; font-weight: 700; letter-spacing: 2px;
}
.brand h1 span { color: var(--accent); }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent); align-self: center;
  animation: dot-blink 2.4s infinite;
}
@keyframes dot-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.tagline { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); letter-spacing: 1px; }

.status-group { display: flex; gap: 26px; align-items: center; }
.status { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 11px; }
.status .label { color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.status-text { color: var(--accent); }
#rescan-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(55, 240, 194, 0.08); border: 1px solid rgba(55, 240, 194, 0.35);
  color: var(--accent); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 2px; padding: 7px 14px; border-radius: 6px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#rescan-btn:hover:not(:disabled) { background: rgba(55, 240, 194, 0.18); border-color: var(--accent); }
#rescan-btn:disabled { opacity: 0.45; cursor: wait; }
#rescan-btn.spin #rescan-icon { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse-ring {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); position: relative;
}
.pulse-ring.on { background: var(--accent); }
.pulse-ring.on::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 1px solid var(--accent); animation: ring 1.8s infinite;
}
@keyframes ring {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* --- Layout --------------------------------------------------------------- */
main { position: relative; z-index: 1; width: 100%; height: 100%; }

#map {
  position: absolute; inset: 0;
}
/* Assombrit légèrement les tuiles déjà sombres.
   NB : pas de `filter` sur le canvas maplibre — Firefox recompose le filtre à
   chaque frame pendant pan/zoom → lag visible (Chrome le tolère). */

/* --- Vues (onglets) ------------------------------------------------------- */
#view-tabs {
  position: absolute; top: 74px; left: 20px; z-index: 10;
  display: flex; gap: 6px;
}
.view-tab {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 2px; padding: 7px 13px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.view-tab:hover { border-color: var(--border-strong); color: var(--text); }
.view-tab.active {
  background: rgba(55, 240, 194, 0.1); border-color: var(--accent);
  color: var(--accent);
}

/* --- Flux latéral ---------------------------------------------------------- */
#feed {
  position: absolute; top: 74px; right: 20px; bottom: 20px; width: 330px; z-index: 10;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.feed-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px 10px; border-bottom: 1px solid var(--border); gap: 10px;
}
.feed-head h2 { font-family: var(--font-mono); font-size: 12px; letter-spacing: 3px; color: var(--accent); }
#source-filter {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; font-family: var(--font-mono); font-size: 10px;
  padding: 5px 8px; max-width: 150px; cursor: pointer; outline: none;
}
#source-filter:hover { border-color: var(--border-strong); }
#source-filter option { background: var(--bg-2); color: var(--text); }

#feed-list { list-style: none; overflow-y: auto; flex: 1; }
#feed-list::-webkit-scrollbar { width: 5px; }
#feed-list::-webkit-scrollbar-thumb { background: rgba(120,180,255,0.2); border-radius: 3px; }

.feed-item {
  padding: 12px 16px; border-bottom: 1px solid rgba(120,160,200,0.07);
  cursor: pointer; transition: background 0.15s;
  animation: slide-in 0.35s ease;
}
.feed-item:hover { background: rgba(55, 240, 194, 0.06); }
.feed-item.newest { border-left: 2px solid var(--accent); }
@keyframes slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
.feed-item-meta {
  display: flex; gap: 8px; align-items: center; margin-bottom: 4px;
  font-family: var(--font-mono); font-size: 10px;
}
.feed-country { color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.feed-source { color: var(--text-dim); }
.feed-time { color: var(--text-dim); margin-left: auto; }
.feed-item-title { font-size: 13px; line-height: 1.45; color: var(--text); }
.feed-item-sub {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-dim);
  margin-top: 3px; letter-spacing: 0.3px;
}

/* --- Marqueurs OSIRIS (vols, sats, conflits, séismes) ----------------------- */
.osiris-marker { cursor: pointer; }
.osiris-marker .core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 7px; height: 7px; border-radius: 50%;
}
/* Forme + couleur par type */
.osiris-marker.kind-flight .core {
  background: #4fc3f7; box-shadow: 0 0 8px #4fc3f7;
  border-radius: 1px; width: 8px; height: 8px;
  transform: translate(-50%, -50%) rotate(45deg); /* losange = avion */
}
.osiris-marker.kind-satellite .core {
  background: #ffd54f; box-shadow: 0 0 8px #ffd54f;
  border-radius: 0; width: 7px; height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
}
.osiris-marker.kind-conflict .core {
  background: #ff5470; box-shadow: 0 0 10px #ff5470;
  width: 10px; height: 10px;
}
.osiris-marker.kind-earthquake .core {
  background: #ff8a65; box-shadow: 0 0 8px #ff8a65;
  border-radius: 2px; width: 9px; height: 9px;
}

/* --- Détail ---------------------------------------------------------------- */
#detail {
  position: absolute; bottom: 20px; left: 20px; z-index: 11;
  width: min(420px, calc(100vw - 400px));
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 20px 22px;
  transition: opacity 0.2s, transform 0.2s;
}
#detail.hidden { opacity: 0; transform: translateY(12px); pointer-events: none; }
#detail-close {
  position: absolute; top: 8px; right: 12px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1;
}
#detail-close:hover { color: var(--text); }
.detail-meta { display: flex; gap: 10px; margin-bottom: 8px; font-family: var(--font-mono); font-size: 11px; }
.detail-country { color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.detail-source { color: var(--text-dim); }
#detail-title { font-size: 16px; font-weight: 600; line-height: 1.4; margin-bottom: 8px; }
#detail-desc { font-size: 12px; line-height: 1.6; color: var(--text-dim); margin-bottom: 12px; }
#detail-link {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  text-decoration: none; letter-spacing: 0.5px;
}
#detail-link:hover { text-decoration: underline; }

/* Navigation multi-articles (‹ 2/5 ›) */
#detail-nav {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
#detail-nav button {
  width: 30px; height: 30px; border-radius: 6px;
  background: rgba(55, 240, 194, 0.08); border: 1px solid rgba(55, 240, 194, 0.3);
  color: var(--accent); font-size: 17px; cursor: pointer; line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
#detail-nav button:hover:not(:disabled) { background: rgba(55, 240, 194, 0.18); border-color: var(--accent); }
#detail-nav button:disabled { opacity: 0.3; cursor: default; }
#detail-pos {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); letter-spacing: 1px;
}
#detail-nav.hidden { display: none; }

/* --- Marqueurs maplibre ------------------------------------------------------ */
.event-marker { cursor: pointer; }
.event-marker .ring {
  position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.23);
  border: 1.5px solid currentColor;
  animation: marker-ring 2.6s infinite;
}
/* Transform-only : animer width/height déclenche du layout à chaque frame.
   NB : PAS de will-change ici — avec ~100 marqueurs, Firefox crée une couche
   GPU par élément et la compositing explose. */
@keyframes marker-ring {
  0% { transform: translate(-50%, -50%) scale(0.23); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
.event-marker .core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 12px currentColor;
}
.event-marker.hot .core {
  width: 12px; height: 12px; box-shadow: 0 0 18px currentColor, 0 0 34px currentColor;
}
/* Badge : nombre d'articles groupés au même endroit */
.event-marker .badge {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--bg-2); border: 1px solid currentColor; border-radius: 9px;
  color: currentColor; font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  padding: 1px 6px; line-height: 1.3; white-space: nowrap;
}

/* --- Responsive -------------------------------------------------------------- */
@media (max-width: 900px) {
  #feed { width: 260px; }
  #detail { width: calc(100vw - 320px); }
  .tagline { display: none; }
  #view-tabs { flex-wrap: wrap; max-width: calc(100vw - 300px); }
}
@media (max-width: 640px) {
  #feed { display: none; }
  #detail { width: calc(100vw - 40px); }
}
