/*
 * Sign-in surface.
 *
 * Same arrangement as landing.css: loaded after app.css and only by the pages
 * that link it, so re-pointing the tokens in one :root block turns app.css's
 * card, form, inputs, alerts and language picker dark here and nowhere else.
 * Nothing in this file restates a component app.css already owns — it changes
 * what those components are made of, then adds the three things a sign-in page
 * needs that an admin page does not: the lit backdrop, the glass card, and the
 * focus ring that goes with a dark field.
 *
 * Named for the surface rather than the page: login.html and signup.html both
 * link it, and share the backdrop partial (templates/_auth_backdrop.html) so
 * the two cannot drift apart.
 *
 * The palette is deliberately cooler than landing.css. That page sells with an
 * indigo-to-violet sweep; this one is a place to type a password, so the accent
 * settles on blue and the decoration stays under the card rather than beside it.
 */

:root {
  color-scheme: dark;

  /* --- app.css tokens, re-pointed ---------------------------------------- */
  --canvas: #08090b;
  --surface: #101319;
  --muted: #171b22;

  --border: #1d222c;
  --border-strong: #2a313d;

  --ink: #f2f4f8;
  --ink-soft: #9aa4b3;
  /* Lifted off the dashboard's faint tier for the same reason landing.css
     lifts its own: everything wearing it here is 12-13px, and darker than
     this sits under 4.5:1 on a near-black page. */
  --ink-faint: #7b8696;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #0e1c33;

  --success: #34d399;
  --success-soft: #06281f;
  --warning: #fbbf24;
  --warning-soft: #2a2005;
  --danger: #f87171;
  --danger-soft: #2b1013;

  --radius: 18px;

  /* --- auth-only ---------------------------------------------------------- */
  --accent-ink: #bfd4fe;
  --ring: rgba(59, 130, 246, 0.2);

  --glass-line: rgba(255, 255, 255, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body.auth-page {
  /* A column so the picker strip and the card share the viewport instead of
     stacking past it. app.css gives .auth `min-height: 100dvh`, which with a
     topbar above it made every sign-in page a little taller than the screen
     and put a scrollbar on a page that has nothing to scroll. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
}

/* --- Backdrop ------------------------------------------------------------- */

/*
 * Four layers, none of them loud: ambient light, two gradient circles, a few
 * drawn curves, grain, and a vignette to close the edges. Fixed and inert, so
 * it costs one paint and never competes with the card.
 */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(48rem 30rem at 18% -6%, rgba(37, 99, 235, 0.16), transparent 60%),
    radial-gradient(42rem 28rem at 84% 6%, rgba(124, 58, 237, 0.13), transparent 58%);
}

/*
 * Circles as radial gradients rather than a solid disc under filter: blur().
 * A gradient with a soft falloff already *is* the blurred circle, and it costs
 * no filter pass on a page the browser paints before anyone can type.
 */
.auth-orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.55;
}

.auth-orb-a {
  width: 46rem;
  height: 46rem;
  top: -18rem;
  left: -14rem;
  background: radial-gradient(closest-side, rgba(59, 130, 246, 0.3), transparent 70%);
}

.auth-orb-b {
  width: 38rem;
  height: 38rem;
  right: -12rem;
  bottom: -16rem;
  background: radial-gradient(closest-side, rgba(139, 92, 246, 0.26), transparent 70%);
}

/* Curves, drawn in the markup so they stay crisp at any width. */
.auth-curves {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.5;
}

/*
 * Grain. An inline SVG turbulence rather than an image file: the CSP allows
 * data: URIs for images and this app ships no binary assets, so the texture
 * travels with the stylesheet.
 */
.auth-grain {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

.auth-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(58% 58% at 50% 46%, transparent 40%, rgba(0, 0, 0, 0.5) 100%);
}

/* The page itself sits above all of it. */
.auth-topbar,
.auth {
  position: relative;
  z-index: 1;
}

/* --- Layout --------------------------------------------------------------- */

.auth-topbar {
  flex: none;
}

.auth {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px 24px 56px;
}

/* --- Card ----------------------------------------------------------------- */

.auth .card {
  position: relative;
  width: 100%;
  max-width: 404px;
  padding: 34px 32px 30px;
  border-radius: 20px;
  border: 1px solid var(--glass-line);
  background: linear-gradient(180deg, rgba(24, 28, 37, 0.72), rgba(13, 16, 21, 0.76));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow:
    0 32px 72px -22px rgba(0, 0, 0, 0.8),
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: auth-in 0.5s var(--ease) both;
}

/* A single lit hairline across the top edge — the one place the accent shows
   without being asked for. */
.auth .card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 22px;
  right: 22px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(147, 179, 255, 0.42),
    transparent
  );
}

@keyframes auth-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.auth-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.auth-sub {
  margin: 8px 0 26px;
}

.auth-foot {
  margin: 22px 0 0;
  text-align: center;
}

/* Links inside the card read as links; the Google button is a .btn and keeps
   its own treatment. */
.auth .card a:not(.btn) {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(191, 212, 254, 0.4);
}

.auth .card a:not(.btn):hover {
  text-decoration-color: currentColor;
}

/* --- Buttons -------------------------------------------------------------- */

.auth .btn {
  height: 44px;
  border-radius: 11px;
  font-size: 0.9375rem;
  font-weight: 550;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    box-shadow 0.22s var(--ease), transform 0.18s var(--ease);
}

/*
 * The submit button, and the only saturated surface on the page.
 *
 * The blue is deeper than the accent token because this is the one place white
 * text sits on it: a lighter, prettier blue put "Sign in" at 3.3:1, and the
 * lightest stop of a gradient is the one that has to clear AA, not the average.
 * Both stops here are above 4.5:1, hover included.
 */
.auth form .btn {
  width: 100%;
  background: linear-gradient(180deg, #2f6fe4 0%, #2158d8 100%);
  box-shadow:
    0 10px 26px -10px rgba(37, 99, 235, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.auth form .btn:hover {
  background: linear-gradient(180deg, #3170e6 0%, #2560dc 100%);
  box-shadow:
    0 14px 32px -10px rgba(37, 99, 235, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.auth .btn-secondary {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-line);
  color: var(--ink);
}

.auth .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--ink);
}

/* --- Fields --------------------------------------------------------------- */

.auth .form {
  gap: 16px;
  max-width: none;
}

.auth label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.auth input[type="text"],
.auth input[type="email"],
.auth input[type="password"] {
  height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--ink);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}

.auth input::placeholder {
  color: var(--ink-faint);
}

/* Sign-up's password rule, sitting under its field. */
.auth .hint {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.auth input[type="text"]:hover,
.auth input[type="email"]:hover,
.auth input[type="password"]:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

/*
 * The ring replaces app.css's global 2px outline, which was drawn for a white
 * page. `outline` is kept as a transparent shape rather than removed, so
 * Windows high-contrast mode — which ignores box-shadow — still marks the
 * focused field.
 */
.auth input[type="text"]:focus,
.auth input[type="email"]:focus,
.auth input[type="password"]:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: rgba(59, 130, 246, 0.65);
  background: rgba(59, 130, 246, 0.06);
  box-shadow: 0 0 0 3px var(--ring);
}

/*
 * Chrome paints autofilled fields with its own near-white background, which on
 * a dark card renders the value unreadable. The inset shadow is the only way to
 * repaint it; the absurd transition delay is the standard trick for keeping it
 * from flashing back on blur.
 */
.auth input:-webkit-autofill,
.auth input:-webkit-autofill:hover,
.auth input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px #151a23 inset;
  box-shadow: 0 0 0 1000px #151a23 inset;
  caret-color: var(--ink);
  transition: background-color 100000s ease-in-out 0s;
}

/* --- Divider and alerts --------------------------------------------------- */

.auth .auth-divider {
  margin: 18px 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.auth .auth-divider::before,
.auth .auth-divider::after {
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.auth .alert {
  margin: 0 0 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 0.8125rem;
}

.auth .alert-error {
  border-color: rgba(248, 113, 113, 0.28);
}

.auth .alert-ok {
  border-color: rgba(52, 211, 153, 0.28);
}

/* --- Language picker ------------------------------------------------------ */

/* app.css dresses the picker for a white page; only what assumed white is
   restated. */
.auth-page .lang-menu {
  background: #12161d;
  border-color: var(--border-strong);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
}

.auth-page .lang-menu a {
  color: var(--ink-soft);
}

.auth-page .lang-menu a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.auth-page .lang-menu a[aria-current="true"] {
  color: var(--accent-ink);
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 520px) {
  .auth {
    padding: 16px 16px 40px;
  }

  .auth .card {
    padding: 28px 22px 26px;
    border-radius: 18px;
  }

  .auth-topbar {
    padding: 14px 16px 0;
  }

  .auth-orb-a,
  .auth-orb-b {
    /* Half the screen is a lot of glow on a phone. */
    opacity: 0.4;
  }
}

/* app.css already flattens animation and transition durations under this
   preference; the entrance is switched off outright so nothing starts hidden. */
@media (prefers-reduced-motion: reduce) {
  .auth .card {
    animation: none;
  }
}
