/* =========================================================================
   Mode sombre (#26)
   Tailwind est chargé via CDN avec darkMode:'class' (voir index.html).
   Plutôt que de ré-annoter chaque élément avec des classes dark:, on
   surcharge ici les classes utilitaires déjà présentes dans le HTML dès que
   <html> porte la classe .dark. C'est volontairement une surcharge globale
   pour couvrir tout le site sans tout réécrire.
   ========================================================================= */

html.dark {
  color-scheme: dark;
}

html.dark body { background-color: #0b1220; }

/* Fonds */
html.dark .bg-white { background-color: #111827 !important; }
html.dark .bg-gray-50 { background-color: #0b1220 !important; }
html.dark .bg-gray-100 { background-color: #1f2937 !important; }
html.dark .bg-gray-900 { background-color: #05070d !important; }
html.dark .bg-white\/90 { background-color: rgba(17, 24, 39, .9) !important; }
html.dark .bg-white\/50 { background-color: rgba(17, 24, 39, .5) !important; }

/* Textes */
html.dark .text-gray-900 { color: #f1f5f9 !important; }
html.dark .text-gray-800 { color: #e2e8f0 !important; }
html.dark .text-gray-700 { color: #cbd5e1 !important; }
html.dark .text-gray-600 { color: #94a3b8 !important; }
html.dark .text-gray-500 { color: #94a3b8 !important; }
html.dark .text-gray-400 { color: #94a3b8 !important; }

/* Bordures */
html.dark .border-gray-100 { border-color: #1f2937 !important; }
html.dark .border-gray-200 { border-color: #263140 !important; }
html.dark .border-gray-300 { border-color: #334155 !important; }
html.dark .border-gray-800 { border-color: #1f2937 !important; }

/* Cartes / ombres : on adoucit les ombres claires sur fond sombre */
html.dark .shadow-md,
html.dark .shadow-sm,
html.dark .shadow-lg,
html.dark .shadow-xl {
  box-shadow: 0 10px 25px rgba(0, 0, 0, .45) !important;
}

/* Champs de formulaire */
html.dark input,
html.dark textarea,
html.dark select {
  background-color: #1f2937 !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: #64748b; }
html.dark .checkmark { background-color: #1f2937 !important; }

/* Logo : bascule vers la variante claire en mode sombre */
html.dark img[src*="logo-navy"],
html.dark img[src*="logo-metal"] {
  filter: brightness(0) invert(1);
}

/* Header */
html.dark #mainHeader.scrolled { box-shadow: 0 4px 20px rgba(0, 0, 0, .5); }

/* Fond défilant du hero (#26 fix) : le calque de fondu est peint en blanc en
   dur dans style.css pour se fondre avec un fond clair — en mode sombre il
   fallait un fondu vers le fond sombre, sinon le texte du hero (rendu clair
   par les règles ci-dessus) se retrouve sur un calque resté blanc, donc
   illisible. */
html.dark .hero-scroll-overlay {
  background: linear-gradient(90deg, #0b1220 0%, #0b1220 32%, rgba(11,18,32,.88) 50%, rgba(11,18,32,.55) 68%, rgba(11,18,32,.25) 100%),
              linear-gradient(0deg, #0b1220 0%, rgba(11,18,32,0) 18%, rgba(11,18,32,0) 82%, #0b1220 100%);
}

/* Composants annexes utilisant un fond blanc en dur (non couvert par les
   classes Tailwind ci-dessus) */
html.dark .testimonial-card,
html.dark .blog-card,
html.dark .project-skeleton,
html.dark .portfolio-search input,
html.dark .portfolio-sort,
html.dark .faq-search-wrap input,
html.dark .availability-badge {
  background-color: #111827;
  border-color: #263140;
  color: #e2e8f0;
}
html.dark .portfolio-search input::placeholder,
html.dark .faq-search-wrap input::placeholder { color: #64748b; }

html.dark .quote-calc-option { border-color: #263140; }
html.dark .quote-calc-option:hover { border-color: rgba(30,90,245,.5); }
html.dark .quote-calc-option.selected { background: rgba(30,90,245,.15); }

/* Bouton bascule thème */
#themeToggle {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: background-color .2s ease;
}
#themeToggle:hover { background-color: rgba(30, 90, 245, .1); }
#themeToggle .ri-moon-line { display: none; }
html.dark #themeToggle .ri-sun-line { display: none; }
html.dark #themeToggle .ri-moon-line { display: inline-block; }

/* Empêche un flash de transition au premier rendu */
html.theme-init * { transition: none !important; }
