/* ===== DIMENSION LOADING OVERLAY =====
 * Full-screen transition triggered by the gate button.
 * Design follows Stitch template (stitch_loading.html).
 */

.dim-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.dim-loading.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Transition video — sits behind all UI layers */
.dim-loading__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background: var(--bg-deep);
}

/* Background layers — z-index 1-3 sit above canvas (z:0), below center content (z:10) */
.dim-loading__grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image:
    linear-gradient(to right, rgb(var(--accent) / 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(var(--accent) / 0.05) 1px, transparent 1px);
  background-size: 80px 80px;
}

.dim-loading__vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(circle at center, transparent 0%, rgb(var(--bg-deep-rgb) / 0.8) 100%);
}

/* Inherits background from .crt-lines (effects.css).
   Overrides scanline height from 3px to 2px for a tighter CRT effect
   on the loading overlay. */
.dim-loading__scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.25;
  background-size: 100% 2px, 3px 100%;
}

/* Corner brackets: see panel.css bracket system (.dim-bracket variant) */

/* Top metadata */
.dim-meta {
  position: absolute;
  top: 32px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dim-meta--tl { left: 96px; }
.dim-meta--tr { right: 96px; text-align: right; }

.dim-meta__line {
  font-family: var(--font-headline);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgb(var(--accent) / 0.6);
  font-weight: 500;
}

.dim-meta__line--dim {
  color: rgb(var(--accent) / 0.4);
}

/* Center content */
.dim-loading__center {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  max-width: 560px;
  padding: 0 24px;
  text-align: center;
}

/* Scan dot above title (shares base with .dim-loading__dot) */
.dim-scan-dot {
  margin-bottom: -16px;
}

/* Title */
.dim-loading__title {
  font-family: var(--font-headline);
  font-size: clamp(16px, 2.5vw, 24px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  color: var(--accent-hex);
  line-height: 1.4;
}

/* Progress bar */
.dim-progress {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dim-progress__track {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border: 1px solid rgb(var(--accent) / 0.2);
  position: relative;
  overflow: hidden;
}

.dim-progress__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent-hex);
  box-shadow: 0 0 15px rgb(var(--accent) / 0.5);
  transition: width 0.1s linear;
}

.dim-progress__sweep {
  position: absolute;
  inset: 0;
  width: 80px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgb(var(--accent) / 0.2), transparent);
  animation: dim-sweep 2s infinite linear;
}

.dim-progress__meta {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
}

.dim-progress__status,
.dim-progress__pct {
  font-family: var(--font-headline);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-hex);
}

.dim-progress__pct {
  font-weight: 700;
}

/* Coordinate blocks */
.dim-coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: 16px;
  text-align: left;
}

.dim-coords__block {
  border-left: 1px solid rgb(var(--accent) / 0.2);
  padding-left: 16px;
}

.dim-coords__block--right {
  text-align: right;
  border-left: none;
  border-right: 1px solid rgb(var(--accent) / 0.2);
  padding-left: 0;
  padding-right: 16px;
}

.dim-coords__label {
  display: block;
  font-family: var(--font-headline);
  font-size: 8px;
  text-transform: uppercase;
  color: rgb(var(--accent) / 0.5);
  margin-bottom: 4px;
}

.dim-coords__value {
  display: block;
  font-family: var(--font-headline);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--accent-hex);
  font-weight: 500;
}

/* Bottom status */
.dim-loading__bottom {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dim-loading__status-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Shared dot base for loading overlay */
.dim-loading__dot,
.dim-scan-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-hex);
  box-shadow: 0 0 8px rgb(var(--accent) / 0.8);
}

.dim-loading__dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

.dim-loading__status-text {
  font-family: var(--font-headline);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--accent-hex);
  font-weight: 600;
  animation: dim-blink 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.dim-loading__separator {
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgb(var(--accent) / 0.4), transparent);
  margin-top: 8px;
}

/* Footer */
.dim-loading__footer {
  position: absolute;
  bottom: 32px;
  left: 96px;
  right: 96px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  opacity: 0.4;
}

.dim-loading__footer div {
  display: flex;
  gap: 16px;
}

.dim-loading__footer span {
  font-family: var(--font-headline);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-primary);
}

/* Animations */
@keyframes dim-sweep {
  0% { transform: translateX(-80px); }
  100% { transform: translateX(400px); }
}

@keyframes dim-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .dim-progress__sweep { animation: none; }
  .dim-loading__status-text { animation: none; }
  .dim-loading__dot { animation: none; }
}
