/*
 * Poppins auto-hébergée (WOFF2 dans /public/assets/fonts/poppins/).
 * Avantages vs Google Fonts CDN :
 *  - 0 dépendance externe (résilience + RGPD)
 *  - Cache navigateur 1 an (vs 1 jour côté Google) → revisites instantanées
 *  - Aucun render-block CSS sur le critical path (~590 ms gagnés)
 *  - Mêmes métriques que la version CDN, font-display: swap conservé
 */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/poppins/poppins-v24-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/poppins/poppins-v24-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/poppins/poppins-v24-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/poppins/poppins-v24-latin-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/assets/fonts/poppins/poppins-v24-latin-800.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/poppins/poppins-v24-latin-italic.woff2') format('woff2');
}

/*
 * Fallback "métrique-compatible" pour réduire le CLS (Cumulative Layout Shift).
 * Tant que Poppins n'est pas chargée, on utilise Arial mais ajustée pour avoir
 * exactement les mêmes métriques (ascent/descent/size) que Poppins.
 * Résultat : le texte ne saute pas au moment du font swap.
 * Valeurs issues de https://screenspan.net/fallback?font=Poppins
 */
@font-face {
  font-family: "Poppins Fallback";
  src: local("Arial");
  ascent-override: 92.8%;
  descent-override: 30.93%;
  line-gap-override: 8.84%;
  size-adjust: 113.2%;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", "Poppins Fallback", system-ui, -apple-system, sans-serif;
}

/* ===== Accessibilité : skip-link (WCAG 2.4.1 Bypass Blocks) ===== */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 9999;
    padding: .75rem 1.25rem;
    background: #0c0c0c;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 6px 0;
}
.skip-link:focus {
    left: 0;
    outline: 3px solid #a855f7;
    outline-offset: 2px;
}

/* ===== Accessibilité : label visuellement masqué mais lu par les SR ===== */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Respecter prefers-reduced-motion globalement ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Anti-CLS : tout média obtient une hauteur calculée d'office ===== */
img, video, iframe {
    height: auto;
    max-width: 100%;
}
img[width][height], video[width][height] {
    /* Quand width et height sont déclarés, le navigateur calcule l'aspect-ratio
       et réserve l'espace même avant le chargement de l'image */
    height: auto;
}
/* Stack font fallback proche pour minimiser le shift quand Poppins charge */
body {
    font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-display: swap;
}

/* Le padding-left de la sidebar est désormais ciblé sur .layout-main
   (pas sur main générique) pour ne pas casser la home (<main class="home">) */
.layout-main {
  padding-left: 76px;
}

body {
  min-height: 100dvh;
  background: #f0f4ff;
}

/* Sidebar de base — perfs optimisées (anti-lag) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 76px;
  display: flex;
  overflow-x: hidden;
  flex-direction: column;
  background: #161a2d;
  padding: 20px 14px;
  /* On limite la transition à width (cheap à animer) au lieu de "all" qui force des repaints partout */
  transition: width 0.3s ease;
  /* Hint au navigateur pour prépromouvoir en couche compositée */
  will-change: width;
  /* Force GPU layer pour fluidifier l'animation, évite repaints des éléments dessous */
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  z-index: 1001;
  /* Contient les recalculs de layout/style aux enfants de la sidebar */
  contain: layout style;
}

.sidebar:hover {
  width: 260px;
}

/* ── Header sidebar : avatar + nom/rôle (DA alignée sur le drawer mobile) ── */
.sidebar .sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.5rem;
}

.sidebar .sidebar-avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #4f52ba;
  display: block;
}

.sidebar .sidebar-user-info {
  min-width: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar:hover .sidebar-user-info {
  opacity: 1;
}
.sidebar .sidebar-user-info strong {
  display: block;
  font-size: 0.95rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .sidebar-user-info span {
  display: block;
  font-size: 0.78rem;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .sidebar-user-info span a {
  color: #7c4dff;
  text-decoration: none;
}
.sidebar .sidebar-user-info span a:hover {
  text-decoration: underline;
}

/* ── Liens : items + sections (DA drawer mobile) ── */
.sidebar-links {
  list-style: none;
  margin-top: 0.5rem;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-links::-webkit-scrollbar {
  display: none;
}
.sidebar-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Section title : small caps gris (style .mobile-drawer__sep) — masqué quand sidebar collapsed */
.sidebar-links .sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 400;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 1rem 0 0.4rem;
  padding: 0 0.5rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar:hover .sidebar-links .sidebar-section-title {
  opacity: 1;
}

/* Items : icône violette + label + hover violet subtil (style .mobile-drawer__links li a) */
.sidebar-links li a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 0.6rem;
  color: #ddd;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-links li a:hover {
  background: rgba(79, 82, 186, 0.15);
  color: #fff;
}
.sidebar-links li a .material-symbols-outlined {
  font-size: 1.25rem;
  color: #7c4dff;
  flex-shrink: 0;
}

/* Label texte de chaque lien : invisible quand sidebar collapsée, apparait au hover */
.sidebar-link-label {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar:hover .sidebar-link-label {
  opacity: 1;
}

/* ── Footer : LinkedIn · GitHub (caché collapsed, visible au hover) ── */
.sidebar-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.sidebar:hover .sidebar-footer {
  opacity: 1;
}
.sidebar-footer a {
  color: #ccc;
  text-decoration: none;
  margin: 0 0.4rem;
}
.sidebar-footer a:hover {
  color: #fff;
}

/* Avatar texte (initiales) — utilisé par AvatarService quand pas de photo */
.avatar-text {
  width: 44px;
  height: 44px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background-color: #4f52ba;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
  border: 2px solid #fff;
  text-transform: uppercase;
  flex-shrink: 0;
}