/*
 * Login, participant view, overview and notice pages.
 *
 * All pages here are reading pages with one column. They are centred and
 * get a maximum width: text across the full width of a laptop reads badly,
 * and tiles stretching over half a metre look wrong.
 */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 24px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.login__card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login__card--quiet {
  background: transparent;
  border-style: dashed;
  gap: 8px;
}

.login__title {
  font-size: 1.5rem;
}

.login__subtitle {
  font-size: 1rem;
}

.login__text {
  color: var(--muted);
  font-size: 0.9375rem;
  max-width: 60ch;
}

.login__form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.login__label {
  font-size: 0.875rem;
  font-weight: 600;
}

.login__field {
  min-height: 52px;
  padding: 0 14px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-small);
  font-size: 1rem;
  transition: border-color 120ms ease-out;
}

/* Digits of the PIN, spaced so a typo is easy to spot. */
.login__field--pin {
  font-family: var(--font-numeric);
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
}

.login__field::placeholder {
  color: var(--muted);
}

.login__field:hover {
  border-color: var(--line-strong);
}

.login__field:focus-visible {
  border-color: var(--ink);
  outline-offset: 1px;
}

.login__disclosure {
  align-self: flex-start;
  min-height: var(--target);
  padding: 0;
  background: none;
  border: 0;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.login__disclosure:hover {
  color: var(--ink);
}

.login__message {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.login__message--ok {
  color: #1d6046;
}

.login__message--error {
  color: var(--error-ink);
}

/* --- Reading pages: participants and overview ---------------------- */

.page {
  /* Centred and with a maximum width, on every screen. */
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.page--wide {
  max-width: 1040px;
}

.page__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 0 18px;
  padding-top: calc(22px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}

.page__title {
  font-size: 1.5rem;
  line-height: 1.2;
}

.page__note {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 2px;
}

/* Everything at the top right next to the title. */
.page__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.page__logout {
  margin-left: auto;
  flex-shrink: 0;
  min-height: var(--target);
  padding: 0 14px;
  border-width: 1.5px;
  border-radius: var(--radius-small);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.page__content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 22px 0 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

/* --- Tiles --------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile__value {
  font-size: 1.75rem;
  line-height: 1.1;
}

.tile__text {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* --- Blocks -------------------------------------------------------- */

.block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.block__head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.block__title {
  font-size: 1.125rem;
}

.block__note {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 62ch;
}

.block__tools {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.select {
  font: inherit;
  font-size: 0.875rem;
  /* Windows in dark mode would otherwise colour a select box by itself. */
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-small);
  min-height: var(--target);
  padding: 0 10px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button-link {
  min-height: var(--target);
  padding: 0 16px;
  border-width: 1.5px;
  border-radius: var(--radius-small);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

.notice-bar {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-ink);
  border-radius: var(--radius-small);
  padding: 11px 13px;
  font-size: 0.875rem;
  font-weight: 500;
}

.notice-bar--error {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-ink);
}

/* --- Boulder list -------------------------------------------------- */

.boulder-list,
.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.boulder-list__row,
.ranking__row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.boulder-list__color {
  width: 8px;
  height: 26px;
  border-radius: 3px;
  background: var(--line-strong);
  flex-shrink: 0;
}

.boulder-list__name,
.ranking__name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boulder-list__points {
  min-width: 3ch;
  text-align: right;
  flex-shrink: 0;
}

.progress-bar {
  width: 96px;
  height: 6px;
  border-radius: 3px;
  background: #dfe4e9;
  overflow: hidden;
  flex-shrink: 0;
}

.progress-bar__fill {
  display: block;
  height: 100%;

  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--ink);
  transition: transform 200ms ease-out;
}

/* --- Ranking ------------------------------------------------------- */

.ranking__rank {
  width: 3.5ch;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.ranking__school {
  color: var(--muted);
  font-size: 0.8125rem;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking__points {
  min-width: 4ch;
  text-align: right;
  flex-shrink: 0;
}

.ranking__row--own {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.ranking__row--unranked {
  opacity: 0.65;
}

.ranking__row--tied .ranking__rank {
  color: var(--warn-ink);
}

.ranking__empty {
  color: var(--muted);
  font-size: 0.9375rem;
  padding: 8px 0;
}


@media (max-width: 559px) {
  .ranking__school {
    display: none;
  }
}

@media (min-width: 560px) {
  .tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 760px) {
  .login__card {
    padding: 30px 28px;
  }

  .page__title {
    font-size: 1.75rem;
  }

  .tile__value {
    font-size: 2rem;
  }
}

/* --- Admin --------------------------------------------------------- */

/*
 * The admin page is the only page with real forms. It is used on a laptop,
 * not on a phone between two rounds - so it may contain text fields that
 * would have no place at the station.
 */

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}

/* Columns of different height (e.g. a note below one text area): align at the top. */
.form-grid--top {
  align-items: start;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row__label {
  font-size: 0.875rem;
  font-weight: 600;
}

.input,
.textarea {
  font: inherit;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-small);
  padding: 10px 12px;
  min-height: var(--target);
  transition: border-color 120ms ease-out;
}

.textarea {
  font-family: var(--font-numeric);
  font-size: 0.8125rem;
  line-height: 1.6;
  resize: vertical;
  white-space: pre;
  overflow-x: auto;
}

.input:hover,
.textarea:hover {
  border-color: var(--line-strong);
}

.input:focus-visible,
.textarea:focus-visible {
  border-color: var(--ink);
  outline-offset: 1px;
}

.file-input {
  font-size: 0.875rem;
}

.select--multiple {
  min-height: 0;
  padding: 6px 8px;
}

.block__message {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.block__message--ok {
  color: #1d6046;
}

.block__message--pending {
  color: var(--warn-ink);
}

.block__message--error {
  color: var(--error-ink);
}

/*
 * Import errors are listed line by line. The server rejects the whole file
 * as soon as one line is wrong - so the list is the to-do list of what to
 * fix in the file.
 */
.error-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.error-list__row {
  background: var(--error-bg);
  border: 1px solid var(--error-line);
  color: var(--error-ink);
  border-radius: var(--radius-small);
  padding: 8px 11px;
  font-size: 0.875rem;
}

.button-row--tight {
  gap: 8px;
}

/*
 * Print sheet: all freshly created QR codes, shown as a grid on screen.
 * It is printed via body.printing-sheet, see below.
 */
.print-sheet-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.print-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.qr--sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.qr {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.qr__image {
  width: 168px;
  height: 168px;
}

.qr__image svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qr__text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qr__title {
  font-weight: 600;
}

.qr__address {
  font-family: var(--font-numeric);
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
  max-width: 44ch;
}

@media (min-width: 720px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-row--wide,
  .form-grid .primary-button {
    grid-column: 1 / -1;
  }
}

/*
 * Only the QR code is printed: the sheet hangs at the boulder on
 * competition day, everything else on it would be clutter.
 */
@media print {
  body * {
    visibility: hidden;
  }

  .qr,
  .qr * {
    visibility: visible;
  }

  .qr {
    border: 0;
    page-break-inside: avoid;
  }

  .qr__image {
    width: 240px;
    height: 240px;
  }

  .no-print {
    display: none !important;
  }

  /*
   * Printing the sheet: everything except the sheet drops out of the flow,
   * so the codes start at the top of the first page. Two per row, none is
   * split across two pages.
   */
  body.printing-sheet .page__head,
  body.printing-sheet .page__content > :not(.admin) {
    display: none !important;
  }

  body.printing-sheet .print-sheet {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }

  body.printing-sheet .qr--sheet {
    border: 1px solid #000;
    break-inside: avoid;
    flex-direction: column;
    text-align: center;
  }
}
