/* =========================================================
   Veille Cyber — feuille de styles
   Couleur d'accent : menthe. Thèmes : sombre (graphite) et clair.
   ========================================================= */

/* ---------- Couleurs ---------- */
:root,
[data-theme="dark"] {
  --bg: #15181c;          /* graphite */
  --surface: #1d2126;
  --surface-2: #262b31;
  --border: #323940;
  --text: #e9ecef;
  --muted: #a3adb7;       /* contraste ≥ 4.5:1 sur --surface */
  --accent: #3ddc97;      /* menthe */
  --accent-strong: #5ee8ab;
  --accent-ink: #082117;  /* texte posé sur la menthe */
  --accent-soft: rgba(61, 220, 151, 0.13);
  --danger: #ff7b72;
  --danger-soft: rgba(255, 123, 114, 0.14);
  --warn: #f2c14e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.18);
  --skeleton: linear-gradient(90deg, #22272d 0%, #2c3238 50%, #22272d 100%);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #eef1f3;
  --border: #dbe1e5;
  --text: #15191d;
  --muted: #56616b;
  --accent: #0b7a55;      /* menthe foncée : lisible sur fond blanc */
  --accent-strong: #096446;
  --accent-ink: #ffffff;
  --accent-soft: rgba(11, 122, 85, 0.1);
  --danger: #c4312b;
  --danger-soft: rgba(196, 49, 43, 0.1);
  --warn: #8a6100;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 6px 20px rgba(16, 24, 32, 0.06);
  --skeleton: linear-gradient(90deg, #eceff1 0%, #f7f8f9 50%, #eceff1 100%);
  color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

a { color: inherit; }

button,
input { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.wrap {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: 12px; }

.ico { width: 20px; height: 20px; flex: none; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
}

.logo { width: 32px; height: 32px; }
.brand-owner { color: var(--accent); font-weight: 650; } /* « CyberAnou » en menthe */
.logo-shield { fill: var(--accent); }
.logo-wave { stroke: var(--accent-ink); }
.logo-dot { fill: var(--accent-ink); }

.actions { display: flex; align-items: center; gap: 6px; }

.updated {
  color: var(--muted);
  font-size: 0.84rem;
  margin-right: 6px;
  white-space: nowrap;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:disabled { cursor: progress; }

/* Icône soleil en thème sombre (pour passer au clair), lune en thème clair */
[data-theme="dark"] .ico-moon,
[data-theme="light"] .ico-sun { display: none; }

/* Rotation de l'icône « Actualiser » pendant le chargement */
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bandeau hors connexion ---------- */
.offline {
  background: var(--warn);
  color: #1d1600;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 0;
}
[data-theme="light"] .offline { background: #fbe3a0; color: #3b2a00; }

/* ---------- À la une en France ---------- */
.une { margin: 22px 0 6px; }

.une-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.02rem;
  margin: 0 0 12px;
}

.flag {
  width: 22px; height: 15px;
  border-radius: 3px;
  background: linear-gradient(90deg, #1f4fbf 0 33.3%, #ffffff 33.3% 66.6%, #e1323c 66.6%);
  box-shadow: 0 0 0 1px var(--border);
}

.une-list {
  list-style: none;
  margin: 0;
  padding: 0 0 8px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.une-item {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  min-height: 146px; /* même hauteur pour les squelettes et les vraies cartes */
}
.une-item a {
  font-weight: 650;
  line-height: 1.35;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.une-item a:hover { text-decoration: underline; }
.une-item .meta { margin-top: auto; }

/* ---------- Filtres ---------- */
.filters {
  display: grid;
  gap: 12px;
  margin: 20px 0 8px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 46px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.search input::placeholder { color: var(--muted); opacity: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 36px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 550;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip .n {
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.8;
}
.chip[aria-pressed="true"] .n { opacity: 1; } /* contraste suffisant sur la menthe */
.chip-fav .ico { width: 16px; height: 16px; }

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

/* Sélecteur de langue (boutons groupés) */
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--muted);
}
.seg button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
}
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.count {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 14px 0 10px;
  min-height: 1.5em; /* réserve la place pendant le chargement */
}

/* ---------- Liste d'articles ---------- */
.list { display: grid; gap: 12px; }

.card {
  position: relative;
  padding: 16px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 6px 0 6px;
  font-size: 1.06rem;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.card h3 a::after { /* toute la carte reste lisible, seul le titre est cliquable */
  content: " ↗";
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

.summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Article déjà ouvert : atténué */
.card.is-read h3 a { color: var(--muted); font-weight: 550; }
.card.is-read { box-shadow: none; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 0.8rem;
  color: var(--muted);
}
.meta .src { font-weight: 650; color: var(--text); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.badge-new { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.badge-officiel { border-color: var(--accent); color: var(--accent); }

.card .meta,
.card h3 { padding-right: 36px; } /* place pour l'étoile des favoris */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.tag {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
}
.tag-alerte { background: var(--danger-soft); color: var(--danger); }
.tag-officiel { background: var(--accent-soft); color: var(--accent); }

.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.fav-btn:hover { background: var(--surface-2); color: var(--text); }
.fav-btn .ico { width: 22px; height: 22px; }
.fav-btn .ico path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.fav-btn[aria-pressed="true"] { color: var(--warn); }
.fav-btn[aria-pressed="true"] .ico path { fill: currentColor; }

/* ---------- États vides / erreurs ---------- */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.empty button {
  margin-top: 14px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* Bouton « Afficher plus » */
.more {
  justify-self: center;
  margin-top: 6px;
  padding: 10px 22px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  font-weight: 600;
}
.more:hover { background: var(--accent); color: var(--accent-ink); }
.more span { font-weight: 400; }

/* ---------- Squelettes de chargement ---------- */
.skeleton { pointer-events: none; }
.skeleton .sk {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: var(--skeleton);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton .sk + .sk { margin-top: 10px; }
.skeleton .sk-meta { width: 30%; }
.skeleton .sk-title { width: 85%; height: 18px; }
.skeleton .sk-line { width: 100%; }
.skeleton .sk-short { width: 60%; }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ---------- État des sources ---------- */
.sources {
  margin: 24px 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 16px;
}
.sources summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
}
.status-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px 18px;
  font-size: 0.9rem;
}
.status-list li { display: flex; align-items: baseline; gap: 8px; }
.status-list a { text-decoration-color: var(--border); }
.status-list .info { color: var(--muted); margin-left: auto; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); transform: translateY(-1px); }
.dot.ko { background: var(--danger); }

.footer {
  color: var(--muted);
  font-size: 0.82rem;
  padding-top: 12px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

/* ---------- Petits écrans ---------- */
@media (max-width: 560px) {
  .updated { display: none; }
  .brand-name { font-size: 1.02rem; }
  .card { padding: 14px 14px 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .une-list { grid-auto-columns: 82%; }
}

/* Animations réduites si l'utilisateur le demande */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .spin { animation: spin 0.9s linear infinite !important; } /* reste visible : indique un chargement */
}
