/* ═══════════════════════════════════════════════════════════
   Scientific Memory™ OS — Pre-Auth (Deep Space Theme)
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:         #020408;
  --glass:      rgba(10, 16, 26, 0.82);
  --border:     rgba(0, 242, 254, 0.18);
  --border-hot: rgba(0, 242, 254, 0.65);
  --cyan:       #00F2FE;
  --cyan-dim:   rgba(0, 242, 254, 0.12);
  --text:       #E0E6ED;
  --text-dim:   #4A5568;
  --text-mid:   #718096;
  --error:      rgba(255, 100, 100, 0.85);
  --mono:       'JetBrains Mono', monospace;
  --sans:       'Syne', sans-serif;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: var(--sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── BACKGROUND CANVAS ─────────────────────────────────── */
#bg-canvas {
  position: fixed; inset: 0;
  z-index: 0;
}

@media (prefers-reduced-motion: reduce) {
  #bg-canvas { display: none; }
  body { background: radial-gradient(ellipse at 50% 40%, rgba(0,18,32,0.55) 0%, var(--bg) 70%); }
}

/* ── SYSTEM STATUS BAR ─────────────────────────────────── */
.sys-bar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 32px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  opacity: 0;
  animation: fadeIn 1s ease 2.4s forwards;
}
.sys-bar .status-dot {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  margin-right: 6px;
  animation: pulse-dot 3s ease-in-out infinite;
}
.sys-bar span { color: var(--text-mid); }
.sys-bar .val { color: var(--cyan); }
.sys-bar .sep { margin: 0 16px; opacity: 0.3; }

/* ── FOOTER ────────────────────────────────────────────── */
.sys-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 10;
  text-align: center;
  padding: 16px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  opacity: 0;
  animation: fadeIn 1s ease 2.6s forwards;
}

/* ── SCENE (centered main) ─────────────────────────────── */
.scene {
  position: fixed; inset: 0;
  z-index: 5;
  display: flex; align-items: center; justify-content: center;
}

/* ── LOGIN LAYOUT (two-column) ─────────────────────────── */
.login-layout {
  display: flex;
  align-items: center;
  gap: 60px;
}

/* ── CONSOLE (glass card) ──────────────────────────────── */
.console {
  width: 400px;
  max-width: 90vw;
  flex-shrink: 0;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 40px 32px;
  position: relative;
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  box-shadow:
    0 0 0 1px rgba(0,242,254,0.06),
    0 0 60px rgba(0,242,254,0.04),
    0 40px 120px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.04);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  animation: materialize 1.1s cubic-bezier(0.16,1,0.3,1) 0.6s forwards;
}

/* Scan line on entry */
.console::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 12px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,242,254,0.06) 48%,
    rgba(0,242,254,0.12) 50%,
    rgba(0,242,254,0.06) 52%,
    transparent 100%
  );
  background-size: 100% 200%;
  background-position: 0% 0%;
  animation: scan 0.9s ease-out 0.5s forwards;
  pointer-events: none;
  z-index: 1;
}

/* Corner glow accents */
.console::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0,242,254,0.14) 0%, transparent 40%, transparent 60%, rgba(0,242,254,0.07) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ── LOGO AREA ─────────────────────────────────────────── */
.logo-area {
  text-align: center;
  margin-bottom: 32px;
  position: relative; z-index: 2;
  opacity: 0;
  animation: fadeSlideUp 0.8s ease 1.2s forwards;
}

.logo-svg {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  display: block;
}

.logo-title {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--text);
  line-height: 1;
}
.logo-title sup {
  font-size: 10px;
  vertical-align: super;
  color: var(--cyan);
  font-weight: 300;
}

.logo-sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  margin-top: 5px;
  text-transform: uppercase;
}

/* ── FORM ──────────────────────────────────────────────── */
.console-form {
  position: relative;
  z-index: 2;
}

.form-group {
  position: relative;
  margin-bottom: 16px;
  opacity: 0;
  animation: fadeSlideUp 0.7s ease forwards;
}
.form-group:nth-child(1) { animation-delay: 1.45s; }
.form-group:nth-child(2) { animation-delay: 1.6s; }

.field-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
  transition: color 0.3s ease;
}

.field-wrap {
  position: relative;
}

.field-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 10px 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--text);
  outline: none;
  transition: border-color 0.4s ease;
}
.field-input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.1em;
  font-size: 12px;
}

.field-line {
  position: absolute;
  bottom: 0; left: 0;
  width: 0%; height: 1px;
  background: var(--cyan);
  transition: width 0.5s cubic-bezier(0.16,1,0.3,1);
  box-shadow: 0 0 8px rgba(0,242,254,0.6);
}

.field-input:focus ~ .field-line { width: 100%; }
.field-input:focus { border-color: transparent; }
.form-group:focus-within .field-label { color: var(--cyan); }

/* ── SUBMIT BUTTON ─────────────────────────────────────── */
.btn-wrap {
  position: relative; z-index: 2;
  margin-top: 24px;
  opacity: 0;
  animation: fadeSlideUp 0.7s ease 1.75s forwards;
}

.btn-auth {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(0,242,254,0.28);
  border-radius: 4px;
  padding: 12px 24px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s ease, color 0.3s ease;
}

.btn-auth::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0,242,254,0.06), transparent);
  transform: translateX(-100%);
  transition: transform 0s;
}
.btn-auth:hover::before {
  transform: translateX(100%);
  transition: transform 0.6s ease;
}
.btn-auth:hover {
  border-color: rgba(0,242,254,0.6);
  color: var(--cyan);
  box-shadow: 0 0 20px rgba(0,242,254,0.08), inset 0 0 20px rgba(0,242,254,0.04);
}

.btn-auth.loading {
  pointer-events: none;
  border-color: rgba(0,242,254,0.5);
  color: var(--cyan);
}
.btn-auth.loading .btn-text { opacity: 0.4; }
.btn-auth.loading .btn-loader { display: flex; }

.btn-text { transition: opacity 0.2s; }
.btn-loader {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  gap: 4px;
}
.btn-loader span {
  width: 3px; height: 3px;
  background: var(--cyan);
  border-radius: 50%;
  animation: loader-dot 1.2s ease-in-out infinite;
}
.btn-loader span:nth-child(2) { animation-delay: 0.2s; }
.btn-loader span:nth-child(3) { animation-delay: 0.4s; }

/* ── ERROR MESSAGE ─────────────────────────────────────── */
.error-msg {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--error);
  text-align: center;
  margin-top: 16px;
  min-height: 16px;
  position: relative; z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.error-msg.visible { opacity: 1; }

/* ── SECONDARY LINKS ───────────────────────────────────── */
.links {
  position: relative; z-index: 2;
  text-align: center;
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  opacity: 0;
  animation: fadeIn 0.8s ease 2s forwards;
}
.links a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.3s ease;
}
.links a:hover { color: var(--cyan); }
.links .sep { margin: 0 10px; opacity: 0.4; }

/* ── SYSTEM TERMINAL (right panel) ─────────────────────── */
.sys-terminal {
  width: 360px;
  max-height: 420px;
  overflow: hidden;
  opacity: 0;
  animation: fadeIn 1.2s ease 2.2s forwards;
}

.term-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.term-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.5;
  animation: pulse-dot 3s ease-in-out infinite;
}

.term-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.term-body {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.term-line {
  opacity: 0;
  animation: termLineIn 0.3s ease forwards;
  white-space: nowrap;
}

.term-line .cyan   { color: var(--cyan); }
.term-line .mid    { color: var(--text-mid); }
.term-line .green  { color: #68D391; }
.term-line .dim    { color: var(--text-dim); }

@keyframes termLineIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hide terminal on narrow screens */
@media (max-width: 900px) {
  .login-layout { gap: 0; }
  .sys-terminal { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════════ */

@keyframes materialize {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes scan {
  0%   { background-position: 0% -100%; opacity: 1; }
  100% { background-position: 0% 200%; opacity: 0; }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--cyan); }
  50%      { opacity: 0.4; box-shadow: none; }
}

@keyframes loader-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1.2); opacity: 1; }
}

/* Shake on error */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-6px); }
  30%      { transform: translateX(5px); }
  45%      { transform: translateX(-4px); }
  60%      { transform: translateX(3px); }
  75%      { transform: translateX(-2px); }
}
.console.shake {
  animation: shake 0.5s ease !important;
}

/* Success dissolve */
@keyframes dissolve {
  0%   { opacity: 1; transform: scale(1); filter: blur(0); }
  60%  { opacity: 0.6; transform: scale(1.04); filter: blur(2px); }
  100% { opacity: 0; transform: scale(1.1); filter: blur(12px); }
}
.console.dissolve {
  animation: dissolve 1.2s cubic-bezier(0.4,0,0.2,1) forwards !important;
}
