/* The sign-in page. The same scale as the town: its colours, its corners, its
   controls and their states. It loads nothing but this file and one script. */

:root {
  color-scheme: light dark;
  --bg: #dce8f7;
  --card: #ffffff;
  --ink: #1f2a44;
  --soft: #5b6b88;
  --line: rgba(47, 76, 130, 0.22);
  --blue: #2f7de0;
  --blue-deep: #1f66c4;
  --bad: #b23a30;
  --ring: 0 0 0 2px var(--card), 0 0 0 4px var(--blue);
  --fast: 120ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131a22;
    --card: #1c2632;
    --ink: #e8eef5;
    --soft: #9fb0c2;
    --line: #33414f;
    --blue: #4d8fe8;
    --blue-deep: #6ea2f5;
    --bad: #ff8a80;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  /* 16 pixels in the fields, so a phone does not zoom into them. */
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  width: 380px;
  max-width: 100%;
  width: min(380px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 6px 22px rgba(36, 70, 122, 0.12);
  animation: in 180ms var(--ease) both;
}

a { color: var(--blue); }
a:focus, input:focus, button:focus { outline: 2px solid var(--blue); outline-offset: 3px; }

@keyframes in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

h1 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

label {
  display: block;
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--soft);
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  transition:
    border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}

input:hover {
  border-color: var(--blue);
}

input:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--soft);
}

button {
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color var(--fast) var(--ease),
    transform var(--fast) var(--ease),
    opacity var(--fast) var(--ease);
}

button:hover {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
}

button:not([disabled]):active {
  transform: scale(0.98);
}

button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* While the server checks: a small ring turns beside the word. */
button[aria-busy='true'] {
  opacity: 1;
  cursor: progress;
}

button[aria-busy='true']::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: turn 0.7s linear infinite;
}

@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

.message {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--bad);
}

@media (prefers-reduced-motion: reduce) {
  main,
  button[aria-busy='true']::before {
    animation: none;
  }

  input,
  button {
    transition: none;
  }
}
