/* ==========================================================================
   HALAMEEN — NEW UNIVERSAL PAGE TRANSITION SYSTEM
   Dedicated Stylesheet for #halameenTransition
   Universal Cross-Platform Architecture: Phones, Tablets (iPad), Desktop
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. ROOT CANVAS TRANSITION REINFORCEMENT
   -------------------------------------------------------------------------- */
html.halameen-transitioning,
body.halameen-transitioning {
  background-color: #4F0D0E !important;
  background-image: none !important;
}

/* --------------------------------------------------------------------------
   1. ROOT TRANSITION CONTAINER (Viewport-Independent Outer Shell)
   -------------------------------------------------------------------------- */
.halameen-transition {
  position: fixed !important;
  /* Top-anchored with continuous boundary bleed eliminating edge gaps on dynamic browser toolbars */
  top: -100px !important;
  left: -100px !important;
  right: -100px !important;
  bottom: auto !important;
  width: calc(100vw + 200px) !important;
  width: calc(100% + 200px) !important;
  height: calc(100vh + 600px) !important;
  height: calc(100svh + 600px) !important;
  height: calc(100dvh + 600px) !important;
  height: calc(100lvh + 600px) !important;
  height: calc(var(--viewport-actual-height, 100lvh) + 600px) !important;
  min-height: calc(100vh + 600px) !important;
  min-height: calc(100svh + 600px) !important;
  min-height: calc(100dvh + 600px) !important;
  min-height: calc(100lvh + 600px) !important;
  min-height: calc(var(--viewport-actual-height, 100lvh) + 600px) !important;
  min-height: -webkit-fill-available !important;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  z-index: 999999 !important;
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  overscroll-behavior: none;
  /* Crucial: transform MUST be none so fixed children position relative to the browser window */
  transform: none !important;
  -webkit-transform: none !important;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.35s ease;
}

/* Dismissed / Inactive State */
.halameen-transition.is-dismissed {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Active Entrance & Initial Presentation State */
.halameen-transition.is-active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* --------------------------------------------------------------------------
   2. INDEPENDENT BACKGROUND LAYER (Continuous Crimson Radial Gradient)
   -------------------------------------------------------------------------- */
.halameen-transition-bg {
  position: absolute !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  background-color: #4F0D0E !important;
  background-image: radial-gradient(circle at 50% 50%, #6A181A 0%, #4F0D0E 60%, #2E0506 100%) !important;
  background-image: radial-gradient(circle at 50% calc(50dvh + 100px), #6A181A 0%, #4F0D0E 60%, #2E0506 100%) !important;
  pointer-events: none !important;
  z-index: 1 !important;
}

/* --------------------------------------------------------------------------
   3. INDEPENDENT CONTENT LAYER (Strictly Locked to (50vw, 50dvh))
   -------------------------------------------------------------------------- */
.halameen-transition-content {
  position: fixed !important;
  left: 50vw !important;
  left: 50% !important;
  top: 50% !important;
  top: 50vh !important;
  top: 50svh !important;
  top: 50lvh !important;
  top: 50dvh !important;
  transform: translate(-50%, -50%) !important;
  -webkit-transform: translate(-50%, -50%) !important;
  transform-origin: center center !important;
  -webkit-transform-origin: center center !important;
  z-index: 10 !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  pointer-events: none !important;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Content Entrance Animation: Scaled strictly symmetrically around center */
.halameen-transition.is-active .halameen-transition-content {
  animation: halameenLogoEntrance 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  -webkit-animation: halameenLogoEntrance 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

/* Invariant: translate(-50%, -50%) preserved in EVERY frame (Zero Sideways Drift) */
@keyframes halameenLogoEntrance {
  0% {
    transform: translate(-50%, -50%) scale(0.92);
    -webkit-transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    -webkit-transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}
@-webkit-keyframes halameenLogoEntrance {
  0% {
    -webkit-transform: translate(-50%, -50%) scale(0.92);
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
  }
  100% {
    -webkit-transform: translate(-50%, -50%) scale(1);
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   4. BRAND LOGO LOCKUP, BUTTERFLY & 3D YARN BALL SPINNER
   -------------------------------------------------------------------------- */
.halameen-transition-logo-box {
  position: relative;
  width: clamp(140px, 36vw, 195px);
  height: clamp(140px, 36vw, 195px);
  margin-bottom: clamp(12px, 2.5vh, 18px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.halameen-transition-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
}

.halameen-transition-butterfly {
  position: absolute;
  top: clamp(4px, 1.5vw, 8px);
  right: clamp(8px, 2.5vw, 12px);
  width: clamp(30px, 8vw, 36px);
  height: clamp(30px, 8vw, 36px);
  pointer-events: none;
  animation: halameenButterflyFloat 2s ease-in-out infinite alternate;
}

.halameen-transition-butterfly img {
  width: 100%;
  height: 100%;
  filter: brightness(0) invert(1) drop-shadow(0 2px 6px rgba(255, 255, 255, 0.7));
}

@keyframes halameenButterflyFloat {
  0% { transform: translateY(0) rotate(-6deg) scale(0.95); }
  100% { transform: translateY(-12px) rotate(8deg) scale(1.08); }
}

.halameen-transition-typography {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: clamp(14px, 3vh, 20px);
}

.halameen-transition-brand {
  font-family: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.5rem, 4.8vw, 1.85rem);
  letter-spacing: 0.18em;
  color: #FFFDF9;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  line-height: 1.2;
}

.halameen-transition-arabic {
  font-family: 'Amiri', 'Traditional Arabic', serif;
  font-size: clamp(1.2rem, 3.8vw, 1.45rem);
  color: #E8C4C4;
  line-height: 1.2;
  margin-top: 2px;
}

.halameen-transition-spinner {
  width: clamp(32px, 8vw, 38px);
  height: clamp(32px, 8vw, 38px);
  position: relative;
}

.halameen-yarn-spinner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #F4BAC0;
  background-image: url('../images/yarn-ball-3d.svg');
  background-size: cover;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  animation: halameenSpinYarn 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes halameenSpinYarn {
  0% { transform: rotate(0deg) scale(0.96); }
  50% { transform: rotate(180deg) scale(1.04); }
  100% { transform: rotate(360deg) scale(0.96); }
}

/* --------------------------------------------------------------------------
   5. TABLET & IPAD SPECIFIC OPTIMISATIONS (768px – 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1024px) {
  .halameen-transition-logo-box {
    width: clamp(170px, 24vw, 215px);
    height: clamp(170px, 24vw, 215px);
    margin-bottom: 18px;
  }
  .halameen-transition-butterfly {
    width: 36px;
    height: 36px;
    top: 6px;
    right: 10px;
  }
  .halameen-transition-brand {
    font-size: 1.95rem;
    letter-spacing: 0.18em;
  }
  .halameen-transition-arabic {
    font-size: 1.45rem;
    margin-top: 3px;
  }
  .halameen-transition-spinner {
    width: 38px;
    height: 38px;
  }
}

/* --------------------------------------------------------------------------
   6. DESKTOP SCREENS (> 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 1025px) {
  .halameen-transition-logo-box {
    width: 180px;
    height: 180px;
    margin-bottom: 18px;
  }
  .halameen-transition-butterfly {
    width: 34px;
    height: 34px;
    top: 6px;
    right: 10px;
  }
  .halameen-transition-brand {
    font-size: 1.75rem;
    letter-spacing: 0.18em;
  }
  .halameen-transition-arabic {
    font-size: 1.35rem;
    margin-top: 3px;
  }
  .halameen-transition-spinner {
    width: 36px;
    height: 36px;
  }
}

/* --------------------------------------------------------------------------
   7. ACCESSIBILITY: PREFERS REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .halameen-transition {
    transition: none !important;
    display: none !important;
  }
}
