/* Composants (lot D) : niveaux et puces (nv-), dessin des lèvres (lv-), graphiques (gr-).
   Couleurs : uniquement les variables de css/style.css (§ 8.8 du plan). Le rose → cramoisi reste au degré. */

/* ========== niveaux, puces, oui / non ========== */

.nv-groupe {
  margin: 0 0 16px;
}

.nv-groupe:last-child {
  margin-bottom: 0;
}

.nv-legende {
  margin: 0 0 8px;
  color: var(--encre);
  font-size: 1rem;
  font-weight: 650;
}

.nv-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nv-niveaux .nv-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.nv-option {
  position: relative;
  display: flex;
  min-width: 0;
}

/* La vraie case couvre tout le bouton (toucher, VoiceOver) mais reste invisible : le span dessine le bouton. */
.nv-entree {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.nv-texte {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--toucher);
  padding: 8px 16px;
  border: 1.5px solid var(--trait-fort, var(--encre-3));
  border-radius: 999px;
  background: var(--surface);
  color: var(--encre);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

/* 4 boutons de 76 px à 390 px : texte un peu plus petit, au moins 6 px d'écart avec le bord (« très bien »). */
.nv-niveaux .nv-texte {
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 12px;
  font-size: 0.8rem;
  letter-spacing: -0.005em;
}

/* Très petit écran : 2 × 2 plutôt que des mots coupés. */
@media (max-width: 359px) {
  .nv-niveaux .nv-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.nv-entree:checked + .nv-texte {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--sur-accent);
}

.nv-entree:focus-visible + .nv-texte {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (hover: hover) {
  .nv-entree:not(:checked):hover + .nv-texte {
    border-color: var(--accent);
  }
}

/* Cases à cocher : une coche dessinée (pas de caractère lu par les lecteurs d'écran). */
.nv-multiple .nv-entree:checked + .nv-texte::before {
  content: "";
  flex: none;
  width: 6px;
  height: 11px;
  margin: -3px 0 0 -2px;
  border: solid currentColor;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

/* Degré : un rond de la couleur au-dessus de chaque libellé ; le choix prend toute la couleur. */
.nv-couleur-degre .nv-d-1 { --nv-couleur: var(--degre-1); --nv-sur: var(--sur-degre-1); }
.nv-couleur-degre .nv-d-2 { --nv-couleur: var(--degre-2); --nv-sur: var(--sur-degre-2); }
.nv-couleur-degre .nv-d-3 { --nv-couleur: var(--degre-3); --nv-sur: var(--sur-degre-3); }
.nv-couleur-degre .nv-d-4 { --nv-couleur: var(--degre-4); --nv-sur: var(--sur-degre-4); }

.nv-couleur-degre .nv-texte {
  flex-direction: column;
  gap: 5px;
  min-height: 60px;
}

.nv-couleur-degre .nv-texte::before {
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--nv-couleur);
}

.nv-couleur-degre .nv-entree:checked + .nv-texte {
  border-color: var(--nv-couleur);
  background: var(--nv-couleur);
  color: var(--nv-sur);
}

.nv-couleur-degre .nv-entree:checked + .nv-texte::before {
  background: var(--nv-sur);
}

/* ========== lèvres ========== */

.lv-saisie {
  margin: 0;
}

.lv-cache,
.lv-cases,
.gr-cache {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.lv-aide {
  margin: 0 0 8px;
  color: var(--encre-2);
  font-size: 0.9375rem;
}

.lv-cadre {
  max-width: 400px;
  margin: 0 auto;
}

.lv-dessin {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  -webkit-user-select: none;
  user-select: none;
}

/* Saisie : le svg déborde de chaque côté sur la marge de la carte (--lv-debord, en part de la largeur du dessin,
   fixé par levres.js). La cible invisible de l'anneau s'y touche aussi, sans compter sur overflow: visible ; le
   dessin garde toute la largeur du cadre. */
.lv-saisie-dessin {
  width: calc(100% * (1 + 2 * var(--lv-debord, 0)));
  max-width: none;
  margin-inline: calc(-100% * var(--lv-debord, 0));
}

.lv-dessin [hidden] {
  display: none;
}

.lv-forme {
  fill: var(--levre);
  stroke: var(--levre-contour);
  stroke-width: 1;
  stroke-linejoin: round;
  transition: fill 0.15s, stroke 0.15s;
}

.lv-degre-0 { --lv-plein: var(--encre-3); --lv-sur: var(--surface); }
.lv-degre-1 { --lv-plein: var(--degre-1); --lv-sur: var(--sur-degre-1); }
.lv-degre-2 { --lv-plein: var(--degre-2); --lv-sur: var(--sur-degre-2); }
.lv-degre-3 { --lv-plein: var(--degre-3); --lv-sur: var(--sur-degre-3); }
.lv-degre-4 { --lv-plein: var(--degre-4); --lv-sur: var(--sur-degre-4); }

.lv-saisie-dessin .lv-zone,
.lv-cible {
  cursor: pointer;
}

.lv-cible {
  fill: transparent;
}

/* Cible de l'anneau : seulement son trait épais (stroke-width dans levres.js) ; le trou garde les écarts vides. */
.lv-cible-anneau {
  fill: none;
  stroke: transparent;
  pointer-events: stroke;
}

.lv-zone.lv-choisie .lv-forme,
.lv-mini .lv-forme.lv-choisie {
  fill: var(--lv-plein);
  stroke: var(--lv-plein);
}

.lv-coche {
  display: none;
  fill: none;
  stroke: var(--lv-sur);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.lv-choisie .lv-coche {
  display: inline;
}

.lv-nom-anneau {
  fill: var(--encre-2);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.lv-choisie .lv-nom-anneau {
  fill: var(--lv-sur);
}

.lv-bouche {
  fill: none;
  stroke: var(--levre-contour);
  stroke-width: 1;
  pointer-events: none;
}

.lv-focus-halo,
.lv-focus-anneau {
  fill: none;
  stroke-linejoin: round;
  pointer-events: none;
}

.lv-focus-halo {
  stroke: var(--surface);
  stroke-width: 8;
}

.lv-focus-anneau {
  stroke: var(--accent);
  stroke-width: 3.5;
}

@media (hover: hover) {
  .lv-saisie-dessin .lv-zone:not(.lv-choisie):hover .lv-forme {
    stroke: var(--accent);
    stroke-width: 1.5;
  }
}

.lv-cotes {
  display: flex;
  justify-content: space-between;
  max-width: 400px;
  margin: 2px auto 0;
  padding: 0 2px;
  color: var(--encre-2);
  font-size: 0.8125rem;
}

.lv-texte {
  margin: 10px 0 0;
  color: var(--encre);
  font-size: 0.9375rem;
}

/* Carte des endroits : couleur selon le nombre de poussées, chiffre écrit dans la zone. */
.lv-carte {
  margin: 0;
}

.lv-legende-titre {
  margin: 0 0 8px;
  color: var(--encre-2);
  font-size: 0.9375rem;
}

.lv-n-0 { --lv-plein: var(--levre); --lv-bord: var(--levre-contour); --lv-sur: var(--encre); }
.lv-n-1 { --lv-plein: var(--degre-1); --lv-bord: var(--degre-1); --lv-sur: var(--sur-degre-1); }
.lv-n-2 { --lv-plein: var(--degre-2); --lv-bord: var(--degre-2); --lv-sur: var(--sur-degre-2); }
.lv-n-3 { --lv-plein: var(--degre-3); --lv-bord: var(--degre-3); --lv-sur: var(--sur-degre-3); }
.lv-n-4 { --lv-plein: var(--degre-4); --lv-bord: var(--degre-4); --lv-sur: var(--sur-degre-4); }

.lv-carte-dessin .lv-forme {
  fill: var(--lv-plein);
  stroke: var(--lv-bord);
}

/* Liseré de la couleur de la zone : il masque la ligne de la bouche derrière le chiffre. */
.lv-chiffre {
  fill: var(--lv-sur);
  stroke: var(--lv-plein);
  stroke-width: 3px;
  stroke-linejoin: round;
  paint-order: stroke fill;
  font-size: 17px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.lv-chiffre-petit {
  font-size: 13px;
}

.lv-legende {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 12px 0 0;
  padding: 0;
  color: var(--encre-2);
  font-size: 0.875rem;
  list-style: none;
}

.lv-legende-el {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lv-pastille {
  width: 14px;
  height: 14px;
  border: 1px solid var(--lv-bord);
  border-radius: 4px;
  background: var(--lv-plein);
}

.lv-mini {
  display: block;
  flex: none;
  overflow: visible;
}

.lv-mini .lv-forme {
  stroke: none;
}

.lv-mini .lv-contour {
  fill: none;
  stroke: var(--levre-contour);
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

/* ========== tableaux des chiffres (lèvres et graphiques) ========== */

.lv-table,
.gr-table {
  width: 100%;
  margin: 12px 0 0;
  border-collapse: collapse;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.lv-table th,
.lv-table td,
.gr-table th,
.gr-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--trait);
  text-align: left;
  vertical-align: baseline;
}

.lv-table :is(th, td):first-child,
.gr-table :is(th, td):first-child {
  padding-left: 0;
}

.lv-table :is(th, td):last-child,
.gr-table :is(th, td):last-child {
  padding-right: 0;
}

.lv-table thead th,
.gr-table thead th {
  color: var(--encre-2);
  font-size: 0.8125rem;
  font-weight: 650;
}

.lv-table tbody th,
.gr-table tbody th {
  font-weight: 500;
}

.lv-num,
.gr-num {
  text-align: right !important;
}

.lv-zero {
  color: var(--encre-2);
}

.gr-table tfoot :is(th, td) {
  border-bottom: 0;
  font-weight: 750;
}

/* ========== graphiques ========== */

.gr-figure {
  margin: 0;
}

.gr-figure + .gr-figure {
  margin-top: 24px;
}

.gr-titre {
  margin: 0 0 8px;
  color: var(--encre);
  font-size: 1rem;
  font-weight: 700;
}

.gr-figure .serie-annee { --gr-couleur: var(--accent); }
.gr-figure .serie-precedente { --gr-couleur: var(--serie-prec); }

.gr-legende {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 10px;
  padding: 0;
  color: var(--encre-2);
  font-size: 0.875rem;
  list-style: none;
}

.gr-legende li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gr-cle {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--gr-couleur, var(--accent));
}

.gr-graphe {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  grid-template-rows: 140px auto;
  column-gap: 6px;
  border-radius: 8px;
}

.gr-graphe:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.gr-axe-y {
  position: relative;
  grid-row: 1;
  grid-column: 1;
}

.gr-graduation {
  position: absolute;
  right: 0;
  bottom: calc(var(--gr-y) * 100%);
  color: var(--encre-3);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transform: translateY(50%);
}

.gr-trace {
  position: relative;
  grid-row: 1;
  grid-column: 2;
  touch-action: pan-y;
  cursor: crosshair;
}

.gr-grille,
.gr-colonnes-mois {
  position: absolute;
  inset: 0;
}

.gr-grille {
  pointer-events: none;
}

.gr-ligne {
  position: absolute;
  right: 0;
  bottom: calc(var(--gr-y) * 100%);
  left: 0;
  height: 1px;
  background: var(--trait);
}

.gr-ligne-base {
  background: var(--trait-fort, var(--encre-3));
}

.gr-colonnes-mois {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.gr-mois {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 100%;
  padding: 0 3px;
}

.gr-mois.gr-actif::before {
  content: "";
  position: absolute;
  inset: -4px 1px 0;
  border-radius: 6px;
  background: var(--trait);
  opacity: 0.6;
}

.gr-col {
  position: relative;
  flex: 0 1 9px;
  min-width: 3px;
  height: calc(var(--gr-h) * 100%);
  border-radius: 4px 4px 0 0;
  background: var(--gr-couleur, var(--accent));
}

.gr-series-1 .gr-col {
  flex-basis: 14px;
}

.gr-col-zero {
  visibility: hidden;
}

.gr-axe-x {
  display: grid;
  grid-row: 2;
  grid-column: 2;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  padding-top: 6px;
  color: var(--encre-3);
  font-size: 0.75rem;
  line-height: 1;
  text-align: center;
}

.gr-bulle {
  position: absolute;
  top: 0;
  left: var(--gr-gauche, 0);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 104px;
  padding: 8px 10px;
  border: 1px solid var(--trait);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--ombre-forte);
  color: var(--encre-2);
  font-size: 0.8125rem;
  line-height: 1.3;
  pointer-events: none;
}

.gr-bulle[hidden] {
  display: none;
}

.gr-bulle-titre {
  color: var(--encre);
  font-weight: 700;
}

.gr-bulle-ligne {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.gr-bulle-cle {
  flex: none;
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: var(--gr-couleur, var(--accent));
}

.gr-bulle strong {
  color: var(--encre);
  font-variant-numeric: tabular-nums;
}

/* Barres horizontales : le tableau est le graphique. */
.gr-table-barres {
  width: 100%;
  border-collapse: collapse;
}

.gr-table-barres th,
.gr-table-barres td {
  padding: 10px 0;
  border-bottom: 1px solid var(--trait);
}

.gr-table-barres tr:last-child :is(th, td) {
  border-bottom: 0;
}

.gr-table-barres th {
  font-weight: 400;
  text-align: left;
  vertical-align: top;
}

.gr-tete {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  line-height: 1.3;
}

.gr-libelle {
  color: var(--encre);
  font-size: 0.9375rem;
  font-weight: 600;
}

.gr-detail {
  color: var(--encre-2);
  font-size: 0.8125rem;
}

.gr-barre {
  display: block;
  width: calc(var(--gr-part) * 100%);
  min-width: 3px;
  height: 10px;
  margin-top: 6px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.gr-barre-zero {
  width: 0;
  min-width: 0;
}

.gr-table-barres .gr-valeur {
  width: 1%;
  padding-left: 12px;
  color: var(--encre);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  vertical-align: bottom;
}

.gr-vide {
  margin: 0;
}

/* Mini-calendrier : un petit mois dans un bouton, lundi en premier. */
.gr-mini {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
  min-height: var(--toucher);
  margin: 0;
  padding: 8px;
  border: 1px solid var(--trait);
  border-radius: 10px;
  background: var(--surface);
  color: var(--encre);
  font: inherit;
  text-align: left;
}

.gr-mini:active {
  background: var(--accent-doux, var(--fond));
}

@media (hover: hover) {
  .gr-mini:hover {
    border-color: var(--accent);
  }
}

.gr-mini-titre {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
}

.gr-mini-grille {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
}

.gr-mini-jour,
.gr-mini-vide {
  aspect-ratio: 1;
  border-radius: 2px;
}

.gr-mini-jour {
  position: relative;
  background: var(--fond);
}

/* Journal rempli : un point au milieu du jour, comme dans la vue mois (--encre-3 : 3:1 au moins sur --fond, dans
   les deux thèmes). Les jours colorés par un degré n'en ont pas. */
.gr-mini-journal::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: var(--encre-3);
}

.gr-mini-jour.gr-d-1 { background: var(--degre-1); }
.gr-mini-jour.gr-d-2 { background: var(--degre-2); }
.gr-mini-jour.gr-d-3 { background: var(--degre-3); }
.gr-mini-jour.gr-d-4 { background: var(--degre-4); }

.gr-mini-futur {
  opacity: 0.4;
}

.gr-mini-aujourdhui {
  box-shadow: 0 0 0 1.5px var(--encre);
}
