/**
 * Helport AI — Premium boot / splash loader
 * Dark neon glass, matches scanner console language.
 */

:root {
  --boot-bg0: #05070a;
  --boot-bg1: #0b0f14;
  --boot-green: #00e676;
  --boot-green-2: #00c853;
  --boot-cyan: #00ffd5;
  --boot-text: #f4f7fa;
  --boot-muted: #8b9aab;
  --boot-glass: rgba(12, 18, 24, 0.72);
  --boot-border: rgba(0, 230, 118, 0.22);
  --boot-glow: rgba(0, 230, 118, 0.35);
  --boot-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --boot-font: "Plus Jakarta Sans", system-ui, sans-serif;
  --boot-mono: "JetBrains Mono", ui-monospace, monospace;
}

html.is-booting,
html.is-booting body {
  overflow: hidden !important;
  background: var(--boot-bg0) !important;
}

html.is-booting .app-shell,
html.is-booting #authModal,
html.is-booting #notifPanel,
html.is-booting #notifBackdrop,
html.is-booting .auth-modal {
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* —— Overlay —— */
.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  font-family: var(--boot-font);
  color: var(--boot-text);
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(0, 230, 118, 0.14), transparent 55%),
    radial-gradient(700px 420px at 92% 8%, rgba(0, 255, 213, 0.09), transparent 50%),
    radial-gradient(600px 400px at 50% 110%, rgba(0, 200, 83, 0.08), transparent 55%),
    linear-gradient(165deg, var(--boot-bg0) 0%, var(--boot-bg1) 55%, #070b10 100%);
  isolation: isolate;
  transition:
    opacity 0.55s var(--boot-ease),
    filter 0.55s var(--boot-ease),
    transform 0.55s var(--boot-ease),
    visibility 0.55s;
}

.boot-loader.is-exiting {
  opacity: 0;
  filter: blur(14px);
  transform: scale(1.04);
  pointer-events: none;
  visibility: hidden;
}

.boot-loader[hidden] {
  display: none !important;
}

/* Background layers */
.boot-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.boot-grid {
  position: absolute;
  inset: -20%;
  background-image:
    linear-gradient(rgba(0, 230, 118, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 230, 118, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(600px) rotateX(58deg) translateY(-12%);
  transform-origin: center top;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 75%);
  animation: bootGridDrift 28s linear infinite;
  opacity: 0.7;
}

.boot-hex {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath fill='none' stroke='%2300e676' stroke-opacity='0.06' d='M28 66L0 50V20L28 4l28 16v30L28 66zM28 100L0 84V54l28 16 28-16v30L28 100z'/%3E%3C/svg%3E");
  opacity: 0.5;
  animation: bootHexPulse 8s ease-in-out infinite;
}

.boot-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(0, 0, 0, 0.12) 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.35;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.boot-wave {
  position: absolute;
  left: -10%;
  right: -10%;
  height: 180px;
  bottom: 8%;
  background: radial-gradient(ellipse at center, rgba(0, 230, 118, 0.12), transparent 70%);
  filter: blur(20px);
  animation: bootWave 6s ease-in-out infinite;
}

.boot-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
  animation: bootOrbFloat 10s ease-in-out infinite;
}

.boot-orb--a {
  width: min(42vw, 320px);
  height: min(42vw, 320px);
  background: rgba(0, 230, 118, 0.22);
  top: 8%;
  left: 6%;
}

.boot-orb--b {
  width: min(36vw, 260px);
  height: min(36vw, 260px);
  background: rgba(0, 255, 213, 0.14);
  bottom: 12%;
  right: 8%;
  animation-delay: -4s;
}

.boot-particles {
  position: absolute;
  inset: 0;
}

.boot-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--boot-green);
  box-shadow: 0 0 10px var(--boot-glow);
  opacity: 0.55;
  animation: bootParticleRise linear infinite;
}

.boot-streak {
  position: absolute;
  height: 1px;
  width: 120px;
  background: linear-gradient(90deg, transparent, rgba(0, 230, 118, 0.7), transparent);
  opacity: 0.4;
  animation: bootStreak 7s linear infinite;
}

.boot-streak:nth-child(1) { top: 22%; left: -10%; animation-duration: 6.5s; }
.boot-streak:nth-child(2) { top: 58%; left: -20%; animation-duration: 8s; animation-delay: -2s; }
.boot-streak:nth-child(3) { top: 78%; left: -5%; animation-duration: 7.2s; animation-delay: -4s; }

/* —— Stage —— */
.boot-stage {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(18px, 3vw, 28px);
  animation: bootStageIn 0.7s var(--boot-ease) both;
}

.boot-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.boot-logo-wrap {
  position: relative;
  width: clamp(132px, 28vw, 168px);
  height: clamp(132px, 28vw, 168px);
  display: grid;
  place-items: center;
}

.boot-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 230, 118, 0.18);
  box-shadow:
    0 0 24px rgba(0, 230, 118, 0.12),
    inset 0 0 24px rgba(0, 230, 118, 0.06);
}

.boot-ring--spin {
  border-color: transparent;
  border-top-color: var(--boot-green);
  border-right-color: rgba(0, 255, 213, 0.55);
  animation: bootSpin 1.6s linear infinite;
  filter: drop-shadow(0 0 8px var(--boot-glow));
}

.boot-ring--dash {
  inset: 8px;
  border-style: dashed;
  border-color: rgba(0, 255, 213, 0.28);
  animation: bootSpin 12s linear infinite reverse;
}

.boot-radar {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(0, 230, 118, 0.28) 50deg,
    transparent 90deg
  );
  animation: bootSpin 2.8s linear infinite;
  opacity: 0.85;
  mask-image: radial-gradient(circle, transparent 52%, #000 54%, #000 72%, transparent 74%);
}

.boot-logo-core {
  position: relative;
  width: clamp(72px, 16vw, 92px);
  height: clamp(72px, 16vw, 92px);
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: rgba(8, 14, 18, 0.85);
  border: 1px solid var(--boot-border);
  box-shadow:
    0 0 0 1px rgba(0, 230, 118, 0.08),
    0 0 40px rgba(0, 230, 118, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  animation: bootLogoPulse 2.4s ease-in-out infinite;
}

.boot-logo-core img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(0, 230, 118, 0.35));
  animation: bootLogoIn 0.9s var(--boot-ease) both;
}

.boot-logo-sweep {
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    115deg,
    transparent 40%,
    rgba(255, 255, 255, 0.18) 50%,
    transparent 60%
  );
  animation: bootSweep 3.2s ease-in-out infinite;
  pointer-events: none;
}

.boot-product {
  font-size: clamp(0.72rem, 2vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--boot-green);
  text-shadow: 0 0 18px rgba(0, 230, 118, 0.45);
}

.boot-tagline {
  margin-top: -4px;
  font-size: clamp(0.8rem, 2.2vw, 0.9rem);
  color: var(--boot-muted);
  font-weight: 500;
}

/* Message + progress */
.boot-copy {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.boot-message {
  min-height: 1.4em;
  font-size: clamp(0.92rem, 2.4vw, 1.05rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--boot-text);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.boot-message.is-swap {
  opacity: 0;
  transform: translateY(6px);
}

.boot-progress-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.boot-pct-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--boot-mono);
  font-size: 0.85rem;
  color: var(--boot-muted);
}

.boot-pct-row strong {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--boot-green);
  text-shadow: 0 0 14px rgba(0, 230, 118, 0.4);
  font-variant-numeric: tabular-nums;
}

.boot-ring-pct {
  position: relative;
  width: 64px;
  height: 64px;
}

.boot-ring-pct svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.boot-ring-pct circle {
  fill: none;
  stroke-width: 3.5;
}

.boot-ring-track {
  stroke: rgba(0, 230, 118, 0.12);
}

.boot-ring-fill {
  stroke: var(--boot-green);
  stroke-linecap: round;
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  filter: drop-shadow(0 0 6px var(--boot-glow));
  transition: stroke-dashoffset 0.35s var(--boot-ease);
}

.boot-bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 230, 118, 0.1);
  border: 1px solid rgba(0, 230, 118, 0.15);
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

.boot-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--boot-green-2), var(--boot-green), var(--boot-cyan));
  box-shadow: 0 0 16px rgba(0, 230, 118, 0.55);
  transition: width 0.4s var(--boot-ease);
  position: relative;
}

.boot-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: bootBarShine 1.6s ease-in-out infinite;
}

.boot-progress-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
}

.boot-progress-row .boot-bar {
  flex: 1;
}

.boot-footer {
  font-size: 0.72rem;
  color: rgba(139, 154, 171, 0.55);
  letter-spacing: 0.04em;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .boot-grid,
  .boot-hex,
  .boot-wave,
  .boot-orb,
  .boot-particle,
  .boot-streak,
  .boot-ring--spin,
  .boot-ring--dash,
  .boot-radar,
  .boot-logo-core,
  .boot-logo-sweep,
  .boot-bar-fill::after {
    animation: none !important;
  }

  .boot-loader,
  .boot-loader.is-exiting {
    transition-duration: 0.2s;
  }
}

/* Responsive */
@media (max-width: 480px) {
  .boot-ring-pct {
    width: 52px;
    height: 52px;
  }
}

@media (max-height: 640px) {
  .boot-stage {
    gap: 14px;
  }

  .boot-logo-wrap {
    width: 120px;
    height: 120px;
  }
}

/* Keyframes */
@keyframes bootStageIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes bootLogoIn {
  from { opacity: 0; transform: scale(0.82); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes bootLogoPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(0, 230, 118, 0.08), 0 0 36px rgba(0, 230, 118, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
  50% { box-shadow: 0 0 0 1px rgba(0, 230, 118, 0.18), 0 0 52px rgba(0, 230, 118, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
}

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

@keyframes bootSweep {
  0% { transform: translateX(-60%) rotate(15deg); }
  100% { transform: translateX(60%) rotate(15deg); }
}

@keyframes bootGridDrift {
  from { background-position: 0 0; }
  to { background-position: 0 48px; }
}

@keyframes bootHexPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.65; }
}

@keyframes bootWave {
  0%, 100% { transform: translateY(0) scaleX(1); opacity: 0.5; }
  50% { transform: translateY(-18px) scaleX(1.08); opacity: 0.85; }
}

@keyframes bootOrbFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(18px, -22px); }
}

@keyframes bootParticleRise {
  0% { transform: translateY(20px); opacity: 0; }
  15% { opacity: 0.6; }
  100% { transform: translateY(-100vh); opacity: 0; }
}

@keyframes bootStreak {
  from { transform: translateX(0); }
  to { transform: translateX(120vw); }
}

@keyframes bootBarShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
