/* ============================================================
   GATINONDATION — Design System
   ============================================================ */

/* 1. Custom Properties */
:root {
  --glass-bg:       rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.08);
  --glass-border:   rgba(255, 255, 255, 0.10);
  --glass-blur:     blur(12px);

  --emerald:        #34D399;
  --emerald-dim:    rgba(52, 211, 153, 0.12);
  --emerald-border: rgba(52, 211, 153, 0.22);
  --sky:            #38bdf8;

  --alert-red:      #f87171;
  --alert-orange:   #fb923c;
  --alert-amber:    #fbbf24;

  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);

  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  --bg-base:       #000;
  --text-base:     #e4e4e7;
}

/* Light theme tokens — toggled via data-theme="light" on <html> */
[data-theme="light"] {
  --glass-bg:       rgba(0, 0, 0, 0.03);
  --glass-bg-hover: rgba(0, 0, 0, 0.06);
  --glass-border:   rgba(0, 0, 0, 0.10);

  --emerald:        #059669;
  --emerald-dim:    rgba(5, 150, 105, 0.10);
  --emerald-border: rgba(5, 150, 105, 0.25);
  --sky:            #0284c7;

  --alert-red:      #dc2626;
  --alert-orange:   #ea580c;
  --alert-amber:    #d97706;

  --bg-base:        #fafafa;
  --text-base:      #18181b;
}

/* 2. Base */
html, body {
  background: var(--bg-base);
  color: var(--text-base);
  transition: background-color 200ms ease, color 200ms ease;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
}

h1, h2, h3, h4 {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1.05;
}

/* 3. Glass system — grain via ::before */
.glass-lg,
.glass,
.glass-sm {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
}

.glass-lg { border-radius: 2.5rem; }
.glass    { border-radius: 1.5rem; }
.glass-sm { border-radius: 1rem; }

.glass-lg::before,
.glass::before,
.glass-sm::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.glass-lg > *,
.glass > *,
.glass-sm > * {
  position: relative;
  z-index: 1;
}

/* 4. Navigation */
.gato-nav {
  background: rgba(0, 0, 0, 0.85) !important;
  backdrop-filter: var(--glass-blur) !important;
  -webkit-backdrop-filter: var(--glass-blur) !important;
  border-bottom: 1px solid var(--glass-border) !important;
}

/* 5. Active state (nav links, tabs) */
.ds-active {
  background: var(--emerald-dim) !important;
  color: var(--emerald) !important;
  border-color: var(--emerald-border) !important;
}

/* 6. Gradient text accent */
.gradient-text {
  background: linear-gradient(90deg, var(--emerald), var(--sky));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 7. Hero radial glow hints */
.hero-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 10% 20%, rgba(52, 211, 153, 0.07) 0%, transparent 50%),
    radial-gradient(circle at 85% 75%, rgba(56, 189, 248, 0.05) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* 8. Card hover scale */
.card-hover {
  transition: transform 300ms var(--ease-out-expo), background 300ms;
  cursor: default;
}

.card-hover:hover {
  background: var(--glass-bg-hover) !important;
  transform: scale(1.05);
}

/* 9. Entry animation */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.anim {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}
.anim.anim-visible {
  opacity: 1;
  transform: translateY(0);
}

.anim-1 { transition-delay: 0.10s; }
.anim-2 { transition-delay: 0.20s; }
.anim-3 { transition-delay: 0.30s; }
.anim-4 { transition-delay: 0.40s; }

/* 10. Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .anim {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .card-hover:hover {
    transform: none !important;
  }
}

/* 11. Skeleton (fond noir) */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.09) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 12. Scrollbar */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #27272a; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

/* 13. Focus */
*:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
}

/* 14. Ticker */
@keyframes ticker {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-scroll {
  animation: ticker 30s linear infinite;
}

.ticker-scroll:hover {
  animation-play-state: paused;
}

@media (max-width: 639px) {
  .ticker-scroll { animation-duration: 20s; }
  #region-grid   { max-height: 200px; overflow-y: auto; }
  #chart-container { height: 200px !important; }
}

/* 15. Alert pulse */
@keyframes pulse-alert {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.alert-pulse {
  animation: pulse-alert 2s ease-in-out infinite;
}

/* 16. Fade-in (legacy) */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

/* 17. Line clamp */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 18. Splash screen */
#splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  animation: splash-exit 0.8s var(--ease-out-expo) 4.2s forwards;
  pointer-events: none;
}

@keyframes splash-exit {
  to { opacity: 0; visibility: hidden; }
}

#splash-logo {
  width: 96px;
  height: 96px;
  animation: splash-logo-in 0.9s var(--ease-out-expo) 0.1s both;
}

@keyframes splash-logo-in {
  from { opacity: 0; transform: scale(0.75); }
  to   { opacity: 1; transform: scale(1); }
}

#splash-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  background: linear-gradient(90deg, var(--emerald), var(--sky));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: splash-text-in 0.9s var(--ease-out-expo) 0.35s both;
}

#splash-tagline {
  font-size: 0.75rem;
  color: #52525b;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  animation: splash-text-in 0.9s var(--ease-out-expo) 0.55s both;
}

@keyframes splash-text-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#splash-bar-track {
  width: 160px;
  height: 2px;
  background: rgba(255,255,255,0.07);
  border-radius: 1px;
  overflow: hidden;
  animation: splash-text-in 0.9s var(--ease-out-expo) 0.7s both;
}

#splash-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--emerald), var(--sky));
  border-radius: 1px;
  animation: splash-progress 3.8s cubic-bezier(0.4, 0, 0.2, 1) 0.8s forwards;
}

@keyframes splash-progress {
  0%   { width: 0%; }
  60%  { width: 75%; }
  90%  { width: 95%; }
  100% { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  #splash { animation: splash-exit 0s 0.5s forwards; }
  #splash-logo, #splash-title, #splash-tagline, #splash-bar-track { animation: none; opacity: 1; transform: none; }
  #splash-bar-fill { animation: none; width: 100%; }
}

/* 19. Select option contrast — les <option> n'héritent pas du fond sombre du <select> */
select option {
  background-color: #18181b;
  color: #e4e4e7;
}

/* 19. Leaflet popup overrides (carte.html) */
.leaflet-popup-content-wrapper {
  background: rgba(0, 0, 0, 0.88) !important;
  backdrop-filter: var(--glass-blur) !important;
  border: 1px solid var(--glass-border) !important;
  color: #e4e4e7 !important;
  border-radius: 16px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;
}

.leaflet-popup-tip {
  background: rgba(0, 0, 0, 0.88) !important;
}

.leaflet-popup-close-button {
  color: #71717a !important;
  font-size: 18px !important;
}

.leaflet-popup-close-button:hover {
  color: #fff !important;
}

/* ============================================================
   20. Light mode — Tailwind utility overrides
   Scoped to [data-theme="light"] on <html>. Targets only the
   utilities actually used in index/carte/cameras HTML + JS.
   ============================================================ */

[data-theme="light"] .text-white        { color: #09090b; }
[data-theme="light"] .text-zinc-200     { color: #27272a; }
[data-theme="light"] .text-zinc-300     { color: #3f3f46; }
[data-theme="light"] .text-zinc-400     { color: #52525b; }
[data-theme="light"] .text-zinc-500     { color: #71717a; }

[data-theme="light"] .bg-black\/90      { background-color: rgba(255, 255, 255, 0.92); }
[data-theme="light"] .bg-black\/85      { background-color: rgba(255, 255, 255, 0.90); }
[data-theme="light"] .bg-black\/60      { background-color: rgba(255, 255, 255, 0.70); }
[data-theme="light"] .bg-black\/40      { background-color: rgba(255, 255, 255, 0.55); }
[data-theme="light"] .bg-white\/5       { background-color: rgba(0, 0, 0, 0.04); }
[data-theme="light"] .bg-white\/\[0\.02\] { background-color: rgba(0, 0, 0, 0.02); }
[data-theme="light"] .bg-white\/10      { background-color: rgba(0, 0, 0, 0.07); }

[data-theme="light"] .border-white\/5   { border-color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .border-white\/10  { border-color: rgba(0, 0, 0, 0.10); }
[data-theme="light"] .border-white\/20  { border-color: rgba(0, 0, 0, 0.15); }

[data-theme="light"] .hover\:text-white:hover       { color: #09090b; }
[data-theme="light"] .hover\:bg-white\/5:hover      { background-color: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .hover\:bg-white\/10:hover     { background-color: rgba(0, 0, 0, 0.08); }

/* Navigation wrapper — base .gato-nav uses !important, must match or beat it */
[data-theme="light"] .gato-nav { background: rgba(255, 255, 255, 0.92) !important; }

/* Urgency banner — text-red-{50,100,200} are too pale on light bg.
   Darken the text and slightly strengthen the bg for AA contrast. */
[data-theme="light"] .bg-red-500\/10      { background-color: rgba(254, 226, 226, 0.70); }
[data-theme="light"] .border-red-500\/40  { border-color: rgba(220, 38, 38, 0.45); }
[data-theme="light"] .text-red-50         { color: #7f1d1d; }
[data-theme="light"] .text-red-100        { color: #991b1b; }
[data-theme="light"] .text-red-200        { color: #991b1b; }
[data-theme="light"] .text-red-200\/80    { color: rgba(127, 29, 29, 0.85); }
[data-theme="light"] .text-red-400        { color: #dc2626; }
[data-theme="light"] .text-red-50.font-bold,
[data-theme="light"] strong.text-red-50   { color: #7f1d1d; font-weight: 700; }

/* Scrollbar */
[data-theme="light"] ::-webkit-scrollbar-thumb       { background: #d4d4d8; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* Skeleton shimmer */
[data-theme="light"] .skeleton {
  background: linear-gradient(90deg,
    rgba(0, 0, 0, 0.04) 25%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.04) 75%);
  background-size: 200% 100%;
}

/* Select options (native dropdown) */
[data-theme="light"] select option {
  background-color: #ffffff;
  color: #18181b;
}

/* Leaflet popups — override the dark variant's !important values */
[data-theme="light"] .leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.96) !important;
  color: #18181b !important;
  border: 1px solid rgba(0, 0, 0, 0.10) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
}
[data-theme="light"] .leaflet-popup-tip {
  background: rgba(255, 255, 255, 0.96) !important;
}
[data-theme="light"] .leaflet-popup-close-button       { color: #71717a !important; }
[data-theme="light"] .leaflet-popup-close-button:hover { color: #09090b !important; }

/* Splash screen — also needs to match the active theme */
[data-theme="light"] #splash { background: #fafafa; }
[data-theme="light"] #splash-tagline { color: #71717a; }
[data-theme="light"] #splash-bar-track { background: rgba(0, 0, 0, 0.07); }

/* Theme toggle button — currently-inactive icon is hidden via .hidden (Tailwind) */
[data-theme-toggle] { position: relative; }
[data-theme-toggle] [data-icon-sun],
[data-theme-toggle] [data-icon-moon] { transition: transform 200ms ease, opacity 200ms ease; }
