/* core/ui.css

   Composants de la refonte UX (nov. 2026) : statut écrit, onglets segmentés
   d'Apprendre, en-tête de section avec compteur, prochain cours.

   Chargé par index.html juste après cards.css. Les listes elles-mêmes
   réutilisent .home-group / .home-row (student/dashboard.css). */

/* ---------- statut : toujours un mot, la couleur ne fait que l'appuyer ---------- */

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: var(--fs-2);
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-2);
}
.pill.is-go { background: var(--primary-tint); color: var(--primary-strong); }
.pill.is-ok { background: var(--green-tint); color: var(--green); }
.pill.is-late { background: var(--amber-tint); color: var(--amber); }

.home-row.is-done .home-row-title { color: var(--muted); }

/* ---------- titre de bloc avec compteur à droite ---------- */

.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  max-width: var(--w-read);
  margin: 0 0 var(--s-3);
}
.block-head h2 { margin: 0; font-size: var(--fs-6); font-weight: 650; letter-spacing: -.01em; }
.block-head span { font-size: var(--fs-3); color: var(--muted); }

/* ---------- Apprendre : onglets segmentés ---------- */

.seg {
  display: flex;
  gap: 4px;
  max-width: var(--w-read);
  margin: 0 0 var(--s-5);
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.seg button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  font: inherit;
  font-size: var(--fs-3);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 0 0 1px var(--border); }
.seg button:hover:not(.on) { color: var(--text); }

/* Les sous-pages d'Apprendre n'ont plus de phrase d'introduction. */
.learn-page .page-lead { display: none; }

/* ---------- prochain cours ---------- */

.home-row .row-icon {
  width: 36px; height: 36px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
}
.home-row .row-icon .icon { width: 20px; height: 20px; }
.row-action { flex: 0 0 auto; font-weight: 600; color: var(--primary-strong); white-space: nowrap; }
a.home-row { text-decoration: none; }

/* ---------- Profil ---------- */

.me-head { display: flex; align-items: center; gap: var(--s-4); max-width: var(--w-read); margin: 0 0 var(--s-5); }
.me-head .page-title { margin: 0; font-size: var(--fs-7); }
.me-head .meta { margin: 2px 0 0; }
.me-head .me-avatar { width: 56px; height: 56px; font-size: var(--fs-5); flex: 0 0 auto; }
.me-level {
  display: flex; align-items: center; gap: var(--s-4);
  width: 100%; padding: var(--s-4); font: inherit; color: var(--text); text-align: left; cursor: pointer;
}
.me-level:hover { background: var(--surface-2); }
.me-level-n { font-size: var(--fs-8); font-weight: 800; letter-spacing: -.02em; color: var(--primary-strong); min-width: 56px; }
.me-skills { display: grid; gap: var(--s-3); margin: var(--s-4) 2px 0; }
.me-skill { display: grid; grid-template-columns: 110px 1fr 32px; gap: var(--s-3); align-items: center; font-size: var(--fs-3); }
.me-skill .bar { display: block; margin: 0; background: var(--surface-2); }
.me-skill b { text-align: right; }
.me-logout { max-width: var(--w-read); margin: var(--s-2) 0 0; }
.btn.is-danger { color: var(--red); }

/* ---------- Apprendre : titre du parcours sous les onglets ---------- */

.learn-page .pl-title { font-size: var(--fs-6); margin: 0; }
.learn-head .page-header { margin-bottom: var(--s-4); }
.work-past { max-width: var(--w-read); margin-top: var(--s-3); }
.work-past summary { list-style: none; cursor: pointer; display: inline-flex; }
.work-past summary::-webkit-details-marker { display: none; }

@media (max-width: 640px) {
  .seg button { font-size: var(--fs-3); padding: 0 4px; }
  .me-skill { grid-template-columns: 96px 1fr 30px; }
}

/* ---------- mouvement réduit : le téléphone l'a demandé, on l'applique partout ---------- */

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

/* ================= Cours et Exercices (nov. 2026) ================= */

/* ---------- filtres : passent à la ligne, jamais coupés ---------- */
.filter-chips.filter-wrap { flex-wrap: wrap; overflow: visible; max-width: var(--w-read); margin-bottom: var(--s-4); }
.filter-chips.filter-wrap .filter-chip { min-height: 36px; }
.filter-label { margin: 0 0 var(--s-2); font-size: var(--fs-2); font-weight: 700; color: var(--muted); }
.part-select { display: none; max-width: var(--w-read); margin-bottom: var(--s-4); }
.part-select select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-4); }
@media (max-width: 640px) {
  .filter-chips.part-chips { display: none; }
  .part-select { display: block; }
}

/* ---------- recommandé ---------- */
.reco-card { display: flex; align-items: center; gap: var(--s-4); max-width: var(--w-read); margin: 0 0 var(--s-6); padding: var(--s-4) var(--s-5); border: 1px solid var(--primary); border-radius: var(--r-md); background: var(--primary-tint); }
.reco-main { flex: 1; min-width: 0; }
.reco-k { margin: 0 0 2px; font-size: var(--fs-2); font-weight: 700; color: var(--primary-strong); }
.reco-title { margin: 0 0 2px; font-size: var(--fs-5); font-weight: 700; color: var(--text); }
.reco-card .meta { margin: 0; }
@media (max-width: 640px) {
  .reco-card { flex-direction: column; align-items: stretch; }
  .reco-card .btn { width: 100%; }
}

/* ---------- exercices ---------- */
.px-list { display: grid; gap: var(--s-2); max-width: var(--w-read); margin-bottom: var(--s-5); }
.px-block { margin-top: var(--s-4); }
.px-block h3 { margin: 0; font-size: var(--fs-5); font-weight: 650; }
.px-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 64px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.px-item:hover { border-color: var(--border-strong); }
.px-item:hover .px-btn { background: var(--primary); color: var(--on-primary, #fff); border-color: var(--primary); }
.px-ico { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); }
.px-ico .icon { width: 20px; height: 20px; }
.px-ico.px-exam { background: var(--text); color: var(--bg); }
.px-ico.px-grammar { background: var(--primary-tint); color: var(--primary-strong); }
.px-ico.px-vocabulary { background: var(--green-tint); color: var(--green); }
.px-ico.px-listening { background: var(--amber-tint); color: var(--amber); }
.px-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.px-title { font-weight: 600; font-size: var(--fs-4); line-height: 1.35; }
.px-tag { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: var(--fs-1); font-weight: 700; vertical-align: 1px; white-space: nowrap; }
.px-tag.is-exam { background: var(--text); color: var(--bg); }
.px-done { color: var(--green); font-weight: 600; }
.px-btn { flex: 0 0 auto; height: 38px; padding: 0 14px; display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font-weight: 700; font-size: var(--fs-3); color: var(--primary-strong); white-space: nowrap; }
@media (max-width: 640px) {
  .px-item { gap: 10px; padding: 12px; align-items: flex-start; }
  .px-ico { width: 32px; height: 32px; }
  .px-ico .icon { width: 17px; height: 17px; }
  .px-btn { height: 32px; padding: 0 10px; font-size: var(--fs-2); align-self: center; }
  .px-tag { margin-left: 0; }
}

/* ---------- cours : cartes de module ---------- */
.level-badge { flex: 0 0 auto; display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: var(--fs-1); font-weight: 800; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-6); }
.module-card { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.module-card.is-current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.mc-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.mc-state { font-size: var(--fs-2); color: var(--muted); }
.mc-state.is-go { color: var(--primary-strong); font-weight: 700; }
.mc-state.is-ok { color: var(--green); font-weight: 700; }
.mc-title { margin: 0; font-size: var(--fs-5); font-weight: 650; line-height: 1.3; }
.mc-desc { margin: 0; font-size: var(--fs-3); line-height: 1.45; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mc-progress { display: flex; align-items: center; gap: var(--s-3); margin-top: auto; padding-top: var(--s-2); font-size: var(--fs-2); color: var(--muted); white-space: nowrap; }
.mc-progress .bar { flex: 1; margin: 0; display: block; }
.module-card .btn { margin-top: var(--s-1); }
.home-row .level-badge { margin-right: 2px; }

/* ---------- leçon ---------- */
.lesson-pager { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.lesson-pager .btn { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar > .bar-fill { display: block; }
.block-head span { white-space: nowrap; }

/* ---------- lecteur audio (js/core/player.js) ----------
   Une ligne : lecture, -10, barre, +10, temps, vitesse. Aux couleurs du thème. */
.ap {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 8px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface-2); max-width: 640px;
}
.ap audio { display: none; }
.ap-play {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--primary); color: var(--on-primary);
}
.ap-play .icon { width: 18px; height: 18px; fill: currentColor; }
.ap-skip, .ap-speed {
  flex: none; min-width: 44px; height: 36px; padding: 0 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.ap-skip:hover, .ap-speed:hover { border-color: var(--primary); }
.ap-time { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 84px; text-align: right; }
.ap-bar {
  --ap-fill: 0%;
  flex: 1; min-width: 60px; height: 28px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.ap-bar::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--primary) var(--ap-fill), var(--border) var(--ap-fill));
}
.ap-bar::-moz-range-track { height: 6px; border-radius: 3px; background: var(--border); }
.ap-bar::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--primary); }
.ap-bar::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%;
  background: var(--text); border: 0;
}
.ap-bar::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; }

@media (max-width: 560px) {
  .ap { flex-wrap: wrap; row-gap: 6px; padding: 8px; }
  .ap-bar { order: 10; flex-basis: 100%; }
  .ap-time { margin-left: auto; }
}
@media (max-width: 560px) {
  .ap-time { min-width: 0; }
}
/* Le lecteur a déjà son cadre : pas de second cadre autour en lecture seule. */
.rec.rec-readonly { padding: 0; border: 0; background: none; }
