@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600&display=swap');

/* Full-screen overlay container */
.kc-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #FCFCFC;
  z-index: 999999;
  font-family: 'Figtree', sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.kc-loading-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Loader layout */
.kc-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Quadrant stage - the arena the shape moves within */
.kc-quad-stage {
  position: relative;
  width: 160px;
  height: 160px;
}

/* The shape that visits all quadrants */
.kc-quad-shape {
  position: absolute;
  width: 72px;
  height: 72px;
  top: 4px;
  left: 4px;
  background: #3248F4;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: kc-quad-move 6s ease-in-out infinite;
}

.kc-quad-shape svg {
  width: 28px;
  height: 36px;
  animation: kc-logo-visibility 6s ease-in-out infinite;
}

/* Message text */
.kc-message {
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  color: #1a1a2e;
  margin-top: 40px;
  transition: opacity 0.5s ease-in-out;
}

/* Broker loading page: hide header only; overlay is inside card but position:fixed so it stays on top */
body.kc-loading-overlay-page #kc-header {
  display: none !important;
}

/* Clockwise quadrant loop - circle at corners, pill during moves */
@keyframes kc-quad-move {
  /* HOLD: Upper-left - center (40,40) */
  0% {
    top: 4px;
    left: 4px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }
  3% {
    top: 4px;
    left: 4px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* UL -> UR: horizontal pill - centered on top row */
  12.5% {
    top: 9px;
    left: 10px;
    width: 140px;
    height: 62px;
    opacity: 0.35;
  }

  22% {
    top: 4px;
    left: 84px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* HOLD: Upper-right - center (120,40) */
  25% {
    top: 4px;
    left: 84px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }
  28% {
    top: 4px;
    left: 84px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* UR -> LR: vertical pill - centered on right column */
  37.5% {
    top: 10px;
    left: 89px;
    width: 62px;
    height: 140px;
    opacity: 0.35;
  }

  47% {
    top: 84px;
    left: 84px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* HOLD: Lower-right - center (120,120) */
  50% {
    top: 84px;
    left: 84px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }
  53% {
    top: 84px;
    left: 84px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* LR -> LL: horizontal pill - centered on bottom row */
  62.5% {
    top: 89px;
    left: 10px;
    width: 140px;
    height: 62px;
    opacity: 0.35;
  }

  72% {
    top: 84px;
    left: 4px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* HOLD: Lower-left - center (40,120) */
  75% {
    top: 84px;
    left: 4px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }
  78% {
    top: 84px;
    left: 4px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* LL -> UL: vertical pill - centered on left column */
  87.5% {
    top: 10px;
    left: 9px;
    width: 62px;
    height: 140px;
    opacity: 0.35;
  }

  97% {
    top: 4px;
    left: 4px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }

  /* RETURN: Upper-left */
  100% {
    top: 4px;
    left: 4px;
    width: 72px;
    height: 72px;
    opacity: 1;
  }
}

/* Logo only visible at upper-left quadrant */
@keyframes kc-logo-visibility {
  0% {
    opacity: 1;
  }
  3% {
    opacity: 1;
  }
  5% {
    opacity: 0;
  }
  95% {
    opacity: 0;
  }
  97% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

/* Reduced-motion fallback */
@media (prefers-reduced-motion: reduce) {
  .kc-loading-overlay {
    transition: none;
  }

  .kc-quad-shape {
    animation: none;
    top: 50%;
    left: 50%;
    width: 72px;
    height: 72px;
    transform: translate(-50%, -50%);
  }
}
