/* ============================================================
   Splash Screen — Edificio de Ladrillos
   BEM: .acfhel-splash
   Usado en index.html (Web + MAUI) dentro de #app
   Blazor reemplaza #app al terminar la carga → splash desaparece solo
   ============================================================ */

/* ── Variables locales (fallback si app.css aún no cargó) ── */
.acfhel-splash {
  --sp-bg:           #f0f4fa;
  --sp-primary:      #2c4f94;
  --sp-primary-dark: #254477;
  --sp-amber:        #f59e0b;
  --sp-amber-dark:   #d97706;
  --sp-amber-light:  #fde68a;
  --sp-text:         #111827;
  --sp-text-muted:   #6b7280;
  --sp-surface:      #ffffff;
  --sp-border:       #ccd8ee;

  /* layout */
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--sp-bg);
  z-index: 9999;
  font-family: system-ui, -apple-system, sans-serif;
  gap: 32px;
  padding: 24px;
  box-sizing: border-box;
}

/* ── Tarjeta central ── */
.acfhel-splash__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: 20px;
  padding: 40px 48px;
  box-shadow: 0 8px 40px rgba(44, 79, 148, 0.13), 0 2px 8px rgba(44, 79, 148, 0.07);
  max-width: 380px;
  width: 100%;
}

/* ── Escena del edificio ── */
.acfhel-splash__scene {
  width: 160px;
  height: 160px;
  position: relative;
}

/* ── SVG ocupa toda la escena ── */
.acfhel-splash__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ── Suelo ── */
.acfhel-splash__ground {
  fill: var(--sp-primary-dark);
  rx: 3px;
}

/* ── Ladrillo genérico ── */
.acfhel-splash__brick {
  fill: var(--sp-primary);
  rx: 2px;
  transform-origin: center bottom;
  animation: sp-brick-drop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  opacity: 0;
}

/* Ladrillo de acento (color construcción / ámbar) */
.acfhel-splash__brick--accent {
  fill: var(--sp-amber);
}

.acfhel-splash__brick--accent-dark {
  fill: var(--sp-amber-dark);
}

/* ── Ventanas ── */
.acfhel-splash__window {
  fill: var(--sp-amber-light);
  rx: 1px;
  opacity: 0;
  animation: sp-window-appear 0.3s ease forwards;
}

/* ── Grúa ── */
.acfhel-splash__crane-mast {
  stroke: var(--sp-primary-dark);
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
  animation: sp-fade-in 0.4s ease forwards;
  animation-delay: 1.6s;
}

.acfhel-splash__crane-arm {
  stroke: var(--sp-primary-dark);
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
  animation: sp-fade-in 0.4s ease forwards;
  animation-delay: 1.7s;
}

.acfhel-splash__crane-cable {
  stroke: var(--sp-amber-dark);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 4 3;
  fill: none;
  opacity: 0;
  animation: sp-fade-in 0.4s ease forwards, sp-cable-sway 2s ease-in-out infinite;
  animation-delay: 1.8s, 2.2s;
}

.acfhel-splash__crane-hook {
  fill: var(--sp-amber-dark);
  opacity: 0;
  animation: sp-fade-in 0.3s ease forwards;
  animation-delay: 1.9s;
}

/* ── Nube de polvo ── */
.acfhel-splash__dust {
  fill: var(--sp-border);
  opacity: 0;
  animation: sp-dust-puff 0.6s ease forwards;
}

/* ── Texto ── */
.acfhel-splash__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.acfhel-splash__title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--sp-primary);
  letter-spacing: -0.02em;
  margin: 0;
}

.acfhel-splash__subtitle {
  font-size: 0.78rem;
  color: var(--sp-text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
}

/* ── Barra de progreso ── */
.acfhel-splash__progress {
  width: 100%;
  height: 4px;
  background: var(--sp-border);
  border-radius: 99px;
  overflow: hidden;
}

.acfhel-splash__progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--sp-primary) 0%, var(--sp-amber) 100%);
  animation: sp-progress 3.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  transform-origin: left center;
}

/* ── Texto de carga ── */
.acfhel-splash__label {
  font-size: 0.82rem;
  color: var(--sp-text-muted);
  letter-spacing: 0.04em;
  animation: sp-pulse 1.4s ease-in-out infinite;
}

/* ============================================================
   KEYFRAMES
   ============================================================ */

/* Ladrillo cae y rebota */
@keyframes sp-brick-drop {
  0%   { opacity: 0; transform: translateY(-28px) scaleY(0.6); }
  60%  { opacity: 1; transform: translateY(0) scaleY(1.08); }
  80%  { transform: translateY(-3px) scaleY(0.97); }
  100% { opacity: 1; transform: translateY(0) scaleY(1); }
}

/* Ventana aparece */
@keyframes sp-window-appear {
  0%   { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

/* Polvo */
@keyframes sp-dust-puff {
  0%   { opacity: 0; transform: scale(0.4) translateY(4px); }
  40%  { opacity: 0.5; transform: scale(1.3) translateY(-4px); }
  100% { opacity: 0; transform: scale(1.6) translateY(-8px); }
}

/* Fade in simple */
@keyframes sp-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Oscilación cable grúa */
@keyframes sp-cable-sway {
  0%, 100% { transform: rotate(-2deg); transform-origin: top center; }
  50%       { transform: rotate(2deg);  transform-origin: top center; }
}

/* Barra de progreso */
@keyframes sp-progress {
  0%   { width: 0%; }
  20%  { width: 28%; }
  50%  { width: 55%; }
  75%  { width: 78%; }
  90%  { width: 88%; }
  100% { width: 96%; }
}

/* Pulso texto */
@keyframes sp-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Delays escalonados para cada ladrillo ──
   Se aplican inline en el HTML (atributo style) ya que son valores
   únicos por elemento y no constituyen un "estilo de diseño" sino
   datos de la animación — equivalente a un data-attribute de timing */

/* ── Responsive ── */
@media (max-width: 400px) {
  .acfhel-splash__card {
    padding: 28px 20px;
  }
  .acfhel-splash__scene {
    width: 120px;
    height: 120px;
  }
  .acfhel-splash__title {
    font-size: 1.1rem;
  }
}

/* ── Dark mode ── */
@media (prefers-color-scheme: dark) {
  .acfhel-splash {
    --sp-bg:           #0f172a;
    --sp-primary:      #6f98df;
    --sp-primary-dark: #4a7bd0;
    --sp-amber:        #fbbf24;
    --sp-amber-dark:   #f59e0b;
    --sp-amber-light:  #fef3c7;
    --sp-text:         #f1f5f9;
    --sp-text-muted:   #94a3b8;
    --sp-surface:      #1e293b;
    --sp-border:       #334155;
  }
}
