/* Sign-in page. Colors come from the demo tokens in frame.css.
   The card uses --surface-solid so it stays lighter than the fields. */

/* Page shell. The page background is the demo page color. Beam sizes stay local. */
#nx-login {
  width: 100%;
  max-width: none;
  --nx-login-beam: 28%;
  --nx-login-beam2: 18%;
  --nx-login-tick: 50%;
  --nx-login-edge: 28%;
  --nx-login-under: 20%;
  --nx-login-page-mid: var(--bg);
  --nx-login-page-edge: var(--bg);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  box-sizing: border-box;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 30px;
  font-family: var(--nx-font);
  color: var(--fg);
  background: radial-gradient(ellipse 70% 80% at 50% 45%,var(--nx-login-page-mid),var(--nx-login-page-edge) 100%);
  background-repeat: no-repeat;
}
/* Light theme uses a flat page and the demo accent wash. */
#nx-login:is(:root[data-theme="light"] *) {
  --nx-login-page-mid: initial;
  --nx-login-page-edge: initial;
  background-color: var(--bg);
  background-image: radial-gradient(1200px 500px at 10% -10%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 70%);
}
/* Stage, wordmark, and card. */
#nx-login .nx-login-stage { position: relative; z-index: 1; width: min(100%, 400px); margin: auto; display: flex; flex-direction: column; align-items: center; gap: 24px; }
#nx-login .nx-login-lockup { display: flex; justify-content: center; height: 32px; }
#nx-login .nx-login-logo { width: 106px; height: 32px; }
#nx-login .nx-login-logo-light { display: none; }
#nx-login .nx-login-logo-dark:is(:root[data-theme="light"] *) { display: none; }
#nx-login .nx-login-logo-light:is(:root[data-theme="light"] *) { display: block; }
#nx-login .nx-card {
  background: var(--surface-solid);
  border-radius: 24px;
  box-shadow: var(--shadow-border), var(--shadow-lg);
}
#nx-login .nx-login-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 32px;
  animation: nxIn 250ms var(--ease);
  box-shadow: inset 0 1px 0 0 #ffffff14, 0 0 0 1px color-mix(in srgb, var(--accent) var(--nx-login-edge), transparent), 0 28px 64px -24px #0000008c, 0 40px 80px -40px color-mix(in srgb, var(--accent) var(--nx-login-under), transparent);
}
#nx-login .nx-login-card:is(:root[data-theme="light"] *) { box-shadow: var(--shadow-border), var(--shadow-lg); }
/* Heading and the line under it. */
#nx-login h1 {
  margin: 0;
  color: var(--fg);
  font-size: 26px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
#nx-login p { margin: 0; }
#nx-login .nx-login-sub { margin-top: 4px; color: var(--fg-muted); font-size: 14.5px; }
/* Form fields. */
#nx-login .nx-login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
#nx-login .nx-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Field titles. The capitals come from this rule. */
#nx-login .nx-label {
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
/* Text controls, the invalid state, and the reveal button. */
#nx-login .nx-login-control { position: relative; }
#nx-login .nx-login-glyph { position: absolute; left: 12px; top: 0; bottom: 0; display: flex; align-items: center; pointer-events: none; color: var(--fg-muted); }
#nx-login .nx-login-glyph .nx-icon,
#nx-login .nx-login-reveal .nx-icon,
#nx-login .nx-login-spinner .nx-icon { width: 16px; height: 16px; }
#nx-login .nx-input {
  width: 100%;
  height: 44px;
  padding: 0 12px 0 38px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-raised);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--border);
  font: inherit;
  font-size: 15px;
}
#nx-login .nx-login-password { padding-right: 44px; }
#nx-login .nx-input:hover {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
#nx-login .nx-input:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent), var(--ring);
}
#nx-login .nx-input[aria-invalid="true"],
#nx-login .nx-input[aria-invalid="true"]:hover,
#nx-login .nx-input[aria-invalid="true"]:focus-visible { box-shadow: inset 0 0 0 1px var(--danger); }
#nx-login .nx-input:-webkit-autofill,
#nx-login .nx-input:-webkit-autofill:hover,
#nx-login .nx-input:-webkit-autofill:focus,
#nx-login .nx-input:autofill { -webkit-text-fill-color: var(--fg); caret-color: var(--fg); box-shadow: inset 0 0 0 1px var(--border), inset 0 0 0 1000px var(--bg-raised); }
#nx-login .nx-login-reveal { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: transparent; color: var(--fg-muted); }
#nx-login .nx-login-reveal[hidden] { display: none; }
#nx-login .nx-login-reveal:hover { color: var(--fg); }
#nx-login .nx-login-eye-off { display: none; }
#nx-login .nx-login-reveal[aria-pressed="true"] .nx-login-eye { display: none; }
#nx-login .nx-login-reveal[aria-pressed="true"] .nx-login-eye-off { display: inline-flex; }
/* Caps warning. An empty message is clipped out of the layout. */
#nx-login .nx-login-caps { display: flex; align-items: center; gap: 6px; color: var(--warn); font-size: 12.5px; }
#nx-login .nx-login-caps:has(.nx-login-caps-text:empty) { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); }
#nx-login .nx-login-caps .nx-icon { width: 14px; height: 14px; }
/* Sign-in button and the busy spinner. */
#nx-login .nx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#nx-login .nx-btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
#nx-login .nx-btn-primary:hover {
  background: var(--accent-hover);
}
#nx-login .nx-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
#nx-login .nx-btn:active {
  transform: scale(0.96);
}
#nx-login .nx-btn:disabled {
  opacity: 0.5;
}
#nx-login .nx-login-spinner[hidden] { display: none; }
#nx-login .nx-login-spinner { display: inline-flex; }
#nx-login .nx-login-spinner .nx-icon { animation: nx-login-spin 700ms linear infinite; }
/* Failed sign-in message. */
#nx-login .nx-alert.danger {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--danger);
  font-size: 14px;
}
#nx-login .nx-login-alert-icon { flex: none; color: var(--danger); }
#nx-login .nx-login-alert-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#nx-login .nx-login-alert-title { font-weight: 700; }
/* Theme control, held above the page. */
#nx-login .nx-login-theme { position: fixed; top: 16px; right: 16px; z-index: 2; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--nx-bg); color: var(--fg); box-shadow: var(--shadow-border); }
#nx-login .nx-login-theme[hidden] { display: none; }
/* Backdrop layers (dark only). Light keeps today's page. */
#nx-login .nx-login-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
#nx-login .nx-login-bg > * { position: absolute; pointer-events: none; }
#nx-login .nx-login-bg:is(:root[data-theme="light"] *) { display: none; }
#nx-login .nx-login-wash { inset: 0; background: radial-gradient(ellipse 700px 420px at 50% 100%, color-mix(in oklab, var(--accent) 45%, transparent), transparent 70%); }
#nx-login .nx-login-dots { --nx-reach: 77.5vmin; inset: 0; -webkit-mask-image: radial-gradient(ellipse max(520px, 40.625vw) max(430px, 53.75vh) at 50% 48%, transparent 55%, #000 100%); mask-image: radial-gradient(ellipse max(520px, 40.625vw) max(430px, 53.75vh) at 50% 48%, transparent 55%, #000 100%); }
#nx-login .nx-login-dots span { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(circle, color-mix(in srgb, var(--accent) 32%, transparent) var(--nx-dot), transparent var(--nx-dot)), radial-gradient(circle, color-mix(in srgb, var(--accent) 32%, transparent) var(--nx-dot), transparent var(--nx-dot)); background-size: 22px 38.1px; background-position: 0 190.55px, -11px 209.55px; -webkit-mask-image: radial-gradient(circle at 0 100%, transparent calc(var(--nx-in) - 4px), #000 var(--nx-in), #000 var(--nx-out), transparent calc(var(--nx-out) + 4px)), radial-gradient(circle at 100% 100%, transparent calc(var(--nx-in) - 4px), #000 var(--nx-in), #000 var(--nx-out), transparent calc(var(--nx-out) + 4px)); mask-image: radial-gradient(circle at 0 100%, transparent calc(var(--nx-in) - 4px), #000 var(--nx-in), #000 var(--nx-out), transparent calc(var(--nx-out) + 4px)), radial-gradient(circle at 100% 100%, transparent calc(var(--nx-in) - 4px), #000 var(--nx-in), #000 var(--nx-out), transparent calc(var(--nx-out) + 4px)); mask-composite: add; }
#nx-login .nx-login-dots-1 { --nx-dot: 2.46px; --nx-in: 0px; --nx-out: calc(var(--nx-reach) * 0.121); }
#nx-login .nx-login-dots-2 { --nx-dot: 2.18px; --nx-in: calc(var(--nx-reach) * 0.121); --nx-out: calc(var(--nx-reach) * 0.242); }
#nx-login .nx-login-dots-3 { --nx-dot: 1.9px; --nx-in: calc(var(--nx-reach) * 0.242); --nx-out: calc(var(--nx-reach) * 0.363); }
#nx-login .nx-login-dots-4 { --nx-dot: 1.63px; --nx-in: calc(var(--nx-reach) * 0.363); --nx-out: calc(var(--nx-reach) * 0.484); }
#nx-login .nx-login-dots-5 { --nx-dot: 1.32px; --nx-in: calc(var(--nx-reach) * 0.484); --nx-out: calc(var(--nx-reach) * 0.621); }
#nx-login .nx-login-dots-6 { --nx-dot: 1.01px; --nx-in: calc(var(--nx-reach) * 0.621); --nx-out: calc(var(--nx-reach) * 0.758); }
#nx-login .nx-login-dots-7 { --nx-dot: 0.71px; --nx-in: calc(var(--nx-reach) * 0.758); --nx-out: calc(var(--nx-reach) * 0.879); }
#nx-login .nx-login-dots-8 { --nx-dot: 0.45px; --nx-in: calc(var(--nx-reach) * 0.879); --nx-out: var(--nx-reach); }
#nx-login .nx-login-beamglow { inset: 0; background: radial-gradient(760px 420px at 50% 0%, color-mix(in srgb, var(--accent) var(--nx-login-beam2), transparent), transparent 72%); }
#nx-login .nx-login-beam {
  inset: 0;
  background: conic-gradient(from 138deg at 50% -8%, transparent 0deg, color-mix(in srgb, var(--accent) calc(var(--nx-login-beam) * 0.45), transparent) 18deg, color-mix(in srgb, var(--accent) var(--nx-login-beam), transparent) 42deg, color-mix(in srgb, var(--accent) calc(var(--nx-login-beam) * 0.45), transparent) 66deg, transparent 84deg, transparent 360deg);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.55) 38%, transparent 70%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.55) 38%, transparent 70%);
}
#nx-login .nx-login-tick { width: 10px; height: 10px; border: 0 solid color-mix(in srgb, var(--accent) var(--nx-login-tick), transparent); }
#nx-login .nx-login-tick-tl { top: 6px; left: 6px; border-top-width: 1px; border-left-width: 1px; }
#nx-login .nx-login-tick-tr { top: 6px; right: 6px; border-top-width: 1px; border-right-width: 1px; }
#nx-login .nx-login-tick-bl { bottom: 6px; left: 6px; border-bottom-width: 1px; border-left-width: 1px; }
#nx-login .nx-login-tick-br { bottom: 6px; right: 6px; border-bottom-width: 1px; border-right-width: 1px; }
/* ==========================================================================
   Sign-in scene (views/login.ejs only, dark theme only)
   --------------------------------------------------------------------------
   The sign-in page replaces the beam-and-dots backdrop above (still used by
   set-password.ejs) with an "operations" scene, drawn with static inline
   SVG and CSS gradients, no images and no animation:
     1. .nx-login-scene-sky       deep navy base with soft blue light
     2. .nx-login-panels          faint, blurred dashboard screens, left
     3. .nx-login-hex             glowing blue hexagon grid, right
     4. .nx-login-net             dot-and-line network along the bottom
     5. .nx-login-scene-vignette  darkens the edges and the centre so the
                                  card keeps its contrast
   Every layer is absolutely placed by `.nx-login-bg > *`, ignores the
   pointer and sits under .nx-login-stage (z-index 1). The light theme
   hides .nx-login-bg as before, so light mode is unchanged.
   ========================================================================== */

/* Scene palette. Hues sit near the demo accent; kept local to the scene. */
#nx-login .nx-login-scene {
  --nx-scene-navy: #07111f;
  --nx-scene-navy-mid: #0b1a33;
  --nx-scene-blue: #3b82f6;
  --nx-scene-glow: #60a5fa;
  background: var(--nx-scene-navy);
}

/* 1. Sky: a vertical navy gradient, lifted by a cool glow on the right
      (behind the hex grid) and a faint one low on the left (the panels). */
#nx-login .nx-login-scene-sky {
  inset: 0;
  background:
    radial-gradient(ellipse 55% 60% at 82% 38%, color-mix(in srgb, var(--nx-scene-blue) 16%, transparent), transparent 70%),
    radial-gradient(ellipse 45% 40% at 12% 72%, color-mix(in srgb, var(--nx-scene-blue) 9%, transparent), transparent 70%),
    linear-gradient(180deg, var(--nx-scene-navy-mid) 0%, var(--nx-scene-navy) 70%);
}

/* 2. Dashboard panels: bottom-left, turned slightly away in perspective and
      blurred so they read as out-of-focus screens rather than content. */
#nx-login .nx-login-panels {
  left: 0;
  bottom: 6%;
  width: min(48vw, 760px);
  height: auto;
  opacity: 0.5;
  filter: blur(1.2px);
  transform: perspective(1200px) rotateY(14deg);
  transform-origin: left center;
  /* Fade the right edge so the panels melt into the sky. */
  -webkit-mask-image: linear-gradient(90deg, #000 55%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 55%, transparent 100%);
}
/* Far screens: soft blocks blurred inside the SVG (#nx-login-panel-blur). */
#nx-login .nx-login-panels-far rect { fill: color-mix(in srgb, var(--nx-scene-blue) 22%, transparent); }
/* Near screens: translucent glass with a thin blue edge. */
#nx-login .nx-login-panel-frame {
  fill: color-mix(in srgb, var(--nx-scene-navy-mid) 70%, transparent);
  stroke: color-mix(in srgb, var(--nx-scene-glow) 45%, transparent);
  stroke-width: 1;
}
#nx-login .nx-login-panel-ink { fill: color-mix(in srgb, var(--nx-scene-glow) 35%, transparent); }
#nx-login .nx-login-panel-bar { fill: color-mix(in srgb, var(--nx-scene-glow) 55%, transparent); }
#nx-login .nx-login-panel-line {
  fill: none;
  stroke: color-mix(in srgb, var(--nx-scene-glow) 60%, transparent);
  stroke-width: 1.2;
}

/* 3. Hex grid: the right half of the page. The SVG pattern draws the cells
      in currentColor and an SVG blur filter (#nx-login-hex-glow) gives the
      glow. The mask keeps it brightest right of centre and fades it out
      toward the card and the top and bottom edges. */
#nx-login .nx-login-hex {
  top: 0;
  right: 0;
  width: 58%;
  height: 100%;
  color: color-mix(in srgb, var(--nx-scene-glow) 55%, transparent);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 70% 42%, #000 20%, rgba(0, 0, 0, 0.45) 55%, transparent 85%);
  mask-image: radial-gradient(ellipse 75% 70% at 70% 42%, #000 20%, rgba(0, 0, 0, 0.45) 55%, transparent 85%);
}

/* 4. Network: links and nodes across the bottom, fading in from below. */
#nx-login .nx-login-net {
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 40%;
  -webkit-mask-image: linear-gradient(0deg, #000 35%, transparent 100%);
  mask-image: linear-gradient(0deg, #000 35%, transparent 100%);
}
#nx-login .nx-login-net-links {
  fill: none;
  stroke: color-mix(in srgb, var(--nx-scene-glow) 28%, transparent);
  stroke-width: 0.8;
}
/* Nodes glow through #nx-login-net-glow; the larger ones are hubs. */
#nx-login .nx-login-net-nodes { fill: color-mix(in srgb, var(--nx-scene-glow) 85%, #fff); }

/* 5. Vignette: dims the centre column behind the card and the outer edges,
      so the scene never competes with the form. */
#nx-login .nx-login-scene-vignette {
  inset: 0;
  background:
    radial-gradient(ellipse 34% 52% at 50% 48%, color-mix(in srgb, var(--nx-scene-navy) 70%, transparent), transparent 100%),
    radial-gradient(ellipse 120% 100% at 50% 50%, transparent 60%, color-mix(in srgb, var(--nx-scene-navy) 85%, transparent) 100%);
}

/* Narrow screens: the panels would sit under the card, so drop them and
   let the hex grid span the full width at lower strength. */
@media (width < 720px) {
  #nx-login .nx-login-panels { display: none; }
  #nx-login .nx-login-hex { width: 100%; opacity: 0.6; }
}

/* Spinner motion. */
@keyframes nx-login-spin { to { transform: rotate(360deg); } }
/* Narrow layout. Controls grow so they stay easy to tap. */
@media (width < 720px) {
  #nx-login { padding-top: 24px; }
  #nx-login .nx-login-stage { width: 100%; margin: 0; }
  #nx-login .nx-login-card { padding: 24px; border-radius: 16px; box-shadow: inset 0 1px 0 0 #ffffff14, 0 0 0 1px color-mix(in srgb, var(--accent) var(--nx-login-edge), transparent), 0 40px 80px -40px color-mix(in srgb, var(--accent) var(--nx-login-under), transparent); }
  #nx-login .nx-login-card:is(:root[data-theme="light"] *) { box-shadow: var(--shadow-border); }
  #nx-login .nx-input, #nx-login .nx-btn { height: 48px; font-size: 16px; }
  #nx-login .nx-login-reveal { width: 40px; height: 40px; }
  #nx-login .nx-login-password { padding-right: 52px; }
  #nx-login .nx-login-theme { width: 40px; height: 40px; }
}
/* Dot mask when the page is short on width. */
@media (width < 820px) {
  #nx-login .nx-login-dots { -webkit-mask-image: radial-gradient(ellipse 130% 78% at 50% 46%, transparent 48%, #000 100%); mask-image: radial-gradient(ellipse 130% 78% at 50% 46%, transparent 48%, #000 100%); }
}
/* Dot mask when the page is short on height. */
@media (height < 500px) {
  #nx-login .nx-login-dots { -webkit-mask-image: radial-gradient(ellipse 130% 78% at 50% 46%, transparent 48%, #000 100%); mask-image: radial-gradient(ellipse 130% 78% at 50% 46%, transparent 48%, #000 100%); }
}
/* Reduced motion. */
@media (prefers-reduced-motion: reduce) {
  #nx-login .nx-login-card { animation: none; }
  #nx-login .nx-login-spinner .nx-icon { animation: none; }
}
/* Set-password rules and the quiet sign-out link under the card. */
#nx-login .nx-login-rules {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--fg-muted);
  font-size: 13px;
}
#nx-login .nx-login-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 13px;
}
#nx-login .nx-login-error:empty { display: none; }
#nx-login .nx-login-exit { margin-top: 16px; text-align: center; }
#nx-login .nx-login-exit button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg-muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
