/* The login screen. The top row and the bottom come from site.css (as on the front page);
   the buttons and the input from session.css. This file adds only the middle. Plan:
   1. middle of the screen: a greeting, one line of help, one field for the code, one button
   2. a wrong code: a clear message under the field */

/* The whole page is a column as tall as the window: the middle takes the room, the bottom stays at the bottom */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* In a column the top row would shrink to its content: it keeps the full width, as on the front page */
.login-page .site-top {
  width: 100%;
}

/* 1. The middle */
.login-main {
  flex: 1;
  box-sizing: border-box;
  padding: var(--space-10) var(--space-6) var(--space-20);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
}

.login-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(40px, 5vw, 56px);
  line-height: 1.1;
}

.login-text {
  margin: 0;
  max-width: 22em;
  font-size: 20px;
}

.login-form {
  margin-top: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.login-label {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* One step of the login: everything in a column, in the middle */
.login-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.login-step[hidden] {
  display: none;
}

/* The code field: six large shaded cells, one for each character of the code; no box around them.
   Two layers lie exactly on top of each other: the cells below, the typed characters above.
   1ch is the width of one character in this font (every character is equally wide).
   Upper layer: each typed character is followed by 1.6ch of air -> a character every 2.6ch,
                starting 0.6ch from the left.
   Lower layer: a cell 2.2ch wide, then 0.4ch of gap -> a cell every 2.6ch;
                each character (1ch) stands in the middle of its cell (0.6ch on each side). */
.code-field {
  position: relative;
  box-sizing: border-box;
  width: 15.2ch;              /* six cells and five gaps: 6 x 2.2ch + 5 x 0.4ch */
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 34px;
  line-height: 1.8;           /* the height of a cell */
}

/* The lower layer: the six cells, a little darker than the page */
.code-slots {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 0.4ch;
  pointer-events: none; /* clicks go through to the real field */
}

.code-slots span {
  flex: none;
  width: 2.2ch;
  height: 100%;
  border-radius: 10px;
  background: rgba(43, 43, 46, 0.07);
  box-shadow: inset 0 0 0 1px rgba(43, 43, 46, 0.14);
}

/* The upper layer: the real field, with nothing of its own but the text.
   It is a little wider than the cells, so that the air after the sixth character never makes it scroll. */
.code-input {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: calc(100% + 2ch);
  margin: 0 -2ch 0 0;
  padding: 0 0 0 0.6ch;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  letter-spacing: 1.6ch;
  text-transform: uppercase;
  white-space: pre;
}

/* After the sixth character the blinking line would stand outside the cells (login.js) */
.code-input.caret-hidden {
  caret-color: transparent;
}

.code-input:focus {
  outline: none;
}

/* The ring goes around the six cells when the field is active */
.code-field:focus-within {
  outline: 3px solid var(--teal);
  outline-offset: 6px;
}

/* The password fields of the team step: the same width as the code field */
.password-input {
  flex: none;
  box-sizing: border-box;
  width: 16em;
  text-align: center;
}

/* 2. The message for a wrong code */
.login-error {
  margin: 0;
  max-width: 24em;
  font-size: 16px;
  color: var(--berry);
}

/* The code in the password form, for the browser's password manager only: not shown, not reachable
   (not display:none, which some password managers skip) */
.username-for-browser {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
