/* ==========================================================================
   Police personnalisée
   ========================================================================== */

@font-face {
  font-display: swap;
  font-family: 'Josefin Sans';
  font-style: normal;
  font-weight: 100 700;
  src: url('../../font/josefin-sans/JosefinSans-VariableFont_wght.ttf')
    format('truetype');
}

body {
  font-family: 'Josefin Sans', Arial, sans-serif;
}

/* ==========================================================================
   Structure de la page
   ========================================================================== */

header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.page {
  margin: 0 auto;
  max-width: 1000px;
  width: calc(100% - 40px);
}

h1,
.registration h2 {
  text-align: center;
}

/* Lien de retour à l'accueil */

.back-link {
  align-items: center;
  color: #007cb7;
  display: inline-flex;
  font-weight: bold;
  gap: 5px;
  text-decoration: none;
}

.back-link::before {
  color: #2e2e2e;
  content: '>';
  font-weight: bold;
}

.back-link:hover {
  color: #005680;
}

/* Conteneur Admission */

.admission {
  background-color: #f6f7f8;
  border: 1px solid #d6d8db;
  border-radius: 5px;
  margin-top: 20px;
  padding: 20px;
}

.admission h2 {
  text-align: left;
}

/* Conteneur du formulaire */

.registration {
  background-color: white;
  margin-top: 20px;
  padding: 20px;
}

.registration h2 {
  margin-bottom: 40px;
}

/* ==========================================================================
   Grille du formulaire
   ========================================================================== */

.form-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 auto;
  max-width: 1000px;
}

/* Alignement des labels et des champs */

.form-field {
  min-width: 0;
}

.form-field:not(fieldset) {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 34% minmax(0, 1fr);
}

.form-field > label,
.form-field > legend {
  color: #007cb7;
  font-weight: bold;
  text-align: right;
}

.form-field > label {
  cursor: pointer;
}

.field-content {
  min-width: 0;
}

/* Groupes fieldset */

fieldset.form-field {
  border: none;
  margin: 0;
  padding: 0;
  position: relative;
}

fieldset.form-field > legend {
  left: 0;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34%;
}

fieldset.form-field > .field-content {
  margin-left: calc(34% + 10px);
}

/* ==========================================================================
   Boutons radio et cases à cocher
   ========================================================================== */

.choice {
  align-items: center;
  display: flex;
  gap: 10px;
  min-height: 24px;
}

.choice input {
  margin: 0;
}

.choice label {
  cursor: pointer;
}

/* ==========================================================================
   Champs de saisie
   ========================================================================== */

.field-content input:not([type='radio'], [type='checkbox']),
.field-content select,
.field-content textarea {
  background-color: white;
  border: 1px solid #868e96;
  border-radius: 5px;
  color: inherit;
  font: inherit;
  padding: 5px 8px;
  width: 100%;
}

/* Liste déroulante Etat civil */

.field-content select {
  appearance: none;
  background-color: white;
  background-image: url('../../img/icon-arrow-down.svg');
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 16px;
  cursor: pointer;
  padding-right: 32px;
}

/* Date de naissance */

.field-content input[type='date'] {
  cursor: pointer;
}

/* ==========================================================================
   Indicateurs de validation
   ========================================================================== */

.field-content input:required:not([type='radio']),
.field-content select:required {
  border-left: 5px solid #868e96;
}

.field-content input:required:user-valid:not([type='radio']),
.field-content select:required:user-valid {
  border-left-color: #218838;
}

.field-content input:required:user-invalid:not([type='radio']),
.field-content select:required:user-invalid {
  border-left-color: #c82333;
}

/* ==========================================================================
   Messages d'erreur
   ========================================================================== */

.error-message {
  color: #c82333;
  display: none;
  font-size: 14px;
  margin: 5px 0 0;
}

.form-field:has(input:user-invalid) .error-message,
.form-field:has(select:user-invalid) .error-message {
  display: block;
}

/* Texte facultatif et indications */

.optional {
  color: #5c6166;
  font-weight: normal;
}

.field-info {
  color: #5c6166;
  font-size: 14px;
  margin: 5px 0 0;
}

/* ==========================================================================
   Adresse
   ========================================================================== */

.address-fields {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.address-row {
  display: grid;
  gap: 5px;
  grid-template-columns: 1fr 2fr;
}

/* ==========================================================================
   Remarque
   ========================================================================== */

.form-field:not(fieldset).full-width {
  grid-column: 1 / -1;
  grid-template-columns: calc(17% - 3.4px) minmax(0, 1fr);
}

.field-content textarea {
  resize: vertical;
}

/* ==========================================================================
   Bouton Envoyer
   ========================================================================== */

.submit-container {
  display: flex;
  grid-column: 1 / -1;
  justify-content: center;
}

.submit-container button {
  background-color: #007cb7;
  border: 2px solid black;
  border-radius: 5px;
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: bold;
  min-width: 180px;
  padding: 10px 20px;
}

.submit-container button:hover {
  background-color: #005680;
}

/* ==========================================================================
   Responsive Web Design
   ========================================================================== */

/* Tablette : 768px et moins */

@media (width <= 768px) {
  /* Deux colonnes de formulaire */

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Les labels passent au-dessus des champs */

  .form-field:not(fieldset),
  .form-field:not(fieldset).full-width {
    display: block;
  }

  .form-field > label,
  fieldset.form-field > legend {
    display: block;
    margin-bottom: 5px;
    text-align: left;
  }

  /* Réorganisation des fieldset */

  fieldset.form-field > legend {
    position: static;
    top: auto;
    transform: none;
    width: auto;
  }

  fieldset.form-field > .field-content {
    margin-left: 0;
  }

  /* Remarque sur deux colonnes */

  .form-field:not(fieldset).full-width {
    grid-column: 1 / -1;
  }
}

/* Smartphone : 480px et moins */

@media (width <= 480px) {
  /* Une seule colonne principale */

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

  /* Labels à gauche des champs */

  .form-field:not(fieldset),
  .form-field:not(fieldset).full-width {
    align-items: start;
    display: grid;
    gap: 10px;
    grid-template-columns: 34% minmax(0, 1fr);
  }

  .form-field > label,
  fieldset.form-field > legend {
    margin-bottom: 0;
    text-align: right;
  }

  /* Fieldset avec titre à gauche */

  fieldset.form-field > legend {
    left: 0;
    padding: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 34%;
  }

  fieldset.form-field > .field-content {
    margin-left: calc(34% + 10px);
  }

  /* Remarque et bouton sur une colonne */

  .form-field:not(fieldset).full-width,
  .submit-container {
    grid-column: 1;
  }
}

/* Petit smartphone : 430px et moins */

@media (width <= 430px) {
  /* Tous les labels passent au-dessus */

  .form-field:not(fieldset),
  .form-field:not(fieldset).full-width {
    display: block;
  }

  .form-field > label,
  fieldset.form-field > legend {
    margin-bottom: 5px;
    text-align: left;
  }

  /* Fieldset en disposition verticale */

  fieldset.form-field > legend {
    position: static;
    top: auto;
    transform: none;
    width: auto;
  }

  fieldset.form-field > .field-content {
    margin-left: 0;
  }
}
