/**
 * Micro-Animations for Mobile Menu System
 * Enhanced v2.2.0 - Premium animation experience
 *
 * Features:
 * - Hamburger morphing animation
 * - Spring physics transitions
 * - Touch ripple effects
 * - Staggered menu item entrances
 * - Icon hover animations
 * - Scroll indicator animations
 * - GPU-accelerated transforms
 *
 * @package EthicalHackingYouTube
 * @version 2.2.0
 */

/* ============================================
   CSS CUSTOM PROPERTIES FOR ANIMATIONS
   ============================================ */
:root {
  /* Timing functions */
  --spring-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --spring-smooth: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-back: cubic-bezier(0.68, -0.6, 0.32, 1.6);

  /* Duration */
  --animation-fast: 150ms;
  --animation-normal: 300ms;
  --animation-slow: 500ms;
  --animation-slower: 700ms;

  /* Scale */
  --tap-scale: 0.95;
  --hover-scale: 1.02;
  --press-scale: 0.92;
}

/* ============================================
   HAMBURGER ICON MORPHING ANIMATION
   ============================================ */
@media screen and (max-width: 991px) {
  /* Hamburger container */
  .wp-block-navigation__responsive-container-open {
    position: relative;
    overflow: hidden;
  }

  /* Create custom hamburger lines */
  .wp-block-navigation__responsive-container-open::before,
  .wp-block-navigation__responsive-container-open::after {
    content: '';
    position: absolute;
    left: 50%;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transform: translateX(-50%);
    transition: all var(--animation-normal) var(--spring-smooth);
  }

  .wp-block-navigation__responsive-container-open::before {
    top: calc(50% - 5px);
  }

  .wp-block-navigation__responsive-container-open::after {
    bottom: calc(50% - 5px);
  }

  /* Middle line (use SVG as middle) */
  .wp-block-navigation__responsive-container-open svg {
    transition: all var(--animation-normal) var(--spring-smooth);
  }

  /* Morphing animation on menu open */
  body.ehc-menu-open .wp-block-navigation__responsive-container-open::before {
    transform: translateX(-50%) rotate(45deg) translateY(5px);
    top: calc(50% - 1px);
  }

  body.ehc-menu-open .wp-block-navigation__responsive-container-open::after {
    transform: translateX(-50%) rotate(-45deg) translateY(-5px);
    bottom: calc(50% - 1px);
  }

  body.ehc-menu-open .wp-block-navigation__responsive-container-open svg {
    opacity: 0;
    transform: scale(0) rotate(180deg);
  }

  /* Hamburger hover pulse */
  .wp-block-navigation__responsive-container-open:hover::before,
  .wp-block-navigation__responsive-container-open:hover::after {
    width: 24px;
  }

  /* Press animation */
  .wp-block-navigation__responsive-container-open:active {
    transform: scale(var(--press-scale));
    transition: transform var(--animation-fast) ease-out;
  }
}

/* ============================================
   MENU CONTAINER - ANDROID SAFE
   ============================================ */
@media screen and (max-width: 991px) {
  /* ANDROID CHROME FIX: Simple translateX works fine - only disable complex animations */
  /* Let mobile-responsive.css handle the slide-in with translateX */
  /* Do NOT override transform - it breaks the menu show/hide mechanism */

  .wp-block-navigation__responsive-container {
    /* Disable GPU-heavy properties that cause black screen on Android */
    will-change: auto !important;
    backface-visibility: visible !important;
    perspective: none !important;
    /* Animation is handled by mobile-responsive.css */
  }

  .wp-block-navigation__responsive-container.is-menu-open {
    /* No complex animations - just let the CSS transition work */
    animation: none !important;
  }

  /* DISABLED: menuSlideIn animation causes black screen on Android Chrome */
  /* @keyframes menuSlideIn - REMOVED FOR ANDROID COMPATIBILITY */
}

/* ============================================
   OVERLAY BLUR BREATHING ANIMATION
   ============================================ */
.ehc-mobile-menu-overlay {
  transition: opacity var(--animation-slow) ease;
  /* Solid fallback for Android/devices without backdrop-filter support */
  background: rgba(10, 10, 15, 0.95);
}

/* Only apply backdrop-filter on devices that support it well (iOS Safari, desktop) */
@supports (backdrop-filter: blur(12px)) and (-webkit-appearance: none) {
  .ehc-mobile-menu-overlay {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

.ehc-mobile-menu-overlay.is-visible {
  /* Simple fade - no complex animations that break on Android */
  opacity: 1;
}

/* Disable breathing animation - causes rendering issues on Android */
/* @keyframes overlayBreathing - DISABLED */

/* ============================================
   MENU ITEMS - ANDROID SAFE (NO TRANSFORMS)
   ============================================ */
@media screen and (max-width: 991px) {
  /* ANDROID CHROME FIX: Menu items visible immediately */
  /* DO NOT use opacity: 0 or transforms - causes black screen */
  .wp-block-navigation__responsive-container .wp-block-navigation-item {
    opacity: 1 !important;
    transform: none !important;
    /* Items are always visible when menu is open */
  }

  /* DISABLED: menuItemSpring animation - breaks Android Chrome */
  /* @keyframes menuItemSpring - REMOVED FOR ANDROID COMPATIBILITY */

  .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
    /* NO animation - Android Chrome compatibility */
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  /* DISABLED: Staggered delays - not needed without animations */
  /* All items appear at once for better Android compatibility */

  /* DISABLED: Exit animation - causes black screen on Android */
  /* @keyframes menuItemExit - REMOVED FOR ANDROID COMPATIBILITY */

  .wp-block-navigation__responsive-container:not(.is-menu-open) .wp-block-navigation-item {
    /* NO exit animation - Android Chrome compatibility */
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
}

/* ============================================
   TOUCH RIPPLE EFFECT
   ============================================ */
@media screen and (max-width: 991px) {
  .wp-block-navigation__responsive-container .wp-block-navigation-item__content {
    position: relative;
    overflow: hidden;
    isolation: isolate;
  }

  /* Ripple element */
  .wp-block-navigation__responsive-container .wp-block-navigation-item__content::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(0, 255, 136, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width var(--animation-slow) ease-out,
                height var(--animation-slow) ease-out,
                opacity var(--animation-slow) ease-out;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
  }

  /* Ripple on active/tap */
  .wp-block-navigation__responsive-container .wp-block-navigation-item__content:active::after {
    width: 200%;
    height: 200%;
    opacity: 1;
  }

  /* Link press animation */
  .wp-block-navigation__responsive-container .wp-block-navigation-item__content:active {
    transform: scale(0.98);
  }
}

/* ============================================
   ACTIVE INDICATOR LINE ANIMATION
   ============================================ */
@media screen and (max-width: 991px) {
  .wp-block-navigation__responsive-container .wp-block-navigation-item__content::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, #00ff88 0%, #00d4ff 100%);
    border-radius: 0 3px 3px 0;
    transition: height var(--animation-normal) var(--spring-bounce);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
  }

  .wp-block-navigation__responsive-container .wp-block-navigation-item__content:hover::before,
  .wp-block-navigation__responsive-container .wp-block-navigation-item__content:focus::before {
    height: 70%;
    animation: indicatorPulse 1.5s ease-in-out infinite;
  }

  @keyframes indicatorPulse {
    0%, 100% {
      box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    }
    50% {
      box-shadow: 0 0 20px rgba(0, 255, 136, 0.8);
    }
  }
}

/* ============================================
   CLOSE BUTTON - ANDROID SAFE (NO TRANSFORMS)
   ============================================ */
@media screen and (max-width: 991px) {
  .wp-block-navigation__responsive-container-close {
    /* Color transitions only - no transforms */
    transition: background var(--animation-fast) ease,
                border-color var(--animation-fast) ease;
    /* NO transform-origin - not needed without transforms */
  }

  /* DISABLED: closeButtonEntrance animation - breaks Android Chrome */
  /* @keyframes closeButtonEntrance - REMOVED FOR ANDROID COMPATIBILITY */

  .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close {
    /* NO animation - Android Chrome compatibility */
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  /* Hover - color change only, no transforms */
  .wp-block-navigation__responsive-container-close:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
    /* NO transform - Android Chrome compatibility */
  }

  /* Press effect - color change only */
  .wp-block-navigation__responsive-container-close:active {
    background: rgba(239, 68, 68, 0.3) !important;
    /* NO transform - Android Chrome compatibility */
  }

  /* X icon - no animation */
  .wp-block-navigation__responsive-container-close svg {
    transition: none;
    transform: none !important;
  }
}

/* ============================================
   SUBSCRIBE CTA - ANDROID SAFE (NO TRANSFORMS)
   ============================================ */
@media screen and (max-width: 991px) {
  .wp-block-navigation__responsive-container-content::after {
    /* Simple box-shadow pulse only - no transforms */
    transition: box-shadow var(--animation-normal) ease;
    /* NO transform animations - Android Chrome compatibility */
    animation: ctaShadowPulse 3s ease-in-out infinite;
  }

  /* Shadow-only pulse - no transforms */
  @keyframes ctaShadowPulse {
    0%, 100% {
      box-shadow: 0 4px 20px rgba(255, 0, 0, 0.3);
    }
    50% {
      box-shadow: 0 8px 35px rgba(255, 0, 0, 0.5);
    }
  }

  /* DISABLED: ctaSlideUp animation - breaks Android Chrome */
  /* @keyframes ctaSlideUp - REMOVED FOR ANDROID COMPATIBILITY */

  .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content::after {
    /* Shadow pulse only - no transforms */
    opacity: 1;
    transform: none !important;
    animation: ctaShadowPulse 3s ease-in-out infinite;
  }

  /* Tap state - shadow change only */
  .wp-block-navigation__responsive-container-content:active::after {
    box-shadow: 0 2px 15px rgba(255, 0, 0, 0.4);
    /* NO transform - Android Chrome compatibility */
  }
}

/* ============================================
   SCROLL INDICATOR - ANDROID SAFE (NO TRANSFORMS)
   ============================================ */
@media screen and (max-width: 991px) {
  /* DISABLED: Swipe indicator animation - breaks Android Chrome */
  /* Animation uses transforms which cause black screen on Samsung S24 Ultra */
  .wp-block-navigation__responsive-container::after {
    animation: none !important;
    opacity: 0;
  }

  /* @keyframes swipeHint - REMOVED FOR ANDROID COMPATIBILITY */

  .wp-block-navigation__responsive-container.is-menu-open::after {
    animation: none !important;
    opacity: 0;
  }
}

/* ============================================
   MENU HEADER BRANDING - ANDROID SAFE (NO TRANSFORMS)
   ============================================ */
@media screen and (max-width: 991px) {
  /* ANDROID CHROME FIX: No transforms, simple visibility */
  .wp-block-navigation__responsive-container::before {
    opacity: 1;
    transform: none !important;
    transition: none;
  }

  .wp-block-navigation__responsive-container.is-menu-open::before {
    opacity: 1;
    transform: none !important;
    /* DISABLED: brandingShimmer animation - Android compatibility */
    animation: none !important;
  }

  /* @keyframes brandingShimmer - REMOVED FOR ANDROID COMPATIBILITY */
}

/* ============================================
   LOADING STATE ANIMATIONS
   ============================================ */
@keyframes skeletonPulse {
  0%, 100% {
    background-position: 200% 0;
  }
  50% {
    background-position: -200% 0;
  }
}

.ehc-menu-loading {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

/* ============================================
   FOCUS STATES WITH ANIMATION
   ============================================ */
@media screen and (max-width: 991px) {
  .wp-block-navigation__responsive-container .wp-block-navigation-item__content:focus-visible {
    outline: 2px solid var(--ehc-primary, #00ff88);
    outline-offset: 2px;
    animation: focusRing var(--animation-normal) ease;
  }

  @keyframes focusRing {
    0% {
      outline-offset: 0px;
      outline-color: transparent;
    }
    100% {
      outline-offset: 2px;
      outline-color: var(--ehc-primary, #00ff88);
    }
  }
}

/* ============================================
   ICON ANIMATIONS FOR MENU ITEMS
   ============================================ */
@media screen and (max-width: 991px) {
  /* Add icon animation class */
  .wp-block-navigation-item__content .menu-icon {
    display: inline-block;
    transition: transform var(--animation-normal) var(--spring-bounce);
  }

  .wp-block-navigation-item__content:hover .menu-icon {
    transform: scale(1.2) rotate(-10deg);
  }

  .wp-block-navigation-item__content:active .menu-icon {
    transform: scale(0.9);
  }
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .ehc-mobile-menu-overlay.is-visible {
    animation: none;
  }

  .wp-block-navigation__responsive-container-content::after {
    animation: none !important;
  }

  .wp-block-navigation__responsive-container::after {
    animation: none !important;
  }
}

/* ============================================
   GPU HINTS - DISABLED FOR ANDROID COMPATIBILITY
   ============================================ */
/* ANDROID CHROME FIX: Remove GPU acceleration hints */
/* will-change, translateZ, backface-visibility cause black screen on Android */
@media screen and (max-width: 991px) {
  .wp-block-navigation__responsive-container,
  .wp-block-navigation__responsive-container-close,
  .wp-block-navigation-item,
  .ehc-mobile-menu-overlay {
    /* DISABLED: These cause black rendering on Android Chrome */
    /* will-change: transform, opacity; */
    /* transform: translateZ(0); */
    /* backface-visibility: hidden; */
    will-change: auto;
    transform: none;
    backface-visibility: visible;
  }
}

/* ============================================
   DARK MODE GLOW EFFECTS
   ============================================ */
@media screen and (max-width: 991px) {
  /* Simplified shadow for better Android compatibility */
  .wp-block-navigation__responsive-container.is-menu-open {
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  }

  /* Disable text-shadow glow on mobile - causes rendering issues */
  /* Menu items use solid colors instead */
}

/* ============================================
   HEADER MICRO-ANIMATIONS & ENHANCEMENTS
   ============================================ */

/* Site title show/hide for responsive display */
.kb-site-title .site-title-short {
  display: none;
}

.kb-site-title .site-title-full {
  display: inline;
}

/* Header entrance animation */
@keyframes headerSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kb-site-header {
  animation: headerSlideIn 0.6s var(--ease-out-expo) forwards;
}

/* Logo hover animation with spring bounce */
.kb-main-header .wp-block-site-logo img {
  transition: transform var(--animation-normal) var(--spring-bounce);
}

.kb-main-header .wp-block-site-logo:hover img {
  transform: scale(1.08) rotate(-3deg);
}

.kb-main-header .wp-block-site-logo:active img {
  transform: scale(0.95);
  transition: transform var(--animation-fast) ease-out;
}

/* Site title hover effect with cyber glow */
.kb-site-title a {
  position: relative;
  transition: all var(--animation-normal) var(--ease-out-expo);
}

.kb-site-title a:hover {
  text-shadow:
    0 0 10px rgba(0, 255, 136, 0.3),
    0 0 20px rgba(0, 255, 136, 0.2),
    0 0 30px rgba(0, 255, 136, 0.1);
}

/* Navigation link micro-animations */
.kb-main-nav .wp-block-navigation-item__content {
  position: relative;
  transition: color var(--animation-fast) ease-out;
}

/* Underline slide animation */
.kb-main-nav .wp-block-navigation-item__content::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #00ff88, #00cc6a);
  border-radius: 2px;
  transition: width var(--animation-normal) var(--spring-bounce);
}

.kb-main-nav .wp-block-navigation-item:hover .wp-block-navigation-item__content::after {
  width: 100%;
}

/* Nav item spring hover */
.kb-main-nav .wp-block-navigation-item {
  transition: transform var(--animation-fast) var(--spring-smooth);
}

.kb-main-nav .wp-block-navigation-item:hover {
  transform: translateY(-2px);
}

.kb-main-nav .wp-block-navigation-item:active {
  transform: translateY(0) scale(0.98);
}

/* Header subscribe button pulse animation */
@keyframes subtlePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(0, 255, 136, 0);
  }
}

.kb-header-subscribe .wp-block-button__link {
  animation: subtlePulse 3s ease-in-out infinite;
  transition: all var(--animation-normal) var(--spring-bounce);
}

.kb-header-subscribe .wp-block-button__link:hover {
  transform: scale(1.05);
  animation-play-state: paused;
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
}

/* Top bar social icons hover */
.kb-top-bar .wp-block-social-link {
  transition: transform var(--animation-fast) var(--spring-bounce);
}

.kb-top-bar .wp-block-social-link:hover {
  transform: scale(1.2) translateY(-2px);
}

.kb-top-bar .wp-block-social-link:active {
  transform: scale(0.9);
}

/* Header scroll shadow - activated via JS */
.kb-site-header.scrolled {
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(0, 255, 136, 0.05);
  transition: box-shadow var(--animation-slow) ease-out;
}

/* Sticky header reveal animation */
@keyframes stickyReveal {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.kb-site-header.sticky-revealed {
  animation: stickyReveal 0.4s var(--ease-out-expo) forwards;
}

/* Search input focus animation */
.kb-header-search input[type="search"] {
  transition: all var(--animation-normal) var(--spring-smooth);
}

.kb-header-search input[type="search"]:focus {
  box-shadow:
    0 0 0 2px rgba(0, 255, 136, 0.3),
    0 4px 16px rgba(0, 0, 0, 0.2);
  transform: scale(1.02);
}

/* Terminal cursor blink on site title (optional visual) */
@keyframes terminalCursor {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.kb-site-title a::after {
  content: '_';
  opacity: 0;
  animation: terminalCursor 1s step-end infinite;
  color: #00ff88;
  font-weight: 400;
  margin-left: 2px;
  transition: opacity var(--animation-fast) ease;
}

.kb-site-title:hover a::after {
  opacity: 1;
}

/* Header needs position relative for pseudo element */
.kb-main-header {
  position: relative;
}

/* Cyber grid background for header on hover */
.kb-main-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, 0.02) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0;
  transition: opacity var(--animation-slow) ease;
  pointer-events: none;
  z-index: -1;
}

.kb-main-header:hover::before {
  opacity: 1;
}

/* Mobile-specific header animations */
@media screen and (max-width: 991px) {
  /* Faster entrance on mobile */
  .kb-site-header {
    animation-duration: 0.4s;
  }

  /* Disable hover effects that don't work well on touch */
  .kb-main-header::before {
    display: none;
  }

  /* Touch-friendly nav button scaling */
  .wp-block-navigation__responsive-container-open {
    transition: transform var(--animation-fast) var(--spring-bounce);
  }

  .wp-block-navigation__responsive-container-open:active {
    transform: scale(0.9);
  }
}
