/* Sign-in: Paper MeshGradient hero + lockup sequence + white form.
   Tokens from DESIGN.md. */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0891b2;
  --sidebar-bg: #0f4c5c;
  --sidebar-hover: #1a6275;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --input-tint-bg: #fafbff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --brand-dot: #fd6b3d;
  --radius-sm: 8px;
  --radius: 12px;
  --font: var(--font-sans-stack);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

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

html,
body {
  margin: 0;
  min-height: 100dvh;
}

body {
  font-family: var(--font);
  color: #fff;
  background: var(--sidebar-bg);
  -webkit-font-smoothing: antialiased;
}

.shader-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--sidebar-bg);
}

.shader-stage.is-live {
  background: transparent;
}

.shader-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    70% 60% at 50% 42%,
    color-mix(in srgb, var(--sidebar-bg) 18%, transparent) 0%,
    color-mix(in srgb, var(--sidebar-bg) 55%, transparent) 100%
  );
}

.stage {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 28px;
  padding: 48px 24px 32px;
}

.lockup {
  position: relative;
  width: min(640px, 100%);
}

.lockup-hero {
  position: relative;
  isolation: isolate;
}

.slogan {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.15em;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #fff;
  text-wrap: balance;
}

.care {
  color: var(--brand-dot);
}

.typewriter {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 0;
  animation: typing 2.4s steps(22, end) 0.4s forwards;
}

.caret {
  display: inline-block;
  flex-shrink: 0;
  width: 3px;
  height: 0.82em;
  margin-left: 4px;
  background: #fff;
  animation: caret-blink 0.7s step-end infinite, caret-hide 0.01s 3.4s forwards;
}

@keyframes typing {
  from {
    max-width: 0;
  }
  to {
    max-width: 24em;
  }
}

@keyframes caret-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes caret-hide {
  to {
    opacity: 0;
  }
}

.logo-stage {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  padding: 4px 0 8px;
  opacity: 0;
  animation: fade-in 0.7s var(--ease-out) 2.8s forwards;
}

.neon-tail {
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

.lockup-hero.has-neon .comet {
  display: none;
}

.comet {
  position: absolute;
  left: 0;
  top: 0;
  width: 148px;
  height: 6px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  offset-path: ellipse(46% 48% at 50% 48%);
  offset-rotate: auto;
  animation: comet-orbit 4.5s linear 2.8s infinite;
}

.comet-orange {
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--brand-dot) 28%, transparent) 24%,
    var(--brand-dot) 78%,
    #fff 100%
  );
  box-shadow: 0 0 16px 3px color-mix(in srgb, var(--brand-dot) 72%, transparent);
}

.comet-cyan {
  width: 118px;
  height: 4px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--accent) 28%, transparent) 24%,
    var(--accent) 78%,
    #fff 100%
  );
  box-shadow: 0 0 16px 3px color-mix(in srgb, var(--accent) 70%, transparent);
  animation-duration: 5.6s;
  animation-direction: reverse;
}

@keyframes comet-orbit {
  to {
    offset-distance: 100%;
  }
}

.brand {
  position: relative;
  z-index: 1;
  display: block;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin-inline: auto;
}

.tagline {
  margin: 16px auto 0;
  max-width: 22em;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.3px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  text-wrap: pretty;
  opacity: 0;
  animation: fade-in 0.55s var(--ease-out) 3.5s forwards;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.auth-panel {
  width: min(400px, 100%);
  padding: 24px;
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px color-mix(in srgb, var(--sidebar-bg) 28%, transparent);
}

.auth-panel h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.lede {
  margin: 0 0 20px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.field {
  margin-bottom: 14px;
}

.field label,
.check label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-tint-bg);
  font: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.field input.is-invalid,
.field select.is-invalid {
  border-color: var(--danger);
}

.field-help {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.field-error {
  margin-top: 6px;
  font-size: 13px;
  color: var(--danger);
}

.field-ok {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--accent);
}

.field input.code-input {
  height: 48px;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-align: center;
}

.field input[readonly] {
  background: var(--border-light);
  color: var(--text-secondary);
}

.auth-workspace {
  margin-bottom: 20px;
  padding: 12px 14px;
  background: var(--primary-subtle);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius);
}

.auth-workspace-hint {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-workspace-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--text-primary);
}

.auth-workspace-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-footer {
  margin: 24px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 18px;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.check label {
  margin: 0;
  font-weight: 500;
}

.btn {
  display: block;
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.resend,
.auth-switch {
  margin: 16px 0 0;
  text-align: center;
}

.btn-text {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.auth-switch a {
  color: var(--text-secondary);
  font-size: 13px;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 8px 0 0;
  font-size: 13px;
}

.foot a,
.replay {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.foot a:hover,
.replay:hover {
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .typewriter,
  html:not(.force-motion) .caret,
  html:not(.force-motion) .logo-stage,
  html:not(.force-motion) .comet,
  html:not(.force-motion) .tagline,
  html:not(.force-motion) .btn {
    animation: none;
    transition: none;
  }

  html:not(.force-motion) .typewriter {
    max-width: 24em;
  }

  html:not(.force-motion) .logo-stage,
  html:not(.force-motion) .tagline {
    opacity: 1;
  }

  html:not(.force-motion) .comet,
  html:not(.force-motion) .neon-tail {
    display: none;
  }

  html:not(.force-motion) .caret {
    opacity: 0;
  }
}

body.is-settled .typewriter,
body.is-settled .caret,
body.is-settled .logo-stage,
body.is-settled .tagline {
  animation: none;
}

body.is-settled .typewriter {
  max-width: 24em;
}

body.is-settled .logo-stage,
body.is-settled .tagline {
  opacity: 1;
}

body.is-settled .caret {
  opacity: 0;
}
