/**
 * Rising Bubble Menu Component
 * ============================
 * A water-themed slide-up menu drawer from the bottom-right
 * Features animated water backgrounds and rising bubble particles
 */

/* ====================
   TOGGLE BUTTON
   ==================== */

/* Bubble Menu Toggle Button */
.bubble-menu-toggle {
  position: fixed !important;
  right: calc(var(--giw-fab-right) + var(--giw-fab-avoid-right) + var(--giw-fab-size) + var(--giw-fab-gap)) !important;
  bottom: calc(var(--giw-fab-bottom) + var(--giw-fab-avoid-bottom)) !important;
  top: auto !important;
  left: auto !important;
  width: var(--giw-fab-size);
  height: var(--giw-fab-size);
  border-radius: 50%;
  background: linear-gradient(135deg, #0077BE, #00D4E4);
  border: 3px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10005 !important;
  box-shadow: 0 8px 25px rgba(0, 119, 190, 0.4);
  transition: all 0.3s ease;
}

.bubble-menu-toggle[aria-expanded="true"] {
  z-index: 10030 !important;
}

.bubble-menu-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  box-shadow: 0 10px 35px rgba(0, 119, 190, 0.6);
}

.bubble-menu-toggle:focus-visible {
  outline: 3px solid rgba(0, 212, 228, 0.85);
  outline-offset: 4px;
  box-shadow: 0 0 0 6px rgba(0, 119, 190, 0.22), 0 10px 35px rgba(0, 119, 190, 0.5);
}

.bubble-menu-icon {
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ====================
   BACKDROP OVERLAY
   ==================== */

.bubble-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 30, 60, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  z-index: 10010;
}

.bubble-menu-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ====================
   DRAWER PANEL
   ==================== */

.bubble-menu-drawer {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 400px;
  height: auto;
  max-height: 70vh;
  background: linear-gradient(180deg,
    rgba(13, 59, 102, 0.95) 0%,
    rgba(20, 50, 70, 0.98) 25%,
    rgba(0, 119, 190, 0.25) 50%,
    rgba(20, 50, 70, 0.98) 75%,
    rgba(13, 59, 102, 0.98) 100%);
  border-radius: 20px 20px 0 0;
  transform: translateY(calc(100% + 30px));
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.6s ease;
  z-index: 10020;
  overflow: hidden;
  box-shadow: none;
  pointer-events: none;
}

.bubble-menu-drawer.active {
  transform: translateY(0);
  box-shadow: -15px 0 60px rgba(0, 119, 190, 0.5),
              0 -5px 20px rgba(0, 212, 228, 0.3);
  pointer-events: auto;
}

/* ====================
   WATER BACKGROUND
   ==================== */

.bubble-menu-water-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background:
    /* Deep ripples */
    radial-gradient(ellipse 200px 150px at 20% 30%, rgba(79, 195, 247, 0.15) 0%, rgba(41, 128, 185, 0.08) 30%, transparent 50%),
    radial-gradient(ellipse 180px 140px at 70% 50%, rgba(60, 150, 200, 0.12) 0%, rgba(41, 128, 185, 0.06) 28%, transparent 48%),
    radial-gradient(ellipse 160px 120px at 40% 70%, rgba(79, 195, 247, 0.1) 0%, rgba(41, 128, 185, 0.04) 25%, transparent 45%),
    /* Light caustics */
    radial-gradient(ellipse 120px 160px at 15% 20%, rgba(150, 200, 230, 0.12) 0%, rgba(79, 195, 247, 0.06) 20%, transparent 40%),
    radial-gradient(ellipse 100px 140px at 85% 35%, rgba(160, 210, 235, 0.1) 0%, rgba(60, 150, 200, 0.05) 18%, transparent 38%);
  animation: bubbleWaterFlow 20s ease-in-out infinite;
}

/* Rising Bubble Particles */
.bubble-menu-water-bg::before,
.bubble-menu-water-bg::after {
  content: '';
  position: absolute;
  bottom: -50px;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.bubble-menu-water-bg::before {
  background-image:
    radial-gradient(circle at 10% 100%, rgba(255, 255, 255, 0.15) 2px, transparent 2px),
    radial-gradient(circle at 30% 100%, rgba(255, 255, 255, 0.1) 3px, transparent 3px),
    radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.12) 2px, transparent 2px),
    radial-gradient(circle at 70% 100%, rgba(255, 255, 255, 0.08) 4px, transparent 4px),
    radial-gradient(circle at 90% 100%, rgba(255, 255, 255, 0.11) 2px, transparent 2px);
  background-size: 100% 100%;
  animation: riseUp 15s linear infinite;
}

.bubble-menu-water-bg::after {
  background-image:
    radial-gradient(circle at 20% 100%, rgba(79, 195, 247, 0.2) 3px, transparent 3px),
    radial-gradient(circle at 40% 100%, rgba(79, 195, 247, 0.15) 2px, transparent 2px),
    radial-gradient(circle at 60% 100%, rgba(79, 195, 247, 0.18) 3px, transparent 3px),
    radial-gradient(circle at 80% 100%, rgba(79, 195, 247, 0.12) 2px, transparent 2px);
  background-size: 100% 100%;
  animation: riseUp 20s linear infinite;
  animation-delay: 5s;
}

@media (prefers-reduced-motion: reduce) {
  .bubble-menu-toggle {
    transition: none !important;
  }

  .bubble-menu-toggle:hover {
    transform: none !important;
    box-shadow: 0 8px 25px rgba(0, 119, 190, 0.4);
  }

  .bubble-menu-drawer {
    transition: none !important;
  }

  .bubble-menu-water-bg,
  .bubble-menu-water-bg::before,
  .bubble-menu-water-bg::after {
    animation: none !important;
  }
}

/* ====================
   CLOSE BUTTON
   ==================== */

.bubble-menu-drawer .bubble-menu-close {
  position: absolute !important;
  top: 1rem !important;
  right: 1rem !important;
  left: unset !important;
  bottom: unset !important;
  width: 36px !important;
  height: 36px !important;
  border-radius: 50%;
  background: rgba(0, 119, 190, 0.2);
  border: 2px solid rgba(79, 195, 247, 0.4);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  z-index: 1000 !important;
  transition: all 0.3s ease;
  transform: none !important;
  margin: 0 !important;
  padding: 0 !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.bubble-menu-drawer .bubble-menu-close svg {
  width: 20px !important;
  height: 20px !important;
  stroke: #C5E3F6 !important;
  fill: none !important;
  opacity: 1 !important;
}

.bubble-menu-drawer .bubble-menu-close:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  transform: rotate(90deg) scale(1.1) !important;
  border-color: rgba(79, 195, 247, 0.6);
}

.bubble-menu-drawer .bubble-menu-close:focus-visible {
  outline: 3px solid rgba(0, 212, 228, 0.85);
  outline-offset: 4px;
}

.bubble-menu-drawer .bubble-menu-close:hover svg {
  stroke: #00D4E4 !important;
}

/* ====================
   NAVIGATION
   ==================== */

.bubble-menu-nav {
  position: relative;
  z-index: 5;
  padding: 3.5rem 2rem 2rem;
  height: auto;
  min-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.bubble-menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bubble-menu-list li {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bubble-menu-drawer.active .bubble-menu-list li {
  opacity: 1;
  transform: translateY(0);
}

/* ====================
   MENU ITEMS
   ==================== */

.bubble-menu-list a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.5rem;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.06) 100%);
  border: 1px solid rgba(79, 195, 247, 0.25);
  border-radius: 15px;
  color: var(--water-200);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 500;
  transition: all 0.35s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.bubble-menu-list a:focus-visible {
  outline: 3px solid rgba(0, 212, 228, 0.65);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .bubble-menu-toggle,
  .bubble-menu-backdrop,
  .bubble-menu-drawer,
  .bubble-menu-list li {
    transition: none !important;
    animation: none !important;
  }

  .bubble-menu-toggle:hover {
    transform: none;
  }
}

.bubble-menu-list a::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(79, 195, 247, 0.3), rgba(0, 212, 228, 0.2), transparent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.bubble-menu-list a:hover::before {
  width: 300%;
  height: 300%;
}

.bubble-menu-list a:hover {
  background: linear-gradient(135deg,
    rgba(79, 195, 247, 0.12) 0%,
    rgba(0, 212, 228, 0.10) 100%);
  border-color: rgba(79, 195, 247, 0.6);
  color: var(--water-100);
  transform: translateX(8px) scale(1.02);
  box-shadow: 0 6px 25px rgba(0, 119, 190, 0.35),
              inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.bubble-menu-list .menu-icon {
  font-size: 1.375rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  flex-shrink: 0;
}

/* ====================
   ANIMATIONS
   ==================== */

@keyframes riseUp {
  0% {
    transform: translateY(100%);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100%);
    opacity: 0;
  }
}

@keyframes bubbleWaterFlow {
  0%, 100% {
    transform: scale(1) translateY(0);
    opacity: 0.8;
  }
  25% {
    transform: scale(1.05) translateY(-10px);
    opacity: 0.9;
  }
  50% {
    transform: scale(0.95) translateY(5px);
    opacity: 0.85;
  }
  75% {
    transform: scale(1.02) translateY(-5px);
    opacity: 0.88;
  }
}

/* ====================
   MOBILE RESPONSIVE
   ==================== */

@media (max-width: 768px) {
  /* Toggle sizing/position handled by variables.css + desktop rule */

  .bubble-menu-icon {
    width: 20px;
    height: 20px;
  }

  .bubble-menu-drawer {
    width: 100%;
    height: 60vh;
    max-height: 500px;
    border-radius: 30px 30px 0 0;
  }

  .bubble-menu-nav {
    padding: 3rem 1.5rem 1.75rem;
  }

  .bubble-menu-list a {
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
  }

  .bubble-menu-drawer .bubble-menu-close {
    top: 0.875rem !important;
    right: 0.875rem !important;
    left: unset !important;
    width: 32px !important;
    height: 32px !important;
  }

  .bubble-menu-drawer .bubble-menu-close svg {
    width: 16px !important;
    height: 16px !important;
  }
}

/* ====================
   DARK MODE
   ==================== */

body.dark-mode .bubble-menu-drawer {
  background: linear-gradient(180deg,
    rgba(5, 15, 30, 0.95) 0%,
    rgba(10, 30, 45, 0.98) 25%,
    rgba(0, 60, 95, 0.25) 50%,
    rgba(10, 30, 45, 0.98) 75%,
    rgba(5, 15, 30, 0.98) 100%);
}

body.dark-mode .bubble-menu-drawer.active {
  box-shadow: -15px 0 60px rgba(0, 60, 95, 0.6),
              0 -5px 20px rgba(0, 150, 200, 0.3);
}

body.dark-mode .bubble-menu-backdrop {
  background: rgba(0, 10, 20, 0.85);
}

body.dark-mode .bubble-menu-list a {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(79, 195, 247, 0.15);
}

body.dark-mode .bubble-menu-list a:hover {
  background: rgba(79, 195, 247, 0.1);
  border-color: rgba(79, 195, 247, 0.4);
}
