/*
 * Neo.Identity — the sign-in and sign-out pages.
 *
 * Tokens are taken from Neo's design system (neo-design-system, styles/design-tokens.scss,
 * commit 4846802) and the layout from its "Login" design (app/designs/login): a warm-grey
 * page, a white card at most 420px wide, the wordmark at 32px, an H5 heading, outlined
 * 56px fields and a full-width primary button.
 *
 * ⛔ Self-hosted, all of it. The pages are served under `default-src 'self'`
 * (SecurityHeadersAttribute): no CDN, no Google Fonts, no inline style or script.
 * A `style="…"` attribute is an inline style and the CSP blocks it — put it here.
 *
 * Light only (Karthik, 2026-10-06): the design system draws no dark theme.
 */

/* ── Fonts (SIL Open Font License 1.1 — see fonts/*-OFL.txt) ───────────────────── */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("../fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
}

/* ── Tokens ──────────────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  /* design-tokens.scss */
  --neo-primary-900: #000133;
  --neo-primary-500: #151dbd;
  --neo-primary-400: #7b85ff;
  --neo-primary-300: #9da4ff;
  --neo-primary-100: #e1e2ff;
  --neo-tertiary-500: #3fab73;
  --neo-warm-grey-500: #eae9e6;
  --neo-warm-grey-300: #f9f9f8;
  --neo-bw-900: #060714;
  --neo-bw-500: #606169;
  --neo-bw-400: #86868d;
  --neo-bw-300: #c1c1c5;
  --neo-bw-200: #d7d7d9;
  --neo-white: #ffffff;
  --neo-error-900: #7f0b0b;
  --neo-error-500: #ba1a1a;
  --neo-error-400: #e29090;
  --neo-error-100: #f4dede;

  --neo-font-heading: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --neo-font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --neo-space-1: 4px;
  --neo-space-2: 8px;
  --neo-space-3: 12px;
  --neo-space-4: 16px;
  --neo-space-5: 20px;
  --neo-space-6: 24px;
  --neo-space-8: 32px;

  --neo-radius-sm: 4px;
  --neo-radius-md: 8px;
  --neo-radius-lg: 12px;
  --neo-radius-xl: 16px;

  --neo-shadow-md: 0 4px 8px rgba(6, 7, 20, 0.10), 0 1px 2px rgba(6, 7, 20, 0.06);

  /* Roles — what the pages use, as the design system draws them. */
  --page-bg: var(--neo-warm-grey-300);
  --surface: var(--neo-white);
  --surface-border: transparent;
  --surface-shadow: var(--neo-shadow-md);
  --text: var(--neo-bw-900);
  --text-muted: var(--neo-bw-500);
  --rule: var(--neo-bw-200);
  --field-bg: var(--neo-white);
  --field-border: var(--neo-bw-200);
  --field-border-hover: var(--neo-bw-900);
  --field-border-focus: var(--neo-primary-500);
  --focus-ring-gap: var(--neo-white);
  --focus-ring: var(--neo-primary-400);
  --action-bg: var(--neo-primary-500);
  --action-text: var(--neo-white);
  --action-disabled-bg: var(--neo-bw-200);
  --action-disabled-text: var(--neo-bw-500);
  --link: var(--neo-primary-500);
  --alert-bg: var(--neo-error-100);
  --alert-border: var(--neo-error-500);
  --alert-text: var(--neo-error-900);
  --alert-icon: var(--neo-error-500);
}

/* ── Base ────────────────────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--neo-font-body);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
}

h1,
p {
  margin: 0;
}

a {
  color: var(--link);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring-gap), 0 0 0 4px var(--focus-ring);
}

/* ── Shell: one centred card ─────────────────────────────────────────────────────── */

.neo-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: var(--neo-space-8) var(--neo-space-4);
}

.neo-card {
  width: 100%;
  max-width: 420px;
  padding: var(--neo-space-8);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--neo-radius-md);
  box-shadow: var(--surface-shadow);
}

/* Brand guidelines: digital minimum 30px high. */
.neo-brand {
  display: block;
  margin-bottom: var(--neo-space-8);
}

.neo-brand img {
  display: block;
  height: 32px;
  width: auto;
}

/* H5 — Plus Jakarta Sans 700, 23/32. */
.neo-title {
  font-family: var(--neo-font-heading);
  font-size: 23px;
  font-weight: 700;
  line-height: 32px;
  margin-bottom: var(--neo-space-6);
}

/* Body 2 — Inter 400, 14/20. */
.neo-lede {
  color: var(--text-muted);
  margin-top: calc(-1 * var(--neo-space-2));
  margin-bottom: var(--neo-space-6);
}

/* ── Alert ───────────────────────────────────────────────────────────────────────── */

.neo-alert {
  display: flex;
  gap: var(--neo-space-3);
  align-items: flex-start;
  margin-bottom: var(--neo-space-6);
  padding: var(--neo-space-3) var(--neo-space-4);
  background: var(--alert-bg);
  border-left: 4px solid var(--alert-border);
  border-radius: var(--neo-radius-sm);
  color: var(--alert-text);
  font-size: 14px;
  line-height: 20px;
}

.neo-alert svg {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--alert-icon);
}

/* ── Form ────────────────────────────────────────────────────────────────────────── */

.neo-form {
  display: flex;
  flex-direction: column;
  gap: var(--neo-space-5);
}

.neo-field {
  display: flex;
  flex-direction: column;
  gap: var(--neo-space-2);
}

.neo-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

/* Text field — outlined, 56px, 4px radius (design system TextField). */
.neo-input {
  width: 100%;
  min-height: 56px;
  padding: 0 var(--neo-space-4);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--neo-radius-sm);
  color: var(--text);
  font: inherit;
  /* 16px stops iOS zooming into the field on focus. */
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.neo-input:hover {
  border-color: var(--field-border-hover);
}

.neo-input:focus {
  outline: none;
  border-color: var(--field-border-focus);
  box-shadow: inset 0 0 0 1px var(--field-border-focus);
}

.neo-input:focus-visible {
  box-shadow: inset 0 0 0 1px var(--field-border-focus),
    0 0 0 2px var(--focus-ring-gap), 0 0 0 4px var(--focus-ring);
}

/* Button — primary, large (48px): one-handed, gloved, end of a shift. */
.neo-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--neo-space-2);
  width: 100%;
  min-height: 48px;
  margin-top: var(--neo-space-1);
  padding: 0 var(--neo-space-4);
  background: var(--action-bg);
  border: 0;
  border-radius: var(--neo-radius-xl);
  color: var(--action-text);
  cursor: pointer;
  font-family: var(--neo-font-heading);
  font-size: 16px;
  font-weight: 700;
  line-height: 24px;
  text-decoration: none;
  transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

/* M3 state layers, as the design system's Button: 8% hover, 12% press. */
.neo-button:hover {
  box-shadow: inset 0 0 0 100px rgba(255, 255, 255, 0.08);
}

.neo-button:active {
  box-shadow: inset 0 0 0 100px rgba(0, 0, 0, 0.12);
}

.neo-button:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring-gap), 0 0 0 4px var(--focus-ring);
}

.neo-button:disabled,
.neo-button[aria-disabled="true"] {
  background: var(--action-disabled-bg);
  color: var(--action-disabled-text);
  cursor: progress;
  box-shadow: none;
}

/* Submitting: login.js sets aria-disabled and data-busy; without JS none of this shows. */
.neo-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: neo-spin 0.8s linear infinite;
}

.neo-button[data-busy="true"] .neo-spinner {
  display: inline-block;
}

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

@media (prefers-reduced-motion: reduce) {
  .neo-spinner {
    animation-duration: 2.4s;
  }

  .neo-input,
  .neo-button {
    transition: none;
  }
}

/* ── Secondary: "other ways to sign in" ──────────────────────────────────────────── */

.neo-secondary {
  margin-top: var(--neo-space-6);
  padding-top: var(--neo-space-5);
  border-top: 1px solid var(--rule);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 20px;
}

.neo-secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--neo-space-2) var(--neo-space-4);
}

.neo-secondary a {
  font-weight: 600;
}

/* ── Error page: what to quote to support ────────────────────────────────────────── */

.neo-details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--neo-space-1) var(--neo-space-4);
  margin: var(--neo-space-6) 0 0;
  padding-top: var(--neo-space-5);
  border-top: 1px solid var(--rule);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 20px;
}

.neo-details dt {
  font-weight: 600;
}

.neo-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.neo-details code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

/* ── Utilities ───────────────────────────────────────────────────────────────────── */

/* The front-channel sign-out frame: loaded, never seen. */
.neo-hidden-frame {
  position: absolute;
  width: 0;
  height: 0;
  border: 0;
}

/* ── Small screens: down to 360px ────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .neo-shell {
    align-items: flex-start;
    padding: var(--neo-space-6) var(--neo-space-4);
  }

  .neo-card {
    padding: var(--neo-space-6) var(--neo-space-5);
  }

  .neo-brand {
    margin-bottom: var(--neo-space-6);
  }
}

@media (forced-colors: active) {
  .neo-button,
  .neo-input,
  .neo-alert {
    border: 1px solid CanvasText;
  }
}
