/* ==========================================================================

Registration form of Elia Dell'Andrino

========================================================================== */

/* Font

========================================================================== */
@font-face {
  font-display: swap;
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-weight: 200 800;
  src: url('../../font/atkinson-hyperlegible-next/atkinson-hyperlegible-next.woff2')
    format('woff2');
}

/* Global styles

========================================================================== */
html {
  scroll-padding-top: 94px;
}

body {
  font-family: 'Atkinson Hyperlegible Next', sans-serif;
  padding-top: 94px;
}

/* Fixed page header (94px high, the body padding keeps the content visible)

========================================================================== */
header {
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1;
}

/* Page content

========================================================================== */
a {
  color: #007cb7;
}

a:hover {
  color: #005680;
}

.back-link {
  display: block;
  font-weight: bold;
  margin-bottom: 20px;
  text-decoration: none;
}

.back-link::before {
  color: #2e2e2e;
  content: '> ';
}

.admission,
.registration {
  padding: 20px;
}

.admission {
  background-color: #f6f7f8;
  border: 1px solid #d6d8db;
  border-radius: 5px;
  margin-bottom: 20px;
}

.admission p {
  hyphens: auto;
  text-align: justify;
}

.admission p:last-child {
  margin-bottom: 0;
}

.registration h2 {
  margin-bottom: 40px;
  text-align: center;
}

/* Form grid: 2 columns of fields, each field = label + control

========================================================================== */
form {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
}

.field {
  align-items: center;
  border: 0;
  display: grid;
  gap: 20px;
  grid-template-columns: 160px 1fr;
  margin: 0;
  min-width: 0;
  padding: 0;
}

input[type='date'],
label {
  cursor: pointer;
}

.field > label,
.field > legend {
  color: #007cb7;
  font-weight: bold;
  text-align: right;
}

/* A floated legend becomes a normal grid item of its fieldset */
.field > legend {
  float: left;
  padding: 0;
}

.optional {
  color: #5c6166;
  font-weight: normal;
}

.remark,
form button {
  grid-column: 1 / -1;
}

/* Form controls

========================================================================== */
input,
select,
textarea {
  border: 1px solid #868e96;
  border-radius: 5px;
  padding: 5px 8px;
  width: 100%;
}

input[type='checkbox'],
input[type='radio'] {
  margin: 0;
  width: auto;
}

select {
  appearance: none;
  background: #fff url('../../img/icon-arrow-down.svg') no-repeat right 8px
    center;
  cursor: pointer;
  padding-right: 32px;
}

textarea {
  height: 150px;
  resize: vertical;
}

.choice {
  align-items: center;
  display: flex;
  gap: 10px;
}

.choice + .choice {
  margin-top: 5px;
}

.address {
  display: grid;
  gap: 5px;
  grid-template-columns: 90px 1fr;
}

.street {
  grid-column: 1 / -1;
}

.help,
.error {
  font-size: 1.4rem;
  grid-column: 1 / -1;
  margin: 5px 0 0;
}

.help {
  color: #5c6166;
}

form button {
  background-color: #007cb7;
  border: 2px solid #000;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  justify-self: center;
  margin-top: 20px;
  padding: 8px 50px;
}

form button:hover {
  background-color: #005680;
}

/* Validation: 5px bar on the left (grey, green or red) + error message

========================================================================== */
input:not([type='checkbox'], [type='radio']),
select {
  border-left: 5px solid #868e96;
}

input:user-valid,
select:user-valid {
  border-left-color: #218838;
}

input:user-invalid,
select:user-invalid {
  border-left-color: #c82333;
}

.error {
  color: #c82333;
  display: none;
}

.control:has(:user-invalid) .error {
  display: block;
}

/* ==========================================================================

Media queries (Desktop First)

========================================================================== */

/* Tablet: 2 columns, label above the field */
@media (width <= 768px) {
  .field {
    gap: 10px;
    grid-template-columns: 1fr;
  }

  .field > label,
  .field > legend {
    text-align: left;
  }
}

/* Smartphone: 1 column, label on the left of the field */
@media (width <= 480px) {
  form {
    grid-template-columns: 1fr;
  }

  .field {
    gap: 20px;
    grid-template-columns: 1fr 2fr;
  }

  .remark {
    gap: 10px;
    grid-template-columns: 1fr;
  }
}

/* Small smartphone: 1 column, label above the field */
@media (width <= 430px) {
  .field {
    gap: 10px;
    grid-template-columns: 1fr;
  }
}
