/**
 * IMRD COTA - Animaciones de Carga Deportivas
 * Instituto Municipal de Recreación y Deporte de Cota (2026)
 * Estética Unificada: Modern SVG Vector + Athleisure Dark Slate + Brand Colors
 * 
 * 1. Halterofilia (Weightlifter - Levantamiento 0% a 100%)
 * 2. Natación (Swimmer - 100 Metros estilo libre en piscina olímpica)
 * 3. Atletismo (Marathoner / Runner - 100 Metros pista y meta)
 */

:root {
  --imrd-green: #4B8B0B;
  --imrd-green-light: #65a30d;
  --imrd-green-neon: #84cc16;
  --imrd-green-glow: rgba(75, 139, 11, 0.35);
  
  --imrd-blue: #3366CC;
  --imrd-blue-light: #38bdf8;
  --imrd-blue-glow: rgba(51, 102, 204, 0.35);
  
  --imrd-gold: #f59e0b;
  --imrd-gold-glow: rgba(245, 158, 11, 0.4);
  
  --imrd-dark-bg: #0F172A;
  --imrd-card-bg: rgba(30, 41, 59, 0.85);
  --imrd-card-border: rgba(255, 255, 255, 0.08);
  --imrd-card-border-active: rgba(75, 139, 11, 0.4);
  
  --imrd-text-primary: #F8FAFC;
  --imrd-text-muted: #94A3B8;
  
  --progress: 0%;
  --progress-num: 0;
  --anim-speed: 2.2s;
}

/* Base Container & Card System */
.imrd-loader-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: var(--imrd-card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--imrd-card-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5),
              0 0 20px var(--imrd-green-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  color: var(--imrd-text-primary);
  font-family: 'Work Sans', system-ui, -apple-system, sans-serif;
  user-select: none;
}

.imrd-loader-card:hover {
  border-color: var(--imrd-card-border-active);
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.6),
              0 0 30px var(--imrd-green-glow);
  transform: translateY(-2px);
}

/* Card Header */
.imrd-loader-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.imrd-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: rgba(75, 139, 11, 0.15);
  color: var(--imrd-green-neon);
  border: 1px solid rgba(132, 204, 22, 0.3);
}

.imrd-badge-blue {
  background: rgba(51, 102, 204, 0.18);
  color: var(--imrd-blue-light);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.imrd-badge-gold {
  background: rgba(245, 158, 11, 0.18);
  color: var(--imrd-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.imrd-loader-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #FFFFFF;
  margin: 0;
}

.imrd-loader-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 220px;
}

/* Progress Footer & Gauges */
.imrd-loader-footer {
  width: 100%;
  margin-top: 1rem;
}

.imrd-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.imrd-progress-fill {
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--imrd-blue) 0%, var(--imrd-green) 70%, var(--imrd-green-neon) 100%);
  border-radius: 9999px;
  box-shadow: 0 0 12px var(--imrd-green-neon);
  transition: width 0.15s ease-out;
  position: relative;
}

/* Infinite loop progress bar animation when in loop mode */
.imrd-mode-loop .imrd-progress-fill {
  width: 100%;
  animation: imrdLoopTrack var(--anim-speed) ease-in-out infinite;
}

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

.imrd-hud-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--imrd-text-muted);
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.imrd-hud-percent {
  font-size: 1rem;
  font-weight: 800;
  color: var(--imrd-green-neon);
  text-shadow: 0 0 10px var(--imrd-green-glow);
}


/* Shared studio treatment for the three local WebGL scenes. */
.imrd-loader-card { padding: 1.35rem; background: linear-gradient(155deg, #23343c, #17242e 75%); box-shadow: 0 16px 36px #0003; border-color: #b5d3d31a; border-radius: 20px; }
.imrd-loader-card:hover { box-shadow: 0 18px 40px #0004; border-color: #9dc97655; }
.imrd-loader-header { align-items: flex-start; gap: .5rem; min-height: 82px; margin: 0; }
.imrd-loader-header > div { flex-direction: column; align-items: flex-start !important; gap: .65rem !important; min-width: 0; }
.imrd-loader-title { font-size: 1.15rem; line-height: 1.25; letter-spacing: -.035em; }
.imrd-loader-header > .imrd-badge { flex-shrink: 0; max-width: 43%; text-align: right; justify-content: center; margin-top: 2px; font-size: .6rem; padding: .35rem .5rem; line-height: 1.4; }
.imrd-badge { font-size: .62rem; letter-spacing: .09em; border-color: #9cc98433; background: #94be7910; color: #bddb9e; }
.imrd-badge-blue, .imrd-badge-gold { color: #b8ceca; background: #b5d3d30c; border-color: #b5d3d322; }
.imrd-loader-stage { height: 315px; min-height: 315px; background: radial-gradient(ellipse at 50% 60%, #9fbba818, transparent 68%); margin: 0 -1rem; width: calc(100% + 2rem); }
.imrd-loader-stage canvas { display: block; width: 100%; height: 100%; }
.imrd-loader-stage[data-error]::after { content: attr(data-error); position: absolute; inset: 35% 1rem; color: #dce7dc; font-size: .85rem; }
.imrd-scene-loading, .imrd-render-error { color: #abc1c5; font-size: .85rem; text-align: center; padding: 2rem; }
.imrd-loader-footer { margin-top: .6rem; }
.imrd-progress-track { height: 4px; border: 0; }
.imrd-progress-fill { background: linear-gradient(90deg, #4d8395, #b3d885); box-shadow: none; }
.imrd-hud-stats { margin-top: .8rem; font-size: .72rem; gap: .5rem; }
.imrd-hud-percent { font-size: .8rem; text-shadow: none; color: #c3dfa1 !important; white-space: nowrap; }
@media (max-width: 420px) { .imrd-loader-card { padding: 1.1rem; } .imrd-loader-stage { height: 290px; min-height: 290px; } .imrd-loader-title { font-size: 1.05rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ============================================================
   IMRD COTA - SISTEMA DE OVERLAY DE CARGA Y DIFUMINADO
   ============================================================ */

.imrd-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.imrd-loading-overlay.imrd-overlay-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.imrd-loading-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background-image: radial-gradient(circle at 50% 45%, rgba(75, 139, 11, 0.14) 0%, transparent 60%),
                    radial-gradient(circle at 80% 80%, rgba(51, 102, 204, 0.12) 0%, transparent 50%);
  z-index: 1;
}

.imrd-loading-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  transform: scale(0.94) translateY(12px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.imrd-overlay-active .imrd-loading-container {
  transform: scale(1) translateY(0);
}

.imrd-loading-container .imrd-loader-card {
  width: 100%;
  box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.7),
              0 0 35px rgba(75, 139, 11, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.imrd-loading-status-text {
  font-family: 'Work Sans', system-ui, -apple-system, sans-serif;
  color: #F8FAFC;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.55rem 1.25rem;
  border-radius: 9999px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: imrdPulseStatus 2s infinite ease-in-out;
}

@keyframes imrdPulseStatus {
  0%, 100% { box-shadow: 0 0 15px rgba(75, 139, 11, 0.2); }
  50% { box-shadow: 0 0 25px rgba(75, 139, 11, 0.45); }
}

/* Contenedor del área de carga localizada (asegura encuadre perfecto sin desbordamientos) */
.imrd-contained-parent {
  position: relative !important;
  width: 100% !important;
  min-height: 520px !important;
  height: 520px !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  background: #0B1120 !important;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Overlay en contenedor localizado (no bloquea toda la pantalla) */
.imrd-loading-overlay.imrd-overlay-contained {
  position: absolute;
  inset: 0;
  z-index: 35;
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem;
  overflow: hidden;
  border-radius: inherit;
}

.imrd-loading-overlay.imrd-overlay-contained .imrd-loading-backdrop {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background-image: radial-gradient(circle at 50% 40%, rgba(75, 139, 11, 0.16) 0%, transparent 65%),
                    radial-gradient(circle at 80% 80%, rgba(51, 102, 204, 0.14) 0%, transparent 55%);
  z-index: 1;
}

.imrd-loading-overlay.imrd-overlay-contained .imrd-loading-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: auto;
  transform: scale(0.96) translateY(4px);
}

.imrd-loading-overlay.imrd-overlay-contained.imrd-overlay-active .imrd-loading-container {
  transform: scale(1) translateY(0);
}

.imrd-loading-overlay.imrd-overlay-contained .imrd-loader-card {
  width: 100%;
  max-width: 390px;
  padding: 1.15rem 1.25rem;
  border-radius: 14px;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.75), 0 0 30px rgba(75, 139, 11, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.imrd-loading-overlay.imrd-overlay-contained .imrd-loader-stage {
  min-height: 185px;
  height: 185px;
}

.imrd-loading-overlay.imrd-overlay-contained .imrd-loading-status-text {
  font-size: 0.8rem;
  padding: 0.45rem 1.15rem;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
}



