/*
 * Sign-in screen, ported from the original Atlas app's LoginView
 * (src/components/app-shell.tsx) and its globals.css backdrop layers.
 *
 * Written as plain CSS rather than Tailwind utilities because this app builds
 * tailwind.css but never links it into the layout.
 */

.login-page {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  background: hsl(255 12% 6%);
  color: hsl(220 35% 94%);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Backdrop ── */

.login-backdrop {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.atlas-login-stars,
.atlas-login-horizon,
.atlas-login-scan {
  position: absolute;
  inset: 0;
}

.atlas-login-horizon {
  background:
    linear-gradient(90deg, hsl(232 58% 4% / 0.96), hsl(229 46% 7% / 0.62) 44%, hsl(235 48% 5% / 0.86)),
    linear-gradient(180deg, hsl(230 70% 5% / 0.08), hsl(228 68% 5% / 0.16) 50%, hsl(222 80% 4% / 0.56)),
    url("/images/earth-horizon.jpg");
  background-position: center bottom;
  background-size: cover;
}

.atlas-login-stars {
  background-image:
    radial-gradient(circle, hsl(0 0% 100% / 0.72) 0 1px, transparent 1px),
    radial-gradient(circle, hsl(190 96% 54% / 0.5) 0 1px, transparent 1px),
    radial-gradient(circle, hsl(39 95% 55% / 0.55) 0 1px, transparent 1px);
  background-position: 0 0, 28px 42px, 88px 18px;
  background-size: 96px 96px, 144px 144px, 210px 210px;
  opacity: 0.2;
  animation: atlas-star-drift 42s linear infinite;
  z-index: 1;
}

.atlas-login-scan {
  background:
    radial-gradient(ellipse at center bottom, transparent 0 36%, hsl(231 70% 4% / 0.18) 64%, hsl(231 70% 4% / 0.64) 100%),
    linear-gradient(90deg, hsl(231 70% 4% / 0.32), transparent 35%, hsl(231 70% 4% / 0.54));
  mix-blend-mode: screen;
  opacity: 0.82;
  z-index: 2;
}

.login-credit {
  pointer-events: auto;
  position: absolute;
  bottom: 0.75rem;
  left: 1rem;
  z-index: 10;
  font-size: 10px;
  color: hsl(0 0% 100% / 0.35);
  text-decoration: none;
  transition: color 150ms;
}

.login-credit:hover {
  color: hsl(0 0% 100% / 0.65);
}

@keyframes atlas-star-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-96px, 48px, 0); }
}

/* ── Layout ── */

.login-shell {
  position: relative;
  z-index: 10;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-column {
  width: 100%;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Wordmark ── */

.login-wordmark {
  margin-bottom: 0.5rem;
  text-align: center;
}

.login-wordmark h1 {
  position: relative;
  display: inline-block;
  margin: 0;
  user-select: none;
  font-weight: 900;
  line-height: 1;
  font-size: clamp(3.5rem, 18vw, 5.5rem);
  letter-spacing: 0.22em;
  padding-right: 0.22em;
}

.login-atlas-logo {
  position: relative;
  background: linear-gradient(
    90deg,
    #c0c0c0 0%,
    #e0e0e0 18%,
    #f8f8f8 36%,
    #ffffff 50%,
    #f8f8f8 64%,
    #e0e0e0 82%,
    #c0c0c0 100%
  );
  background-size: 320% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: atlas-shine 12s linear infinite;
}

.login-atlas-glow {
  position: absolute;
  inset: 0;
  color: white;
  filter: blur(10px);
  animation: login-glow-pulse 12s linear infinite;
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}

@keyframes atlas-shine {
  0%, 100% { background-position: -180% center; }
  30% { background-position: 260% center; }
}

@keyframes login-glow-pulse {
  0%, 100% { opacity: 0.15; }
  15% { opacity: 0.5; }
  30% { opacity: 0.15; }
}

@keyframes login-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Notice ── */

.login-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0.75rem;
  border: 1px solid hsl(0 0% 100% / 0.15);
  background: hsl(0 0% 100% / 0.05);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: hsl(0 0% 100% / 0.8);
  box-shadow: 0 1px 3px hsl(0 0% 0% / 0.3);
  backdrop-filter: blur(12px);
  animation: login-fade-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-notice button {
  margin-left: 0.75rem;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 0.375rem;
  padding: 0.25rem;
  line-height: 0;
  color: hsl(0 0% 100% / 0.4);
  transition: color 150ms;
}

.login-notice button:hover {
  color: hsl(0 0% 100% / 0.8);
}

/* ── Card ── */

.login-card {
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid hsl(0 0% 100% / 0.1);
  background: hsl(0 0% 100% / 0.05);
  padding: 1.75rem;
  box-shadow: 0 25px 50px -12px hsl(0 0% 0% / 0.5);
  backdrop-filter: blur(24px);
  animation: login-fade-up 0.7s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-card-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-back {
  display: flex;
  height: 1.75rem;
  width: 1.75rem;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid hsl(0 0% 100% / 0.1);
  background: hsl(0 0% 100% / 0.05);
  color: hsl(0 0% 100% / 0.6);
  cursor: pointer;
  transition: all 300ms;
}

.login-back:hover {
  background: hsl(0 0% 100% / 0.1);
  color: white;
}

/* Collapsed out of the layout while the Microsoft panel is showing. */
.login-page[data-mode="microsoft"] .login-back {
  pointer-events: none;
  margin-left: -2.25rem;
  transform: scale(0.75);
  opacity: 0;
}

.login-eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: hsl(0 0% 100% / 0.4);
}

.login-title {
  margin: 0.125rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

/* ── Sliding panels ── */

.login-panels {
  position: relative;
  transition: height 300ms ease-out;
}

.login-panel {
  position: absolute;
  inset-inline: 0;
  top: 0;
  transition: all 300ms ease-out;
}

.login-page[data-mode="microsoft"] .login-panel--microsoft,
.login-page[data-mode="credentials"] .login-panel--credentials {
  transform: translateX(0);
  opacity: 1;
}

.login-page[data-mode="credentials"] .login-panel--microsoft {
  pointer-events: none;
  transform: translateX(-1.5rem);
  opacity: 0;
}

.login-page[data-mode="microsoft"] .login-panel--credentials {
  pointer-events: none;
  transform: translateX(1.5rem);
  opacity: 0;
}

.login-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Buttons ── */

.login-microsoft {
  display: flex;
  height: 3rem;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border-radius: 0.75rem;
  background: white;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  color: #111827;
  text-decoration: none;
  box-shadow: 0 10px 15px -3px hsl(0 0% 0% / 0.3);
  transition: all 150ms;
}

.login-microsoft:hover {
  background: hsl(0 0% 100% / 0.9);
}

.login-microsoft:active {
  transform: scale(0.98);
}

.login-ms-mark {
  display: grid;
  height: 1rem;
  width: 1rem;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
}

.login-ms-mark span:nth-child(1) { background: #f25022; }
.login-ms-mark span:nth-child(2) { background: #7fba00; }
.login-ms-mark span:nth-child(3) { background: #00a4ef; }
.login-ms-mark span:nth-child(4) { background: #ffb900; }

.login-hint {
  margin: 0;
  text-align: center;
  font-size: 11px;
  color: hsl(0 0% 100% / 0.3);
}

.login-divider {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.25rem;
}

.login-divider span:first-child,
.login-divider span:last-child {
  height: 1px;
  flex: 1;
  background: hsl(0 0% 100% / 0.1);
}

.login-divider em {
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(0 0% 100% / 0.3);
}

.login-secondary {
  display: flex;
  height: 2.5rem;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(0 0% 100% / 0.1);
  background: hsl(0 0% 100% / 0.05);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(0 0% 100% / 0.7);
  cursor: pointer;
  transition: all 150ms;
}

.login-secondary:hover {
  background: hsl(0 0% 100% / 0.1);
  color: white;
}

.login-secondary:active {
  transform: scale(0.98);
}

/* ── Credentials form ── */

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-form label {
  display: block;
}

.login-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(0 0% 100% / 0.5);
}

.login-form input {
  margin-top: 0.375rem;
  height: 2.75rem;
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid hsl(0 0% 100% / 0.1);
  background: hsl(0 0% 100% / 0.05);
  padding: 0 0.875rem;
  font-size: 0.875rem;
  color: white;
  backdrop-filter: blur(4px);
}

.login-form input:focus {
  outline: none;
  border-color: hsl(0 0% 100% / 0.25);
  box-shadow: 0 0 0 1px hsl(0 0% 100% / 0.2);
}

.login-error {
  margin: 0;
  border-radius: 0.5rem;
  border: 1px solid hsl(0 84% 60% / 0.3);
  background: hsl(0 84% 60% / 0.1);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(0 91% 80%);
}

.login-error[hidden] {
  display: none;
}

.login-submit {
  margin-top: 0.25rem;
  display: flex;
  height: 2.75rem;
  width: 100%;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.75rem;
  background: white;
  font-weight: 700;
  letter-spacing: 0.025em;
  color: #111827;
  cursor: pointer;
  box-shadow: 0 1px 3px hsl(0 0% 0% / 0.3);
  transition: all 150ms;
}

.login-submit:hover {
  background: hsl(0 0% 100% / 0.9);
}

.login-submit:active {
  transform: scale(0.98);
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-back-link {
  display: flex;
  height: 2.25rem;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  border-radius: 0.75rem;
  background: none;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(0 0% 100% / 0.4);
  cursor: pointer;
  transition: color 150ms;
}

.login-back-link:hover {
  color: hsl(0 0% 100% / 0.8);
}

.login-footer {
  margin: 0;
  text-align: center;
  font-size: 11px;
  color: hsl(0 0% 100% / 0.2);
}

@media (prefers-reduced-motion: reduce) {
  .atlas-login-stars,
  .login-atlas-logo,
  .login-atlas-glow,
  .login-card,
  .login-notice {
    animation: none;
  }

  .login-panel,
  .login-panels {
    transition: none;
  }
}
