/* ==========================================================
   Première visite : étape 1 « Choisir un cours » par niveau.
   Quatre onglets (les repères de niveau), puis les cartes des cours de ce niveau.
   Sans JavaScript : pas d'onglets, les quatre niveaux s'affichent les uns sous les autres.
   ========================================================== */

.pv-lvl {
  margin-top: 1.75rem;
}

/* Pastilles : mêmes couleurs que .levels-dot (lignee.css, session B seulement) */
.pv-lvl__dot {
  display: inline-block;
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
}

/* Couleurs des niveaux : --level-* dans tokens.css */
.pv-lvl__dot--debuter { background: var(--level-debuter); }
.pv-lvl__dot--reguliere { background: var(--level-reguliere); }
.pv-lvl__dot--tous { background: var(--level-tous); }
.pv-lvl__dot--sans { background: var(--level-sans); }

/* ---------- Onglets ---------- */

.pv-lvl__tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.pv-lvl__tabs[hidden] {
  display: none;
}

.pv-lvl__tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.3s var(--ease), background-color 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.pv-lvl__tab:hover {
  background: var(--card-hover);
}

.pv-lvl__tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Onglet choisi : filet coloré en bas, léger relief */
.pv-lvl__tab::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: -1px;
  height: 3px;
  background: var(--pv-lvl-color, var(--color-primary));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease);
}

.pv-lvl__tab[aria-selected="true"] {
  border-color: var(--pv-lvl-color, var(--color-primary));
  box-shadow: 0 6px 18px rgba(35, 40, 46, 0.08);
  transform: translateY(-2px);
}

.pv-lvl__tab[aria-selected="true"]::after {
  transform: scaleX(1);
}

/* Invitation à cliquer (aucun niveau choisi) : vague légère sur les onglets, trois fois */
.pv-lvl.is-inviting .pv-lvl__tab {
  animation: pv-lvl-invite 2.6s var(--ease) 0.3s 3 both;
}

.pv-lvl.is-inviting .pv-lvl__tab::after {
  animation: pv-lvl-invite-line 2.6s var(--ease) 0.3s 3 both;
}

.pv-lvl.is-inviting .pv-lvl__tab:nth-child(2),
.pv-lvl.is-inviting .pv-lvl__tab:nth-child(2)::after { animation-delay: 0.45s; }
.pv-lvl.is-inviting .pv-lvl__tab:nth-child(3),
.pv-lvl.is-inviting .pv-lvl__tab:nth-child(3)::after { animation-delay: 0.6s; }
.pv-lvl.is-inviting .pv-lvl__tab:nth-child(4),
.pv-lvl.is-inviting .pv-lvl__tab:nth-child(4)::after { animation-delay: 0.75s; }

/* Survol pendant l'invitation : l'animation s'arrête sur cet onglet */
.pv-lvl.is-inviting .pv-lvl__tab:hover,
.pv-lvl.is-inviting .pv-lvl__tab:hover::after {
  animation: none;
}

@keyframes pv-lvl-invite {
  0%, 40%, 100% {
    transform: none;
    box-shadow: none;
  }
  18% {
    transform: translateY(-4px);
    box-shadow: 0 8px 18px rgba(35, 40, 46, 0.1);
  }
}

@keyframes pv-lvl-invite-line {
  0%, 40%, 100% { transform: scaleX(0); }
  18% { transform: scaleX(0.4); }
}

.pv-lvl__tab--debuter { --pv-lvl-color: var(--level-debuter); }
.pv-lvl__tab--reguliere { --pv-lvl-color: var(--level-reguliere); }
.pv-lvl__tab--tous { --pv-lvl-color: var(--level-tous); }
.pv-lvl__tab--sans { --pv-lvl-color: var(--level-sans); }

.pv-lvl__tab-name {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-weight: 600;
  line-height: 1.3;
}

/* Pastille alignée sur la première ligne du titre (même s'il passe à la ligne) */
.pv-lvl__tab-name .pv-lvl__dot,
.pv-lvl__panel-title .pv-lvl__dot {
  margin-top: calc((1.3em - 0.75rem) / 2);
}

.pv-lvl__tab-hint {
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Tablette et téléphone : deux onglets par ligne, sans la phrase d'aide sur petit écran */
@media (max-width: 56em) {
  .pv-lvl__tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 30em) {
  .pv-lvl__tab {
    padding: 0.8rem 0.9rem 0.9rem;
  }

  .pv-lvl__tab-hint {
    font-size: 0.85rem;
  }
}

/* ---------- Panneaux ---------- */

.pv-lvl__panel {
  padding-top: 1.75rem;
}

.pv-lvl__panel + .pv-lvl__panel {
  margin-top: 1rem;
}

/* Avec onglets, le titre du panneau ne sert qu'aux lecteurs d'écran */
.pv-lvl.is-ready .pv-lvl__panel-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pv-lvl.is-ready .pv-lvl__panel + .pv-lvl__panel {
  margin-top: 0;
}

.pv-lvl__panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start; /* aligné à gauche, sur la colonne du texte */
  gap: 0.55rem;
  max-width: var(--measure);
  margin: 0 auto 0.5rem;
  line-height: 1.3;
}

.pv-lvl__desc {
  max-width: var(--measure);
  margin: 0 auto 1.5rem;
  color: var(--color-muted);
}

.pv-lvl__panel:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 6px;
}

/* Cartes : grille qui passe à la ligne (jusqu'à cinq cours), centrée quand il y en a peu */
.pv-lvl__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 16rem));
  justify-content: center;
  gap: 1.5rem;
}

.pv-lvl__item {
  display: flex;
  flex-direction: column;
}

.pv-lvl__item > .card {
  flex: 1 1 auto;
  height: auto;
}

/* Note dans la carte (onglet « Tous niveaux ») : entre le texte et « Découvrir le cours » */
.pv-lvl .card__note {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.pv-lvl .card__note-label {
  color: var(--color-muted);
}

/* Liens de la note au-dessus du lien qui couvre toute la carte */
.pv-lvl .card__note a {
  position: relative;
  z-index: 2;
}

.pv-lvl .card__note-sep {
  color: var(--color-muted);
  padding-inline: 0.2rem;
}

/* Apparition des cartes l'une après l'autre quand on change de niveau */
.pv-lvl__panel.is-entering .pv-lvl__desc,
.pv-lvl__panel.is-entering .pv-lvl__item {
  animation: pv-lvl-in 0.55s var(--ease) both;
}

.pv-lvl__panel.is-entering .pv-lvl__item:nth-child(1) { animation-delay: 0.08s; }
.pv-lvl__panel.is-entering .pv-lvl__item:nth-child(2) { animation-delay: 0.16s; }
.pv-lvl__panel.is-entering .pv-lvl__item:nth-child(3) { animation-delay: 0.24s; }
.pv-lvl__panel.is-entering .pv-lvl__item:nth-child(4) { animation-delay: 0.32s; }
.pv-lvl__panel.is-entering .pv-lvl__item:nth-child(n+5) { animation-delay: 0.4s; }

@keyframes pv-lvl-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Mouvement réduit : pas d'animation */
@media (prefers-reduced-motion: reduce) {
  .pv-lvl__tab,
  .pv-lvl__tab::after {
    transition: none;
  }

  .pv-lvl__tab[aria-selected="true"] {
    transform: none;
  }

  .pv-lvl.is-inviting .pv-lvl__tab,
  .pv-lvl.is-inviting .pv-lvl__tab::after {
    animation: none;
  }

  .pv-lvl__panel.is-entering .pv-lvl__desc,
  .pv-lvl__panel.is-entering .pv-lvl__item {
    animation: none;
  }
}
