/* =====================
   Preloader
   ===================== */

#preloader {
  position: fixed;
  inset: 0;
  background: #060d08;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#preloader.pl-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Hide main content while loading (desktop only) */
@media (min-width: 769px) {
  body.is-loading > header,
  body.is-loading > main {
    opacity: 0;
  }
}
body > header,
body > main {
  transition: opacity 0.5s ease 0.2s;
}

/* ---- Background code text ---- */
.pl-code {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: rgba(57, 211, 83, 0.18);
  line-height: 1.7;
  pointer-events: none;
  white-space: pre;
}
.pl-code--left  { left: 3vw; }
.pl-code--right { right: 3vw; text-align: right; }

/* ---- Scattered dots ---- */
.pl-dots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pl-dots span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(57, 211, 83, 0.35);
  animation: dot-pulse 3s ease-in-out infinite;
}
.pl-dots span:nth-child(1)  { top: 20%; left: 12%;  animation-delay: 0s; }
.pl-dots span:nth-child(2)  { top: 35%; left: 5%;   animation-delay: 0.4s; }
.pl-dots span:nth-child(3)  { top: 60%; left: 18%;  animation-delay: 0.8s; }
.pl-dots span:nth-child(4)  { top: 75%; left: 8%;   animation-delay: 1.2s; }
.pl-dots span:nth-child(5)  { top: 15%; right: 15%; animation-delay: 0.2s; }
.pl-dots span:nth-child(6)  { top: 45%; right: 6%;  animation-delay: 0.6s; }
.pl-dots span:nth-child(7)  { top: 68%; right: 20%; animation-delay: 1.0s; }
.pl-dots span:nth-child(8)  { top: 82%; right: 10%; animation-delay: 1.4s; }
@keyframes dot-pulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50%       { opacity: 0.9;  transform: scale(1.6); }
}

/* ---- Corner decorations ---- */
.pl-corner { position: absolute; pointer-events: none; }
.pl-corner--tr { top: 16px; right: 16px; }
.pl-corner--br { bottom: 0;  right: 0; }
.pl-corner--bl { bottom: 16px; left: 16px; }

/* ---- Main body ---- */
.pl-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  padding: 0 20px;
}

/* Logo */
.pl-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 36px;
  font-family: 'Inter', sans-serif;
}
.pl-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(57, 211, 83, 0.15);
  border: 1.5px solid rgba(57, 211, 83, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #39d353;
}

/* ---- Circular ring ---- */
.pl-ring-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin-bottom: 32px;
}

.pl-ring {
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 12px rgba(57, 211, 83, 0.5));
}

.pl-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 8;
}

.pl-ring-fill {
  fill: none;
  stroke: #39d353;
  stroke-width: 8;
  stroke-linecap: round;
  /* circumference of r=88: 2π×88 ≈ 552.9 */
  stroke-dasharray: 552.9;
  stroke-dashoffset: 552.9;
  transition: stroke-dashoffset 0.1s linear;
}

.pl-ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pl-percent {
  font-size: 2.6rem;
  font-weight: 900;
  color: #39d353;
  line-height: 1;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.03em;
  text-shadow: 0 0 20px rgba(57, 211, 83, 0.6);
}
.pl-percent span {
  font-size: 1.4rem;
  font-weight: 700;
}

.pl-loading-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 4px;
}

/* ---- Text ---- */
.pl-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
  text-align: center;
}
.pl-accent { color: #39d353; }

.pl-subtitle {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 28px;
  text-align: center;
  font-family: 'Inter', sans-serif;
  min-height: 1.3em;
  transition: opacity 0.3s;
}

/* ---- Linear bar ---- */
.pl-bar-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 28px;
}

.pl-bar-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  overflow: hidden;
}

.pl-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #39d353, #72ffb4);
  border-radius: 100px;
  box-shadow: 0 0 12px rgba(57, 211, 83, 0.6);
  transition: width 0.1s linear;
}

.pl-bar-pct {
  font-size: 0.82rem;
  font-weight: 700;
  color: #39d353;
  min-width: 36px;
  text-align: right;
  font-family: 'Inter', sans-serif;
}

/* ---- Steps ---- */
.pl-steps {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  justify-content: center;
}

.pl-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.35);
  font-family: 'Inter', sans-serif;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  padding: 8px 16px;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}

.pl-step.active {
  color: #fff;
  border-color: rgba(57, 211, 83, 0.3);
  background: rgba(57, 211, 83, 0.08);
}

.pl-step-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(57, 211, 83, 0.3);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.pl-step.active .pl-step-dot {
  background: #39d353;
  box-shadow: 0 0 8px rgba(57, 211, 83, 0.7);
  animation: dot-pulse 1s ease-in-out infinite;
}

.pl-step-icon {
  color: rgba(57, 211, 83, 0.5);
  font-size: 0.75rem;
}
.pl-step.active .pl-step-icon { color: #39d353; }

@media (max-width: 768px) {
  #preloader { display: none !important; }
}

@media (max-width: 480px) {
  .pl-code { display: none; }
  .pl-corner { display: none; }

  .pl-body {
    gap: 0;
    padding: 0 16px;
    justify-content: center;
  }

  .pl-logo {
    font-size: 1.25rem;
    margin-bottom: 20px;
  }
  .pl-logo-icon {
    width: 38px;
    height: 38px;
  }

  .pl-ring-wrap {
    width: 130px;
    height: 130px;
    margin-bottom: 18px;
  }

  .pl-percent { font-size: 1.7rem; }
  .pl-percent span { font-size: 1rem; }
  .pl-loading-label { font-size: 0.6rem; }

  .pl-title { font-size: 1.05rem; margin-bottom: 6px; }
  .pl-subtitle { font-size: 0.78rem; margin-bottom: 18px; }

  .pl-bar-wrap { margin-bottom: 18px; }

  .pl-steps { gap: 8px; flex-wrap: nowrap; }
  .pl-step {
    font-size: 0.7rem;
    padding: 5px 10px;
    gap: 5px;
  }
  .pl-step-icon { display: none; }
}
