/* ============================================
   KED'Lab : plateforme de formation au matériel informatique
   Design system commun
   ============================================ */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/space-grotesk.woff2") format("woff2");
}

/* Palette « graphite et cuivre » : acier des boîtiers, cuivre des contacts,
   ambre des voyants, vert des circuits imprimés */
:root {
  --bg: #111213;
  --bg-2: #191b1d;
  --bg-3: #24272b;
  --card: rgba(255, 255, 255, 0.045);
  --card-hover: rgba(255, 255, 255, 0.075);
  --card-border: rgba(255, 255, 255, 0.1);
  --text: #ecebe8;
  --text-dim: #a8a49c;
  --accent: #d98b3a;
  --accent-hover: #e6a05a;
  --accent-ink: #1c1006;
  --accent-2: #f0b44a;
  --accent-2-hover: #f5c46e;
  --accent-2-soft: #fde3b2;
  --success: #4fae6a;
  --success-soft: #c6edd2;
  --danger: #e5574b;
  --danger-soft: #f8cdc8;
  --steel: #7f9bb3;
  /* Triplets pour les variantes transparentes : rgba(var(--accent-rgb), 0.12).
     Pas de color-mix(), que les vieux navigateurs Android ne connaissent pas. */
  --bg-rgb: 17, 18, 19;
  --bg-2-rgb: 25, 27, 29;
  --accent-rgb: 217, 139, 58;
  --accent-2-rgb: 240, 180, 74;
  --success-rgb: 79, 174, 106;
  --danger-rgb: 229, 87, 75;
  --steel-rgb: 127, 155, 179;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Inter", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h: 64px;
  /* Longueur de ligne du texte courant : autour de 70 caractères */
  --measure: 32em;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 620px at 85% -8%, rgba(var(--accent-rgb), 0.13), transparent 60%),
    radial-gradient(900px 520px at -10% 30%, rgba(var(--accent-2-rgb), 0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  padding-top: var(--nav-h); /* la navigation est fixe : on lui réserve sa place */
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.2; }

/* Passage fluide d'une page à l'autre, là où le navigateur le permet */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: page-out 0.16s ease-in both; }
::view-transition-new(root) { animation: page-in 0.26s var(--ease) both; }
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Icônes ---------- */
.icon { width: 1.15em; height: 1.15em; flex: 0 0 auto; vertical-align: -0.2em; }
[data-icon] { display: inline-flex; }

/* ---------- Navigation ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 22px;
  background: rgba(var(--bg-rgb), 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
  view-transition-name: site-nav;
}

.nav .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  margin-right: 14px;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.nav .brand { min-height: 44px; }
.nav .brand .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-hover), #a8642a);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-size: 1.05rem;
  box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.3);
}
.nav .brand b { color: var(--accent); font-weight: 700; }

.nav .links { display: flex; align-items: center; gap: 4px; flex: 1; }

/* Lien direct (Quiz) et boutons des menus : même allure */
.nav a.link, .nav .nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.nav a.link:hover, .nav .nav-toggle:hover, .nav-group.open .nav-toggle { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.nav a.link.active { color: var(--accent-ink); background: var(--accent); }
/* Le menu qui contient la page ouverte */
.nav-group.current .nav-toggle { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.nav-toggle .chevron { width: 1em; height: 1em; transform: rotate(90deg); transition: transform 0.2s var(--ease); }
.nav-group.open .nav-toggle .chevron { transform: rotate(-90deg); }

.nav-group { position: relative; }
.nav-panel {
  display: none;
  position: absolute;
  top: calc(100% + 12px); left: 0;
  width: 340px;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--bg-2);
  box-shadow: var(--shadow);
}
.nav-panel:focus { outline: none; }
.nav-group.open .nav-panel { display: grid; gap: 2px; animation: fadeIn 0.18s var(--ease) both; }
.nav-group-title { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: background 0.18s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); }
.nav-item[aria-current="page"] { background: rgba(var(--accent-rgb), 0.14); }
.nav-item-icon {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 1.1rem;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}
.nav-item-text { display: grid; line-height: 1.3; }
.nav-item-text b { font-size: 0.93rem; font-weight: 600; }
.nav-item-text small { color: var(--text-dim); font-size: 0.8rem; }

/* Étape faite : un ✓ vert au bout de l'entrée */
.done-mark { display: inline-flex; align-items: center; color: var(--success); }
.done-mark[hidden] { display: none; }
.nav-item .done-mark { margin-left: auto; padding-left: 8px; font-size: 1.05rem; }
.nav-item.is-done .nav-item-icon { color: var(--success); background: rgba(var(--success-rgb), 0.12); }

/* Mon parcours, à droite de la barre, avec le nombre d'étapes faites */
.nav .nav-progress { margin-left: auto; }
.nav-count:empty { display: none; }
.nav-count {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  background: var(--success);
}
.nav a.link.active .nav-count { background: var(--accent-ink); color: var(--accent); }

.nav .menu-btn {
  display: none;
  margin-left: auto;
  width: 44px; height: 44px;
  border-radius: 11px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  place-items: center;
}

@media (max-width: 900px) {
  .nav .menu-btn { display: grid; }
  .nav .links {
    position: fixed;
    top: var(--nav-h); left: 0; right: 0;
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 12px 16px 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--card-border);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.22s var(--ease), opacity 0.22s, visibility 0.22s;
  }
  .nav.open .links { transform: none; opacity: 1; visibility: visible; }
  .nav a.link { padding: 12px 14px; font-size: 1rem; }
  /* Sur petit écran, les trois groupes sont dépliés l'un sous l'autre, chacun avec son titre */
  .nav .nav-toggle { display: none; }
  .nav-panel, .nav-group.open .nav-panel {
    display: grid; gap: 2px;
    position: static;
    width: auto;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    animation: none;
  }
  .nav-group + .nav-group, .nav-group + .link { margin-top: 10px; }
  .nav .nav-progress { margin-left: 0; border-top: 1px solid var(--card-border); border-radius: 0 0 10px 10px; }
  .nav-group-title {
    display: block;
    padding: 4px 12px;
    font-size: 0.75rem; font-weight: 800;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-dim);
  }
}

/* ---------- Bandeau du parcours, avant le pied de page ---------- */
.next-step {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px 24px;
  width: calc(100% - 48px);
  max-width: 1232px;
  margin: 0 auto 28px;
  padding: 18px 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  background: rgba(var(--accent-rgb), 0.07);
}
.next-step-where { display: grid; gap: 2px; }
.next-step-where > span { color: var(--text-dim); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.next-step-where strong { font-family: var(--font-display); font-size: 1.1rem; }
.next-step-status { display: flex; align-items: flex-start; gap: 7px; margin-top: 4px; font-size: 0.88rem; color: var(--text-dim); }
.next-step-status .icon { margin-top: 0.2em; color: var(--accent); }
.next-step-status.done { color: var(--success); font-weight: 600; }
.next-step-status.done .icon { color: var(--success); }
.next-step-links { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 720px) {
  .next-step { width: calc(100% - 32px); padding: 16px; }
  .next-step-links, .next-step-links .btn { width: 100%; }
  .next-step-links .btn { justify-content: center; text-align: center; }
}

/* Nouvelle version disponible : posé en bas de l'écran, au-dessus de tout */
.update-bar {
  position: fixed; left: 50%; bottom: 16px; z-index: 300;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  background: var(--bg-3);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
}
.update-bar span { display: inline-flex; align-items: center; gap: 8px; }
.update-bar .icon { color: var(--accent); }

.site-footer {
  display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between;
  max-width: 1280px; margin: 0 auto;
  padding: 22px 24px 30px;
  border-top: 1px solid var(--card-border);
  color: var(--text-dim);
  font-size: 0.8rem;
}
.site-footer a { color: var(--accent); }

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 30px 24px 70px; }

.page-title {
  display: flex; align-items: center; gap: 14px;
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  font-weight: 700;
  margin-bottom: 8px;
}
.title-icon {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 1.35rem;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
}
.page-sub { color: var(--text-dim); margin-bottom: 26px; max-width: var(--measure); }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h3 { display: flex; align-items: center; gap: 9px; }
.card h3 .icon { color: var(--accent); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
  user-select: none;
  font-family: var(--font);
  text-decoration: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: var(--accent-hover); box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.35); }
.btn.warn { background: var(--accent-2); color: var(--accent-ink); border-color: transparent; }
.btn.warn:hover { background: var(--accent-2-hover); }
.btn.small { padding: 7px 12px; font-size: 0.84rem; border-radius: 9px; }
.btn.large { padding: 14px 26px; font-size: 1rem; border-radius: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.18s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- Grilles ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Sliders ---------- */
/* Le champ fait 24 px de haut pour le doigt ; seule la piste de 6 px se voit */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent);
}
input[type="range"]:focus-visible { outline-offset: 4px; }

/* ---------- Sections de guide : titres, tableaux, encadrés ---------- */
.section-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.section-sub { color: var(--text-dim); margin-bottom: 18px; max-width: var(--measure); }
.section-sub a, .guide p a, .callout a { color: var(--accent); }
/* La barre de navigation est fixe : un lien vers #section ne doit pas cacher son titre */
.guide { margin-top: 48px; scroll-margin-top: calc(var(--nav-h) + 16px); }
.guide h3 { margin-bottom: 10px; }
.guide p { max-width: var(--measure); }
.guide p + p { margin-top: 10px; }
.table-scroll { overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.compare-table th, .compare-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--card-border); }
.compare-table th { color: var(--text-dim); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 1px; }
.compare-table td:first-child { font-weight: 700; }
.callout {
  border-left: 3px solid var(--accent-2);
  background: rgba(var(--accent-2-rgb), 0.09);
  border-radius: 0 10px 10px 0;
  padding: 11px 15px;
  font-size: 0.92rem;
}
.callout b { color: var(--accent-2); }
.callout.warn { border-left-color: var(--danger); background: rgba(var(--danger-rgb), 0.08); }
.callout.warn b { color: var(--danger-soft); }
/* Une étiquette ou une référence découpée en morceaux expliqués */
.decode { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.decode li { display: grid; grid-template-columns: minmax(84px, max-content) 1fr; gap: 12px; align-items: baseline; font-size: 0.92rem; }
.subsection-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 12px; }
.decode code, .ref-code {
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
  color: var(--accent-2);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* ---------- Divers ---------- */
/* Texte lu par le lecteur d'écran, invisible à l'écran */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--text-dim); font-size: 0.9rem; }
.value-big { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.spacer { height: 20px; }

/* Apparition en douceur du contenu, avec un léger décalage entre voisins */
.fade-in { animation: fadeIn 0.5s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeIn 0.5s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(7) { animation-delay: 240ms; }
.stagger > *:nth-child(8) { animation-delay: 280ms; }
.stagger > *:nth-child(n + 9) { animation-delay: 320ms; }

:focus-visible { outline: 3px solid #fff; outline-offset: 2px; border-radius: 6px; }

/* Lien d'évitement : caché jusqu'à ce que le clavier l'atteigne */
.skip-link {
  position: fixed; left: 12px; top: 10px; z-index: 400;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

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

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

@media (max-width: 720px) {
  .container { padding: 20px 16px 56px; }
  .title-icon { width: 40px; height: 40px; font-size: 1.15rem; }
  /* Au doigt : 44 px de haut pour tout ce qui se touche */
  .btn, .chip { min-height: 44px; }
  input[type="range"] { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
