/* =========================================================
   DESIGN TOKENS
   ========================================================= */
:root {
  /* Light theme (default) — white & light-blue base */
  --bg-1: #eaf2fc;
  --bg-2: #d9e9fb;
  --bg-3: #cfe2f9;
  --surface: rgba(255, 255, 255, 0.6);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --surface-border: rgba(255, 255, 255, 0.85);
  --text: #12213e;
  --text-muted: #55658a;
  --accent: #5582f5;
  --accent-2: #528dfb;
  --accent-contrast: #ffffff;
  --danger: #d92d4c;
  --danger-bg: rgba(217, 45, 76, 0.09);
  --success: #1f9d6b;
  --success-bg: rgba(31, 157, 107, 0.1);
  --shadow-soft: 0 20px 60px rgba(28, 61, 122, 0.16);
  --shadow-btn: 0 10px 24px rgba(47, 111, 237, 0.35);
  --ring: rgba(47, 111, 237, 0.35);
  --font-display: "Space Grotesk", "Arial", sans-serif;
  --font-body: "Inter", "Arial", sans-serif;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --bg-1: #0a0f1e;
  --bg-2: #191B1C;
  --bg-3: #273454;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --surface-border: rgba(255, 255, 255, 0.14);
  --text: #eaf1ff;
  --text-muted: #93a3c4;
  --accent: #5b9cff;
  --accent-2: #8ecbff;
  --accent-contrast: #061224;
  --danger: #ff6b85;
  --danger-bg: rgba(255, 107, 133, 0.12);
  --success: #4fd6a3;
  --success-bg: rgba(79, 214, 163, 0.12);
  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-btn: 0 10px 26px rgba(91, 156, 255, 0.35);
  --ring: rgba(91, 156, 255, 0.4);
}

/* =========================================================
   RESET & BASE
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.5s ease, color 0.4s ease;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  margin: 0;
}

p {
  margin: 0;
}

button {
  font-family: inherit;
}

a {
  color: inherit;
}

/* Visible, accessible focus state everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* =========================================================
   PAGE LAYOUT — split screen
   ========================================================= */
.page {
  flex: 1;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
}

/* ---------- LEFT: showcase / illustration ---------- */
.showcase {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: radial-gradient(circle at 30% 20%, var(--bg-3), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1));
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.55;
  animation: drift 16s ease-in-out infinite;
}

.blob-a {
  width: 420px;
  height: 420px;
  background: transparent;
  top: -120px;
  left: -100px;
}

.blob-b {
  width: 360px;
  height: 360px;
  background: transparent;
  bottom: -140px;
  right: -80px;
  animation-delay: -8s;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -24px) scale(1.06); }
}

/* Orbit stage: central lock + rotating icon tracks */
.orbit-stage {
  position: relative;
  width: min(380px, 70vw);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.lock-core {
  position: relative;
  z-index: 3;
  width: 108px;
  height: 108px;
  border-radius: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-contrast);
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 18px 40px rgba(47, 111, 237, 0.4), inset 0 1px 0 rgba(255,255,255,0.4);
  animation: pulse-glow 4s ease-in-out infinite;
}

.lock-core svg {
  width: 46px;
  height: 46px;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 18px 40px rgba(47, 111, 237, 0.35), inset 0 1px 0 rgba(255,255,255,0.4); }
  50% { box-shadow: 0 22px 54px rgba(47, 111, 237, 0.55), inset 0 1px 0 rgba(255,255,255,0.5); }
}

.orbit-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px dashed var(--surface-border);
  opacity: 0.7;
}

.ring-1 { width: 62%; height: 62%; animation: spin 40s linear infinite; }
.ring-2 { width: 92%; height: 92%; animation: spin 70s linear infinite reverse; }

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

/* Each track rotates around the center; each icon counter-rotates to stay upright */
.orbit-track {
  position: absolute;
  inset: 0;
  animation: spin 22s linear infinite;
}

.track-1 { width: 62%; height: 62%; margin: auto; animation-duration: 18s; }
.track-2 { width: 62%; height: 62%; margin: auto; animation-duration: 18s; animation-delay: -4.5s; }
.track-3 { width: 92%; height: 92%; margin: auto; animation-duration: 30s; animation-direction: reverse; }
.track-4 { width: 92%; height: 92%; margin: auto; animation-duration: 30s; animation-direction: reverse; animation-delay: -15s; }

.orbit-icon {
  position: absolute;
  top: -22px;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: var(--accent);
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
  animation: spin-reverse 18s linear infinite;
  animation-delay: var(--delay, 0s);
}

.track-3 .orbit-icon,
.track-4 .orbit-icon {
  animation-duration: 30s;
  animation-direction: normal;
}

@keyframes spin-reverse {
  to { transform: translateX(-50%) rotate(-360deg); }
}

.orbit-icon svg {
  width: 20px;
  height: 20px;
}

.showcase-copy {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 380px;
}

.showcase-copy h1 {
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.showcase-copy p {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

/* ---------- RIGHT: auth / form area ---------- */
.auth {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.auth-topbar {
  position: absolute;
  top: 24px;
  right: 24px;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.3s ease, box-shadow 0.3s ease;
  box-shadow: var(--shadow-soft);
}

.theme-toggle:hover {
  transform: translateY(-2px) rotate(8deg);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  position: absolute;
  transition: opacity 0.3s ease, transform 0.4s ease;
}

.icon-moon { opacity: 0; transform: scale(0.6) rotate(40deg); }
.icon-sun { opacity: 1; transform: scale(1) rotate(0deg); }

[data-theme="dark"] .icon-sun { opacity: 0; transform: scale(0.6) rotate(-40deg); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }

/* Glass card */
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 32px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow-soft);
  transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.badge-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(47, 111, 237, 0.35);
  margin-bottom: 14px;
}

.badge-mark svg {
  width: 24px;
  height: 24px;
}

.auth-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-sub {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Form field */
.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 13px 44px 13px 16px;
  font-size: 0.98rem;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
}

input[type="password"]::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
  outline: none;
}

input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pw-visibility {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.pw-visibility:hover {
  color: var(--accent);
}

.pw-visibility svg {
  width: 18px;
  height: 18px;
  position: absolute;
  transition: opacity 0.2s ease;
}

.icon-eye-off { opacity: 0; }
.pw-visibility[aria-pressed="true"] .icon-eye { opacity: 0; }
.pw-visibility[aria-pressed="true"] .icon-eye-off { opacity: 1; }

.hint {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hint code {
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.76rem;
}

/* Primary button */
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 200;
  color: var(--accent-contrast);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  transition: transform 0.20s ease, box-shadow 0.25s ease, filter 0.4s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(47, 111, 237, 0.42);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

/* Shake animation for wrong password */
.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Messages */
.message {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.message svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.message-error {
  color: var(--danger);
  background: transparent;
  border: transparent;
}

.message-lockout {
  color: var(--text);
  background: transparent;
}

.message-success {
  color: var(--success);
  background: transparent;
  border: transparent;
}

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(10px);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-social {
  display: flex;
  gap: 14px;
}

.footer-social a {
  color: var(--text-muted);
  display: inline-flex;
  transition: color 0.2s ease, transform 0.2s ease;
}

.footer-social a:hover {
  color: var(--accent);
  transform: translateY(-2px);
}

.footer-social svg {
  width: 20px;
  height: 20px;
}

.footer-contact a {
  color: var(--accent);
  text-decoration: none;
}

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

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 980px) {
  .page {
    grid-template-columns: 1fr;
  }

  .showcase {
    padding: 32px 24px 24px;
    min-height: 38vh;
  }

  .orbit-stage {
    width: min(240px, 55vw);
    margin-bottom: 18px;
  }

  .showcase-copy h1 {
    font-size: 1.3rem;
  }

  .showcase-copy p {
    font-size: 0.88rem;
  }

  .auth {
    padding: 32px 20px 40px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 30px 22px 26px;
    border-radius: 22px;
  }

  .orbit-stage {
    display: none; /* keep mobile view calm and fast */
  }

  .showcase {
    min-height: 22vh;
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
