body {
  margin: 0;
}

html {
  overflow-x: hidden;
  overflow-y: scroll;
}

/* Startup loader: always white, one thin ring, one slim progress bar. */
#loading-bg {
  --ld-teal: #0e8aa0;
  --ld-cyan: #2dd4e6;
  --ld-text: #10252c;
  --ld-muted: #7a8a90;
  --ld-line: #e6eef0;

  position: absolute;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  block-size: 100%;
  gap: 0;
  inline-size: 100%;
  animation: ld-in 0.5s ease both;
}

/* Faint dot grid that fades out toward the edges */
#loading-bg::before {
  position: absolute;
  background-image: radial-gradient(circle, #c9d8dc 1px, transparent 1.5px);
  background-size: 28px 28px;
  content: "";
  inset: 0;
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 60%);
  mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 60%);
  opacity: 0.7;
  pointer-events: none;
}

/* Footer line */
#loading-bg::after {
  position: absolute;
  color: var(--ld-muted);
  content: "Secure sign-in  ·  Multi-tenant business platform";
  font-family: Inter, "Public Sans", system-ui, sans-serif;
  font-size: 11px;
  inset-block-end: 28px;
  letter-spacing: 0.06em;
  opacity: 0.8;
  animation: ld-rise 0.8s ease 0.9s both;
}

/* Logo with a thin spinning arc around it */
.loading-logo {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  block-size: 150px;
  inline-size: 150px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--ld-line);
  animation: ld-pop 0.7s cubic-bezier(0.34, 1.4, 0.64, 1) 0.1s both;
}

/* a second, fainter arc travelling the other way gives the ring depth */
.loading-logo::before {
  position: absolute;
  background: conic-gradient(from 180deg, transparent 0%, transparent 78%, rgba(14, 138, 160, 0.35) 100%);
  border-radius: 50%;
  content: "";
  inset: 7px;
  animation: ld-spin 2.6s linear infinite reverse;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1.5px));
}

.loading-logo img {
  --ld-glow: 0 10px 30px rgba(16, 37, 44, 0.12);
}

.loading-logo::after {
  position: absolute;
  background: conic-gradient(from 0deg, transparent 0%, transparent 68%, var(--ld-teal) 92%, var(--ld-cyan) 100%);
  border-radius: 50%;
  content: "";
  inset: 0;
  animation: ld-spin 1.4s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
}

.loading-logo img {
  position: relative;
  z-index: 1;
  padding: 14px;
  border: 0 !important;
  background: #fff;
  border-radius: 50% !important;
  block-size: 110px !important;
  box-shadow: var(--ld-glow);
  inline-size: 110px !important;
  animation: ld-breathe 2.8s ease-in-out infinite;
  object-fit: contain;
}

/* Wordmark + tagline (injected via pseudo-elements on the progress wrapper) */
.loading {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-block-start: 28px;
  gap: 14px;
}

.loading::before {
  background: linear-gradient(100deg, var(--ld-text) 40%, var(--ld-teal) 50%, var(--ld-text) 60%) 100% 0 / 250% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: ld-rise 0.7s ease 0.35s both, ld-shine 3.2s ease-in-out 1.2s infinite;
  content: "VIA";
  font-family: Inter, "Public Sans", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.4em;
  padding-inline-start: 0.4em;
}

.loading::after {
  color: var(--ld-muted);
  content: "Preparing your workspace";
  font-family: Inter, "Public Sans", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  order: 3;
  animation: ld-rise 0.7s ease 0.5s both, ld-msg 9s steps(1, end) 1.2s infinite;
}

/* Slim progress bar built from the existing effect nodes */
.loading .effect-1,
.loading .effect-2,
.loading .effect-3 {
  position: absolute;
  display: none;
}

.loading .effect-1 {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--ld-line);
  border-radius: 99px;
  block-size: 3px;
  inline-size: 140px;
  order: 2;
  animation: ld-grow 0.7s ease 0.45s both;
}

.loading .effect-1::after {
  position: absolute;
  background: linear-gradient(90deg, var(--ld-teal), var(--ld-cyan));
  border-radius: 99px;
  content: "";
  inline-size: 40%;
  inset-block: 0;
  animation: ld-slide 1.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes ld-pop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}

@keyframes ld-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes ld-grow {
  from { opacity: 0; inline-size: 0; }
  to { opacity: 1; inline-size: 140px; }
}

@keyframes ld-breathe {
  0%, 100% { box-shadow: 0 10px 30px rgba(16, 37, 44, 0.12); }
  50% { box-shadow: 0 12px 36px rgba(14, 138, 160, 0.28); }
}

@keyframes ld-shine {
  0% { background-position: 100% 0; }
  60%, 100% { background-position: 0% 0; }
}

/* three short status lines in turn (falls back to the first where `content` can't animate) */
@keyframes ld-msg {
  0% { content: "Preparing your workspace"; }
  33% { content: "Securing your session"; }
  66% { content: "Loading your modules"; }
}

@keyframes ld-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ld-spin {
  to { transform: rotate(1turn); }
}

@keyframes ld-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
  #loading-bg,
  .loading-logo::before,
  .loading-logo::after,
  .loading-logo img,
  .loading::before,
  .loading::after,
  .loading .effect-1::after {
    animation-duration: 6s !important;
  }
}
