/* UniGuide — the sign-in page (ARCHITECTURE.md §16, web/DESIGN.md §F).

   Loaded AFTER styles.css, which owns every token (maroon, the type/spacing scale, radii,
   shadows) and the calm-note family this page reuses for its states. Nothing here redefines
   a token: "the door looks like the room" is the point, so the login page inherits the chat's
   identity and only adds its own layout.

   The room is a dark maroon rail beside a light pane; so is the door. The whole viewport is
   two panes — the brand on the ink-maroon side (the wordmark set large in the display serif,
   the tagline), the one ask on the light side, set flat on the page
   rather than boxed in a card. On a phone the maroon pane becomes a band across the top and
   the form takes the full width beneath it.

   No framework, no build step; all server text is inserted by login.js via textContent. */

.auth-body {
  min-height: 100%;
  background: var(--bg);
}

/* ---- The two panes: brand | form, full viewport ---- */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.auth__pane {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 6vh, 64px) clamp(24px, 6vw, 88px);
}

/* The brand pane: the rail's ink-maroon, with the maroon itself glowing through from the
   corner — the same wash the chat's rail carries, spread across a whole pane. */
.auth__pane--brand {
  color: var(--rail-text);
  background-color: var(--rail-bg);
  background-image: radial-gradient(
      110% 80% at 0% 100%,
      rgba(132, 1, 50, 0.55) 0%,
      rgba(132, 1, 50, 0) 60%
    ),
    radial-gradient(70% 50% at 100% 0%, rgba(132, 1, 50, 0.25) 0%, rgba(132, 1, 50, 0) 70%);
}

.auth__pane--form {
  background: var(--bg);
}

/* ---- Brand block: the mark, the wordmark, the tagline ---- */

.auth__brand {
  max-width: 34rem;
}

/* The same tile-and-glyph lockup the chat header wears (UniGuide's own mark, never AUB's),
   sized up for the door. The glyph is `.brand-glyph` from styles.css (currentColor). */
.auth__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 17px;
  background: linear-gradient(155deg, #a3184d 0%, var(--aub-red) 55%, var(--aub-red-700) 100%);
  color: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.auth__mark .brand-glyph {
  width: 30px;
  height: 30px;
}

/* The signature: the name set large in the display serif, the way a catalogue sets its own. */
.auth__wordmark {
  margin: var(--sp-6) 0 0;
  font-family: var(--font-display);
  font-size: clamp(48px, 7.5vw, 84px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 0.98;
  color: #fff;
}

.auth__tagline {
  margin: var(--sp-3) 0 0;
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.45;
  color: var(--rail-text-muted);
}

/* ---- Attribution: bottom of the brand pane, quiet ---- */

.auth__by {
  margin: clamp(32px, 8vh, 72px) 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--rail-text-faint);
}

.auth__by-name {
  color: var(--rail-text-muted);
  font-weight: 600;
  text-decoration: none;
}

.auth__by-name:hover,
.auth__by-name:focus-visible {
  color: #fff;
  text-decoration: underline;
}

/* ---- The form: flat on the light pane, one column ---- */

.auth__form {
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  transition: opacity 0.25s ease;
}

/* Held briefly while the browser navigates to the chat, so a successful sign-in reads as a
   transition rather than a blink. */
.auth__form--leaving {
  opacity: 0.5;
}

.auth__noscript {
  margin: 0 0 var(--sp-4);
  font-size: 13px;
  color: var(--note-text);
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
}

/* ---- Step marker: two dots, so the whole journey is visible from the first screen ---- */

.auth__progress {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
  font-size: var(--micro-size);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--micro-tracking);
  color: var(--text-faint);
}

.auth__pstep {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth__pdot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
}

.auth__prule {
  width: 34px;
  height: 2px;
  border-radius: 1px;
  background: var(--border-strong);
}

/* Step 1 is current until login.js marks the form as being on the code step. */
.auth__pstep--email {
  color: var(--aub-red);
}

.auth__pstep--email .auth__pdot {
  border-color: var(--aub-red);
  background: var(--aub-red);
}

.auth__form--code .auth__pstep--email {
  color: var(--text-faint);
}

.auth__form--code .auth__pstep--email .auth__pdot {
  border-color: var(--aub-red);
  background: var(--aub-red-tint);
}

.auth__form--code .auth__prule {
  background: var(--aub-red);
}

.auth__form--code .auth__pstep--code {
  color: var(--aub-red);
}

.auth__form--code .auth__pstep--code .auth__pdot {
  border-color: var(--aub-red);
  background: var(--aub-red);
}

/* ---- The two steps (email → code). Only one is ever visible. ---- */

.auth__step {
  display: flex;
  flex-direction: column;
}

.auth__step[hidden] {
  display: none;
}

.auth__heading {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 2.6vw, 32px);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--text);
}

.auth__lede {
  margin: var(--sp-3) 0 var(--sp-6);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* The address the code went to — quoted back so a typo is obvious before the code arrives. */
.auth__target {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.auth__label {
  font-size: var(--micro-size);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--micro-tracking);
  color: var(--text-faint);
  margin-bottom: 8px;
}

/* Inputs sit on the page, not in a box: a surface with a single strong rule beneath, the way a
   form on paper is a line to write on. */
.auth__input {
  width: 100%;
  font-family: inherit;
  font-size: 17px; /* ≥16px keeps iOS from zooming the page on focus */
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom: 2px solid var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 2px 2px;
  padding: 13px var(--sp-4);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth__input::placeholder {
  color: #a79f98;
  letter-spacing: normal;
}

.auth__input:focus {
  outline: none;
  border-color: var(--aub-red);
  box-shadow: 0 0 0 3px rgba(132, 1, 50, 0.12);
}

.auth__input:disabled {
  background: var(--surface-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* The code field reads as a code: large, tracked, tabular, centred. text-indent cancels the
   trailing letter-space so the digits stay optically centred. */
.auth__input--code {
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  font-variant-numeric: tabular-nums;
  padding: 13px var(--sp-3);
}

.auth__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  margin-top: var(--sp-5);
  padding: 14px var(--sp-4);
  font-family: inherit;
  font-size: 16px;
  font-weight: 650;
  color: #fff;
  background: var(--aub-red);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.auth__submit:hover:not(:disabled) {
  background: var(--aub-red-600);
}

.auth__submit:active:not(:disabled) {
  transform: translateY(1px);
}

.auth__submit:focus-visible {
  outline: 2px solid var(--aub-red);
  outline-offset: 2px;
}

.auth__submit:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  box-shadow: none;
}

/* A small ring that spins while a request is in flight; the label changes too, so the
   spinner is decoration and never the only signal. */
.auth__spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: auth-spin 0.7s linear infinite;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Step-2 help: the honest answer to "I can't get in" ---- */

.auth__extras {
  margin-top: var(--sp-4);
}

.auth__extras[hidden] {
  display: none;
}

.auth__hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-faint);
}

.auth__alt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--sp-2);
}

.auth__alt-sep {
  color: var(--text-faint);
}

.auth__link {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--aub-red);
  background: none;
  border: none;
  padding: 4px 6px;
  margin-left: -6px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth__link + .auth__alt-sep + .auth__link {
  margin-left: 0;
}

.auth__link:hover:not(:disabled) {
  background: var(--aub-red-tint);
}

.auth__link:focus-visible {
  outline: 2px solid var(--aub-red);
  outline-offset: 1px;
}

.auth__link:disabled {
  color: var(--text-faint);
  text-decoration: none;
  cursor: not-allowed;
}

/* ---- Server messages: the shared calm-note family from styles.css ---- */

/* The Turnstile box (§16.10). Hidden until the server reports a site key; once rendered it is
   always visible — the flexible size fills the form's width, 65px tall like the inputs. */
.auth__turnstile {
  margin-top: var(--sp-4);
  min-height: 65px;
}

.auth__turnstile[hidden] {
  display: none;
}

.auth__message {
  margin-top: var(--sp-4);
}

.auth__message:empty {
  display: none;
}

.auth__message .note {
  animation: message-in 0.24s ease both;
}

/* ---- Foot: the one line that protects the student (never a password ask) ---- */

.auth__foot {
  margin: var(--sp-8) 0 0;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-strong);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-faint);
}

@media (prefers-reduced-motion: reduce) {
  .auth__form,
  .auth__message .note {
    transition: none;
    animation: none;
  }
  .auth__spinner {
    animation: none;
  }
}

/* ---- Narrow windows and phones: the brand becomes a band, the form fills the width ---- */

@media (max-width: 900px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .auth__pane {
    justify-content: flex-start;
    padding: 28px var(--gutter);
  }

  .auth__pane--brand {
    padding-top: max(28px, env(safe-area-inset-top));
    padding-bottom: 28px;
  }

  .auth__mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }

  .auth__mark .brand-glyph {
    width: 24px;
    height: 24px;
  }

  .auth__wordmark {
    margin-top: var(--sp-4);
    font-size: clamp(40px, 12vw, 56px);
  }

  .auth__tagline {
    font-size: 15.5px;
  }

  .auth__by {
    margin-top: var(--sp-5);
  }

  .auth__pane--form {
    padding-top: 28px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .auth__form {
    max-width: none;
  }

  .auth__heading {
    font-size: 26px;
  }

  .auth__input--code {
    font-size: 24px;
    letter-spacing: 0.28em;
    text-indent: 0.28em;
  }
}

@media (max-width: 380px) {
  .auth__wordmark {
    font-size: 38px;
  }
}
