/**
 * Bubble Particle Animation
 * 
 * Lightweight CSS-only bubble animation for underwater atmosphere.
 * Replaces video backgrounds per ADR-105 Section 5.3 CTO directive.
 * 
 * Performance: ~2KB CSS vs 5-15MB video
 * Battery impact: Minimal (CSS-only, no video decode)
 * 
 * @see .ai_handoffs/plans/ADR-105_ALKEMY_FULL_UI_REDESIGN_SPECIFICATION.md Section 5.3
 */

@layer alkemy-design {
  /* ==========================================================================
     Bubbles Container
     ========================================================================== */
  
  .bubbles-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
  }

  /* ==========================================================================
     Individual Bubble
     ========================================================================== */
  
  .bubble {
    position: absolute;
    bottom: -20px;
    background: radial-gradient(
      circle,
      rgba(0, 212, 255, 0.6) 0%,
      rgba(0, 212, 255, 0.2) 40%,
      transparent 70%
    );
    border-radius: 50%;
    animation: bubble-rise linear infinite;
    will-change: transform, opacity;
  }

  /* ==========================================================================
     Bubble Rise Animation
     ========================================================================== */
  
  @keyframes bubble-rise {
    0% {
      transform: translateY(0) translateX(0) scale(1);
      opacity: 0.6;
    }
    25% {
      transform: translateY(-25vh) translateX(10px) scale(0.9);
      opacity: 0.5;
    }
    50% {
      transform: translateY(-50vh) translateX(-5px) scale(0.8);
      opacity: 0.4;
    }
    75% {
      transform: translateY(-75vh) translateX(8px) scale(0.6);
      opacity: 0.3;
    }
    100% {
      transform: translateY(-100vh) translateX(0) scale(0.4);
      opacity: 0;
    }
  }

  /* ==========================================================================
     Bubble Variations (Position, Size, Timing)
     Staggered across viewport for natural distribution.
     ========================================================================== */
  
  .bubble:nth-child(1) {
    left: 5%;
    width: 8px;
    height: 8px;
    animation-duration: 8s;
    animation-delay: 0s;
  }

  .bubble:nth-child(2) {
    left: 15%;
    width: 6px;
    height: 6px;
    animation-duration: 12s;
    animation-delay: 1s;
  }

  .bubble:nth-child(3) {
    left: 25%;
    width: 10px;
    height: 10px;
    animation-duration: 10s;
    animation-delay: 3s;
  }

  .bubble:nth-child(4) {
    left: 35%;
    width: 5px;
    height: 5px;
    animation-duration: 9s;
    animation-delay: 2s;
  }

  .bubble:nth-child(5) {
    left: 45%;
    width: 7px;
    height: 7px;
    animation-duration: 11s;
    animation-delay: 4s;
  }

  .bubble:nth-child(6) {
    left: 55%;
    width: 9px;
    height: 9px;
    animation-duration: 8s;
    animation-delay: 1.5s;
  }

  .bubble:nth-child(7) {
    left: 65%;
    width: 6px;
    height: 6px;
    animation-duration: 13s;
    animation-delay: 2.5s;
  }

  .bubble:nth-child(8) {
    left: 75%;
    width: 8px;
    height: 8px;
    animation-duration: 9s;
    animation-delay: 0.5s;
  }

  .bubble:nth-child(9) {
    left: 85%;
    width: 5px;
    height: 5px;
    animation-duration: 10s;
    animation-delay: 3.5s;
  }

  .bubble:nth-child(10) {
    left: 95%;
    width: 7px;
    height: 7px;
    animation-duration: 11s;
    animation-delay: 1s;
  }

  /* Additional bubbles for density */
  .bubble:nth-child(11) {
    left: 10%;
    width: 4px;
    height: 4px;
    animation-duration: 14s;
    animation-delay: 5s;
  }

  .bubble:nth-child(12) {
    left: 30%;
    width: 6px;
    height: 6px;
    animation-duration: 12s;
    animation-delay: 6s;
  }

  .bubble:nth-child(13) {
    left: 50%;
    width: 5px;
    height: 5px;
    animation-duration: 15s;
    animation-delay: 4.5s;
  }

  .bubble:nth-child(14) {
    left: 70%;
    width: 8px;
    height: 8px;
    animation-duration: 10s;
    animation-delay: 2s;
  }

  .bubble:nth-child(15) {
    left: 90%;
    width: 6px;
    height: 6px;
    animation-duration: 11s;
    animation-delay: 0s;
  }

  /* ==========================================================================
     Accessibility: Respect Reduced Motion Preference
     Users with vestibular disorders or motion sensitivity.
     ========================================================================== */
  
  @media (prefers-reduced-motion: reduce) {
    .bubble {
      animation: none;
      opacity: 0.2;
      bottom: auto;
      top: 20%;
    }

    .bubble:nth-child(2n) {
      top: 40%;
    }

    .bubble:nth-child(3n) {
      top: 60%;
    }

    .bubble:nth-child(4n) {
      top: 80%;
    }
  }

  /* ==========================================================================
     Login Background with Bubbles
     ========================================================================== */
  
  .login-background {
    position: relative;
    min-height: 100vh;
    background: var(--gradient-ocean, linear-gradient(180deg, #0a1628 0%, #0d2035 100%));
    overflow: hidden;
  }

  /* CSS-only gradient fallback (no image needed) */
  .login-background::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
      radial-gradient(ellipse at 20% 30%, rgba(0, 180, 216, 0.08) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 70%, rgba(0, 119, 182, 0.06) 0%, transparent 50%),
      radial-gradient(ellipse at 50% 100%, rgba(0, 212, 255, 0.04) 0%, transparent 40%);
    z-index: 0;
  }

  /* When background image is available */
  .login-background--with-image {
    background-image: url('/static/images/redesign/backgrounds/login-bg.webp');
    background-size: cover;
    background-position: center;
  }

  /* ==========================================================================
     Dashboard Background with Subtle Bubbles
     Less prominent for readability.
     ========================================================================== */
  
  .dashboard-background .bubbles-container {
    opacity: 0.5;
  }

  .dashboard-background .bubble {
    animation-duration: 15s;
  }
}
