/* ==========================================================================
   Font
   ========================================================================== */

@font-face {
  font-display: swap;
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 400;
  src: url('../../font/source-sans-3/source-sans-3-regular.woff2')
    format('woff2');
}

@font-face {
  font-display: swap;
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 700;
  src: url('../../font/source-sans-3/source-sans-3-bold.woff2') format('woff2');
}

/* ==========================================================================
   Base
   ========================================================================== */

body {
  font-family: 'Source Sans 3', sans-serif;
}

/* The header stays at the top of the window without hiding the content */
body > header {
  position: sticky;
  top: 0;
  z-index: 1;
}

a {
  color: #007cb7;
  font-weight: 700;
  text-decoration: none;
}

a:hover {
  color: #005680;
}

.back-link {
  font-weight: 700;
  margin: 5px 0 20px;
}

label,
input[type='date'],
select,
button {
  cursor: pointer;
}

/* ==========================================================================
   Containers
   ========================================================================== */

.admission {
  background-color: #f6f7f8;
  border: 1px solid #d6d8db;
  border-radius: 5px;
  hyphens: auto;
  padding: 20px;
  text-align: justify;
}

.admission p {
  margin: 20px 0 0;
}

/* Transparent border: the content stays aligned with the admission box */
.registration {
  border: 1px solid transparent;
  margin-top: 20px;
  padding: 20px;
}

.registration h2 {
  margin-bottom: 40px;
  text-align: center;
}

/* ==========================================================================
   Form grid
   ========================================================================== */

/* Reset of the default fieldset styles */
fieldset {
  border: 0;
  margin: 0;
  min-width: 0;
  padding: 0;
}

/* A floated legend becomes a normal grid item (the float itself is ignored) */
legend {
  float: left;
}

.form-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 160px 1fr 160px 1fr;
}

/* Each item (title and field) uses two columns of the grid */
.form-item {
  align-items: center;
  column-gap: 20px;
  display: grid;
  grid-column: span 2;
  grid-template-columns: 160px 1fr;
}

.form-item-full {
  grid-column: 1 / -1;
}

.form-item-full .field {
  grid-column: 2 / -1;
}

.form-item > label,
.form-item > legend {
  color: #007cb7;
  font-weight: 700;
  text-align: right;
}

.optional {
  color: #5c6166;
  display: block;
  font-weight: 400;
}

/* ==========================================================================
   Form fields
   ========================================================================== */

input:not([type='radio'], [type='checkbox']),
select,
textarea {
  background-color: #fff;
  border: 1px solid #868e96;
  border-radius: 5px;
  color: inherit;
  font: inherit;
  padding: 5px 8px;
  width: 100%;
}

select {
  appearance: none;
  background: #fff url('../../img/icon-arrow-down.svg') no-repeat right 8px
    center;
  background-size: 16px;
}

/* Same look for the number field in all browsers (no spin buttons) */
input[type='number'] {
  appearance: textfield;
}

input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
} /* Same height for the date field in Chrome and Edge */
input[type='date']::-webkit-datetime-edit {
  padding: 0;
}

textarea {
  display: block;
  height: 150px;
  resize: vertical;
}

/* Radio buttons and checkboxes with their labels */
.choices {
  align-items: center;
  display: grid;
  gap: 5px 10px;
  grid-template-columns: auto 1fr;
}

.address {
  display: grid;
  gap: 5px;
  grid-template-columns: 90px 1fr;
}

.address .street {
  grid-column: 1 / -1;
}

.form-hint,
.error-message {
  font-size: 1.4rem;
  margin: 5px 0 0;
}

.form-hint {
  color: #5c6166;
}

button {
  background-color: #007cb7;
  border: 2px solid #000;
  color: #fff;
  font: inherit;
  font-weight: 700;
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 20px;
  padding: 10px 50px;
}

button:hover {
  background-color: #005680;
}

/* ==========================================================================
   Validation (HTML and CSS only)
   ========================================================================== */

/* Grey until the user changes the field or submits the form,
   then red (invalid) or green (valid) */
input:not([type='radio'], [type='checkbox']):required,
select {
  border-left: 5px solid #868e96;
}

input:not([type='radio'], [type='checkbox']):required:user-valid,
select:user-valid {
  border-left-color: #218838;
}

input:not([type='radio'], [type='checkbox']):required:user-invalid,
select:user-invalid {
  border-left-color: #c82333;
}

/* The error message is only shown when a field of its block is invalid */
.error-message {
  color: #c82333;
  display: none;
}

.field:has(:user-invalid) .error-message {
  display: block;
}

/* ==========================================================================
   Responsive design
   ========================================================================== */

/* Tablet and smartphone landscape: two columns, title above the field
   ========================================================================== */

@media (width <= 768px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
    row-gap: 25px;
  }

  /* Each item uses two rows of the grid: the fields of two neighbouring
     items start at the same height */
  .form-item {
    align-items: start;
    grid-column: auto;
    grid-row: span 2;
    grid-template-columns: none;
    grid-template-rows: subgrid;
    row-gap: 5px;
  }

  .form-item-full {
    grid-column: 1 / -1;
  }

  .form-item-full .field {
    grid-column: auto;
  }

  .form-item > label,
  .form-item > legend {
    text-align: left;
  }

  .optional {
    display: inline;
  }
}

/* Smartphone portrait: title on the left of the field
   ========================================================================== */

@media (width <= 480px) {
  .form-grid {
    grid-template-columns: 1fr 2fr;
    row-gap: 20px;
  }

  .form-item {
    align-items: center;
    grid-column: 1 / -1;
    grid-row: auto;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: none;
  }

  .form-item-full {
    row-gap: 20px;
  }

  .form-item-full .field {
    grid-column: 1 / -1;
  }

  .optional {
    display: block;
  }
}

/* Small smartphone portrait: one column, title above the field
   ========================================================================== */

@media (width <= 430px) {
  .form-grid {
    grid-template-columns: 1fr;
    row-gap: 25px;
  }

  .form-item {
    grid-template-columns: none;
    row-gap: 5px;
  }

  .optional {
    display: inline;
  }
}
