/* ==========================================================================
   SINAPSIS CINEMATIC SPLASH TRANSITION & CABECERA HOY
   Paridad exacta con la animación nativa de SplashActivity.kt y PantallaHoy.kt
   ========================================================================== */

#sinapsisSplashScreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  box-sizing: border-box;
  background-color: #213C2D;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 1;
  transition: opacity 0.75s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

#sinapsisSplashScreen.splash-fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Ocultar el contenido real de la app mientras la cinemática está activa o no haya sesión */
#app {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

html.auth-already-authenticated #app {
  opacity: 1 !important;
  visibility: visible !important;
  filter: none !important;
  pointer-events: auto !important;
}

html.splash-already-completed #sinapsisSplashScreen,
body.splash-complete #sinapsisSplashScreen {
  display: none !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* Lienzo central donde se dibuja la semilla y el árbol con máscara */
.splash-stage {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

#splashCanvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  pointer-events: none;
}

/* ==========================================================================
   CABECERA CANÓNICA (COMPARTIDA ENTRE DASHBOARD Y SPLASH)
   Garantiza que la posición y tamaño sean 100% idénticos sin saltos
   ========================================================================== */

/* Envoltorio superior que mantiene el saludo en la misma coordenada */
.splash-greeting-layer,
.pantalla-hoy-header {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: clamp(16px, 3.5vw, 28px) clamp(16px, 3vw, 24px) 12px clamp(16px, 3vw, 24px);
  user-select: none;
}

.splash-greeting-layer {
  position: relative;
  z-index: 10;
  pointer-events: none;
}

.pantalla-hoy-header {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

/* Fila de Meta: Fecha y Chip de Racha */
.splash-meta-row,
.hoy-cabecera-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 6px;
}

.splash-date-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: rgba(239, 239, 239, 0.7);
  text-transform: uppercase;
}

.hoy-fecha-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--on-surface-muted, #6F756B);
  text-transform: uppercase;
}

.hoy-chip-racha {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--line-soft, rgba(15, 26, 20, 0.06));
  border: 1px solid var(--line, rgba(15, 26, 20, 0.15));
  color: var(--primary, #1F3A2C);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.racha-llama { width: 18px; height: 22px; flex: 0 0 auto; overflow: visible; }
.racha-llama-externa { fill: #e76a25; transform-origin: 50% 95%; animation: racha-fuego 1.5s ease-in-out infinite alternate; }
.racha-llama-interna { fill: #ffcd63; transform-origin: 50% 95%; animation: racha-fuego 1.1s ease-in-out infinite alternate-reverse; }
@keyframes racha-fuego {
  from { transform: rotate(-3deg) scale(.95, 1); }
  to { transform: rotate(3deg) scale(1.03, .94); }
}
[data-encendida="false"] .racha-llama { opacity: .5; }
[data-encendida="false"] .racha-llama path { fill: currentColor; animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .racha-llama path { animation: none; } }

/* Saludo Tipográfico (Newsreader Light, Letter-spacing -0.015em) */
.splash-greeting-text,
.hoy-saludo-title {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 300;
  font-size: clamp(30px, 5.5vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
  transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.splash-greeting-text {
  color: #EFEFEF;
}

.splash-greeting-text .greeting-keyword {
  font-style: italic;
  font-weight: 400;
  color: #FFFFFF;
}

.hoy-saludo-title {
  color: var(--on-surface, #0F1A14);
}

.hoy-saludo-title .saludo-palabra {
  font-style: italic;
  font-weight: 400;
  color: var(--primary, #1F3A2C);
}

/* Estados de visibilidad en el Splash (Zero-Shift puro sin translateY) */
.splash-date-label {
  opacity: 0;
  transform: none;
  transition: opacity 0.6s ease;
}

.splash-date-label.visible {
  opacity: 1;
  transform: none;
}

.splash-greeting-text {
  opacity: 0;
  transform: none;
  transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.splash-greeting-text.visible {
  opacity: 1;
  transform: none;
}

/* Indicador de toque para iniciar (cuando el navegador requiere interacción previa) */
.splash-tap-prompt {
  position: absolute;
  top: calc(50% + 46px);
  left: 50%;
  transform: translateX(-50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(239, 239, 239, 0.85);
  text-transform: uppercase;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 25;
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  -webkit-tap-highlight-color: transparent;
}

.splash-tap-prompt.visible {
  opacity: 1;
  animation: promptPulse 2s ease-in-out infinite;
}

@keyframes promptPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1.0; }
}

/* Indicador de saltar splash */
.splash-skip-hint {
  position: absolute;
  bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  right: max(20px, calc(env(safe-area-inset-right, 0px) + 16px));
  z-index: 100;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: rgba(239, 239, 239, 0.85);
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(239, 239, 239, 0.25);
  padding: 8px 16px;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-radius: 22px;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.4s ease;
  -webkit-tap-highlight-color: transparent;
}

.splash-skip-hint.visible {
  opacity: 1;
}

@media (max-width: 600px) {
  .splash-greeting-text {
    font-size: 26px !important;
    line-height: 1.15 !important;
  }
}
