/* ==========================================================================
   Hubs : nsi.html (cours NSI) et programmation.html (six langages).
   Pages générées par scripts/build-hubs.js ; comportement dans js/hub.js.

   Identité du site, inchangée : encre #14141a, crème #f7f2ea, rouge #ef4a34 (un seul accent), Manrope.
   Tout est préfixé .hb : style.css et brand-hv2.css restent partagés avec le reste du site, et leurs règles
   génériques (main, section, ul, a…) ne doivent pas entrer ici.

   Idée : un hub est une table des matières, pas une page d'accueil. Chaque chapitre est une ligne de plus en plus lisible :
   son numéro, ses fiches en liens directs, son quiz et ses flashcards. La ligne verticale qui relie les chapitres est le parcours ;
   elle se remplit (encre) à mesure que les fiches sont ouvertes (données du navigateur, voir js/hub.js).
   ========================================================================== */

.hb {
  --hb-ink: #14141a;
  --hb-ink-2: #4a4a52;
  --hb-ink-3: #6b6b73;
  --hb-cream: #f7f2ea;
  --hb-cream-2: #efe6d3;
  --hb-card: #ffffff;
  --hb-line: #e6ddc8;
  --hb-line-2: #d5c9a8;
  --hb-accent: #ef4a34;
  --hb-accent-deep: #c93620;
  --hb-accent-ink: #a82a16;
  --hb-accent-soft: #fde4de;
  --hb-amber: #b5590b;
  --hb-amber-soft: #fdf0c7;
  --hb-on-ink: #f7f2ea;
  --hb-on-ink-2: #d9d6cd;
  --hb-on-ink-3: #a9a69d;
  --hb-ink-line: #2d2d37;
  --hb-font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --hb-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --hb-gutter: clamp(1.25rem, 4vw, 3rem);
  --hb-ease: cubic-bezier(0.16, 0.84, 0.44, 1);

  display: block;
  max-width: none;
  margin: 0;
  padding: 0;
  font-family: var(--hb-font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--hb-ink);
  background: var(--hb-cream);
  -webkit-font-smoothing: antialiased;
}

.hb *,
.hb *::before,
.hb *::after {
  box-sizing: border-box;
}

.hb h1,
.hb h2,
.hb h3,
.hb p,
.hb ul,
.hb ol,
.hb dl,
.hb dd,
.hb dt,
.hb figure {
  margin: 0;
  padding: 0;
}

.hb ul,
.hb ol {
  list-style: none;
}

.hb a {
  color: inherit;
  text-decoration: none;
}

.hb [hidden] {
  display: none !important;
}

.hb .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.hb a:focus-visible,
.hb pre:focus-visible {
  outline: 2px solid var(--hb-accent-deep);
  outline-offset: 3px;
  border-radius: 4px;
}

.hb-head a:focus-visible {
  outline-color: #ff9c88;
}

.hb-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: var(--hb-gutter);
}

/* Fil d'Ariane (posé par theme.js au début de <main>) : il prolonge le bandeau d'encre au lieu de former une bande blanche. */
.hb > .csp-breadcrumb {
  margin: 0;
  padding: 0.8rem var(--hb-gutter) 0;
  background: var(--hb-ink);
}

.hb > .csp-breadcrumb .csp-breadcrumb__list {
  max-width: 1180px;
  margin: 0 auto;
  font-size: 0.78rem;
}

/* css/theme-light.css (chargé par theme.js, après nous) colore ces liens avec un sélecteur plus fort : on le dépasse. */
html:not(.theme-dark) .hb > .csp-breadcrumb a {
  color: var(--hb-on-ink-3);
}

html:not(.theme-dark) .hb > .csp-breadcrumb a:hover {
  color: #fff;
}

html:not(.theme-dark) .hb > .csp-breadcrumb .csp-breadcrumb__sep,
html:not(.theme-dark) .hb > .csp-breadcrumb .csp-breadcrumb__current {
  color: var(--hb-on-ink-3);
}

.hb .csp-preview-banner {
  display: none;
}

/* ---------- Bandeau ---------- */
.hb-head {
  padding: clamp(1.4rem, 3.4vw, 2.6rem) 0 0;
  background: var(--hb-ink);
  color: var(--hb-on-ink);
}

.hb-head__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 2rem clamp(2rem, 5vw, 4.5rem);
  align-items: end;
  padding-bottom: clamp(2rem, 4vw, 3rem);
}

.hb-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ff9c88;
}

.hb-eyebrow::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--hb-accent);
}

.hb-h1 {
  margin: 0.85rem 0 1.05rem;
  font-size: clamp(2.7rem, 6.6vw, 5rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.045em;
  color: #fff;
  overflow-wrap: anywhere;
}

.hb[data-hub="prog"] .hb-h1 {
  font-size: clamp(2.2rem, 5.4vw, 4.2rem);
  white-space: nowrap;
  overflow-wrap: normal;
}

.hb-lead {
  max-width: 33rem;
  font-size: clamp(1rem, 1.35vw, 1.12rem);
  font-weight: 500;
  line-height: 1.6;
  color: var(--hb-on-ink-2);
}

.hb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.55rem;
}

/* Où on en est sur l'ensemble : une ligne et un trait fin sous les boutons du bandeau (rien tant qu'aucune fiche n'est ouverte). */
.hb-journey {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-top: 1.1rem;
  font-size: 0.86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  color: var(--hb-on-ink-2);
}

.hb-journey[hidden] {
  display: none;
}

.hb-journey__bar {
  flex: 0 0 clamp(6.5rem, 20vw, 10.5rem);
  height: 4px;
  border-radius: 2px;
  background: var(--hb-ink-line);
  overflow: hidden;
}

.hb-journey__bar i {
  display: block;
  width: calc(var(--p, 0) * 1%);
  height: 100%;
  border-radius: inherit;
  background: var(--hb-accent);
  transition: width 0.5s var(--hb-ease);
}

.hb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0 1.3rem;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-family: var(--hb-font);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s var(--hb-ease);
}

.hb-btn .hb-arrow {
  flex: none;
  transition: transform 0.2s var(--hb-ease);
}

.hb-btn:hover .hb-arrow {
  transform: translateX(3px);
}

.hb-btn--primary {
  background: var(--hb-accent);
  color: var(--hb-ink);
}

.hb-btn--primary:hover {
  background: #ff5a44;
  transform: translateY(-1px);
}

.hb-btn--ghost {
  border-color: rgba(247, 242, 234, 0.34);
  color: var(--hb-on-ink);
}

.hb-btn--ghost:hover {
  border-color: #fff;
  color: #fff;
  transform: translateY(-1px);
}

/* Les chiffres du site : sobres, alignés sur la ligne de base du titre, comme le colophon d'un livre. */
.hb-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, auto));
  gap: 1.2rem clamp(1.1rem, 2.2vw, 2rem);
  justify-content: end;
}

.hb-stats > div {
  display: flex;
  flex-direction: column-reverse;
  min-width: 0;
  padding-left: 1rem;
  border-left: 1px solid var(--hb-ink-line);
}

.hb-stats dd {
  font-size: clamp(1.7rem, 3.2vw, 2.55rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.hb-stats dt {
  margin-top: 0.55rem;
  min-height: 2.5em;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hb-on-ink-3);
}

/* La règle graduée : un repère par chapitre ; il mène à sa ligne, et se remplit avec la progression. */
.hb-ruler {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  border-top: 1px solid var(--hb-ink-line);
}

.hb-tick {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.95rem 0.5rem 1.05rem 0.75rem;
  color: var(--hb-on-ink-3);
  transition: color 0.18s ease;
}

.hb-tick::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 2px;
  height: 10px;
  background: #5b5b65;
  transition: height 0.28s var(--hb-ease), background 0.2s ease;
}

.hb-tick__n {
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.hb-tick__t {
  overflow: hidden;
  font-size: 0.74rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hb-tick:hover,
.hb-tick:focus-visible,
.hb-tick.is-current {
  color: #fff;
}

.hb-tick:hover::before,
.hb-tick:focus-visible::before,
.hb-tick.is-current::before {
  height: 24px;
  background: var(--hb-accent);
}

.hb-tick.is-part::before {
  background: #bdb9ae;
}

.hb-tick.is-done::before {
  height: 16px;
  background: var(--hb-on-ink);
}

.hb-tick--aside .hb-tick__n {
  color: #ffcb8a;
}

/* ---------- Accès (rempli par js/hub.js) ---------- */
.hb-access {
  background: var(--hb-cream-2);
  border-bottom: 1px solid var(--hb-line-2);
}

.hb-access__in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 1.5rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.95rem var(--hb-gutter);
}

.hb-access__in p {
  flex: 1 1 26rem;
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--hb-ink);
}

.hb-access__in strong {
  font-weight: 800;
}

.hb-access__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hb-access .hb-btn {
  min-height: 40px;
  padding: 0 1rem;
  font-size: 0.86rem;
}

.hb-access .hb-btn--primary {
  color: var(--hb-ink);
}

.hb-access .hb-btn--ghost {
  border-color: var(--hb-ink);
  color: var(--hb-ink);
}

.hb-access .hb-btn--ghost:hover {
  background: var(--hb-ink);
  color: var(--hb-cream);
}

/* ---------- Index ---------- */
.hb-index {
  padding-top: clamp(1.8rem, 4vw, 2.6rem);
  padding-bottom: clamp(1.2rem, 3vw, 2rem);
}

.hb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  margin-bottom: 1.1rem;
}

.hb-label {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--hb-ink-3);
}

.hb-list {
  border-top: 2px solid var(--hb-ink);
}

.hb-row {
  --node-top: 2.45rem;
  --seg-in: var(--hb-line-2);
  --seg-out: var(--hb-line-2);
  position: relative;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  scroll-margin-top: calc(var(--nv-bar, 67px) + 14px);
  animation: hbIn 0.7s var(--hb-ease) both;
  animation-delay: calc(var(--i, 0) * 55ms + 60ms);
}

@keyframes hbIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hb-row::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 60px;
  height: 1px;
  background: var(--hb-line-2);
}

.hb-row:last-child::after {
  display: none;
}

/* La ligne du parcours : traversant chaque rangée, elle change de couleur à la hauteur du nœud
   (segment d'arrivée selon le chapitre précédent, segment de départ selon celui-ci). */
.hb-row::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 29px;
  width: 2px;
  background: linear-gradient(to bottom, var(--seg-in) 0, var(--seg-in) var(--node-top), var(--seg-out) var(--node-top), var(--seg-out) 100%);
}

.hb-row:last-child::before {
  bottom: auto;
  height: var(--node-top);
}

.hb-row[data-prev="done"] {
  --seg-in: var(--hb-ink);
}

.hb-row[data-state="done"] {
  --seg-out: var(--hb-ink);
}

.hb-node {
  position: absolute;
  top: var(--node-top);
  left: 30px;
  z-index: 1;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid var(--hb-ink-3);
  border-radius: 50%;
  background: var(--hb-cream);
  transition: box-shadow 0.25s ease, border-color 0.2s ease;
}

.hb-row[data-state="part"] .hb-node {
  border: 0;
  background: conic-gradient(var(--hb-ink) calc(var(--p, 0) * 1%), var(--hb-line-2) 0);
}

.hb-row[data-state="part"] .hb-node::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--hb-cream);
}

.hb-row[data-state="done"] .hb-node {
  border-color: var(--hb-ink);
  background: var(--hb-ink);
}

.hb-row[data-state="done"] .hb-node::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 5px;
  width: 6px;
  height: 3px;
  border-bottom: 2px solid var(--hb-cream);
  border-left: 2px solid var(--hb-cream);
  transform: rotate(-45deg);
}

.hb-row[data-resume] .hb-node {
  border-color: var(--hb-accent);
  box-shadow: 0 0 0 5px var(--hb-accent-soft);
}

.hb-node--aside {
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-color: var(--hb-amber);
  border-radius: 5px;
  background: var(--hb-amber-soft);
}

.hb-node--aside::after {
  content: "!";
  position: absolute;
  inset: 0;
  color: var(--hb-amber);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 14px;
  text-align: center;
}

.hb-row--aside[data-state="done"] .hb-node,
.hb-row--aside[data-state="part"] .hb-node {
  border-color: var(--hb-amber);
}

.hb-row--aside[data-state="part"] .hb-node {
  background: conic-gradient(var(--hb-amber) calc(var(--p, 0) * 1%), var(--hb-amber-soft) 0);
}

.hb-row--aside[data-state="part"] .hb-node::before {
  border-radius: 2px;
}

.hb-row--aside[data-state="done"] .hb-node {
  background: var(--hb-amber);
}

.hb-row--aside[data-state="done"] .hb-node::after {
  color: #fff;
}

/* ---------- Une ligne ---------- */
.hb-card {
  grid-column: 2;
  display: grid;
  grid-template-columns: 5.4rem minmax(0, 1fr) minmax(13.5rem, 16rem);
  column-gap: clamp(1rem, 2.2vw, 2rem);
  margin: 0.35rem 0;
  padding: 1.7rem 1.4rem 1.8rem;
  border-radius: 16px;
  transition: background 0.2s ease, box-shadow 0.25s ease;
}

.hb-row:hover > .hb-card,
.hb-row:focus-within > .hb-card {
  background: var(--hb-card);
  box-shadow: 0 1px 0 var(--hb-line), 0 22px 44px -30px rgba(20, 20, 26, 0.3);
}

.hb-num {
  align-self: start;
  padding-top: 0.12rem;
  font-size: clamp(2.3rem, 4vw, 3.4rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--hb-ink-3);
  transition: color 0.2s ease;
}

.hb-row:hover .hb-num,
.hb-row:focus-within .hb-num {
  color: var(--hb-accent-deep);
}

.hb-num--aside {
  color: var(--hb-amber);
}

.hb-row--aside:hover .hb-num,
.hb-row--aside:focus-within .hb-num {
  color: var(--hb-amber);
}

.hb-main {
  min-width: 0;
}

.hb-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.8rem;
  font-size: clamp(1.65rem, 2.6vw, 2.25rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.hb-title a {
  color: var(--hb-ink);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.14em;
  transition: text-decoration-color 0.18s ease;
}

.hb-title a:hover {
  text-decoration-color: var(--hb-accent);
}

.hb-count {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--hb-ink-3);
}

/* Le « Reprends ici » : le signet posé à l'endroit où tu t'es arrêté. */
.hb-flag {
  align-self: center;
  padding: 0.28rem 0.6rem 0.28rem 0.5rem;
  border-radius: 4px 4px 4px 0;
  background: var(--hb-accent);
  color: var(--hb-ink);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* Le badge « Parcouru » : toutes les fiches de la ligne ont été ouvertes (sur cet appareil). Encre pleine, pour se distinguer
   du signet rouge « Reprends ici » ; il oriente vers la suite (quiz, flashcards) plutôt que de décorer. */
.hb-badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.26rem 0.62rem 0.26rem 0.5rem;
  border-radius: 999px;
  background: var(--hb-ink);
  color: var(--hb-on-ink);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

.hb-badge[hidden] {
  display: none;
}

.hb-badge svg {
  flex: none;
}

.hb-hint {
  min-height: 1.5em;
  margin: 0.5rem 0 1.1rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--hb-ink-2);
  transition: color 0.15s ease;
}

.hb-hint.is-peek {
  color: var(--hb-ink);
}

.hb-fiches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
  gap: 0.1rem 1.5rem;
}

/* Numéro, titre, coche « vue » et étiquette forment une seule ligne de texte qui revient à la ligne en retrait sous le titre :
   la coche reste collée au dernier mot, l'étiquette « Gratuit » ne comprime plus le titre. */
.hb-fiches a {
  display: block;
  min-height: 2.2rem;
  padding: 0.4rem 0 0.4rem 2.75rem;
  text-indent: -2.75rem;
  font-size: 0.97rem;
  font-weight: 650;
  line-height: 1.35;
  color: var(--hb-ink);
}

.hb-n {
  display: inline-block;
  width: 2.1rem;
  margin-right: 0.65rem;
  text-indent: 0;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--hb-ink-3);
}

.hb-t {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.24em;
  transition: text-decoration-color 0.18s ease, text-underline-offset 0.2s var(--hb-ease);
}

.hb-fiches a:hover .hb-t,
.hb-fiches a:focus-visible .hb-t {
  text-decoration-color: var(--hb-accent);
  text-underline-offset: 0.34em;
}

.hb-fiches a.is-seen .hb-t::after {
  content: "";
  display: inline-block;
  width: 0.78em;
  height: 0.78em;
  margin-left: 0.45em;
  background: var(--hb-ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.6 6.4 12 13 4.6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.6 6.4 12 13 4.6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.hb-fiches a.is-review .hb-n {
  color: var(--hb-accent-ink);
}

.hb-tag {
  align-self: center;
  padding: 0.12rem 0.42rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
}

/* Dans une ligne de fiche, l'étiquette suit le titre comme un mot de plus. */
.hb-fiches .hb-tag {
  display: inline-block;
  margin-left: 0.5rem;
  vertical-align: 0.12em;
  text-indent: 0;
}

.hb-tag--tool {
  border-color: var(--hb-line-2);
  background: var(--hb-cream-2);
  color: var(--hb-ink-2);
}

.hb-tag--free {
  border-color: #f1b4a8;
  background: var(--hb-accent-soft);
  color: var(--hb-accent-ink);
}

/* ---------- Outils de la ligne ---------- */
.hb-tools {
  display: grid;
  align-content: start;
  padding-top: 0.15rem;
}

.hb-tools a {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 0 0.7rem;
  padding: 0.6rem 0.1rem;
  border-bottom: 1px dashed var(--hb-line-2);
  font-size: 0.92rem;
  font-weight: 750;
  color: var(--hb-ink);
}

.hb-tools li:first-child a {
  border-top: 1px dashed var(--hb-line-2);
}

.hb-k {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color 0.18s ease;
}

.hb-v {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--hb-ink-2);
  white-space: nowrap;
}

.hb-v b {
  font-size: 0.98rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--hb-ink);
}

.hb-tools .hb-arrow {
  align-self: center;
  color: var(--hb-ink-3);
  transition: transform 0.2s var(--hb-ease), color 0.15s ease;
}

.hb-tools a:hover .hb-k,
.hb-tools a:focus-visible .hb-k {
  text-decoration-color: var(--hb-accent);
}

.hb-tools a:hover .hb-arrow,
.hb-tools a:focus-visible .hb-arrow {
  color: var(--hb-accent-deep);
  transform: translateX(3px);
}

.hb-tools__note {
  padding: 0.7rem 0.1rem 0;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--hb-ink-2);
}

.hb-progress {
  padding: 0.65rem 0.1rem 0;
}

.hb-progress__t {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--hb-ink-2);
}

/* ---------- Langages ---------- */
.hb-list--prog .hb-row {
  grid-template-columns: minmax(0, 1fr);
}

.hb-list--prog .hb-row::before,
.hb-list--prog .hb-row::after {
  display: none;
}

.hb-list--prog .hb-card {
  grid-column: 1;
}

.hb-list--prog .hb-row {
  border-bottom: 1px solid var(--hb-line-2);
}

.hb-list--prog .hb-row:last-child {
  border-bottom: 0;
}

.hb-row--lang .hb-card {
  grid-template-columns: 4.4rem minmax(0, 1fr) minmax(16rem, 23rem);
  align-items: start;
}

.hb-logo {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-top: 0.1rem;
  border: 1px solid var(--hb-line-2);
  border-radius: 14px;
  background: var(--hb-card);
}

.hb-logo img {
  display: block;
  width: 36px;
  height: 36px;
  filter: grayscale(1) contrast(1.05);
  opacity: 0.86;
  transition: filter 0.25s ease, opacity 0.25s ease;
}

.hb-row--lang:hover .hb-logo img,
.hb-row--lang:focus-within .hb-logo img {
  filter: none;
  opacity: 1;
}

.hb-tools--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  margin-top: 1.1rem;
  padding-top: 0;
}

.hb-tools--inline a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  min-height: 2.35rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--hb-line-2);
  border-radius: 999px;
  background: transparent;
  font-size: 0.86rem;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.hb-tools--inline li:first-child a {
  border-top: 1px solid var(--hb-line-2);
}

.hb-tools--inline a:hover,
.hb-tools--inline a:focus-visible {
  border-color: var(--hb-ink);
  background: var(--hb-ink);
  color: var(--hb-cream);
}

.hb-tools--inline a:hover .hb-v,
.hb-tools--inline a:focus-visible .hb-v,
.hb-tools--inline a:hover .hb-v b,
.hb-tools--inline a:focus-visible .hb-v b {
  color: var(--hb-on-ink-2);
}

.hb-tools--inline .hb-k {
  text-decoration: none;
}

.hb-tools--inline .hb-arrow {
  display: none;
}

.hb-tools--inline .hb-progress {
  align-self: center;
  padding: 0 0.3rem;
}

.hb-notes {
  margin-top: 0.8rem;
}

.hb-notes li {
  max-width: 40rem;
  padding-left: 0.85rem;
  border-left: 3px solid var(--hb-accent);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--hb-ink-2);
}

/* Extrait de code : une vraie fiche, la même fenêtre sombre que sur le reste du site. */
.hb-code {
  align-self: start;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--hb-ink-line);
  border-radius: 12px;
  background: #1b1b22;
  box-shadow: 0 26px 46px -30px rgba(20, 20, 26, 0.75);
}

.hb-code__bar {
  display: flex;
  gap: 6px;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--hb-ink-line);
}

.hb-code__bar span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3a3a45;
}

.hb-code__body {
  margin: 0;
  padding: 0.95rem 1.05rem 1.05rem;
  overflow-x: auto;
  font-family: var(--hb-mono);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.7;
  color: #e8e4da;
  tab-size: 2;
}

.hb-code__body code {
  font: inherit;
}

.hb-code figcaption {
  padding: 0.55rem 1.05rem 0.7rem;
  border-top: 1px solid var(--hb-ink-line);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8f8c84;
}

.hb .tk-kw,
.hb .tk-tag {
  color: #ff8a72;
  font-weight: 600;
}

.hb .tk-mod,
.hb .tk-attr {
  color: #7ec8e3;
}

.hb .tk-str {
  color: #ffb199;
}

.hb .tk-num {
  color: #9ed88a;
}

.hb .tk-builtin {
  color: #ffcb8a;
}

/* ---------- S'entraîner ---------- */
.hb-practice {
  padding-top: clamp(1rem, 3vw, 1.8rem);
  padding-bottom: clamp(3rem, 7vw, 5rem);
}

.hb-practice .hb-label {
  margin-bottom: 1.1rem;
}

.hb-practice__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 2px solid var(--hb-ink);
}

/* Deux colonnes, autant de lignes que de liens : le filet vertical sépare la colonne de droite, un filet horizontal sépare les lignes. */
.hb-practice__list li:nth-child(even) {
  border-left: 1px solid var(--hb-line-2);
}

.hb-practice__list li:nth-child(n + 3) {
  border-top: 1px solid var(--hb-line-2);
}

.hb-practice__list a {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "k arrow" "d arrow";
  align-items: start;
  gap: 0.35rem 1.2rem;
  height: 100%;
  padding: 1.5rem 1.4rem 1.7rem;
  transition: background 0.2s ease;
}

.hb-practice__list a:hover,
.hb-practice__list a:focus-visible {
  background: var(--hb-card);
}

.hb-practice__k {
  grid-area: k;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hb-practice__d {
  grid-area: d;
  max-width: 34rem;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--hb-ink-2);
}

.hb-practice__list .hb-arrow {
  grid-area: arrow;
  align-self: center;
  color: var(--hb-ink-3);
  transition: transform 0.2s var(--hb-ease), color 0.15s ease;
}

.hb-practice__list a:hover .hb-arrow,
.hb-practice__list a:focus-visible .hb-arrow {
  color: var(--hb-accent-deep);
  transform: translateX(4px);
}

/* ---------- Adaptation ---------- */
@media (max-width: 1100px) {
  .hb-head__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hb-stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: stretch;
  }

  .hb-card {
    grid-template-columns: 4.4rem minmax(0, 1fr);
  }

  .hb-card > .hb-tools {
    grid-column: 2;
    margin-top: 1.2rem;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    column-gap: 1.5rem;
  }

  .hb-card > .hb-tools li:first-child a {
    border-top: 0;
  }

  .hb-card > .hb-tools li:nth-child(2) a {
    border-top: 0;
  }

  .hb-card > .hb-tools .hb-progress,
  .hb-card > .hb-tools .hb-tools__note {
    grid-column: 1 / -1;
  }

  .hb-row--lang .hb-card {
    grid-template-columns: 4.4rem minmax(0, 1fr);
  }

  .hb-row--lang .hb-code {
    grid-column: 2;
    margin-top: 1.4rem;
    max-width: 30rem;
  }
}

@media (max-width: 720px) {
  .hb-row {
    --node-top: 1.55rem;
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .hb-row::before {
    left: 9px;
  }

  .hb-row::after {
    left: 30px;
  }

  .hb-node {
    left: 10px;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
  }

  .hb-node--aside {
    width: 15px;
    height: 15px;
    margin: -7.5px 0 0 -7.5px;
  }

  .hb-row[data-state="done"] .hb-node::after {
    top: 2px;
    left: 3.5px;
  }

  .hb-card {
    grid-template-columns: minmax(0, 1fr);
    padding: 1.15rem 0.4rem 1.5rem 0.7rem;
  }

  .hb-num {
    margin-bottom: 0.3rem;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .hb-row:not(.hb-row--aside) .hb-num::before {
    content: "Chapitre ";
  }

  .hb-card > .hb-tools {
    grid-column: 1;
  }

  .hb-title {
    font-size: clamp(1.6rem, 7vw, 2rem);
  }

  .hb-fiches {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
    gap: 0 1rem;
  }

  .hb-fiches a {
    min-height: 2.75rem;
    padding: 0.55rem 0;
  }

  .hb-practice__list {
    grid-template-columns: minmax(0, 1fr);
  }

  .hb-practice__list li + li,
  .hb-practice__list li:nth-child(even) {
    border-top: 1px solid var(--hb-line-2);
    border-left: 0;
  }

  .hb-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.2rem 0.9rem;
  }

  .hb-ruler {
    grid-auto-columns: max-content;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .hb-ruler::-webkit-scrollbar {
    display: none;
  }

  .hb-tick {
    min-width: 4.6rem;
    scroll-snap-align: start;
  }

  .hb-row--lang .hb-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .hb-row--lang .hb-logo {
    margin-bottom: 0.9rem;
  }

  .hb-row--lang .hb-code {
    grid-column: 1;
    max-width: none;
  }

  .hb-list--prog .hb-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .hb-tools--inline a {
    min-height: 2.75rem;
  }

  .hb-btn {
    flex: 1 1 100%;
  }
}

@media (max-width: 420px) {
  .hb-fiches {
    grid-template-columns: minmax(0, 1fr);
  }

  .hb-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .hb-row {
    animation: none;
  }

  .hb *,
  .hb *::before,
  .hb *::after {
    transition-duration: 0.01ms !important;
  }
}
