/* Login page look: gradient background, white rounded card, TU logo top right. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

/*
 * Layout: logo (top right) / card (centred in the free space) / contact
 * footer (always at the bottom). Everything is in the normal flow, so on
 * small screens nothing overlaps and the page just scrolls.
 */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 16px 16px 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 300;
  font-size: 1.125rem;
  color: #222;
  background: linear-gradient(
    45deg,
    rgba(31, 144, 204, 0.9),
    rgba(73, 203, 64, 0.9)
  );
  background-attachment: fixed;
}

.tu-logo {
  position: absolute;
  top: 0;
  right: 0;
  padding: 20px;
}

.tu-logo img {
  display: block;
  width: min(300px, 60vw);
  height: auto;
}

.card {
  /* auto block margins: centred while there is room, never clipped. */
  margin-block: auto;
  width: 100%;
  max-width: 450px;
  padding: 30px;
  background: #fff;
  border-radius: 60px;
  box-shadow: 0 0 100px rgba(50, 50, 50, 0.8);
  /* keeps the footer's shadow from darkening the card */
  z-index: 1;
}

.logo {
  display: block;
  width: 200px;
  max-width: 60%;
  margin: 0 auto;
  opacity: 0.8;
}

h1 {
  margin: 8px 0 0;
  font-weight: 300;
  font-size: 1.4em;
  text-align: center;
}

.doku {
  margin: 10px 0 20px;
  text-align: center;
}

.field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
}

.field input {
  flex: 1;
  min-width: 0;
  padding: 10px 0 10px 10px;
  border: none;
  background: transparent;
  font: inherit;
  /* stays above 16px so iOS does not zoom in on focus */
  font-size: 1.05em;
  box-shadow: none;
}

.field input:focus {
  outline: none;
}

.field:focus-within {
  border-bottom-color: #4990cc;
}

#login-button {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-size: 1em;
  cursor: pointer;
}

#login-button:hover:not(:disabled) {
  background: #f0f0f0;
}

#login-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.message {
  margin: 12px 0 0;
  text-align: center;
  color: #b00020;
}

.hint {
  margin: 20px 0 0;
  font-size: 0.8125rem;
  text-align: center;
  color: #666;
}

.hint summary {
  cursor: pointer;
}

.hint p {
  margin: 8px 0 0;
}

kbd {
  padding: 1px 4px;
  border: 1px solid #888;
  border-radius: 3px;
  font: inherit;
  font-size: 0.9em;
}

a {
  /* darker than the old #1f7fb8 to reach WCAG AA (>= 4.5:1) on white */
  color: #17699a;
}

a:focus-visible,
summary:focus-visible,
button:focus-visible {
  outline: 2px solid #17699a;
  outline-offset: 2px;
}

.contact {
  /* margin-top: auto is a safety net; the card's auto margins already
     push the footer down while it is shorter than the viewport. */
  margin-top: auto;
  padding: 16px 30px;
  background: #fff;
  border-radius: 30px 30px 0 0;
  text-align: center;
  box-shadow: 0 0 100px rgba(50, 50, 50, 0.8);
}

/* QR login (hidden unless qr.enabled in login-config.json) */

.qr-login {
  margin: 20px 0 0;
  text-align: center;
}

.qr-button {
  padding: 10px 20px;
  border: none;
  border-radius: 20px;
  /* white text needs >= 4.5:1, the old #4990cc only reached about 3.4:1 */
  background: #2f77b3;
  color: #fff;
  font: inherit;
  font-size: 0.9em;
  cursor: pointer;
  transition: background-color 0.3s;
}

.qr-button:hover {
  background: #26649a;
}

.qr-popup {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.7);
}

.qr-popup:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-popup-content {
  position: relative;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px 20px 20px;
  border-radius: 10px;
  background: #fff;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.qr-popup-content h2 {
  margin: 0 0 12px;
  font-size: 1em;
  font-weight: 400;
}

.qr-close {
  position: absolute;
  top: 6px;
  right: 12px;
  border: none;
  background: none;
  font-size: 26px;
  color: #888;
  cursor: pointer;
}

.qr-close:hover {
  color: #333;
}

.qr-code {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  background: #f5f5f5;
}

.qr-code img {
  width: 90%;
  height: 90%;
}

.qr-status {
  margin: 12px 0 0;
  font-size: 0.78em;
}

/* The card is 450px wide and the logo 340px: below ~1130px they would
   overlap, so the logo moves into the flow above the card. */
@media (max-width: 1130px) {
  .tu-logo {
    position: static;
    align-self: flex-end;
    padding: 0;
  }

  .tu-logo img {
    width: min(240px, 45vw);
  }
}

@media (max-width: 520px) {
  body {
    font-size: 1rem;
  }

  .card {
    padding: 24px 20px;
    border-radius: 36px;
  }

  /* full-bleed footer: cancel the body padding */
  .contact {
    align-self: stretch;
    margin-inline: -16px;
    border-radius: 0;
  }
}

/* Phones in landscape: little height, so make the card compact. */
@media (max-height: 500px) {
  body {
    gap: 12px;
  }

  .card {
    padding: 16px 30px;
    border-radius: 30px;
  }

  .logo {
    width: 80px;
  }

  .tu-logo img {
    width: 140px;
  }

  h1 {
    margin-top: 4px;
  }

  .doku {
    margin: 4px 0 8px;
  }

  .hint {
    margin-top: 10px;
  }

  .contact {
    padding-block: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qr-button {
    transition: none;
  }
}
