/* ============================================
   Polar Forest Loading — CSS
   ============================================ */

/* ============================================
   LOADING SCREEN
   ============================================ */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  z-index: 99999;
  background: #030405;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  overflow-y: auto;
}
#loading-screen.fade-out {
  transition: opacity 0.5s ease;
}
#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Inner card */
.loading-inner {
  background: #09090b;
  border: 1px solid #27272a;
  padding: 48px 52px;
  max-width: 420px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 0 80px rgba(0,153,255,.04), 0 0 40px rgba(0,0,0,.5);
  position: relative;
  z-index: 10;
}

.loading-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #ffffff;
  text-align: center;
  position: relative;
}
/* Glitch: RGB split on title */
.loading-title.glitch::before,
.loading-title.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.loading-title.glitch::before {
  color: #0099ff;
  clip-path: inset(0 0 50% 0);
  transform: translate(-3px, 0);
  animation: glitch-skew 0.08s ease;
}
.loading-title.glitch::after {
  color: #e8821a;
  clip-path: inset(50% 0 0 0);
  transform: translate(3px, 0);
  animation: glitch-skew 0.08s ease reverse;
}
@keyframes glitch-skew {
  0%, 100% { transform: translate(0, 0); }
  20%      { transform: translate(-5px, 1px); }
  80%      { transform: translate(5px, -1px); }
}

.loading-title-en {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: rgba(168,180,208,.5);
  text-transform: uppercase;
  margin-top: -4px;
}

/* Operator badge */
.operator-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,153,255,.1);
  border: 1px solid rgba(0,153,255,.25);
  padding: 5px 16px;
  margin-top: -4px;
}
.operator-label {
  font-size: 12px;
  color: rgba(168,180,208,.6);
  letter-spacing: 0.1em;
}
.operator-id {
  font-size: 16px;
  font-weight: 600;
  color: rgba(0,153,255,.85);
  letter-spacing: 0.15em;
  font-variant-numeric: tabular-nums;
  transition: transform 0.08s ease;
}
.operator-id.glitch {
  animation: op-id-jitter 0.1s ease;
  text-shadow: -2px 0 rgba(0,153,255,.6), 2px 0 rgba(232,130,26,.6);
}
@keyframes op-id-jitter {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-2px); }
  75%      { transform: translateX(2px); }
}

.operator-welcome {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,.5);
  margin-top: -6px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.operator-welcome.show { opacity: 1; }

/* Progress */
.progress-wrap {
  width: 100%;
}
.progress-bar {
  width: 100%;
  height: 2px;
  background: #1a1a1e;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(160deg, #159bed, #2364c9);
  transition: width 0.3s ease-out;
}

.loading-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.loading-percent {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.loading-status {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(168,180,208,.5);
}

.loading-hint {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(255,255,255,.3);
  text-align: center;
  line-height: 1.6;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.loading-hint.visible { opacity: 1; }
.loading-hint span {
  color: rgba(0,153,255,.7);
}

/* Skip button */
.skip-button {
  font-size: 12px;
  color: rgba(0,153,255,.5);
  background: none;
  border: 1px solid rgba(0,153,255,.2);
  padding: 5px 22px;
  cursor: pointer;
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 0.3s;
  font-family: inherit;
  pointer-events: none;
}
.skip-button.visible {
  opacity: 1;
  pointer-events: auto;
}
.skip-button:hover { color: #0099ff; border-color: rgba(0,153,255,.5); }

/* ============================================
   LOGIN MODAL — aurora transparent
   ============================================ */
#login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  z-index: 80000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #030405;
  padding: 16px;
  overflow-y: auto;
}
#login-overlay.fade-out {
  transition: opacity 0.4s ease;
}
#login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-card {
  background: #09090b;
  border: 1px solid #1a1a24;
  width: 100%;
  max-width: 400px;
  padding: 36px 32px 28px;
  position: relative;
  box-shadow: 0 0 100px rgba(0,153,255,0.04), 0 0 40px rgba(0,0,0,0.4);
  animation: login-in 0.4s ease-out;
}
@keyframes login-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card.glitch-enter {
  animation: login-in-glitch 0.4s ease-out;
}
@keyframes login-in-glitch {
  0%   { opacity: 0; transform: translateY(24px) translateX(6px) scale(0.96); }
  10%  { opacity: 1; transform: translateY(0)    translateX(-3px) scale(1); }
  30%  { transform: translateY(0) translateX(2px) scale(1); }
  100% { transform: translateY(0) translateX(0) scale(1); }
}

.login-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: rgba(168,180,208,.35);
  cursor: pointer;
  padding: 6px;
  transition: color 0.2s;
  font-size: 18px;
  line-height: 1;
  font-family: inherit;
}
.login-close:hover { color: #fff; }

.login-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  text-align: center;
}
.login-subtitle {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(168,180,208,.45);
  text-align: center;
  margin-top: 4px;
}

.login-badge {
  margin: 16px auto 0;
  display: flex;
}

.login-desc {
  font-size: 11px;
  color: rgba(255,255,255,.3);
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.06em;
}

.login-fields {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(168,180,208,.5);
  font-weight: 600;
}
.form-group input {
  background: #1f1f1f;
  border: 1px solid #27272a;
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  border-radius: 3px;
}
.form-group input:focus {
  border-color: #0099ff;
}
.form-group input::placeholder {
  color: rgba(255,255,255,.12);
}

#login-email.typing::after,
#login-password.typing::after {
  content: '|';
  animation: cursor-blink 0.6s step-end infinite;
  color: rgba(0,153,255,.8);
  margin-left: 1px;
}
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

.login-submit {
  margin-top: 0;
  width: 100%;
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: #0099ff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-submit:hover {
  background: #0088e6;
  box-shadow: 0 0 24px rgba(0,153,255,.25);
}
.login-submit:active { transform: scale(0.98); }
.login-submit:disabled {
  background: #27272a;
  color: rgba(255,255,255,.3);
  cursor: not-allowed;
  box-shadow: none;
}

.login-footer-text {
  font-size: 11px;
  color: rgba(168,180,208,.25);
  text-align: center;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

@keyframes spin { to { transform: rotate(360deg); } }
.login-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.login-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0 12px;
  animation: login-in 0.3s ease-out;
}
.login-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2db84a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-success-icon svg { width: 28px; height: 28px; color: #fff; }
.login-success-icon.blur-in { filter: blur(6px); transition: filter 0.3s ease-out; }
.login-success-icon.blur-in.clear { filter: blur(0); }
.login-success h3 { font-size: 18px; font-weight: 700; color: #fff; }
.login-success p { font-size: 13px; color: rgba(168,180,208,.5); }

/* ============================================
   GLITCH EFFECTS
   ============================================ */

/* Scan bar */
.glitch-scan-bar {
  position: fixed;
  z-index: 100002;
  pointer-events: none;
  left: -10%;
  height: 2px;
  background: linear-gradient(to right, transparent, rgba(0,153,255,.5), rgba(255,255,255,.3), transparent);
  opacity: 0;
  animation: scan-bar-fly 0.2s ease-out forwards;
}
@keyframes scan-bar-fly {
  0%   { opacity: 0; transform: translateX(-10%); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(110%); }
}

/* Screen flash */
.glitch-flash {
  position: fixed;
  inset: 0;
  z-index: 99998;
  pointer-events: none;
  background: rgba(0,153,255,.06);
  opacity: 0;
  animation: glitch-flash-fade 0.05s ease-out;
}
@keyframes glitch-flash-fade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Progress tear */
.progress-fill.tear {
  box-shadow: 0 0 12px rgba(232,130,26,.6), 0 0 4px rgba(255,255,255,.4);
  filter: brightness(1.4);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
  .loading-inner { padding: 28px 20px; width: 92vw; gap: 10px; }
  .loading-percent { font-size: 30px; }
  .loading-title { font-size: 21px; }
  .login-card { padding: 24px 18px 20px; max-width: 92vw; }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .glitch-scan-bar, .glitch-flash,
  .loading-title.glitch::before, .loading-title.glitch::after,
  .operator-id.glitch, .progress-fill.tear,
  .login-card.glitch-enter, .login-success-icon.blur-in { animation: none !important; transition: none !important; }
}
