/**
 * Font Modes Configuration
 *
 * Gère les trois modes de police pour l'application N.O.G :
 * 1. Par défaut : Libre Baskerville (titres) + Inter (texte)
 * 2. Suivre le système : system-ui
 * 3. Adapté aux dyslexiques : OpenDyslexic (texte) + Libre Baskerville (titres)
 */

/* ============================================
   CHARGEMENT DE OPENDYSLEXIC
   ============================================ */

@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Italic.woff') format('woff');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ============================================
   VARIABLES DE POLICE
   ============================================ */

:root {
  /* Polices par défaut */
  --font-heading: 'Libre Baskerville', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;

  /* Tailles de police optimisées */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.375rem;   /* 22px - augmenté */
  --font-size-2xl: 1.75rem;   /* 28px - augmenté */
  --font-size-3xl: 2.25rem;   /* 36px - augmenté */
  --font-size-4xl: 2.75rem;   /* 44px - augmenté */
  --font-size-5xl: 3.25rem;   /* 52px - nouveau */
  --font-size-6xl: 4rem;      /* 64px - nouveau */

  /* Line heights optimisés pour la lisibilité */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  --line-height-loose: 2;

  /* Espacements de lettres */
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;
}

/* ============================================
   MODE PAR DÉFAUT
   ============================================ */

body,
.font-default body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  letter-spacing: var(--letter-spacing-normal);
}

/* Titres avec Libre Baskerville */
h1, h2, h3, h4, h5, h6,
.font-default h1,
.font-default h2,
.font-default h3,
.font-default h4,
.font-default h5,
.font-default h6,
.settings-title,
.settings-section-title,
.settings-group-title,
.product-name,
.user-name,
.dropdown-item-title,
button,
.btn,
.nav-item,
.conversation-title,
label {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
}

/* Texte principal avec Inter */
p,
.font-default p,
span,
.font-default span,
.message-text,
.settings-group-description,
.dropdown-item-subtitle,
textarea,
input[type="text"],
input[type="email"],
.chat-textarea {
  font-family: var(--font-body);
  line-height: var(--line-height-relaxed);
}

/* ============================================
   MODE SYSTÈME
   ============================================ */

.font-system,
.font-system * {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
  line-height: var(--line-height-normal);
}

/* ============================================
   MODE DYSLEXIQUE
   ============================================ */

/* Texte principal en OpenDyslexic */
.font-dyslexic p,
.font-dyslexic span:not(.product-name):not(.settings-title):not(.settings-group-title),
.font-dyslexic .message-text,
.font-dyslexic .settings-group-description,
.font-dyslexic .dropdown-item-subtitle,
.font-dyslexic textarea,
.font-dyslexic input[type="text"],
.font-dyslexic input[type="email"],
.font-dyslexic .chat-textarea,
.font-dyslexic li,
.font-dyslexic td,
.font-dyslexic .user-email {
  font-family: 'OpenDyslexic', sans-serif !important;
  font-size: 1.05em; /* Légèrement plus grand pour compenser */
  line-height: var(--line-height-loose);
  letter-spacing: var(--letter-spacing-wide);
}

/* Titres restent en Libre Baskerville même en mode dyslexique */
.font-dyslexic h1,
.font-dyslexic h2,
.font-dyslexic h3,
.font-dyslexic h4,
.font-dyslexic h5,
.font-dyslexic h6,
.font-dyslexic .settings-title,
.font-dyslexic .settings-section-title,
.font-dyslexic .settings-group-title,
.font-dyslexic .product-name,
.font-dyslexic .user-name,
.font-dyslexic .dropdown-item-title,
.font-dyslexic button,
.font-dyslexic .btn,
.font-dyslexic .nav-item span,
.font-dyslexic .conversation-title,
.font-dyslexic label {
  font-family: var(--font-heading) !important;
  font-weight: 600;
}

/* ============================================
   OPTIMISATIONS POUR LA LISIBILITÉ
   ============================================ */

/* Messages du chat */
.message-text {
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  max-width: 65ch; /* Largeur optimale pour la lecture */
  word-spacing: 0.05em;
}

/* Titres de sections - Tailles augmentées pour meilleure hiérarchie */
h1 {
  font-size: var(--font-size-5xl);  /* 52px - très gros pour titres principaux */
  line-height: var(--line-height-tight);
  margin-bottom: 1.25rem;
  font-weight: 700;
}

h2 {
  font-size: var(--font-size-4xl);  /* 44px - gros pour sous-sections */
  line-height: var(--line-height-tight);
  margin-bottom: 1rem;
  font-weight: 700;
}

h3 {
  font-size: var(--font-size-3xl);  /* 36px - sous-titres importants */
  line-height: var(--line-height-tight);
  margin-bottom: 0.875rem;
  font-weight: 600;
}

h4 {
  font-size: var(--font-size-2xl);  /* 28px - sous-titres moyens */
  line-height: var(--line-height-normal);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

h5 {
  font-size: var(--font-size-xl);   /* 22px - petits sous-titres */
  line-height: var(--line-height-normal);
  margin-bottom: 0.625rem;
  font-weight: 600;
}

h6 {
  font-size: var(--font-size-lg);   /* 18px - plus gros que le texte de base */
  line-height: var(--line-height-normal);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* Logo N.O.G dans le sidebar - Toujours en Libre Baskerville et plus gros */
.product-name {
  font-family: var(--font-heading) !important;
  font-size: var(--font-size-2xl) !important;  /* 28px - bien visible */
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
}

/* Boutons */
button,
.btn {
  font-size: var(--font-size-sm);
  font-weight: 500;
  letter-spacing: var(--letter-spacing-wide);
}

/* Inputs et textareas */
input,
textarea,
select {
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
}

/* Labels */
label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: var(--letter-spacing-wide);
}

/* Code blocks - toujours monospace */
code,
pre,
.hljs,
kbd,
samp {
  font-family: var(--font-mono) !important;
  font-size: 0.9em;
  line-height: var(--line-height-normal);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  :root {
    --font-size-base: 0.9375rem;  /* 15px sur mobile */
    --font-size-lg: 1.0625rem;    /* 17px sur mobile */
    --font-size-xl: 1.25rem;      /* 20px sur mobile */
    --font-size-2xl: 1.5rem;      /* 24px sur mobile */
    --font-size-3xl: 1.875rem;    /* 30px sur mobile */
    --font-size-4xl: 2.25rem;     /* 36px sur mobile */
    --font-size-5xl: 2.5rem;      /* 40px sur mobile */
  }

  /* Logo N.O.G légèrement plus petit sur mobile */
  .product-name {
    font-size: var(--font-size-xl) !important;  /* 20px sur mobile */
  }
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */

/* Amélioration du contraste pour les textes */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Meilleure lisibilité pour les liens */
a {
  text-decoration-skip-ink: auto;
}

/* Sélection de texte */
::selection {
  background-color: rgba(249, 228, 121, 0.3);
  color: inherit;
}

::-moz-selection {
  background-color: rgba(249, 228, 121, 0.3);
  color: inherit;
}
