/* Neon design: page-specific rules for the auth pages (shared design system: /static/site.css).
   Sign in, two-step code, confirm, wait, create an account, forgot password, sign-in link.
   A centered "secure terminal" card on a quiet stage: the shield with a halo, a mono status
   line (decorative, from data-status), a chamfered card with the neon hairline, clear fields,
   a big code entry for one-time codes, and error notices that say what they are.
   Every rule is scoped to .auth-stage / .auth: all neon/*.css files load on every page. */

/* ---------- Stage: the card centered on a dim grid floor with a soft glow ---------- */
.auth-stage {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; place-items: center;
  min-height: calc(100svh - 10rem);
  padding: 4rem max(var(--gutter), env(safe-area-inset-right, 0px)) 5rem max(var(--gutter), env(safe-area-inset-left, 0px));
}
/* Perspective grid floor, fading out toward the card. */
.auth-stage::before {
  content: ""; position: absolute; z-index: -2; left: -30%; right: -30%; bottom: -12%; height: 62%; pointer-events: none;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px), linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 3.5rem 3.5rem;
  transform: perspective(32.5rem) rotateX(64deg); transform-origin: center top;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 45%, #000 80%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 45%, #000 80%, transparent);
  animation: auth-floor 14s linear infinite;
}
/* Restrained glow behind the card (a clip-path card cannot carry its own shadow). */
.auth-stage::after {
  content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none;
  background:
    radial-gradient(closest-side at 50% 42%, rgba(24, 224, 255, 0.13), transparent),
    radial-gradient(closest-side at 64% 70%, rgba(255, 47, 180, 0.07), transparent);
  background-size: min(51.25rem, 140%) min(47.5rem, 120%), min(43.75rem, 120%) min(38.75rem, 100%);
  background-position: 50% 30%, 70% 85%;
  background-repeat: no-repeat;
}
@keyframes auth-floor { to { background-position: 0 3.5rem, 0 3.5rem; } }

/* ---------- The card ---------- */
.auth-stage .auth {
  --cut: 1.25rem;
  width: min(30rem, 100%); margin: 0 auto; padding: 1.875rem 2rem 1.625rem;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(24, 224, 255, 0.09), transparent 70%),
    repeating-linear-gradient(0deg, rgba(230, 241, 255, 0.014) 0 1px, transparent 1px 0.1875rem),
    var(--deck);
}
.auth-stage .auth::before {
  background: linear-gradient(160deg, var(--line-hot), rgba(24, 224, 255, 0.12) 34%, rgba(24, 224, 255, 0.08) 66%, var(--line-mag));
}

/* Head: the shield with a halo, then the mono status line. */
/* z-index auto (not the card's 1): no stacking context of its own, so the
   shield blends with the card behind it; the hairline and corner ticks sit
   at the card's edges, clear of the head. */
.auth-stage .auth > .auth-head { z-index: auto; display: grid; justify-items: center; gap: 0.875rem; margin: 0 0 1.125rem; text-align: center; }
.auth-shield {
  position: relative; width: 4rem; height: 4rem;
  mix-blend-mode: lighten; /* the shield's dark square melts into the card (no filter: a drop-shadow would outline the square) */
}
.auth-head::before {
  content: ""; position: absolute; left: 50%; top: 2rem; width: 5.25rem; height: 5.25rem; margin: -2.625rem 0 0 -2.625rem; border-radius: 50%; pointer-events: none;
  border: 1px solid rgba(24, 224, 255, 0.28);
  background: radial-gradient(closest-side, rgba(24, 224, 255, 0.14), transparent);
  box-shadow: 0 0 1.375rem rgba(24, 224, 255, 0.12), inset 0 0 1rem rgba(24, 224, 255, 0.1);
  animation: auth-halo 3.6s ease-in-out infinite;
}
@keyframes auth-halo { 50% { transform: scale(1.07); border-color: rgba(24, 224, 255, 0.46); } }
.auth-stage .auth-status {
  display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0 0.5rem; max-width: 100%;
  margin: 0; padding: 0.3125rem 0.75rem 0.3125rem 1.625rem; color: var(--cyan);
  font: 500 0.7rem/1.5 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; text-wrap: balance;
  border: 1px solid var(--line);
  /* Green "online" dot at the left. */
  background: radial-gradient(circle, var(--ok) 0.1875rem, transparent 0.2188rem) 0.5625rem 50% / 0.5rem 0.5rem no-repeat, rgba(24, 224, 255, 0.06);
}
.auth-stage .auth-status::before { content: attr(data-status); }
/* A blinking cursor after the text. */
.auth-stage .auth-status::after { content: ""; width: 0.55em; height: 1.05em; background: var(--cyan); opacity: 0.75; animation: auth-caret 1.1s steps(1) infinite; }
@keyframes auth-caret { 50% { opacity: 0; } }

/* Title and reading text. */
.auth-stage .auth h1 { margin: 0 0 0.875rem; text-align: center; font-size: clamp(1.55rem, 5.4vw, 2rem); letter-spacing: 0.03em; }
.auth-stage .auth > p:not(.hint) { color: var(--read); line-height: 1.6; }
.auth-stage .auth > p:not(.hint) b { color: var(--text); }
.auth-stage .auth > p.muted { color: var(--dim); }
.auth-stage .auth form { margin: 1.125rem 0 0; }

/* ---------- Fields ---------- */
.auth-stage .field { gap: 0.4375rem; margin-bottom: 1.125rem; }
.auth-stage .field label { color: var(--cyan-soft); }
.auth-stage input[type=email], .auth-stage input[type=text], .auth-stage input[type=password], .auth-stage input[type=tel], .auth-stage input:not([type]) {
  min-height: 3rem; padding: 0.75rem 0.875rem; font-size: 1rem; /* 16px: phones do not zoom in */
  background: linear-gradient(180deg, rgba(24, 224, 255, 0.035), transparent 60%), var(--field);
}
.auth-stage input:focus { border-color: var(--cyan); box-shadow: 0 0 0 0.1875rem rgba(24, 224, 255, 0.2), 0 0 1.125rem rgba(24, 224, 255, 0.12); }
.auth-stage input:user-invalid { border-color: var(--bad); box-shadow: 0 0 0 0.1875rem rgba(255, 92, 138, 0.16); }
.auth-stage .field .hint { margin-top: 0.25rem; line-height: 1.5; }
/* On-screen keyboards: a focused field scrolls clear of the sticky top bar. */
.auth-stage input, .auth-stage button { scroll-margin-top: 6rem; scroll-margin-bottom: 1.5rem; }

/* Big, readable code entry for one-time and recovery codes. */
.auth-stage input.auth-code {
  /* Sized so a 14-character recovery code (abcd-efgh-jkmn) fits at 360 px too. */
  min-height: 4rem; padding: 0.75rem 0.625rem; text-align: center; text-indent: 0.2em;
  font: 500 clamp(1.25rem, 6vw, 1.75rem)/1.2 var(--mono); letter-spacing: 0.2em; font-variant-numeric: tabular-nums;
  color: var(--cyan-soft); caret-color: var(--cyan);
  background:
    linear-gradient(90deg, transparent, rgba(24, 224, 255, 0.5), transparent) 50% 100% / 70% 1px no-repeat,
    linear-gradient(180deg, rgba(24, 224, 255, 0.05), transparent 70%), var(--field);
}
.auth-stage .mono { padding: 1px 0.4375rem; color: var(--cyan-soft); background: rgba(24, 224, 255, 0.07); border: 1px solid var(--line-soft); white-space: nowrap; }

/* ---------- Buttons ---------- */
.auth-stage .btn-block { min-height: 3.125rem; margin-top: 0.25rem; font-size: 0.9rem; white-space: normal; text-align: center; }

/* Password sign-in (administrators): a quiet disclosure under the main form. */
.auth-stage .pw-login { margin-top: 1.375rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); }
.auth-stage .pw-login summary {
  display: flex; align-items: center; gap: 0.625rem; list-style: none; min-height: 2.5rem; padding: 0.25rem 0;
  color: var(--dim); font-size: 0.92rem; transition: color 0.15s;
}
.auth-stage .pw-login summary::-webkit-details-marker { display: none; }
.auth-stage .pw-login summary::before {
  content: ""; flex: none; width: 0.5rem; height: 0.5rem; margin: 0 0.25rem 0 2px;
  border-right: 2px solid var(--cyan); border-bottom: 2px solid var(--cyan); transform: rotate(-45deg); transition: transform 0.2s;
}
.auth-stage .pw-login summary:hover { color: var(--text); }
.auth-stage .pw-login summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.auth-stage .pw-login[open] summary { margin-bottom: 0.875rem; color: var(--text); }
.auth-stage .pw-login[open] summary::before { transform: rotate(45deg); }
.auth-stage .pw-login form { margin-top: 0; }

/* ---------- Notices that say what they are ---------- */
.auth-stage .notice { margin: 0.25rem 0 1.125rem; line-height: 1.5; overflow-wrap: anywhere; }
.auth-stage .notice::before {
  display: block; margin-bottom: 0.1875rem; font: 500 0.68rem/1.4 var(--mono); letter-spacing: 0.16em; text-transform: uppercase;
}
.auth-stage .notice.err::before { content: "\26A0\FE0E  Error"; content: "\26A0\FE0E  Error" / "Error:"; color: var(--bad); }
.auth-stage .notice.warn::before { content: "\25B2\FE0E  Note"; content: "\25B2\FE0E  Note" / "Note:"; color: var(--warn); }

/* ---------- Footer line of the card ---------- */
.auth-stage .auth > .hint { margin: 1rem 0 0; line-height: 1.55; }
.auth-stage .auth > .hint:last-child { margin-top: 1.375rem; padding-top: 0.875rem; border-top: 1px solid var(--line-soft); }
.auth-stage .auth > .hint a { font-weight: 500; }

/* Waiting for the emailed confirmation: a slow scanning line under the head
   (the page reloads itself every few seconds). */
.auth-wait .auth-head::after {
  content: ""; justify-self: stretch; height: 2px; margin-top: 0.25rem;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent) 0 0 / 40% 100% no-repeat, var(--line-soft);
  animation: auth-scan 1.6s ease-in-out infinite alternate;
}
@keyframes auth-scan { from { background-position: -10% 0, 0 0; } to { background-position: 110% 0, 0 0; } }

/* ---------- Fit every screen ---------- */
@media (max-width: 600px) {
  .auth-stage { place-items: start center; min-height: 0; padding-top: 1.75rem; padding-bottom: 2.75rem; }
  .auth-stage::before { height: 46%; }
  .auth-stage .auth { --cut: 1rem; padding: 1.5rem 1.125rem 1.25rem; }
  .auth-stage .auth > .auth-head { gap: 0.75rem; margin-bottom: 0.875rem; }
  .auth-shield { width: 3.25rem; height: 3.25rem; }
  .auth-head::before { top: 1.625rem; width: 4.375rem; height: 4.375rem; margin: -2.1875rem 0 0 -2.1875rem; }
  .auth-stage .auth-status { font-size: 0.64rem; letter-spacing: 0.1em; }
}
@media (max-width: 360px) {
  .auth-stage .auth { padding-left: 0.875rem; padding-right: 0.875rem; }
  .auth-stage input.auth-code { letter-spacing: 0.16em; text-indent: 0.16em; }
}
/* Short screens (phones on their side, a keyboard open): no forced height, less air. */
@media (max-height: 560px) {
  .auth-stage { place-items: start center; min-height: 0; padding-top: 1.25rem; padding-bottom: 2rem; }
  .auth-stage .auth > .auth-head { grid-auto-flow: column; justify-content: center; align-items: center; gap: 0.875rem; margin-bottom: 0.75rem; }
  .auth-shield { width: 2.75rem; height: 2.75rem; }
  .auth-head::before { display: none; }
  .auth-wait .auth-head::after { display: none; }
}

/* ---------- Motion and print ---------- */
@media (prefers-reduced-motion: reduce) {
  .auth-stage::before, .auth-head::before, .auth-stage .auth-status::after, .auth-wait .auth-head::after { animation: none; }
  .auth-stage .pw-login summary::before { transition: none; }
}
@media print {
  .auth-stage { min-height: 0; padding: 0; }
  .auth-stage::before, .auth-stage::after, .auth-head { display: none !important; }
}

/* Polish (site-fit-check, 2026-11-24): on touch screens the "Back to sign in" link under the card is 40 px to tap
   (was 16 px); the larger tap area takes no extra room. */
@media (pointer: coarse), (max-width: 760px) {
  .auth-stage .auth > .hint a { display: inline-block; padding-top: 0.75rem; padding-bottom: 0.75rem; margin-top: -0.75rem; margin-bottom: -0.75rem; }
}
