/**
 * Dowin — calendrier unifié « Ma semaine » (1.168.0).
 *
 * Fenêtre modale : en-tête, filtres en pastilles et sept jours en liste
 * verticale. Le mobile d'abord — sur 369 px de large, une grille de sept
 * colonnes rendrait les intitulés illisibles ; les jours s'empilent donc, et
 * passent à deux colonnes seulement quand la place existe. Les cibles tactiles
 * (filtres, événements, fermeture) font 40 px au moins, et chaque événement
 * porte un liseré de couleur **et** son type écrit, pour rester lisible sans
 * distinguer les couleurs.
 *
 * Toutes les couleurs passent par les variables de `app.css` (thèmes clair,
 * sombre et accents) ; seule la teinte de révision, qui n'a pas de variable, est
 * écrite en dur avec sa variante sombre.
 */

/* ------------------------------- Fenêtre -------------------------------- */

/*
 * Les blocs ci-dessous posent `display: flex` ou `grid` : sans cette règle,
 * l'attribut natif `hidden` serait neutralisé par la feuille de style et le
 * bandeau « rien de prévu » resterait visible alors qu'il est masqué.
 */
.calendrier [hidden] {
  display: none !important;
}

.calendrier__fenetre {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* -------------------------------- En-tête -------------------------------- */

.calendrier__entete {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.calendrier__entete-ligne {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.calendrier__entete-texte {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}

.calendrier__titre-fenetre {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.calendrier__sous-titre {
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-meta);
  overflow-wrap: anywhere;
}

.calendrier__fiches {
  align-self: flex-start;
  margin-top: 2px;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 14%, var(--panel));
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
}

/* Le bouton de fermeture remplace l'en-tête standard de la fenêtre : il doit
 * rester aussi accessible au doigt que la croix habituelle. */
.calendrier__fermer {
  width: 40px;
  height: 40px;
  margin: -6px -8px 0 0;
  border-radius: 50%;
}

.calendrier__prochain {
  padding: 7px 10px;
  border-left: 3px solid var(--green);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* -------------------------------- Filtres -------------------------------- */

.calendrier__filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.calendrier__filtre {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1;
  white-space: nowrap;
}

.calendrier__filtre:hover {
  border-color: var(--green);
  color: var(--text);
}

.calendrier__filtre.is-actif {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, var(--panel));
  color: var(--text);
  font-weight: 600;
}

.calendrier__filtre:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* --------------------------------- Corps --------------------------------- */

.calendrier__corps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.calendrier__vide {
  display: flex;
  grid-column: 1 / -1;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 26px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.calendrier__vide p {
  margin: 0;
  overflow-wrap: anywhere;
}

.calendrier__vide svg {
  width: 26px;
  height: 26px;
  color: var(--text-faint);
}

/* ---------------------------------- Jour --------------------------------- */

.calendrier__jour {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.calendrier__jour.is-aujourdhui {
  border-color: color-mix(in srgb, var(--green) 55%, var(--border));
}

.calendrier__jour-tete {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 7px;
  min-width: 0;
}

.calendrier__jour-nom {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--text-meta);
}

.calendrier__jour-date {
  font-size: 11.5px;
  line-height: 1.2;
  color: var(--text-meta);
  font-variant-numeric: tabular-nums;
}

.calendrier__jour-marque {
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 16%, var(--panel));
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
}

.calendrier__jour-liste {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.calendrier__jour-vide {
  padding: 3px 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

/* -------------------------------- Événement ------------------------------- */

.calendrier__evenement {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  transition: background 0.15s;
}

.calendrier__evenement:hover {
  background: var(--panel-2);
}

.calendrier__evenement:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* Un liseré par type : l'échéance alerte, le devoir prévient, le cours et la
 * révision se suivent au fil de la journée. */
.calendrier__evenement[data-type='echeance'] {
  border-left-color: var(--danger);
}

.calendrier__evenement[data-type='devoir'] {
  border-left-color: var(--warn);
}

.calendrier__evenement[data-type='creneau'] {
  border-left-color: var(--green);
}

.calendrier__evenement[data-type='fiche'] {
  border-left-color: #2f7de1;
}

[data-theme='dark'] .calendrier__evenement[data-type='fiche'] {
  border-left-color: #6aa9f5;
}

.calendrier__heure {
  flex: none;
  min-width: 52px;
  padding-top: 1px;
  color: var(--text-meta);
  font-size: 11px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.calendrier__contenu {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.calendrier__titre {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.calendrier__source {
  color: var(--text-meta);
  font-size: 10.5px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

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

/* Dès qu'il y a la place, deux colonnes de jours : la semaine reste une liste,
 * jamais une grille de sept colonnes illisible sur téléphone. */
@media (min-width: 621px) {
  .calendrier__corps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .calendrier__jour {
    padding: 12px;
  }

  .calendrier__titre {
    font-size: 13px;
  }
}

/* Téléphone étroit (369 px réels) : les pastilles de filtre se resserrent pour
 * tenir sur deux lignes lisibles, et la colonne d'heure cède quelques pixels
 * aux intitulés plutôt que de les couper. */
@media (max-width: 400px) {
  .calendrier__filtre {
    padding: 0 10px;
    font-size: 12px;
  }

  .calendrier__heure {
    min-width: 46px;
  }
}
