/* Login — shared by the Astro shell (prod) and leptos/login/index.html (dev).
   Pure CSS (no @import) so Trunk can link it directly.

   Theming: <html data-brand="storyvis|infervisor" data-theme="light|dark">.
   Components only read the tokens below; brands only override tokens. */

/* The console's self-hosted JetBrains Mono (index.html copies infra-ui/fonts). */
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── storyvis (default brand) ───────────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --bg-alt: #f4f7fc;
  --surface: #ffffff;
  --surface-raised: #fbfcff;
  --hairline: #d7dce6;
  --hairline-soft: #e9edf4;
  --text: #0a0e1f;
  --text-muted: #5a6474;
  --accent: #2563eb;
  --accent-on: #ffffff;
  --accent-fill: linear-gradient(120deg, #2563eb, #0891b2);
  --focus-ring: color-mix(in srgb, var(--accent) 28%, transparent);
  --danger: #b8431f;
  --glow: color-mix(in srgb, var(--accent) 12%, transparent);
  --card-shadow: 0 12px 40px -18px rgb(10 14 31 / 18%);
  /* The animated background: a faint grid and a soft halo behind the card. */
  --grid-line: var(--hairline-soft);
  --halo: color-mix(in srgb, var(--accent) 10%, transparent);

  --radius-sm: 10px;
  --radius-md: 16px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --code-spacing: 0.4em;

  --transition: 180ms cubic-bezier(0.42, 0, 0.58, 1);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #070b16;
  --bg-alt: #0a0e1f;
  --surface: #111831;
  --surface-raised: #18203c;
  --hairline: #283353;
  --hairline-soft: #1b2540;
  --text: #f0ecf7;
  --text-muted: #9aa3b8;
  --accent: #3b82f6;
  --accent-fill: linear-gradient(120deg, #3b82f6, #22d3ee);
  --focus-ring: color-mix(in srgb, var(--accent) 38%, transparent);
  --danger: #f5a384;
  --card-shadow: 0 24px 64px -24px rgb(0 0 0 / 60%);
  color-scheme: dark;
}

/* ── infervisor — flat, square, monospace (infervisor.ai global.css) ───── */
[data-brand="infervisor"] {
  --bg: #f8f9fb;
  --bg-alt: #f0f2f5;
  --surface: #ffffff;
  --surface-raised: #f4f6f8;
  --hairline: #d0d4da;
  --hairline-soft: #e0e3e8;
  --text: #1a1d23;
  --text-muted: #5a6170;
  --accent: #2b7bb9;
  --accent-on: #ffffff;
  --accent-fill: var(--accent);
  --glow: transparent;
  --card-shadow: 0 30px 80px -50px rgb(0 0 0 / 25%);

  --radius-sm: 3px;
  --radius-md: 9px;
  --font: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --code-spacing: 0.3em;

  --grid-line: #e0e3e8;
  --halo: rgb(43 123 185 / 9%);
  /* tile mark */
  --cell-bg: #e8f2fa;
  --cell-bd: #c8dced;
  --dot: #5a9fd4;
  --stem: #2b7bb9;
}

[data-brand="infervisor"][data-theme="dark"] {
  --bg: #0a0b0d;
  --bg-alt: #0c0e12;
  --surface: #101318;
  --surface-raised: #151a21;
  --hairline: #272c34;
  --hairline-soft: #1d2128;
  --text: #e7e9ec;
  --text-muted: #8b929c;
  --accent: #5a9fd4;
  --accent-on: #06121d;
  --card-shadow: 0 50px 120px -55px rgb(0 0 0 / 92%);

  --grid-line: #1d2128;
  --halo: rgb(90 159 212 / 11%);
  --cell-bg: #0e1820;
  --cell-bd: #16242f;
  --dot: #1f4e79;
  --stem: #8fcaf4;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-family: var(--font);
  background: radial-gradient(70% 55% at 50% -5%, var(--glow), transparent 70%) fixed, var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* ── Background: a faint grid drifting slowly, and a soft halo that
   breathes behind the card. Both sit behind everything and ignore input. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 44px 44px;
  mask-image: radial-gradient(55% 60% at 50% 50%, #000 15%, transparent 75%);
  -webkit-mask-image: radial-gradient(55% 60% at 50% 50%, #000 15%, transparent 75%);
  opacity: 0.6;
  animation: grid-drift 40s linear infinite;
}
body::after {
  background: radial-gradient(closest-side, var(--halo), transparent);
  width: min(760px, 120vw);
  height: min(760px, 120vw);
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  animation: halo 9s ease-in-out infinite alternate;
}
@keyframes grid-drift {
  to { background-position: 0 44px, 44px 0; }
}
@keyframes halo {
  from { transform: scale(0.92); opacity: 0.7; }
  to { transform: scale(1.08); opacity: 1; }
}

/* ── Logo (the landing page's tile mark and wordmark) ─────────────────── */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.25rem;
  color: var(--text);
  text-decoration: none;
}
.mark {
  display: inline-grid;
  grid-template-columns: repeat(3, 8px);
  gap: 2.4px;
}
.mark i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 1px;
}
.mark i.e { background: var(--cell-bg, var(--bg-alt)); border: 1px solid var(--cell-bd, var(--hairline)); }
.mark i.d { background: var(--dot, var(--accent)); border: 1px solid var(--dot, var(--accent)); }
.mark i.o { background: var(--stem, var(--accent)); border: 1px solid var(--stem, var(--accent)); }
.wordmark {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.4px;
  line-height: 1;
}
.wordmark .b { color: var(--text-muted); }

button,
input {
  font: inherit;
  touch-action: manipulation; /* no 300ms tap delay */
}

.theme-toggle-corner {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.login-container {
  width: 100%;
  max-width: 400px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  padding: 2.5rem 2rem;
}
.login-header {
  text-align: center;
  margin-bottom: 2rem;
}
.brand-lockup {
  display: block;
  height: auto;
  max-width: 100%;
  margin: 0 auto 1rem;
}
.brand-dark,
[data-theme="dark"] .brand-light {
  display: none;
}
[data-theme="dark"] .brand-dark {
  display: block;
}
.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
}

/* ── Skeleton (replaced by Leptos on mount) ─────────────────────────────── */
.skeleton {
  display: grid;
  gap: 0.75rem;
}
.skeleton-bar {
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--hairline-soft) 25%, var(--hairline) 50%, var(--hairline-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skeleton-divider {
  height: 1px;
  background: var(--hairline-soft);
  margin: 0.5rem 0;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ── Form ───────────────────────────────────────────────────────────────── */
.login-methods,
.field,
.otp-inline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.field {
  gap: 0.375rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0.25rem 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline-soft);
}

.error-banner {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
}

.flow-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
}
.flow-desc strong {
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
}

/* ── Buttons (44px min touch target) ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition),
    opacity var(--transition);
}
.btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--hairline));
  background: var(--surface-raised);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  min-height: 48px;
  background: var(--accent-fill);
  color: var(--accent-on);
  border-color: transparent;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-fill);
  border-color: transparent;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn-link {
  min-height: 36px;
  padding: 6px 4px;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.btn-link:hover:not(:disabled) {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}
.link-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.icon {
  flex-shrink: 0;
}

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.input-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem; /* 16px stops iOS zoom-on-focus */
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.input:read-only {
  background: var(--bg-alt);
  color: var(--text-muted);
}
.input-code {
  text-align: center;
  letter-spacing: var(--code-spacing);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.otp-inline {
  padding: 0.875rem;
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  border: 1px solid var(--hairline-soft);
}

@media (max-width: 440px) {
  .login-card {
    padding: 1.75rem 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-bar,
  body::before,
  body::after {
    animation: none;
  }
}
