/* ========================================================
   EL HORNERO NRO 1 - PANTALLA DE CARGA CINEMATOGRÁFICA
   Fiel a la referencia visual (media_1790639370827.png)
   ======================================================== */

:root {
  --loader-bg: #070605;
  --loader-fire-primary: #FB2602;
  --loader-fire-bright: #FF9A32;
  --loader-fire-gold: #FFD06A;
  --loader-fire-deep: #A63F1D;
  --loader-text-gold: #D8B98A;
}

/* Contenedor principal de pantalla completa absoluta */
#app-loader {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 99999;
  background-color: #070605;
  background-image: 
    radial-gradient(circle 850px at 50% 36%, rgba(251, 38, 2, 0.24) 0%, rgba(234, 106, 36, 0.08) 35%, transparent 70%),
    radial-gradient(ellipse 100% 100% at 50% 50%, #0d0a08 0%, #070605 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  will-change: opacity, transform, filter;
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Transición de salida suave hacia el Hero */
#app-loader.loader-fade-out {
  opacity: 0;
  transform: scale(1.015);
  filter: blur(3px);
  pointer-events: none;
}

/* Botón saltar intro elegante en la esquina superior */
.loader-skip-btn {
  position: absolute;
  top: max(16px, calc(10px + env(safe-area-inset-top, 0px)));
  right: max(16px, calc(12px + env(safe-area-inset-right, 0px)));
  z-index: 100;
  background: rgba(22, 4, 2, 0.75);
  border: 1px solid rgba(216, 185, 138, 0.25);
  color: var(--loader-text-gold);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 8px 18px;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.loader-skip-btn:hover {
  background: rgba(234, 106, 36, 0.25);
  border-color: var(--loader-fire-primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(234, 106, 36, 0.35);
}

/* Flash cálido sutil en los últimos 200ms */
#app-loader.loader-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(234, 106, 36, 0.16) 0%, rgba(255, 154, 50, 0.05) 40%, transparent 70%);
  pointer-events: none;
  animation: loaderWarmFlash 0.35s ease-out forwards;
}

@keyframes loaderWarmFlash {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* Escenario cinematográfico de alta presencia */
.loader-stage {
  position: relative;
  height: 88vh;
  height: 88dvh;
  width: calc(88vh * (16 / 9));
  max-width: 96vw;
  aspect-ratio: 16 / 9;
  margin: auto;
  user-select: none;
  overflow: visible;
}

/* Regla universal para todas las capas de imagen */
.loader-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Animación 01: Horno que surge de la oscuridad en penumbra natural */
.layer-oven-unlit {
  opacity: 0;
  transform: translateY(6px) scale(0.985);
  filter: brightness(0.42) saturate(0.7);
  transition: opacity 1.3s cubic-bezier(0.22, 1, 0.36, 1),
              transform 1.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2;
}

.layer-oven-unlit.revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Horno completamente iluminado por el fuego vivo */
.layer-oven-lit {
  opacity: 0;
  z-index: 3;
  filter: brightness(1) saturate(1);
  transition: opacity 1.4s ease;
}

.layer-oven-lit.revealed {
  opacity: 1;
}

.layer-oven-lit.instant-lit {
  opacity: 1 !important;
  transition: none !important;
}

/* Resplandor ambiental inmersivo que llena suavemente la pantalla */
.oven-backglow {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 1200px;
  height: 70vh;
  background: radial-gradient(ellipse 60% 50% at 50% 50%, rgba(234, 106, 36, 0.18) 0%, rgba(212, 135, 50, 0.06) 40%, transparent 75%);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  filter: blur(40px);
  transition: opacity 1.4s ease;
}

.oven-backglow.active {
  opacity: 1;
  animation: ovenGlowBreathe 3.5s ease-in-out infinite alternate;
}

@keyframes ovenGlowBreathe {
  0% { transform: translate(-50%, -50%) scale(0.96); opacity: 0.85; }
  50% { transform: translate(-50%, -50%) scale(1.04); opacity: 1.0; }
  100% { transform: translate(-50%, -50%) scale(0.98); opacity: 0.90; }
}

/* Cavidad interior del horno */
.oven-interior-glow {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  height: 22%;
  border-radius: 50% 50% 30% 30%;
  background: radial-gradient(circle at 50% 60%, rgba(255, 105, 20, 0.35) 0%, rgba(234, 106, 36, 0.16) 45%, transparent 75%);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.oven-interior-glow.active {
  opacity: 0.9;
  animation: interiorFlicker 2.2s ease-in-out infinite alternate;
}

@keyframes interiorFlicker {
  0% { opacity: 0.75; transform: translate(-50%, -50%) scale(0.98); }
  50% { opacity: 1.0; transform: translate(-50%, -50%) scale(1.02); }
  100% { opacity: 0.82; transform: translate(-50%, -50%) scale(0.99); }
}

/* Animación 02: Primera brasa que nace en la leña */
.oven-first-ember {
  position: absolute;
  top: 41%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5A1204;
  box-shadow: 0 0 6px rgba(120, 20, 5, 0.6);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.oven-first-ember.igniting {
  opacity: 1;
  animation: emberHeatUp 1.6s forwards;
}

@keyframes emberHeatUp {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    background: #701004;
    box-shadow: 0 0 4px #701004;
  }
  30% {
    transform: translate(-50%, -50%) scale(0.8);
    background: #B82A0E;
    box-shadow: 0 0 8px #B82A0E, 0 0 12px rgba(234, 106, 36, 0.4);
  }
  65% {
    transform: translate(-50%, -50%) scale(1.1);
    background: #EA6A24;
    box-shadow: 0 0 12px #EA6A24, 0 0 18px rgba(255, 154, 50, 0.6);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.3);
    background: #FFD06A;
    box-shadow: 0 0 16px #FFD06A, 0 0 25px rgba(255, 208, 106, 0.8);
  }
}

/* Capa de fuego integrada */
.layer-fire {
  display: none !important;
}

/* Humo sobre la chimenea */
.chimney-smoke-wrap {
  position: absolute;
  top: 9%;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 80px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 1.5s ease;
}

.chimney-smoke-wrap.active {
  opacity: 1;
}

.smoke-puff {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(160, 140, 120, 0.12) 0%, rgba(90, 75, 65, 0.05) 50%, transparent 80%);
  filter: blur(10px);
  animation: smokeRise 3.6s infinite ease-out;
}

.smoke-puff:nth-child(2) {
  animation-delay: 1.2s;
  animation-duration: 4.2s;
  width: 36px;
  height: 36px;
}

.smoke-puff:nth-child(3) {
  animation-delay: 2.4s;
  animation-duration: 3.8s;
  width: 32px;
  height: 32px;
}

@keyframes smokeRise {
  0% { transform: translate(-50%, 10px) scale(0.9); opacity: 0; }
  30% { opacity: 0.15; transform: translate(calc(-50% + 2px), -10px) scale(1.02); }
  70% { opacity: 0.08; transform: translate(calc(-50% - 3px), -24px) scale(1.15); }
  100% { transform: translate(calc(-50% + 1px), -36px) scale(1.3); opacity: 0; }
}

/* Canvas para chispas a pantalla completa absoluta */
#loader-particles-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  pointer-events: none;
  z-index: 15;
}

/* ========================================================
   TIPOGRAFÍA Y MARCA
   ======================================================== */
.layer-text-hornero {
  z-index: 10;
  opacity: 0;
  transform: translateY(8px) scale(0.99);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.layer-text-hornero.revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.layer-text-nro1,
.layer-text-subtitle {
  display: none !important;
}

/* Subtítulo dinámico oficial con identidad de horno de panadería a leña o gas */
.loader-brand-subtitle-wrap {
  position: absolute;
  top: 70%;
  left: 0;
  width: 100%;
  text-align: center;
  z-index: 11;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.loader-brand-subtitle-wrap.revealed {
  opacity: 1;
  transform: translateY(0);
}

.loader-subtitle-main {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #E6D0B3;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 16px rgba(234, 106, 36, 0.25);
}

.loader-subtitle-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--loader-fire-bright);
  text-transform: uppercase;
  margin-top: 4px;
  opacity: 0.95;
}

.loader-subtitle-badges .sub-dot {
  color: rgba(216, 185, 138, 0.5);
}

/* ========================================================
   BARRA DE CARGA — BRASA VIAJANDO POR PIEZA DE METAL
   ======================================================== */
.loader-progress-wrap {
  position: absolute;
  top: 81%;
  left: 28%;
  width: 44%;
  height: 14px;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.loader-progress-wrap.revealed {
  opacity: 1;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgba(16, 14, 12, 0.95);
  border: 1px solid rgba(85, 70, 55, 0.4);
  box-shadow: 
    inset 0 1px 3px rgba(0, 0, 0, 0.9),
    0 1px 2px rgba(255, 154, 50, 0.08);
}

.progress-bar-fill {
  position: absolute;
  top: 1px;
  left: 1px;
  bottom: 1px;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #A63F1D 0%,
    #EA6A24 45%,
    #FF9A32 80%,
    #FFD06A 100%
  );
  box-shadow: 0 0 12px rgba(234, 106, 36, 0.55);
  transition: width 0.45s cubic-bezier(0.25, 0.1, 0.25, 1);
  will-change: width;
}

.progress-ember-head {
  position: absolute;
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #FFF5DD;
  box-shadow: 
    0 0 4px #FFF,
    0 0 10px rgba(255, 154, 50, 0.95),
    0 0 22px rgba(234, 106, 36, 0.8),
    0 0 35px rgba(234, 106, 36, 0.45);
  z-index: 14;
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.3s ease;
}

.loader-progress-wrap.revealed .progress-ember-head {
  opacity: 1;
}

.progress-bar-fill.finished .progress-ember-head {
  transform: translateY(-50%) scale(1.45);
  box-shadow: 
    0 0 8px #FFF,
    0 0 18px rgba(255, 208, 106, 1),
    0 0 32px rgba(234, 106, 36, 1),
    0 0 50px rgba(234, 106, 36, 0.85);
}

.progress-floor-glow {
  position: absolute;
  top: 14px;
  left: 5%;
  width: 90%;
  height: 20px;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(234, 106, 36, 0.14) 0%,
    rgba(212, 135, 50, 0.05) 50%,
    transparent 80%
  );
  filter: blur(12px);
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.4s ease;
}

.progress-status-caption {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  margin-top: 9px;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(216, 185, 138, 0.75);
  text-transform: uppercase;
  font-weight: 500;
  pointer-events: none;
}

/* ========================================================
   RESPONSIVIDAD MÓVIL TOTAL — EMBLEMA UNIFICADO Y CENTRADO
   Fiel a la referencia cinematográfica sin vacíos ni colisiones
   ======================================================== */
@media (max-width: 768px) {
  #app-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #070605;
    background-image: 
      radial-gradient(circle 380px at 50% 48%, rgba(234, 106, 36, 0.22) 0%, rgba(180, 80, 20, 0.08) 45%, transparent 75%),
      radial-gradient(ellipse 100% 100% at 50% 50%, #0d0a08 0%, #070605 100%);
    padding: max(16px, env(safe-area-inset-top, 16px)) max(14px, env(safe-area-inset-right, 14px)) max(20px, env(safe-area-inset-bottom, 20px)) max(14px, env(safe-area-inset-left, 14px));
    box-sizing: border-box;
    overflow: hidden;
  }

  /* Escenario móvil: contenedor armónico centrado verticalmente */
  .loader-stage {
    position: relative;
    --mobile-stage-w: min(94vw, 420px);
    --mobile-oven-h: calc(var(--mobile-stage-w) * (9 / 16));
    width: var(--mobile-stage-w);
    height: calc(var(--mobile-oven-h) + 105px);
    max-height: 85dvh;
    margin: auto;
    overflow: visible;
    transform: translateY(-1.5vh); /* Centro óptico natural */
  }

  /* Capas gráficas de horno y tipografía comparten la escala proporcional 16:9 */
  .loader-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--mobile-oven-h);
    object-fit: contain;
    object-position: center top;
  }

  .layer-text-hornero {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--mobile-oven-h);
    object-fit: contain;
    object-position: center top;
  }

  /* Resplandores y elementos visuales del horno calibrados a la escala móvil */
  .oven-backglow {
    position: absolute;
    top: calc(var(--mobile-oven-h) * 0.36);
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95vw;
    max-width: 480px;
    height: 40vh;
    filter: blur(35px);
  }

  .oven-interior-glow {
    position: absolute;
    top: calc(var(--mobile-oven-h) * 0.38);
    left: 50%;
    transform: translate(-50%, -50%);
    width: 25%;
    height: calc(var(--mobile-oven-h) * 0.22);
  }

  .oven-first-ember {
    position: absolute;
    top: calc(var(--mobile-oven-h) * 0.41);
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .chimney-smoke-wrap {
    position: absolute;
    top: calc(var(--mobile-oven-h) * 0.08);
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 60px;
  }

  /* Subtítulo oficial: posicionado con elegancia inmediatamente bajo la marca */
  .loader-brand-subtitle-wrap {
    position: absolute;
    top: calc(var(--mobile-oven-h) * 0.70 + 4px);
    left: 0;
    width: 100%;
    padding: 0 8px;
    box-sizing: border-box;
    text-align: center;
  }

  .loader-subtitle-main {
    font-size: clamp(0.68rem, 2.7vw, 0.80rem);
    font-weight: 700;
    letter-spacing: 0.10em;
    line-height: 1.3;
    white-space: nowrap;
    text-align: center;
  }

  .loader-subtitle-badges {
    font-size: clamp(0.55rem, 2.1vw, 0.64rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    gap: 6px;
    margin-top: 4px;
    white-space: nowrap;
    justify-content: center;
  }

  /* Barra de progreso: integrada al pie del emblema como base térmica */
  .loader-progress-wrap {
    position: absolute;
    top: calc(var(--mobile-oven-h) + 12px);
    left: 8%;
    width: 84%;
    height: 11px;
    margin: 0;
    bottom: auto;
  }

  .progress-floor-glow {
    top: 11px;
    height: 16px;
  }

  .progress-status-caption {
    font-size: clamp(0.68rem, 2.4vw, 0.74rem);
    letter-spacing: 0.06em;
    margin-top: 9px;
    white-space: nowrap;
    text-align: center;
    color: rgba(216, 185, 138, 0.88);
  }

  /* Botón de saltar introducción con zona táctil ergonómica y safe area */
  .loader-skip-btn {
    top: max(16px, calc(10px + env(safe-area-inset-top, 0px)));
    right: max(16px, calc(12px + env(safe-area-inset-right, 0px)));
    font-size: 0.80rem;
    padding: 7px 16px;
    min-height: 42px;
  }
}

/* Pantallas pequeñas (iPhone SE, móviles angostos < 370px) */
@media (max-width: 370px) {
  .loader-stage {
    --mobile-stage-w: 96vw;
  }

  .loader-subtitle-main {
    font-size: 0.65rem;
    letter-spacing: 0.06em;
  }

  .loader-subtitle-badges {
    font-size: 0.52rem;
    gap: 4px;
    letter-spacing: 0.05em;
  }

  .progress-status-caption {
    font-size: 0.65rem;
    letter-spacing: 0.04em;
  }
}

/* Dispositivos móviles en posición horizontal / apaisada */
@media (max-width: 920px) and (orientation: landscape) and (max-height: 520px) {
  #app-loader {
    padding: 10px;
  }

  .loader-stage {
    height: 82vh;
    height: 82dvh;
    width: calc(82vh * (16 / 9));
    max-width: 88vw;
    aspect-ratio: 16 / 9;
    transform: none;
    margin: auto;
  }

  .loader-layer,
  .layer-text-hornero {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
  }

  .oven-backglow {
    top: 36%;
    left: 50%;
    width: 80vw;
    height: 65vh;
  }

  .oven-interior-glow {
    top: 38%;
    left: 50%;
    width: 22%;
    height: 22%;
  }

  .oven-first-ember {
    top: 41%;
    left: 50%;
  }

  .chimney-smoke-wrap {
    top: 9%;
    left: 50%;
    width: 50px;
    height: 60px;
  }

  .loader-brand-subtitle-wrap {
    top: 70%;
    left: 0;
    width: 100%;
    padding: 0;
  }

  .loader-subtitle-main {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
  }

  .loader-subtitle-badges {
    font-size: 0.60rem;
    letter-spacing: 0.08em;
  }

  .loader-progress-wrap {
    top: 81%;
    left: 24%;
    width: 52%;
    height: 11px;
    bottom: auto;
  }

  .progress-status-caption {
    font-size: 0.68rem;
    margin-top: 7px;
  }

  .loader-skip-btn {
    top: max(10px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    padding: 5px 12px;
    font-size: 0.75rem;
    min-height: 36px;
  }
}

