/*
 * Prise de rendez-vous — habillage du calendrier maison.
 *
 * Cette feuille vit dans le thème, et c'est la seule place possible : le
 * balisage est construit par `assets/js/rendez-vous.js` et n'existe donc pas
 * dans le builder. C'est l'exception que la §5 prévoit, la même que `form.css`
 * et `filters.css` — pas une dérogation prise en passant.
 *
 * Tout est exprimé avec les alias du site (`--panel`, `--line`, `--text`,
 * `--sp-*`, `--r-*`, `--fs-*`), qui basculent seuls entre le thème sombre et le
 * thème clair. Aucune règle n'est écrite deux fois pour deux thèmes.
 */

/* ------------------------------------------------------------------ */
/* Enveloppe                                                           */
/* ------------------------------------------------------------------ */

.c-rdv {
  width: 100%;
  align-self: stretch;
}

.c-rdv__inner {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  padding: var(--sp-card-pad);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--panel);
}

.c-rdv__form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  width: 100%;
}

.c-rdv__step {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.c-rdv__step-title {
  margin: 0;
  font-size: var(--fs-s);
  font-weight: 600;
  line-height: var(--lh-head);
  color: var(--text);
}

/* Le titre reçoit le focus au changement de jour : il ne doit pas pour autant
   dessiner un anneau de saisie. */
.c-rdv__step-title:focus {
  outline: none;
}

.c-rdv__step-title:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: var(--r-2xs, 4px);
}

/* ------------------------------------------------------------------ */
/* Barre de mois                                                       */
/* ------------------------------------------------------------------ */

.c-rdv__monthbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.c-rdv__month {
  flex: 1;
  text-align: center;
  font-size: var(--fs-s);
  font-weight: 600;
  color: var(--text);
}

.c-rdv__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--motion-duration-fast, 160ms) var(--ease),
    background-color var(--motion-duration-fast, 160ms) var(--ease);
}

.c-rdv__nav:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--brand-t);
}

.c-rdv__nav:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.c-rdv__nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ------------------------------------------------------------------ */
/* Grille du mois                                                      */
/* ------------------------------------------------------------------ */

.c-rdv__weekdays,
.c-rdv__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--sp-1);
}

.c-rdv__weekday {
  padding-block: var(--sp-1);
  text-align: center;
  /* 12,48 px et non 10,4 : ces sept lettres sont l'en-tête du calendrier, et
     c'est sur elles qu'on aligne un jour du regard. Mesuré le 07/08/2026. */
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

.c-rdv__day {
  display: flex;
  align-items: center;
  justify-content: center;
  /*
   * Bornée en hauteur, et pas seulement en bas.
   *
   * Un `aspect-ratio: 1` dans une grille de sept colonnes donne la largeur de
   * colonne pour hauteur : mesuré à 75 px dans la colonne de 547 px de la page
   * contact, soit une grille de calendrier plus haute que le formulaire qu'elle
   * accompagne. La borne haute règle le cas sans dépendre de la largeur de
   * l'hôte — le module est déposé dans un conteneur dont on ne sait rien.
   */
  min-height: 40px;
  max-height: 46px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-s);
  background: transparent;
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--motion-duration-fast, 160ms) var(--ease),
    border-color var(--motion-duration-fast, 160ms) var(--ease),
    color var(--motion-duration-fast, 160ms) var(--ease);
}

.c-rdv__day--empty {
  cursor: default;
}

/*
 * `:not(.is-selected)` n'est pas une précaution de style, c'est une correction
 * de lisibilité.
 *
 * L'état choisi peint le fond en `--brand` et le texte en `--on-primary`, donc
 * en blanc. Le survol, lui, ne repeignait que le fond — en `--brand-t`, un bleu
 * très clair. Survoler le jour qu'on venait de choisir faisait donc disparaître
 * son numéro : blanc sur bleu pâle. Signalé à l'usage le 06/08/2026.
 */
.c-rdv__day:hover:not([aria-disabled='true']):not(.is-selected) {
  border-color: var(--brand);
  background: var(--brand-t);
}

.c-rdv__day:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/*
 * Un jour fermé reste atteignable au clavier — `aria-disabled`, pas `disabled` —
 * donc il doit se distinguer autrement que par le seul curseur.
 */
.c-rdv__day--off {
  color: var(--text-3, var(--text-2));
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.c-rdv__day.is-selected {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-primary);
  font-weight: 700;
}

/*
 * Le survol d'un élément déjà choisi se dit par un halo, et non par un
 * changement de fond : le contraste texte/fond reste celui qu'on a validé, et
 * l'élément répond quand même au pointeur.
 */
.c-rdv__day.is-selected:hover,
.c-rdv__slot.is-selected:hover {
  box-shadow: 0 0 0 3px var(--brand-t2);
}

/* ------------------------------------------------------------------ */
/* Créneaux                                                            */
/* ------------------------------------------------------------------ */

.c-rdv__day-label {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.c-rdv__slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: var(--sp-2);
}

.c-rdv__slot {
  /*
   * Le centrage est explicite. Un `<button>` centre son texte par défaut, mais
   * la feuille du site aligne à gauche plus haut dans la cascade : l'heure se
   * collait au bord gauche de sa cellule, et une grille d'heures décalées se lit
   * mal — c'est justement une colonne de valeurs comparables.
   */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: transparent;
  font-size: var(--fs-s);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--motion-duration-fast, 160ms) var(--ease),
    background-color var(--motion-duration-fast, 160ms) var(--ease);
}

.c-rdv__slot:hover:not(.is-selected) {
  border-color: var(--brand);
  background: var(--brand-t);
}

.c-rdv__slot:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.c-rdv__slot.is-selected {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-primary);
  font-weight: 600;
}

.c-rdv__empty {
  margin: 0;
  font-size: var(--fs-s);
  color: var(--text-2);
}

/* ------------------------------------------------------------------ */
/* Champs                                                              */
/* ------------------------------------------------------------------ */

.c-rdv__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.c-rdv__field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.c-rdv__field--full {
  grid-column: 1 / -1;
}

.c-rdv__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
}

.c-rdv__optional {
  font-weight: 400;
  color: var(--text-2);
}

.c-rdv__input {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--bg);
  color: var(--text);
  /*
   * La typographie est héritée propriété par propriété, jamais par `font:
   * inherit` : le raccourci apporte aussi la hauteur de ligne du corps de
   * texte, ce qui allonge chaque champ de 5 à 7 px. Sur six champs, la carte
   * gagne une quarantaine de pixels sans qu'aucune règle ne semble en cause.
   */
  font-family: inherit;
  font-size: var(--fs-s);
  transition: border-color var(--motion-duration-fast, 160ms) var(--ease);
}

.c-rdv__input::placeholder {
  color: var(--text-2);
  opacity: 0.75;
}

.c-rdv__input:hover {
  border-color: var(--line-strong);
}

.c-rdv__input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.c-rdv__input[aria-invalid='true'] {
  border-color: var(--danger);
}

.c-rdv__error:empty {
  display: none;
}

.c-rdv__error {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--danger);
}

/* ------------------------------------------------------------------ */
/* Consentement                                                        */
/* ------------------------------------------------------------------ */

.c-rdv__consent {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.c-rdv__checkbox {
  /* La case native est conservée : elle porte le clavier, la validation et
     l'envoi. Seule sa taille est reprise, pour rester une cible atteignable. */
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--brand);
  cursor: pointer;
}

.c-rdv__checkbox:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.c-rdv__consent-label {
  font-size: var(--fs-xs);
  line-height: var(--lh-body);
  color: var(--text-2);
  cursor: pointer;
}

.c-rdv__link {
  color: var(--brand-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.c-rdv__link:hover {
  text-decoration-thickness: 2px;
}

.c-rdv__link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/*
 * Le piège à robots.
 *
 * Ni `display: none` ni `visibility: hidden` : un automate un peu sérieux
 * ignore ce qui est masqué de cette façon. Le champ est sorti du flux et rendu
 * inatteignable au pointeur, tout en restant « affiché » au sens du moteur de
 * rendu.
 */
.c-rdv__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Pied et états                                                       */
/* ------------------------------------------------------------------ */

.c-rdv__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}

.c-rdv__recap {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
}

.c-rdv__recap.is-set {
  color: var(--text);
  font-weight: 600;
}

.c-rdv__status:empty {
  display: none;
}

.c-rdv__status {
  margin: 0;
  padding: var(--sp-3);
  border-radius: var(--r-s);
  font-size: var(--fs-s);
  color: var(--text-2);
}

.c-rdv__status.is-error {
  background: var(--danger-t);
  color: var(--danger);
}

.c-rdv__status.is-success {
  background: var(--ok-t);
  color: var(--ok);
}

/* L'état d'envoi : le bouton dit qu'il travaille, et cesse d'être actionnable. */
[data-rdv-etat='envoi'] .c-rdv__submit {
  opacity: 0.6;
  cursor: progress;
}

[data-rdv-etat='envoi'] .c-rdv__submit-label::after {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: c-rdv-tourne 0.7s linear infinite;
}

@keyframes c-rdv-tourne {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 640px) {
  .c-rdv__inner {
    padding: var(--sp-4);
    gap: var(--sp-5);
  }

  .c-rdv__fields {
    grid-template-columns: minmax(0, 1fr);
  }

  /* La cible tactile prime sur le carré parfait : 44 px est le plancher. */
  .c-rdv__day {
    aspect-ratio: auto;
    min-height: 44px;
  }

  .c-rdv__slots {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  }

  .c-rdv__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .c-rdv__submit {
    justify-content: center;
  }
}

/* ------------------------------------------------------------------ */
/* Mouvement réduit                                                    */
/* ------------------------------------------------------------------ */

/*
 * WCAG 2.3.3. Le rond d'attente est le seul mouvement de ce module ; on le
 * remplace par une pulsation d'opacité, qui dit la même chose sans rotation.
 */
@media (prefers-reduced-motion: reduce) {
  [data-rdv-etat='envoi'] .c-rdv__submit-label::after {
    animation: c-rdv-pulse 1.4s ease-in-out infinite;
  }

  @keyframes c-rdv-pulse {
    50% {
      opacity: 0.3;
    }
  }
}

/* ------------------------------------------------------------------ */
/* Mention d'approximation                                             */
/* ------------------------------------------------------------------ */

/*
 * Le créneau réservé n'est pas un engagement à la minute.
 *
 * La mention est discrète mais lisible — pas un astérisque en 10 px : c'est une
 * réserve sur ce que la personne vient de choisir, elle doit se lire sans
 * effort. Le liseré à gauche la rattache visuellement à la liste des créneaux
 * qu'elle commente.
 */
.c-rdv__note {
  margin: 0;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--line-strong);
  font-size: var(--fs-xs);
  line-height: var(--lh-body);
  color: var(--text-2);
}
