/* ============================================
   FONTS.CSS - SYSTÈME DE POLICES OPTIMISÉ
   Version 2.0 - Chargement simplifié avec font-weight
   ============================================ */

/* ========== Fallback métrique : pendant les ~50ms avant que SF Pro charge,
              -apple-system / system-ui aura les MÊMES proportions que SF Pro,
              donc ZÉRO saut visuel quand SF Pro prend le relais. ========== */
@font-face {
  font-family: 'SF Pro Text Fallback';
  src: local('-apple-system'), local('BlinkMacSystemFont'), local('Segoe UI'), local('Arial');
  size-adjust: 100%;
  ascent-override: 95%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'SF Pro Display Fallback';
  src: local('-apple-system'), local('BlinkMacSystemFont'), local('Segoe UI'), local('Arial');
  size-adjust: 100%;
  ascent-override: 95%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* ========== SF PRO TEXT — WOFF2 subset français (~20 Ko) avec fallback OTF ========== */
@font-face {
  font-family: 'SF Pro Text';
  src: url('/fonts/web/SF-Pro-Text-Light.woff2') format('woff2'),
       url('/fonts/SF-Pro-Text-Light.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Text';
  src: url('/fonts/web/SF-Pro-Text-Regular.woff2') format('woff2'),
       url('/fonts/SF-Pro-Text-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Text';
  src: url('/fonts/web/SF-Pro-Text-Medium.woff2') format('woff2'),
       url('/fonts/SF-Pro-Text-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Text';
  src: url('/fonts/web/SF-Pro-Text-Semibold.woff2') format('woff2'),
       url('/fonts/SF-Pro-Text-Semibold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Text';
  src: url('/fonts/web/SF-Pro-Text-Bold.woff2') format('woff2'),
       url('/fonts/SF-Pro-Text-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ========== SF PRO DISPLAY — WOFF2 subset français avec fallback OTF ========== */
@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/web/SF-Pro-Display-Light.woff2') format('woff2'),
       url('/fonts/SF-Pro-Display-Light.otf') format('opentype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/web/SF-Pro-Display-Regular.woff2') format('woff2'),
       url('/fonts/SF-Pro-Display-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/web/SF-Pro-Display-Medium.woff2') format('woff2'),
       url('/fonts/SF-Pro-Display-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/web/SF-Pro-Display-Semibold.woff2') format('woff2'),
       url('/fonts/SF-Pro-Display-Semibold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/web/SF-Pro-Display-Bold.woff2') format('woff2'),
       url('/fonts/SF-Pro-Display-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ========== SF PRO ROUNDED - Éléments spéciaux (optionnel) ========== */
@font-face {
  font-family: 'SF Pro Rounded';
  src: url('/fonts/SF-Pro-Rounded-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Rounded';
  src: url('/fonts/SF-Pro-Rounded-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Rounded';
  src: url('/fonts/SF-Pro-Rounded-Semibold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Rounded';
  src: url('/fonts/SF-Pro-Rounded-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================
   STYLES DE BASE - Système optimisé
   ============================================ */

/* BASE - Corps du site */
html, body {
  font-family: 'SF Pro Text', 'SF Pro Text Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* TITRES - Hiérarchie visuelle */
h1 {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
}

h2 {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
}

h3 {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

h4, h5, h6 {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

/* NAVIGATION */
.navbar, .navbar-brand {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

.nav-link {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

.nav-link:hover, .nav-link.active {
  font-weight: 500;
}

/* BOUTONS */
.btn, button {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

.btn-primary, .btn-success, .btn-danger {
  font-weight: 600;
}

.btn-secondary, .btn-light {
  font-weight: 400;
}

/* FORMULAIRES */
input, textarea, select, .form-control, .form-select {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

.form-label, label {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

/* TABLEAUX */
table, td {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

th, .table th {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
}

/* CARTES */
.card {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

.card-header {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

.card-title {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
}

/* ALERTES */
.alert {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

.alert-heading {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
}

/* BADGES */
.badge {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

/* FOOTER */
.footer, .footer-modern {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

.footer-title {
  font-weight: 600;
}

.footer-copyright {
  font-weight: 300;
  opacity: 0.8;
}

/* ========== PAGES SPÉCIFIQUES ========== */

/* Dashboard */
.dashboard-title {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
}

.dashboard-subtitle {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

.stat-value, .stat-number {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
}

.stat-label {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
}

/* Profile */
.student-header h2 {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
}

/* Login */
.login-title {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
}

.login-subtitle {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 300;
}

/* Promotion */
.promotion-header h2 {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
}

/* ========== ÉLÉMENTS SPÉCIAUX ========== */

/* Strong/Bold */
strong, b {
  font-weight: 700;
}

/* Emphasis */
em, i {
  font-style: italic;
}

/* Small text */
small, .small {
  font-size: 0.875em;
  opacity: 0.9;
}

/* Muted text */
.text-muted {
  opacity: 0.7;
}

/* Code */
code, pre, .monospace {
  font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

/* ========== CLASSES UTILITAIRES ========== */

/* Font weights */
.fw-light { font-weight: 300; }
.fw-normal { font-weight: 400; }
.fw-medium { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }

/* Font families */
.font-text {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.font-display {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.font-rounded {
  font-family: 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ========== VARIABLES CSS ========== */
:root {
  --font-primary: 'SF Pro Text', 'SF Pro Text Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'SF Pro Display', 'SF Pro Display Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-rounded: 'SF Pro Rounded', 'SF Pro Display Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Courier New', monospace;
  
  /* Font weights */
  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
}

/* ========== OPTIMISATION DU CHARGEMENT ========== */

/*
 * On laisse `font-display: swap` faire son travail :
 *   1) Navigateur rend instantanément avec la police système fallback
 *   2) Quand SF Pro arrive (WOFF2 ~20 Ko), elle prend le relais sans bloquer
 *
 * Le mécanisme opacity:0.01 / .fonts-loaded a été retiré car il causait
 * un double rendu visible (page invisible → fallback → SF Pro avec transition).
 */