/* ==========================================================================
   Registration form page
   ========================================================================== */

/* Web font
   ========================================================================== */

@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  src: url('../../font/fira-sans/fira-sans-regular.woff2') format('woff2');
}

@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 700;
  src: url('../../font/fira-sans/fira-sans-bold.woff2') format('woff2');
}

/* Global styles
   ========================================================================== */

html {
  /* Keep the focused field visible below the fixed header */
  scroll-padding-top: 110px;
}

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

a {
  color: #007cb7;
}

a:hover {
  color: #005680;
}

/* Page header (stays at the top while scrolling)
   ========================================================================== */

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

header img {
  display: block;
}

/* Page content
   ========================================================================== */

.back-link {
  font-weight: 700;
  margin: 0 0 20px;
}

.back-link a {
  text-decoration: none;
}

.admission {
  background-color: #f6f7f8;
  border: 1px solid #d6d8db;
  border-radius: 5px;
  hyphens: auto;
  margin-bottom: 20px;
  padding: 20px;
  text-align: justify;
}

.admission h2 {
  text-align: left;
}

.admission p:last-child {
  margin-bottom: 0;
}

.registration {
  background-color: #fff;
  padding: 20px;
}

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

/* Form layout (CSS Grid)
   ========================================================================== */

form {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
}

.field {
  align-items: center;
  border: 0;
  column-gap: 20px;
  display: grid;
  grid-template-columns: 3fr 5fr;
  margin: 0;
  min-width: 0;
  padding: 0;
}

/* Field titles */
.field > label,
.field > legend {
  color: #007cb7;
  font-weight: 700;
  text-align: right;
}

/* Clicking a title focuses its field */
.field > label {
  cursor: pointer;
}

/* A floated legend becomes a normal grid item */
.field > legend {
  float: left;
}

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

/* The remark spans the whole width: same title column as the other fields */
.remark {
  grid-column: 1 / -1;
  grid-template-columns: calc((100% - 60px) * 3 / 16) 1fr;
}

.submit {
  grid-column: 1 / -1;
  margin-top: 20px;
  text-align: center;
}

/* Fields
   ========================================================================== */

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

input[type='date'],
select,
button {
  cursor: pointer;
}

input[type='number'] {
  appearance: textfield;
}

select {
  appearance: none;
  background: #fff url('../../img/icon-arrow-down.svg') no-repeat right 8px
    center / 16px;
  padding-right: 32px;
}

textarea {
  display: block;
  height: 150px;
  resize: vertical;
}

/* Radio buttons and checkboxes */
.option {
  align-items: center;
  display: flex;
  gap: 10px;
}

.option + .option {
  margin-top: 5px;
}

.option input,
.option label {
  cursor: pointer;
}

.option input {
  margin: 0;
}

/* Street on the first line, NPA and locality on the second line */
.address {
  display: grid;
  gap: 5px;
  grid-template-columns: 1fr 2fr;
}

.address .street {
  grid-column: 1 / -1;
}

/* Hidden title, still read by screen readers */
.visually-hidden {
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Hint and error messages */
.hint,
.error {
  font-size: 1.4rem;
  margin: 5px 0 0;
}

.hint {
  color: #5c6166;
}

.error {
  color: #c82333;
  display: none;
  grid-column: 1 / -1;
}

/* Submit button */
button {
  background-color: #007cb7;
  border: 2px solid #000;
  color: #fff;
  font-weight: 700;
  padding: 9px 50px;
}

button:hover {
  background-color: #005680;
}

/* Validation (HTML and CSS only)
   ========================================================================== */

/* Grey bar before the user edits the field or tries to submit */
input:required:not([type='radio']),
select:required {
  border-left: 5px solid #868e96;
}

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

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

/* Show the message of an invalid field or group */
.control:has(:user-invalid) > .error {
  display: block;
}

/* Responsive design
   ========================================================================== */

/* Tablet and landscape phone: titles above the fields */
@media (width <= 768px) {
  .field,
  .remark {
    align-content: start;
    grid-template-columns: 1fr;
    row-gap: 5px;
  }

  .field > label,
  .field > legend {
    text-align: left;
  }
}

/* Portrait phone: one field per line, title on the left */
@media (width <= 480px) {
  form {
    grid-template-columns: 1fr;
  }

  .field {
    grid-template-columns: 1fr 2fr;
  }

  .remark {
    grid-template-columns: 1fr;
    row-gap: 20px;
  }
}

/* Small portrait phone: titles above the fields */
@media (width <= 430px) {
  .field {
    grid-template-columns: 1fr;
  }

  .remark {
    row-gap: 5px;
  }
}
