/* Fenêtre « Candidature au conseil d'administration » (page S'impliquer).
   Un <dialog> natif plutôt qu'une des superpositions du thème : celles-ci
   sont créées une à une par le script du thème (frontend.min.js), qu'on ne
   modifie pas. Chargé sur toutes les pages, comme les autres feuilles
   d'assets, parce qu'une transition de page ne recharge pas le <head>.

   Structure, de haut en bas :
     - .c-board-dialog__header : titre et bouton « Fermer », toujours visibles ;
     - .c-board-dialog__panel  : présentation et champs, c'est lui qui défile ;
     - le bouton « Envoyer », collé en bas du panneau (voir forms.css pour les
       champs eux-mêmes, communs à tous les formulaires du site). */

.c-board-dialog {
  width: min(760px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 1.7rem;
  background: #f8f5ef;
  color: #062c52;
  overflow: hidden;
}

.c-board-dialog[open] {
  display: flex;
  flex-direction: column;
}

.c-board-dialog::backdrop {
  background: rgba(6, 44, 82, 0.82);
}

.c-board-dialog__header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 2rem clamp(1.6rem, 4vw, 3.6rem) 1.2rem;
  border-bottom: 1px solid rgba(6, 44, 82, 0.12);
}

.c-board-dialog .c-board-dialog__title {
  margin: 0;
  padding-top: 0.4rem;
  font-size: clamp(2.1rem, 4vw, 2.8rem);
  line-height: 1.15;
}

.c-board-dialog__close {
  position: relative;
  flex: 0 0 auto;
  width: 4.4rem;
  height: 4.4rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f9ba00;
  color: #062c52;
  /* Le « × » du texte n'est pas centré dans un rond (sa case est décalée) :
     on le cache et on dessine la croix avec deux traits centrés. */
  font-size: 0;
  line-height: 0;
  cursor: pointer;
}

.c-board-dialog__close::before,
.c-board-dialog__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.c-board-dialog__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.c-board-dialog__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.c-board-dialog__close:hover,
.c-board-dialog__close:focus-visible {
  background: #fadd8a;
}

.c-board-dialog__panel {
  position: relative;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1.6rem clamp(1.6rem, 4vw, 3.6rem) 0;
  outline: none;
}

.c-board-dialog .c-form-block,
.c-board-dialog .c-form-block__text {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

.c-board-dialog .c-form-block__text {
  margin: 0 0 1.4rem;
  padding: 0;
}

.c-board-dialog .c-form-block__text p {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.45;
}

.c-board-dialog .c-form-block__content,
.c-board-dialog .c-form-block__content-wrapper {
  width: 100%;
  max-width: none;
}

/* Le formulaire est une colonne : champs, message d'erreur, puis la barre du
   bouton, collée en bas de la zone qui défile. */
.c-board-dialog .c-form {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.c-board-dialog .c-form__fields {
  order: 1;
}

.c-board-dialog .c-form__messages {
  order: 2;
  margin: 0;
}

.c-board-dialog .c-form__submit-button-container {
  order: 3;
}

/* Une grille à nous : celle du thème dépend de la largeur de la page, pas
   de celle de cette fenêtre. */
.c-board-dialog .c-form__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem 1.6rem;
  margin: 0;
}

.c-board-dialog .c-form__fields > * {
  width: auto;
  max-width: none;
  margin: 0;
  grid-column: span 1;
}

.c-board-dialog .c-form__fields > .o-cols__c-8,
.c-board-dialog .c-form__fields > .o-textarea-ctn {
  grid-column: 1 / -1;
}

.c-board-dialog .c-form__messages-inner {
  padding-top: 1rem;
}

.c-board-dialog .c-form__submit-button-container {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 1.2rem 0 0;
  padding: 1rem 0 1.6rem;
  background: #f8f5ef;
  box-shadow: 0 -1.2rem 1.2rem -0.4rem #f8f5ef;
}

.c-board-dialog .c-form__submit-button-container .c-cta {
  margin: 0;
}

.c-board-dialog .c-form-block__content-message {
  margin: 2.4rem auto 3.2rem;
}

@media (max-width: 640px) {
  .c-board-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .c-board-dialog__header {
    padding-top: 1.4rem;
    padding-bottom: 1rem;
  }

  .c-board-dialog .c-board-dialog__title {
    font-size: 1.75rem;
    padding-top: 0.2rem;
  }

  .c-board-dialog .c-form-block__text p {
    font-size: 1.05rem;
  }

  .c-board-dialog__close {
    width: 4rem;
    height: 4rem;
  }

  .c-board-dialog__panel {
    padding-top: 1.2rem;
  }

  .c-board-dialog .c-form__fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .c-board-dialog .c-form__submit-button-container {
    padding-top: 1rem;
    padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
  }
}
