/* Fenêtre modale (fiche d'un événement) : site public et tableau de bord. */

.modal {
  /* margin:auto rétabli explicitement (annulé par le reset) : centre le <dialog> */
  margin: auto;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(44rem, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 2rem);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  color: var(--ink);
}

/* Modale ouverte : la page derrière ne défile plus (molette, clavier) */
html:has(.modal[open]) {
  overflow: hidden;
  scrollbar-gutter: stable;
}

.modal::backdrop {
  background: rgb(8 30 40 / 0.55);
  backdrop-filter: blur(2px);
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) 0;
}

.modal__title {
  font-size: var(--text-2xl);
}

.modal__close {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-full);
  background: var(--bg-soft);
  color: var(--primary-dark);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  background: var(--line);
}

.modal__body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}


/* Agenda ouvert depuis la nav : calendrier pleine largeur, seul le corps défile */
.agenda-modal {
  width: min(72rem, calc(100vw - 2 * var(--gutter)));
}

.agenda-modal[open] {
  display: flex;
  flex-direction: column;
}

.agenda-modal .modal__header {
  flex: none;
  align-items: center;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.agenda-modal .modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.agenda-modal .calendar {
  border: none;
  box-shadow: none;
  padding: 0;
}

@media (max-width: 639px) {
  .agenda-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .agenda-modal .modal__header,
  .agenda-modal .modal__body {
    padding-inline: var(--gutter);
  }
}
