/*
 * login.css — the login page only.
 *
 * This is the one stylesheet that must load before a session cookie exists, so
 * it lives in /portal/assets/public/, which _routes.json excludes from the
 * gate. Nothing else belongs in this directory: everything in it is public.
 *
 * **It cannot @import portal.css.** portal.css is inside the gated prefix, so
 * an unauthenticated browser would be redirected to the login page when it
 * tried to fetch it — the login page would have no styles at all. The tokens
 * below are therefore a deliberate duplicate of the subset portal.css defines,
 * kept in step by hand. If you change a token there, change it here.
 *
 * Phase 3 (docs/portal-implementation-plan.md) — supersedes the provisional
 * Phase 2 styling, and adds the light theme.
 */

:root {
  --p-font: Poppins, "Segoe UI", system-ui, -apple-system, sans-serif;
  --p-brand: #3660e3;
  --p-warn: #d9683a;
  --p-radius: 14px;
  --p-radius-card: 20px;
  --p-motion: 220ms;
  --p-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Dark is the portal's default. The manual toggle in the portal shell writes
   data-theme on <html>; the inline snippet in this page's <head> reads it back,
   so signing out and in again does not flip the theme under someone. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --p-bg: #0b1533;
  --p-bg-gradient: radial-gradient(ellipse 70rem 45rem at 20% -10%, #1d2c5f, transparent 70%);
  --p-surface: #131f45;
  --p-surface-sunken: #08102a;
  --p-ink: #f4f1ea;
  --p-ink-muted: #b9c2dc;
  --p-line: #2a3868;
  --p-line-strong: #5a6cb0;
  --p-brand-ink: #7093f5;
  --p-warn-ink: #f0855a;
  --p-focus: #4fc3ba;
  --p-shadow: 0 1px 2px #00000040, 0 18px 40px -18px #00000080;
}

:root[data-theme="light"] {
  color-scheme: light;
  --p-bg: #faf7f2;
  --p-bg-gradient: radial-gradient(ellipse 70rem 45rem at 20% -10%, #3660e314, transparent 70%);
  --p-surface: #ffffff;
  --p-surface-sunken: #f2ede4;
  --p-ink: #0b1533;
  --p-ink-muted: #4a5573;
  --p-line: #e5ddd0;
  --p-line-strong: #8d8270;
  --p-brand-ink: #2b4dbb;
  --p-warn-ink: #a8461f;
  --p-focus: #2b4dbb;
  --p-shadow: 0 1px 2px #0b153312, 0 18px 36px -20px #0b153333;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --p-bg: #faf7f2;
    --p-bg-gradient: radial-gradient(ellipse 70rem 45rem at 20% -10%, #3660e314, transparent 70%);
    --p-surface: #ffffff;
    --p-surface-sunken: #f2ede4;
    --p-ink: #0b1533;
    --p-ink-muted: #4a5573;
    --p-line: #e5ddd0;
    --p-line-strong: #8d8270;
    --p-brand-ink: #2b4dbb;
    --p-warn-ink: #a8461f;
    --p-focus: #2b4dbb;
    --p-shadow: 0 1px 2px #0b153312, 0 18px 36px -20px #0b153333;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: var(--p-font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--p-ink);
  background-color: var(--p-bg);
  background-image: var(--p-bg-gradient);
  -webkit-font-smoothing: antialiased;
}

.login-card {
  width: 100%;
  max-width: 26rem;
  padding: 32px;
  background: var(--p-surface);
  border: 1px solid var(--p-line);
  border-radius: var(--p-radius-card);
  box-shadow: var(--p-shadow);
}

.login-logo {
  display: block;
  height: 56px;
  width: auto;
  margin: 0 auto 20px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.01em;
}

.login-lead {
  margin: 0 0 24px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--p-ink-muted);
}

fieldset {
  border: 0;
  margin: 0 0 20px;
  padding: 0;
}

legend,
label {
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0;
}

legend {
  margin-bottom: 10px;
}

/* Area choice: radios styled as a two-up segmented control, but still radios —
   the native control keeps arrow-key selection and screen-reader grouping. */
.area-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.area-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.area-choice span {
  display: block;
  min-height: 48px; /* touch target */
  padding: 12px 8px;
  text-align: center;
  border: 1px solid var(--p-line-strong);
  border-radius: var(--p-radius);
  cursor: pointer;
  transition: background var(--p-motion) var(--p-ease), border-color var(--p-motion) var(--p-ease),
    color var(--p-motion) var(--p-ease);
}

.area-choice input:checked + span {
  background: var(--p-brand);
  border-color: var(--p-brand);
  color: #fff;
  font-weight: 500;
}

.area-choice input:focus-visible + span {
  outline: 3px solid var(--p-focus);
  outline-offset: 2px;
}

label[for="password"] {
  display: block;
  margin-bottom: 8px;
}

input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  font: inherit;
  color: var(--p-ink);
  background: var(--p-surface-sunken);
  border: 1px solid var(--p-line-strong);
  border-radius: var(--p-radius);
}

button {
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--p-brand);
  border: 0;
  border-radius: var(--p-radius);
  cursor: pointer;
  transition: background var(--p-motion) var(--p-ease);
}

button:hover {
  background: #2b4dbb;
}

:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--p-focus);
  outline-offset: 2px;
}

/* Hidden until the inline script fills it in, so an empty box never shows. */
.login-message:empty {
  display: none;
}

.login-message {
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--p-line-strong);
  border-inline-start: 4px solid var(--p-warn);
  border-radius: var(--p-radius);
  background: var(--p-surface-sunken);
  color: var(--p-warn-ink);
  font-size: 0.9rem;
}

.login-message[data-tone="neutral"] {
  border-inline-start-color: var(--p-brand);
  color: var(--p-ink-muted);
}

.login-back {
  display: block;
  margin-top: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--p-brand-ink);
  text-underline-offset: 0.2em;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
