/* CelesticLabs — military-grade terminal boot loader */

html.cl-loading {
  overflow: hidden;
}

.cl-loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  background: #04060c;
  color: #9eb6cc;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  transition: opacity 0.85s ease, visibility 0.85s ease;
}

.cl-loader--exit {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ── Background grid + scanlines ───────────────────────────── */
.cl-loader__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(158, 182, 204, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(158, 182, 204, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 20%, transparent 75%);
  pointer-events: none;
}

.cl-loader__grid::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.35;
  animation: cl-scanlines 8s linear infinite;
}

@keyframes cl-scanlines {
  from { transform: translateY(0); }
  to { transform: translateY(4px); }
}

/* ── HUD corner brackets ─────────────────────────────────────── */
.cl-loader__hud {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(158, 182, 204, 0.22);
  pointer-events: none;
}

.cl-loader__hud--tl { top: 2rem; left: 2rem; border-right: none; border-bottom: none; }
.cl-loader__hud--tr { top: 2rem; right: 2rem; border-left: none; border-bottom: none; }
.cl-loader__hud--bl { bottom: 2rem; left: 2rem; border-right: none; border-top: none; }
.cl-loader__hud--br { bottom: 2rem; right: 2rem; border-left: none; border-top: none; }

/* ── Core logo + rings ─────────────────────────────────────────── */
.cl-loader__core {
  position: relative;
  width: clamp(140px, 28vw, 200px);
  height: clamp(140px, 28vw, 200px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cl-loader__ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.cl-loader__ring--outer {
  inset: -18px;
  border: 1px solid rgba(158, 182, 204, 0.12);
  animation: cl-pulse-ring 2.4s ease-in-out infinite;
}

.cl-loader__ring--scan {
  inset: -10px;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 300deg,
    rgba(158, 182, 204, 0.55) 328deg,
    rgba(196, 212, 228, 0.85) 360deg
  );
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: cl-radar 1.8s linear infinite;
}

.cl-loader__ring--ticks {
  inset: -26px;
  border: 1px dashed rgba(158, 182, 204, 0.18);
  animation: cl-spin-reverse 12s linear infinite;
}

.cl-loader__ring--ticks::before,
.cl-loader__ring--ticks::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 1px;
  height: 8px;
  margin-left: -0.5px;
  background: rgba(158, 182, 204, 0.35);
}

.cl-loader__ring--ticks::before { top: -4px; }
.cl-loader__ring--ticks::after { bottom: -4px; }

.cl-loader__logo {
  position: relative;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(158, 182, 204, 0.2),
    0 0 40px rgba(158, 182, 204, 0.08);
  animation: cl-logo-breathe 2.4s ease-in-out infinite;
}

.cl-loader__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cl-loader__logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(196, 212, 228, 0.12) 50%,
    transparent 60%
  );
  animation: cl-logo-glint 2.4s ease-in-out infinite;
}

@keyframes cl-radar {
  to { transform: rotate(360deg); }
}

@keyframes cl-spin-reverse {
  to { transform: rotate(-360deg); }
}

@keyframes cl-pulse-ring {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

@keyframes cl-logo-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes cl-logo-glint {
  0%, 100% { transform: translateX(-120%); opacity: 0; }
  45%, 55% { opacity: 1; }
  100% { transform: translateX(120%); opacity: 0; }
}

/* ── Terminal readout ──────────────────────────────────────────── */
.cl-loader__terminal {
  width: min(420px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.cl-loader__line {
  font-size: 10px;
  color: #506070;
  min-height: 1.4em;
}

.cl-loader__prompt {
  color: #9eb6cc;
  margin-right: 0.35em;
}

.cl-loader__status {
  color: #c4d4e4;
}

.cl-loader__cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  background: #9eb6cc;
  vertical-align: text-bottom;
  animation: cl-blink 0.9s step-end infinite;
}

@keyframes cl-blink {
  50% { opacity: 0; }
}

.cl-loader__progress {
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  overflow: hidden;
}

.cl-loader__progress::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 4px,
    rgba(158, 182, 204, 0.08) 4px,
    rgba(158, 182, 204, 0.08) 5px
  );
}

.cl-loader__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #506070, #9eb6cc, #c4d4e4);
  box-shadow: 0 0 12px rgba(158, 182, 204, 0.45);
  transition: width 0.12s linear;
}

.cl-loader__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 9px;
  color: #1e2a3a;
}

.cl-loader__meta span:first-child {
  color: #9eb6cc;
  min-width: 3ch;
}

.cl-loader__meta-sep {
  opacity: 0.4;
}

/* ── Corner telemetry ──────────────────────────────────────────── */
.cl-loader__telemetry {
  position: absolute;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #506070;
  line-height: 1.7;
  pointer-events: none;
}

.cl-loader__telemetry--tl { top: 2.75rem; left: 3.25rem; }
.cl-loader__telemetry--br {
  bottom: 2.75rem;
  right: 3.25rem;
  text-align: right;
}

.cl-loader__telemetry strong {
  color: #9eb6cc;
  font-weight: 400;
}

@media (max-width: 640px) {
  .cl-loader__hud { width: 32px; height: 32px; }
  .cl-loader__hud--tl, .cl-loader__hud--tr { top: 1.25rem; }
  .cl-loader__hud--bl, .cl-loader__hud--br { bottom: 1.25rem; }
  .cl-loader__hud--tl, .cl-loader__hud--bl { left: 1.25rem; }
  .cl-loader__hud--tr, .cl-loader__hud--br { right: 1.25rem; }
  .cl-loader__telemetry { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cl-loader__ring--scan,
  .cl-loader__ring--ticks,
  .cl-loader__logo,
  .cl-loader__logo::after,
  .cl-loader__grid::after {
    animation: none;
  }
}
