/* ==========================================================================
   MALECÓN 809 — INICIO TIPO APP (Plantilla Inicio tipo app)
   Todas las clases están prefijadas con .m8-intro para evitar choques.
   4 fases: Logo solo -> Sube el color -> 3 pantallas 3D -> Salida difuminada.
   ========================================================================== */

.m8-intro {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #141210;
  color: #e6dfd4;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: opacity 0.72s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.72s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.72s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, filter, transform;
}

.m8-intro.is-hidden {
  display: none;
}

.m8-intro.is-exiting {
  opacity: 0;
  filter: blur(18px);
  transform: scale(1.045);
  pointer-events: none;
}

/* --- Fase 2: Ola de color Tricolor Bandera RD + Piedra Basalto --- */
.m8-intro-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(65% 70% at 24% 18%, rgba(24, 79, 168, 0.46) 0%, transparent 62%),
    radial-gradient(65% 70% at 78% 22%, rgba(200, 38, 45, 0.44) 0%, transparent 62%),
    linear-gradient(180deg, #1b1718 0%, #171514 54%, #141210 100%);
  transform: translateY(104%);
  transition: transform 0.92s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
}

.m8-intro[data-phase="rise"] .m8-intro-wash,
.m8-intro[data-phase="slides"] .m8-intro-wash {
  transform: translateY(0%);
}

/* Sutil cuadrícula arquitectónica de estudio */
.m8-intro-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  background-image:
    linear-gradient(to right, rgba(227, 225, 220, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(227, 225, 220, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.m8-intro[data-phase="slides"] .m8-intro-grid {
  opacity: 1;
}

/* --- Fase 1: Logo solo que se arma --- */
.m8-intro-splash {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.m8-intro[data-phase="slides"] .m8-intro-splash {
  opacity: 0;
  transform: scale(0.9) translateY(-20px);
  pointer-events: none;
}

.m8-intro-logo-box {
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
}

.m8-intro-logo-svg {
  width: 88px;
  height: 88px;
  overflow: visible;
}

.m8-intro-logo-svg .m8-border {
  stroke-dasharray: 244;
  stroke-dashoffset: 244;
  animation: m8DrawBorder 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.m8-intro-logo-svg .m8-piece {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(0.45);
  animation: m8PopPiece 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.m8-intro-logo-svg .m8-p1 { animation-delay: 0.22s; }
.m8-intro-logo-svg .m8-p2 { animation-delay: 0.32s; }
.m8-intro-logo-svg .m8-p3 { animation-delay: 0.42s; }
.m8-intro-logo-svg .m8-p4 { animation-delay: 0.52s; }
.m8-intro-logo-svg .m8-p5 { animation-delay: 0.62s; }
.m8-intro-logo-svg .m8-p6 { animation-delay: 0.72s; }
.m8-intro-logo-svg .m8-p7 { animation-delay: 0.84s; }

@keyframes m8DrawBorder {
  to { stroke-dashoffset: 0; }
}

@keyframes m8PopPiece {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.m8-intro-wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(10px);
  animation: m8FadeUp 0.65s 0.48s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.m8-intro-wordmark-main {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #e6e4de;
}

.m8-intro-wordmark-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: #a1a5ad;
  text-transform: uppercase;
}

@keyframes m8FadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Fase 3: 3 Pantallas interactivas --- */
.m8-intro-deck {
  position: relative;
  z-index: 6;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) clamp(16px, 4vw, 40px) max(20px, env(safe-area-inset-bottom));
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.m8-intro[data-phase="slides"] .m8-intro-deck {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Barra superior del onboarding */
.m8-intro-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

.m8-intro-mini-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #e6e4de;
}

.m8-intro-mini-brand img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.m8-intro-skip {
  background: rgba(25, 28, 34, 0.72);
  border: 1px solid rgba(227, 225, 220, 0.18);
  color: #d6d4ce;
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.m8-intro-skip:hover {
  background: rgba(232, 122, 36, 0.18);
  border-color: #e87a24;
  color: #f2f0eb;
}

/* Escenario central con los 3 objetos grandes 3D en CSS/SVG */
.m8-intro-stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  perspective: 1100px;
  min-height: 210px;
  max-height: 46vh;
}

.m8-intro-obj {
  position: absolute;
  width: clamp(190px, 34vmin, 290px);
  height: clamp(190px, 34vmin, 290px);
  display: grid;
  place-items: center;
  opacity: 0;
  filter: blur(16px);
  transform: rotateY(-58deg) scale(0.76) translateY(16px);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.65s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.78s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.m8-intro-obj.is-active {
  opacity: 1;
  filter: blur(0px);
  transform: rotateY(0deg) scale(1) translateY(0px);
}

.m8-intro-obj.is-prev {
  opacity: 0;
  filter: blur(18px);
  transform: rotateY(54deg) scale(0.8) translateY(-10px);
}

.m8-intro-obj-inner {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  animation: m8Float3D 5.2s ease-in-out infinite;
  transform-style: preserve-3d;
}

@keyframes m8Float3D {
  0%, 100% { transform: translateY(0px) rotateY(-8deg) rotateX(4deg); }
  50%      { transform: translateY(-10px) rotateY(10deg) rotateX(-3deg); }
}

.m8-intro-obj svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 28px 34px rgba(0, 0, 0, 0.52));
}

/* Hoja de vidrio inferior */
.m8-intro-sheet {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: rgba(21, 24, 30, 0.82);
  border: 1px solid rgba(227, 225, 220, 0.14);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-radius: 10px;
  padding: clamp(20px, 3.2vw, 30px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.m8-intro-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.m8-intro-dot {
  height: 5px;
  width: 18px;
  border-radius: 2px;
  border: none;
  padding: 0;
  background: rgba(227, 225, 220, 0.22);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1), background 0.25s ease;
}

.m8-intro-dot.is-active {
  width: 44px;
  background: rgba(232, 122, 36, 0.28);
}

.m8-intro-dot.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #e87a24;
  transform-origin: left center;
  animation: m8DotFill 3.7s linear forwards;
}

@keyframes m8DotFill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.m8-intro-copy {
  min-height: 108px;
}

.m8-intro-title {
  margin: 0 0 10px;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(1.55rem, 3.6vw, 2.2rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: #eceae4;
}

.m8-intro-title-accent {
  display: block;
  color: #e87a24;
}

.m8-intro-desc {
  margin: 0;
  font-size: clamp(0.9rem, 1.5vw, 0.98rem);
  line-height: 1.5;
  color: #b5b9c0;
}

.m8-intro-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.m8-intro-cta-primary {
  flex: 1 1 210px;
  min-height: 48px;
  background: #e87a24;
  color: #111317;
  border: none;
  border-radius: 4px;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.m8-intro-cta-primary:hover {
  background: #f28a38;
  transform: translateY(-1px);
}

.m8-intro-cta-secondary {
  flex: 1 1 180px;
  min-height: 48px;
  background: transparent;
  color: #d6d4ce;
  border: 1px solid rgba(227, 225, 220, 0.22);
  border-radius: 4px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.m8-intro-cta-secondary:hover {
  border-color: #e3e1dc;
  color: #f3f1ec;
  background: rgba(227, 225, 220, 0.06);
}

/* Reducir movimiento / modo liviano */
@media (prefers-reduced-motion: reduce) {
  .m8-intro,
  .m8-intro-wash,
  .m8-intro-obj,
  .m8-intro-obj-inner,
  .m8-intro-dot.is-active::after {
    animation: none !important;
    transition: opacity 0.25s ease !important;
  }
}

html.lite .m8-intro-obj-inner {
  animation: none !important;
}
