/* ==========================================================================
   3D WHOLE-WEBSITE FLIP EFFECT STYLESHEET
   Ultra-Smooth Hardware-Accelerated Bilingual 3D Transition
   ========================================================================== */

:root {
  --flip-out-duration: 0.28s;
  --flip-in-duration: 0.32s;
  --flip-perspective: 2200px;
  --gold-glow: rgba(212, 175, 55, 0.6);
  --saffron-glow: rgba(230, 81, 0, 0.4);
}

/* Perspective Container around the entire website */
#flip-viewport {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  perspective: var(--flip-perspective);
  perspective-origin: 50% 50%;
  overflow-x: hidden;
  background-color: transparent;
}

/* The element that flips */
#flip-stage {
  width: 100%;
  min-height: 100vh;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, opacity;
  transform-origin: 50% 50%;
  background-color: transparent;
}

/* --------------------------------------------------------------------------
   KEYFRAME ANIMATIONS: Pure GPU-Accelerated (Zero Filter Blur, Zero Layout Lag)
   -------------------------------------------------------------------------- */

/* Phase 1: Rotate out (0deg -> 90deg edge-on) */
#flip-stage.flipping-out {
  animation: pageFlipOut var(--flip-out-duration) cubic-bezier(0.38, 0.0, 0.70, 1.0) forwards;
  pointer-events: none;
}

/* Phase 2: Rotate in (-90deg edge-on -> 0deg rest) */
#flip-stage.flipping-in {
  animation: pageFlipIn var(--flip-in-duration) cubic-bezier(0.18, 0.85, 0.32, 1.0) forwards;
  pointer-events: none;
}

@keyframes pageFlipOut {
  0% {
    transform: rotateY(0deg) scale(1) translateZ(0);
    opacity: 1;
  }
  60% {
    opacity: 0.6;
  }
  100% {
    transform: rotateY(90deg) scale(0.96) translateZ(-40px);
    opacity: 0;
  }
}

@keyframes pageFlipIn {
  0% {
    transform: rotateY(-90deg) scale(0.96) translateZ(-40px);
    opacity: 0;
  }
  40% {
    opacity: 0.6;
  }
  100% {
    transform: rotateY(0deg) scale(1) translateZ(0);
    opacity: 1;
  }
}

/* Accessibility: Graceful fallbacks for reduced motion */
@media (prefers-reduced-motion: reduce) {
  #flip-stage.flipping-out {
    animation: simpleFadeOut 0.2s ease forwards;
  }
  #flip-stage.flipping-in {
    animation: simpleFadeIn 0.22s ease forwards;
  }
  @keyframes simpleFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
  }
  @keyframes simpleFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
  }
}

/* Light Spine Flash on Midpoint Flip */
.flip-spine-glow {
  position: fixed;
  top: 0;
  left: 50%;
  width: 6px;
  height: 100vh;
  transform: translateX(-50%);
  background: linear-gradient(
    to bottom, 
    transparent 0%, 
    rgba(255, 235, 150, 0.9) 20%, 
    rgba(255, 185, 0, 1) 50%, 
    rgba(255, 235, 150, 0.9) 80%, 
    transparent 100%
  );
  box-shadow: 
    0 0 25px 12px rgba(255, 215, 0, 0.8),
    0 0 60px 30px rgba(255, 130, 0, 0.5);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-spine-glow.active {
  opacity: 1;
}

/* Language Toggle Floating Button */
.flip-floating-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #7a1a22 0%, #b81414 100%);
  color: #fff9e6;
  border: 2px solid #ffd700;
  border-radius: 50px;
  box-shadow: 0 8px 25px rgba(122, 26, 34, 0.4), 0 0 15px rgba(255, 215, 0, 0.4);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flip-floating-toggle:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 30px rgba(122, 26, 34, 0.6), 0 0 25px rgba(255, 215, 0, 0.7);
  background: linear-gradient(135deg, #8b1e28 0%, #d32f2f 100%);
}

.flip-floating-toggle .flip-icon {
  display: inline-block;
  font-size: 18px;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-floating-toggle:hover .flip-icon {
  transform: rotate(180deg);
}

/* Header Language Switcher Widget */
.lang-flip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: #ffffff;
  color: #7a1a22;
  border: 1.5px solid #d4af37;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.lang-flip-btn:hover {
  background: #fff9e6;
  border-color: #b81414;
  color: #b81414;
  box-shadow: 0 5px 15px rgba(212, 175, 55, 0.35);
  transform: translateY(-1px);
}

.lang-flip-btn .lang-badge {
  background: #7a1a22;
  color: #ffd700;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Subtle Shimmer Effect on flipped elements */
.lang-flash {
  animation: flashHighlight 0.8s ease-out;
}

@keyframes flashHighlight {
  0% {
    background-color: rgba(255, 215, 0, 0.25);
  }
  100% {
    background-color: transparent;
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  #flip-viewport {
    perspective: 1600px;
  }
  .flip-floating-toggle {
    bottom: 20px;
    right: 20px;
    padding: 10px 16px;
    font-size: 13px;
  }
}
