/* ==========================================================================
   SERENE LIFEWORLD & SKINOPTIX — AUTHENTIC BRAND OPENING SEQUENCE
   Pure GPU Composited • Original Brand Logos • 60/120 FPS Guaranteed
   Failsafe auto-dismiss at 1.25s ensures 100% responsiveness on slow networks.
   ========================================================================== */

/* Lock scroll only while curtain is in initial play */
html.curtain-animating:not(.skip-curtain),
html.curtain-animating:not(.skip-curtain) body {
  overflow: hidden !important;
}

/* Instant skip for internal navigation between pages */
html.skip-curtain #global-curtain {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ==========================================================================
   Global Curtain Stage (Luxury Luminous Canvas with Ambient Lighting & Grid)
   ========================================================================== */
#global-curtain {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 9999999 !important;
  background-color: #f7f5fd;
  background-image:
    radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.98) 0%, rgba(247, 243, 255, 0.90) 45%, rgba(232, 226, 252, 0.95) 100%),
    linear-gradient(140deg, #faf8ff 0%, #ede6fa 50%, #e2ecfb 100%);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  pointer-events: auto;
  cursor: pointer;
  contain: strict;
  transform: translate3d(0, 0, 0);
  -webkit-transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
  /* Pure CSS Fallback: Even if JS is blocked or slow on 2G/3G, curtain slides away smoothly */
  animation: curtainAutoDismissFailsafe 0.62s cubic-bezier(0.76, 0, 0.175, 1) 1.25s forwards;
  box-sizing: border-box !important;
}

/* Precision Scientific Dot Grid Vignette */
#global-curtain::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(91, 66, 190, 0.09) 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  background-position: center center;
  pointer-events: none;
  opacity: 0.85;
  mask-image: radial-gradient(circle at 50% 48%, black 22%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 48%, black 22%, transparent 72%);
}

#global-curtain *,
#global-curtain *::before,
#global-curtain *::after {
  box-sizing: border-box !important;
}

/* Auto-unlock scroll even if JS execution is delayed */
html.curtain-animating,
html.curtain-animating body {
  animation: unlockScrollAuto 0.1s linear 1.35s forwards;
}

@keyframes unlockScrollAuto {
  to {
    overflow: visible !important;
  }
}

/* ==========================================================================
   Central Stage & Architectural Brand Lockup
   ========================================================================== */
.curtain-stage {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  position: relative !important;
  z-index: 2;
  width: 100vw !important;
  max-width: 100vw !important;
  padding: 24px !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;
  transform: translate3d(0, 0, 0);
  -webkit-transform: translate3d(0, 0, 0);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

/* Brand Wrap & Diffuse Atmospheric Aura */
.curtain-brand-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  max-width: 100%;
  transform: translate3d(0, 0, 0);
}

.curtain-brand-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(540px, 90vw);
  height: 260px;
  transform: translate3d(-50%, -50%, 0);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(91, 66, 190, 0.12) 0%, rgba(46, 48, 146, 0.06) 45%, rgba(237, 20, 80, 0.03) 65%, transparent 75%);
  filter: blur(24px);
  animation: curtainAuraPulse 3s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 1;
  will-change: transform, opacity;
}

/* Crystalline Frosted Brand Pedestal for Original Logos */
.curtain-brand-plate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 20px 38px;
  max-width: calc(100vw - 36px);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  box-shadow:
    0 24px 54px -12px rgba(46, 48, 146, 0.13),
    0 8px 24px -4px rgba(22, 25, 46, 0.05),
    0 0 0 1px rgba(91, 66, 190, 0.12),
    0 1px 0 rgba(255, 255, 255, 1) inset;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  position: relative;
  z-index: 2;
  transform: translate3d(0, 8px, 0);
  opacity: 0;
  animation: curtainPlateFadeUp 0.48s cubic-bezier(0.16, 1, 0.3, 1) 0.04s forwards;
  will-change: transform, opacity;
}

.curtain-logo-serene {
  height: clamp(34px, 5.2vw, 46px);
  width: auto;
  max-width: 42vw;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(46, 48, 146, 0.05));
}

.curtain-brand-divider {
  width: 1.5px;
  height: clamp(28px, 4vw, 38px);
  background: linear-gradient(180deg, rgba(237, 20, 80, 0.28) 0%, rgba(91, 66, 190, 0.5) 50%, rgba(46, 48, 146, 0.28) 100%);
  flex-shrink: 0;
  border-radius: 999px;
}

.curtain-logo-skinoptix {
  height: clamp(30px, 4.5vw, 40px);
  width: auto;
  max-width: 42vw;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(46, 48, 146, 0.05));
}

/* Subtitle Tagline (High-Contrast Precision Typography) */
.curtain-tagline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(9px, 2.2vw, 10.5px);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #2e3092;
  margin: 0;
  margin-top: 18px;
  opacity: 0;
  transform: translate3d(0, 6px, 0);
  animation: curtainTextFadeUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.12s forwards;
}

/* Precision Energy Tracer Line */
.curtain-tracer-wrap {
  width: min(220px, 55vw);
  height: 3px;
  background: rgba(108, 47, 168, 0.12);
  border-radius: 999px;
  margin-top: 14px;
  overflow: hidden;
  position: relative;
  opacity: 0;
  transform: translate3d(0, 4px, 0);
  animation: curtainTextFadeUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}

.curtain-tracer-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2e3092 0%, #ed1450 50%, #5b42be 100%);
  box-shadow: 0 0 10px rgba(237, 20, 80, 0.45);
  border-radius: 999px;
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
  animation: curtainTracerFill 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}

/* ==========================================================================
   Exit / Wipe Transitions
   ========================================================================== */
/* Central stage dissolves smoothly */
#global-curtain .curtain-stage.is-leaving {
  opacity: 0 !important;
  transform: translate3d(0, -10px, 0) scale3d(0.97, 0.97, 1) !important;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Silky upward slide wipe */
#global-curtain.is-sliding-up {
  transform: translate3d(0, -100%, 0) !important;
  -webkit-transform: translate3d(0, -100%, 0) !important;
  transition: transform 0.62s cubic-bezier(0.76, 0, 0.175, 1) !important;
  -webkit-transition: -webkit-transform 0.62s cubic-bezier(0.76, 0, 0.175, 1) !important;
  pointer-events: none !important;
}

/* Complete removal */
#global-curtain.is-complete {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ==========================================================================
   Pure Hardware Keyframe Animations
   ========================================================================== */
@keyframes curtainPlateFadeUp {
  0% {
    opacity: 0;
    transform: translate3d(0, 12px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes curtainAuraPulse {
  0% {
    transform: translate3d(-50%, -50%, 0) scale3d(0.94, 0.94, 1);
    opacity: 0.65;
  }
  100% {
    transform: translate3d(-50%, -50%, 0) scale3d(1.06, 1.06, 1);
    opacity: 1;
  }
}

@keyframes curtainTextFadeUp {
  0% {
    opacity: 0;
    transform: translate3d(0, 8px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes curtainTracerFill {
  0% { transform: scaleX(0); }
  60% { transform: scaleX(0.75); }
  100% { transform: scaleX(1); }
}

@keyframes curtainAutoDismissFailsafe {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
  99% {
    transform: translate3d(0, -100%, 0);
    opacity: 1;
  }
  100% {
    transform: translate3d(0, -100%, 0);
    opacity: 0;
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .curtain-stage {
    padding: 16px !important;
  }
  .curtain-brand-glow {
    width: 90vw;
    height: 180px;
    filter: blur(18px);
  }
  .curtain-brand-plate {
    gap: 14px;
    padding: 14px 22px;
    border-radius: 20px;
    max-width: calc(100vw - 28px);
  }
  .curtain-logo-serene {
    height: 26px;
  }
  .curtain-brand-divider {
    height: 22px;
  }
  .curtain-logo-skinoptix {
    height: 23px;
  }
  .curtain-tagline {
    font-size: 8px;
    letter-spacing: 0.14em;
    margin-top: 14px;
  }
  .curtain-tracer-wrap {
    margin-top: 12px;
  }
}

/* Accessibility / Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  #global-curtain {
    display: none !important;
  }
}
