/* ═══════════════════════════════════════════════════════
   AlertMkomori — CSS PWA & Accessibilité
   pwa.css
═══════════════════════════════════════════════════════ */

/* ── ACCESSIBILITÉ GLOBALE ── */
:focus-visible {
  outline: 3px solid var(--vc);
  outline-offset: 3px;
  border-radius: 4px;
}
*:focus:not(:focus-visible) { outline: none; }

/* Taille de police minimale pour la lisibilité */
@media (max-width: 480px) {
  body { font-size: 15px; }
  .signal-desc, .news-excerpt, .droit-card p { font-size: .85rem; }
}

/* ── CONTRASTE ÉLEVÉ ── */
@media (prefers-contrast: high) {
  :root {
    --vert:  #006830;
    --vf:    #003d1a;
    --bleu:  #003580;
    --gris:  #444;
  }
  .signal-card, .cat-card, .droit-card, .news-card {
    border: 2px solid #555;
  }
}

/* ── MODE SOMBRE ── */
@media (prefers-color-scheme: dark) {
  :root {
    --blanc: #0f1a12;
    --gc:    #1a2520;
    --vp:    #0d2218;
    --bp:    #0d1830;
    --txt:   #e8f5ed;
    --gris:  #9ca3af;
  }
  body { background: var(--blanc); color: var(--txt); }
  nav, .signal-card, .cat-card, .droit-card, .news-card,
  .card-box, .admin-stat, .form-wrap, .forum-item,
  .partner-card, .modal { background: #1a2e1e; border-color: #2d4a35; }
  .fg input, .fg select, .fg textarea { background: #0f1a12; color: var(--txt); border-color: #2d4a35; }
  table th { background: #0f1a12; }
  td { border-color: #2d4a35; }
  .anon-toggle, .admin-tabs { background: #0f1a12; }
  .toggle-btn.active, .admin-tab.active { background: #1a2e1e; }
  .upload-zone { background: #0f1a12; border-color: #2d4a35; }
  .topbar { background: #021508; }
}

/* ── RÉDUCTION DE MOUVEMENT ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .map-pin { animation: none; }
}

/* ── MOBILE SAFE AREAS (iPhone notch/Dynamic Island) ── */
@supports (padding: max(0px)) {
  nav         { padding-left:  max(16px, env(safe-area-inset-left));  padding-right:  max(16px, env(safe-area-inset-right)); }
  footer      { padding-bottom: max(30px, env(safe-area-inset-bottom)); }
  .topbar     { padding-left:  max(16px, env(safe-area-inset-left));  padding-right:  max(16px, env(safe-area-inset-right)); }
  #pwa-install-banner { bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ── NAVIGATION MOBILE STICKY BOTTOM (optionnel) ── */
@media (max-width: 640px) {
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0);
    left: 0; right: 0;
    background: #fff;
    border-top: 2px solid var(--vp);
    z-index: 999;
    box-shadow: 0 -4px 20px rgba(0,0,0,.1);
  }
  .mobile-nav a {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 10px 4px;
    font-size: .62rem; color: var(--gris); text-decoration: none; font-weight: 600; gap: 3px;
  }
  .mobile-nav a .nav-icon { font-size: 1.4rem; }
  .mobile-nav a.active { color: var(--vert); }
  .mobile-nav a.signal-mob {
    background: linear-gradient(135deg, var(--vert), var(--bc));
    color: #fff; border-radius: 14px; margin: 6px; flex: 1.3;
  }
  /* Espace pour la nav bottom */
  body { padding-bottom: 72px; }
}
@media (min-width: 641px) {
  .mobile-nav { display: none; }
}

/* ── IMPRESSION ── */
@media print {
  nav, .topbar, footer, .mobile-nav, #pwa-install-banner,
  .modal-overlay, .toast, .btn-signal,
  .pub-banner, .submit-btn, .admin-tabs { display: none !important; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .page { display: block !important; }
  .signal-card, .news-card, .droit-card { break-inside: avoid; border: 1px solid #ccc; }
  a[href]::after { content: ' (' attr(href) ')'; font-size: .8em; color: #666; }
}

/* ── CHARGEMENT LAZY (images) ── */
img[loading="lazy"] { opacity: 0; transition: opacity .3s; }
img[loading="lazy"].loaded { opacity: 1; }

/* ── ÉTAT HORS-LIGNE ── */
.offline-indicator {
  display: none;
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  background: #f59e0b; color: #000; padding: 8px 20px;
  border-radius: 0 0 12px 12px; font-size: .82rem; font-weight: 700;
  z-index: 5000; box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.offline .offline-indicator { display: block; }

/* ── SCROLLBAR PERSONNALISÉE ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--gc); }
::-webkit-scrollbar-thumb { background: var(--vc); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--vert); }

/* ── SÉLECTION TEXTE ── */
::selection { background: var(--vp); color: var(--vf); }

/* ── SMOOTH SCROLL ── */
html { scroll-behavior: smooth; }
