:root {
  /* ========================================
     THÈME CLAIR - Amélioré pour la lisibilité WCAG AA+
     ======================================== */

  /* Arrière-plans */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;

  /* Textes - Contraste WCAG AA+ */
  --text-primary: #212529;
  /* Noir profond pour un contraste maximal */
  --text-secondary: #495057;
  /* Gris foncé, ratio 7.6:1 */
  --text-tertiary: #6c757d;
  /* Gris moyen, ratio 4.5:1 */

  /* Accents - Pour liens et éléments décoratifs */
  --accent-primary: #0056b3;
  /* Bleu foncé, excellent sur blanc */
  --accent-secondary: #7b2cbf;
  /* Violet ajusté */
  --accent-tertiary: #d63384;
  /* Rose/rouge pour la variété */
  --accent-gold: #b8860b;
  /* Or foncé, bon contraste */

  /* Boutons - Contraste WCAG AA+ garanti (4.5:1+) */
  --btn-primary-bg: #003d82;
  /* Ratio 7.1:1 avec blanc ✅ */
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #6b2c91;
  /* Ratio 6.8:1 avec blanc ✅ */

  --btn-secondary-bg: #b91645;
  /* Ratio 5.2:1 avec blanc ✅ */
  --btn-secondary-text: #ffffff;
  --btn-secondary-hover: #8b6914;
  /* Ratio 4.7:1 avec blanc ✅ */

  --btn-tertiary-bg: #8b6914;
  /* Ratio 4.7:1 avec blanc ✅ */
  --btn-tertiary-text: #ffffff;
  --btn-tertiary-hover: #b91645;
  /* Ratio 5.2:1 avec blanc ✅ */

  /* Bordures et éléments UI */
  --border-color: #dee2e6;
  --border-light: #f1f3f4;
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-light: rgba(0, 0, 0, 0.04);
  --shadow-strong: rgba(0, 0, 0, 0.15);

  /* États interactifs */
  --hover-overlay: rgba(0, 86, 179, 0.08);
  --focus-ring: rgba(0, 86, 179, 0.25);

  /* Messages d'état */
  --success-color: #0f5132;
  --success-bg: #d1e7dd;
  --warning-color: #664d03;
  --warning-bg: #fff3cd;
  --error-color: #842029;
  --error-bg: #f8d7da;
  --info-color: #055160;
  --info-bg: #cff4fc;

  /* Fonts */
  --font-primary: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial  sans-serif;
  --font-heading: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", "Monaco", "Inconsolata", monospace;

  --accent-primary-rgb: 0, 86, 179;
  --accent-gold-rgb: 184, 134, 11;
  --text-primary-rgb: 33, 37, 41;

  --bg-nav: var(--bg-primary);
  --bg-header: var(--bg-primary);
  --text-header: var(--text-primary);
  --text-nav: var(--text-primary);
  --border-header: var(--border-color);
  --shadow-header: var(--shadow);

}

[data-theme="dark"] {
  /* ========================================
     THÈME SOMBRE - Contraste optimisé WCAG AA+
     ======================================== */

  /* Arrière-plans - Plus de nuances */
  --bg-primary: #0d1117;
  /* GitHub dark */
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;

  /* Textes - Contraste amélioré */
  --text-primary: #f0f6fc;
  /* Blanc cassé, moins fatiguant */
  --text-secondary: #d4dbe2;
  /* Gris clair, bon contraste */
  --text-tertiary: #8b949e;
  /* Gris moyen */

  /* Accents - Couleurs ajustées pour le fond sombre */
  --accent-primary: #58a6ff;
  /* Bleu clair, excellent sur noir */
  --accent-secondary: #bc8cff;
  /* Violet clair */
  --accent-tertiary: #ff7b72;
  /* Rouge/corail clair */
  --accent-gold: #f2cc60;
  /* Or clair, très lisible */

  /* Boutons - Versions sombres pour contraste blanc optimal */
  --btn-primary-bg: #1f6feb;
  /* Contraste suffisant avec blanc ✅ */
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #8957e5;
  /* Violet pour hover ✅ */

  --btn-secondary-bg: #da3633;
  /* Rouge foncé ✅ */
  --btn-secondary-text: #ffffff;
  --btn-secondary-hover: #bf8700;
  /* Or foncé ✅ */

  --btn-tertiary-bg: #bf8700;
  /* Or foncé ✅ */
  --btn-tertiary-text: #ffffff;
  --btn-tertiary-hover: #da3633;
  /* Rouge pour hover ✅ */

  /* Bordures et éléments UI */
  --border-color: #30363d;
  --border-light: #21262d;
  --shadow: rgba(0, 0, 0, 0.45);
  --shadow-light: rgba(0, 0, 0, 0.2);
  --shadow-strong: rgba(0, 0, 0, 0.6);

  /* États interactifs */
  --hover-overlay: rgba(88, 166, 255, 0.15);
  --focus-ring: rgba(88, 166, 255, 0.4);

  /* Messages d'état - Couleurs adaptées au thème sombre */
  --success-color: #7ce383;
  --success-bg: rgba(124, 227, 131, 0.15);
  --warning-color: #f2cc60;
  --warning-bg: rgba(242, 204, 96, 0.15);
  --error-color: #ff7b72;
  --error-bg: rgba(255, 123, 114, 0.15);
  --info-color: #58a6ff;
  --info-bg: rgba(88, 166, 255, 0.15);

  --accent-primary-rgb: 88, 166, 255;
  --accent-gold-rgb: 242, 204, 96;
  --text-primary-rgb: 240, 246, 252;

  --bg-nav: var(--bg-primary);
  --bg-header: var(--bg-primary);
  --text-header: var(--text-primary);
  --text-nav: var(--text-primary);
  --border-header: var(--border-color);
  --shadow-header: var(--shadow);
}

/* ========================================
   STYLES DE BASE AMÉLIORÉS
   ======================================== */

body {
  font-family: var(--font-primary);
  font-weight: 400;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  /* Amélioration de la lisibilité */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 80%, rgba(var(--accent-primary-rgb), 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(var(--accent-gold-rgb), 0.02) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(var(--accent-secondary-rgb, 123, 44, 191), 0.02) 0%, transparent 50%);
  animation: firefly-dance 20s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1.3;
  font-weight: 400;
}

/* ========================================
   AMÉLIORATION DES LIENS
   ======================================== */

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ========================================
   STYLES DE FORMULAIRES AMÉLIORÉS
   ======================================== */

input,
textarea,
select {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: 0.375rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ========================================
   BOUTONS AVEC CONTRASTE WCAG AA+ GARANTI
   ======================================== */

button,
.btn {
  font-weight: 600;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  padding: 0.75rem 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;

  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transition: all 0.6s ease;
  transform: translate(-50%, -50%);
}

.btn:hover::before {
  width: 200px;
  height: 200px;
}

.btn:hover {
  animation: gentle-breath 1s ease-in-out;
  box-shadow:
    0 8px 25px rgba(var(--accent-primary-rgb), 0.3),
    0 0 20px rgba(var(--accent-primary-rgb), 0.1);
}

.btn-primary {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.btn-primary:hover {
  background-color: var(--btn-primary-hover);
  color: var(--btn-primary-text);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-strong);
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
}

.btn-secondary:hover {
  background-color: var(--btn-secondary-hover);
  color: var(--btn-secondary-text);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-strong);
  text-decoration: none;
}

.btn-tertiary {
  background-color: var(--btn-tertiary-bg);
  color: var(--btn-tertiary-text);
}

.btn-tertiary:hover {
  background-color: var(--btn-tertiary-hover);
  color: var(--btn-tertiary-text);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow-strong);
  text-decoration: none;
}

/* Bouton outline avec bon contraste */
.btn-outline {
  background-color: transparent;
  color: var(--btn-primary-bg);
  border: 2px solid var(--btn-primary-bg);
}

.btn-outline:hover {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  text-decoration: none;
}

[data-theme="dark"] .btn-outline {
  color: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}

[data-theme="dark"] .btn-outline:hover {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

/* ========================================
   MESSAGES D'ÉTAT
   ======================================== */

.alert {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}

.alert-success {
  background-color: var(--success-bg);
  color: var(--success-color);
  border-left-color: var(--success-color);
}

.alert-warning {
  background-color: var(--warning-bg);
  color: var(--warning-color);
  border-left-color: var(--warning-color);
}

.alert-error {
  background-color: var(--error-bg);
  color: var(--error-color);
  border-left-color: var(--error-color);
}

.alert-info {
  background-color: var(--info-bg);
  color: var(--info-color);
  border-left-color: var(--info-color);
}

/* ========================================
   AMÉLIORATION DU CONTRASTE POUR L'ACCESSIBILITÉ
   ======================================== */

/* Mode haut contraste */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #000000;
    --text-secondary: #1f1f1f;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --accent-primary: #0000ff;
    --border-color: #000000;
    --btn-primary-bg: #000000;
    --btn-primary-text: #ffffff;
    --btn-primary-hover: #333333;
  }

  [data-theme="dark"] {
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --accent-primary: #00ffff;
    --border-color: #ffffff;
    --btn-primary-bg: #ffffff;
    --btn-primary-text: #000000;
    --btn-primary-hover: #cccccc;
  }
}

/* ========================================
   AMÉLIORATION POUR LA DYSLEXIE
   ======================================== */

[data-accessibility-font="dyslexic"] {
  --font-primary: "OpenDyslexic", Arial, sans-serif;
  --font-heading: "OpenDyslexic", Arial, sans-serif;
}

[data-accessibility-font="dyslexic"] body {
  font-family: var(--font-primary);
  letter-spacing: 0.12em;
  word-spacing: 0.16em;
  line-height: 1.8;
}

/* ========================================
   AMÉLIORATIONS POUR LA LECTURE
   ======================================== */

/* Espacement amélioré pour les paragraphes */
p {
  margin-bottom: 1.25rem;
  max-width: 70ch;
  /* Largeur optimale pour la lecture */
}

/* Amélioration des listes */
ul,
ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Code et éléments monospace */
code,
pre {
  font-family: var(--font-mono);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
}

code {
  padding: 0.2rem 0.4rem;
  font-size: 0.875em;
}

pre {
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.5;
}

/* ========================================
   SÉLECTION DE TEXTE
   ======================================== */

::selection {
  background-color: var(--accent-primary);
  color: white;
}

::-moz-selection {
  background-color: var(--accent-primary);
  color: white;
}

/* ========================================
   SCROLLBAR PERSONNALISÉE
   ======================================== */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ========================================
   FOCUS VISIBLE POUR NAVIGATION CLAVIER
   ======================================== */

button:focus-visible,
.btn:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ========================================
   UTILITAIRES POUR SKIP LINKS (ACCESSIBILITÉ)
   ======================================== */

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
  font-weight: bold;
}

.skip-link:focus {
  top: 6px;
}


/* ========================================
   ЭФФЕКТЫ "ДЫХАНИЕ ПРИРОДЫ"
   Тонкие, незаметные анимации для создания ощущения живой природы
   ======================================== */

/* ========================================
   БАЗОВЫЕ АНИМАЦИИ ПРИРОДЫ
   ======================================== */

@keyframes gentle-breath {

  0%,
  100% {
    transform: scale(1) translateY(0);
  }

  50% {
    transform: scale(1.005) translateY(-1px);
  }
}

@keyframes floating-leaf {

  0%,
  100% {
    transform: translateY(0px) translateX(0px) rotate(0deg);
    opacity: 0.7;
  }

  25% {
    transform: translateY(-3px) translateX(2px) rotate(0.5deg);
    opacity: 0.9;
  }

  75% {
    transform: translateY(2px) translateX(-1px) rotate(-0.3deg);
    opacity: 0.8;
  }
}

@keyframes river-flow {
  0% {
    transform: translateX(0px);
  }

  25% {
    transform: translateX(1px);
  }

  50% {
    transform: translateX(-0.5px);
  }

  75% {
    transform: translateX(1.5px);
  }

  100% {
    transform: translateX(0px);
  }
}

@keyframes text-shimmer {

  0%,
  100% {
    text-shadow: 0 0 5px rgba(var(--accent-primary-rgb), 0.1);
  }

  50% {
    text-shadow: 0 0 8px rgba(var(--accent-primary-rgb), 0.2);
  }
}

@keyframes subtle-glow {

  0%,
  100% {
    box-shadow: 0 0 10px rgba(var(--accent-gold-rgb), 0.1);
    filter: brightness(1);
  }

  50% {
    box-shadow: 0 0 15px rgba(var(--accent-gold-rgb), 0.2);
    filter: brightness(1.02);
  }
}

@keyframes firefly-dance {

  0%,
  100% {
    opacity: 0.3;
    transform: translateY(0px) translateX(0px);
  }

  25% {
    opacity: 0.8;
    transform: translateY(-5px) translateX(3px);
  }

  50% {
    opacity: 0.6;
    transform: translateY(2px) translateX(-2px);
  }

  75% {
    opacity: 0.9;
    transform: translateY(-3px) translateX(4px);
  }
}

.fade-in-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
  animation: floating-leaf 8s ease-in-out infinite;
}

/* ========================================
   РЕСПОНСИВНОСТЬ И ПРОИЗВОДИТЕЛЬНОСТЬ
   ======================================== */

/* Уменьшаем анимации на мобильных для производительности */
@media (max-width: 768px) {

  .markdown-content,
  .prose,
  article.content {
    animation-duration: 12s;
  }

  .markdown-content p,
  .prose p {
    animation-duration: 16s;
  }

  /* Отключаем сложные эффекты на слабых устройствах */
  body::before {
    animation: none;
    opacity: 0.5;
  }
}

/* Респект к предпочтениям пользователя */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.2s !important;
  }

  body::before {
    animation: none !important;
  }

  .fade-in-on-scroll {
    opacity: 1;
    transform: none;
  }
}

/* ========================================
   УТИЛИТЫ ДЛЯ ПРИМЕНЕНИЯ ЭФФЕКТОВ
   ======================================== */

/* Класс для включения дыхания элемента */
.nature-breath {
  animation: gentle-breath 8s ease-in-out infinite;
}

/* Класс для плавающих элементов */
.nature-float {
  animation: floating-leaf 10s ease-in-out infinite;
}

/* Класс для мерцающих элементов */
.nature-glow {
  animation: subtle-glow 6s ease-in-out infinite;
}

/* Класс для речного течения */
.nature-flow {
  animation: river-flow 15s ease-in-out infinite;
}

/* Возможность настройки скорости для разных элементов */
.nature-slow {
  animation-duration: 20s;
}

.nature-fast {
  animation-duration: 4s;
}

/* ========================================
   СПЕЦИАЛЬНЫЕ ЭФФЕКТЫ ДЛЯ ДУХОВНОГО КОНТЕНТА
   ======================================== */

/* Священные символы пульсируют */
.spiritual-symbol {
  animation: text-shimmer 8s ease-in-out infinite;
  display: inline-block;
}

/* Молитвенные тексты дышат особенно мягко */
.prayer-text,
.meditation-text {
  animation: gentle-breath 12s ease-in-out infinite;
  line-height: 1.9;
}

/* Мантры имеют особое свечение */
.mantra {
  animation:
    text-shimmer 6s ease-in-out infinite,
    subtle-glow 8s ease-in-out infinite;
}

/* ========================================
   ЭФФЕКТ ЧАСТИЦ (light particles)
   ======================================== */

.light-particles {
  position: relative;
  overflow: hidden;
}

.light-particles::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(var(--accent-gold-rgb), 0.3) 1px, transparent 1px),
    radial-gradient(circle at 80% 80%, rgba(var(--accent-primary-rgb), 0.2) 1px, transparent 1px),
    radial-gradient(circle at 40% 40%, rgba(var(--accent-gold-rgb), 0.2) 1px, transparent 1px);
  background-size: 100px 100px, 150px 150px, 80px 80px;
  animation: firefly-dance 25s linear infinite;
  pointer-events: none;
  opacity: 0.4;
}

/* Карточки и контейнеры реагируют как живые существа */
.card,
.collection-item,
.article-card {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before,
.collection-item::before,
.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(var(--accent-gold-rgb), 0.1),
      transparent);
  transition: left 0.8s ease;
}

.card:hover::before,
.collection-item:hover::before,
.article-card:hover::before {
  left: 100%;
}

.card:hover,
.collection-item:hover,
.article-card:hover {
  transform: translateY(-3px) scale(1.01);
  animation: gentle-breath 2s ease-in-out;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.1),
    0 0 20px rgba(var(--accent-primary-rgb), 0.1);
}