/**
 * Cookie Consent Banner - MWANGI Edition
 *
 * A premium, minimal cookie consent experience that's so smooth
 * users might actually enjoy seeing it. Built with glass morphism,
 * electric blue accents, and buttery animations.
 *
 * Features:
 * - Scroll-triggered appearance (not intrusive on load)
 * - Auto-accept at 60% scroll depth
 * - Smooth slide-up/fade-out animations
 * - Premium glass effect with backdrop blur
 * - Electric blue gradient accents
 * - Full accessibility support
 * - Mobile-first responsive design
 *
 * @package MWANGI
 * @version 2.0.0
 */

/* ========================================================================
   COOKIE BANNER - BASE STYLES
   ======================================================================== */

#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;

  /* Glass morphism effect - premium and modern */
  background: rgba(20, 20, 25, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);

  /* Electric blue accent border */
  border-top: 2px solid #29b5ed;
  box-shadow:
    0 -8px 32px rgba(0, 0, 0, 0.6),
    0 -2px 16px rgba(41, 181, 237, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* Start hidden off-screen */
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;

  /* Smooth transitions for all state changes */
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.4s;
}

/* Show state - smooth slide up with fade in */
#cookie-banner.show {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  animation: slideUpFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Hide state - smooth slide down with fade out */
#cookie-banner.hide {
  animation: slideDownFadeOut 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

/* Auto-accept animation - gentle success indicator */
#cookie-banner.auto-accept {
  animation: gentleFadeOut 0.5s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

/* ========================================================================
   ANIMATIONS - BUTTERY SMOOTH 60FPS
   ======================================================================== */

@keyframes slideUpFadeIn {
  0% {
    transform: translateY(100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDownFadeOut {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes gentleFadeOut {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  50% {
    transform: translateY(-4px);
    opacity: 0.8;
  }
  100% {
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
  }
}

/* Subtle pulse for attention (optional, can be triggered on scroll) */
@keyframes subtlePulse {
  0%, 100% {
    box-shadow:
      0 -8px 32px rgba(0, 0, 0, 0.6),
      0 -2px 16px rgba(41, 181, 237, 0.15);
  }
  50% {
    box-shadow:
      0 -8px 32px rgba(0, 0, 0, 0.6),
      0 -2px 24px rgba(41, 181, 237, 0.3);
  }
}

/* ========================================================================
   CONTENT LAYOUT
   ======================================================================== */

.cookie-banner-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.cookie-banner-text {
  flex: 1;
  margin: 0;
}

.cookie-banner-text h3 {
  margin: 0 0 8px 0;
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.3;
  color: #ffffff;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.cookie-banner-text p {
  margin: 0;
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #e0e0e0;
  font-weight: 400;
}

.cookie-banner-text p strong {
  color: #ffffff;
  font-weight: 600;
}

/* ========================================================================
   BUTTONS - PREMIUM STYLING
   ======================================================================== */

.cookie-banner-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 10px 24px;
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  outline: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;

  /* Smooth transitions for all interactions */
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Prevent text selection */
  user-select: none;
  -webkit-user-select: none;
}

/* Primary Button - "OK" - Electric Blue Gradient */
.cookie-btn-primary {
  background: linear-gradient(135deg, #29b5ed 0%, #6366f1 100%);
  color: #ffffff;
  box-shadow:
    0 4px 12px rgba(41, 181, 237, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);

  /* Subtle glow */
  position: relative;
}

.cookie-btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  padding: 2px;
  background: linear-gradient(135deg, #29b5ed, #6366f1);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.cookie-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 24px rgba(41, 181, 237, 0.45),
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 0 40px rgba(41, 181, 237, 0.2);
}

.cookie-btn-primary:hover::before {
  opacity: 1;
}

.cookie-btn-primary:active {
  transform: translateY(0);
  box-shadow:
    0 2px 8px rgba(41, 181, 237, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Secondary Button - "Learn More" - Outline Style */
.cookie-btn-secondary {
  background: transparent;
  color: #e0e0e0;
  border: 2px solid #666;
  box-shadow: none;
}

.cookie-btn-secondary:hover {
  background: rgba(41, 181, 237, 0.08);
  border-color: #29b5ed;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(41, 181, 237, 0.15);
}

.cookie-btn-secondary:active {
  transform: translateY(0);
  background: rgba(41, 181, 237, 0.12);
  box-shadow: 0 2px 6px rgba(41, 181, 237, 0.1);
}

/* ========================================================================
   ACCESSIBILITY - KEYBOARD NAVIGATION
   ======================================================================== */

/* Focus states - clear and accessible */
.cookie-btn:focus-visible {
  outline: 3px solid #29b5ed;
  outline-offset: 3px;
  box-shadow:
    0 0 0 6px rgba(41, 181, 237, 0.2),
    0 4px 12px rgba(41, 181, 237, 0.3);
}

.cookie-btn-primary:focus-visible {
  box-shadow:
    0 0 0 6px rgba(41, 181, 237, 0.3),
    0 8px 24px rgba(41, 181, 237, 0.45),
    0 4px 8px rgba(0, 0, 0, 0.3);
}

/* ARIA hidden state */
#cookie-banner[aria-hidden="true"] {
  display: none;
}

/* Screen reader only text for enhanced accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ======================================================================== */

/* Tablet and below - Stack buttons */
@media (max-width: 768px) {
  .cookie-banner-content {
    padding: 20px 24px;
    gap: 20px;
  }

  .cookie-banner-text h3 {
    font-size: 15px;
    margin-bottom: 6px;
  }

  .cookie-banner-text p {
    font-size: 13px;
  }

  .cookie-btn {
    font-size: 13px;
    padding: 9px 20px;
  }
}

/* Mobile - Vertical layout */
@media (max-width: 480px) {
  .cookie-banner-content {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 20px;
    gap: 16px;
  }

  .cookie-banner-text h3 {
    font-size: 15px;
    text-align: center;
    margin-bottom: 8px;
  }

  .cookie-banner-text p {
    font-size: 14px;
    text-align: center;
  }

  .cookie-banner-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .cookie-btn {
    width: 100%;
    padding: 12px 24px;
    text-align: center;
  }
}

/* Ultra-small screens */
@media (max-width: 360px) {
  .cookie-banner-content {
    padding: 14px 16px;
  }

  .cookie-banner-text h3 {
    font-size: 14px;
  }

  .cookie-banner-text p {
    font-size: 13px;
  }

  .cookie-btn {
    font-size: 13px;
    padding: 10px 20px;
  }
}

/* ========================================================================
   PRINT STYLES - HIDE BANNER
   ======================================================================== */

@media print {
  #cookie-banner {
    display: none !important;
  }
}

/* ========================================================================
   REDUCED MOTION - ACCESSIBILITY
   ======================================================================== */

@media (prefers-reduced-motion: reduce) {
  #cookie-banner,
  .cookie-btn {
    transition: none;
    animation: none;
  }

  #cookie-banner.show {
    animation: none;
    transform: translateY(0);
    opacity: 1;
  }

  #cookie-banner.hide,
  #cookie-banner.auto-accept {
    animation: none;
    opacity: 0;
    visibility: hidden;
  }

  .cookie-btn:hover {
    transform: none;
  }
}

/* ========================================================================
   HIGH CONTRAST MODE - ACCESSIBILITY
   ======================================================================== */

@media (prefers-contrast: high) {
  #cookie-banner {
    border-top-width: 3px;
    background: rgb(20, 20, 25);
    backdrop-filter: none;
  }

  .cookie-banner-text p {
    color: #ffffff;
  }

  .cookie-btn-secondary {
    border-width: 3px;
    border-color: #29b5ed;
  }
}

/* ========================================================================
   DARK MODE OPTIMIZATION (Already dark, but ensure compatibility)
   ======================================================================== */

@media (prefers-color-scheme: dark) {
  /* Already optimized for dark mode - this is MWANGI's default */
  /* Additional tweaks if needed */
}

/* ========================================================================
   LOADING STATE (Optional - for delayed appearance)
   ======================================================================== */

#cookie-banner.loading {
  pointer-events: none;
  opacity: 0.6;
}

#cookie-banner.loading .cookie-btn {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ========================================================================
   SUCCESS INDICATOR (Optional - visual feedback on auto-accept)
   ======================================================================== */

.cookie-banner-content.success::after {
  content: '✓';
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  color: #10b981;
  animation: successPop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes successPop {
  0% {
    transform: translateY(-50%) scale(0);
    opacity: 0;
  }
  50% {
    transform: translateY(-50%) scale(1.2);
  }
  100% {
    transform: translateY(-50%) scale(1);
    opacity: 1;
  }
}

/* ========================================================================
   PERFORMANCE OPTIMIZATIONS
   ======================================================================== */

/* GPU acceleration for smooth animations */
#cookie-banner,
.cookie-btn {
  will-change: transform, opacity;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Remove will-change after animation completes to free up resources */
#cookie-banner.show,
#cookie-banner.hide,
#cookie-banner.auto-accept {
  animation-fill-mode: forwards;
}

/* ========================================================================
   BROWSER-SPECIFIC FIXES
   ======================================================================== */

/* Safari backdrop-filter enhancement */
@supports (-webkit-backdrop-filter: blur(20px)) {
  #cookie-banner {
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
}

/* Firefox backdrop-filter fallback */
@supports not (backdrop-filter: blur(20px)) {
  #cookie-banner {
    background: rgba(20, 20, 25, 0.98);
  }
}

/* Edge legacy support */
@supports (-ms-ime-align: auto) {
  #cookie-banner {
    background: rgba(20, 20, 25, 0.98);
  }
}

/* ========================================================================
   GRANULAR COOKIE PREFERENCES
   ======================================================================== */

/* Cookie category toggles container */
.cookie-categories {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.cookie-category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: background 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cookie-category:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(41, 181, 237, 0.2);
}

.cookie-category-info {
  flex: 1;
  margin-right: 1rem;
}

.cookie-category-title {
  font-weight: 600;
  color: #e0e0e0;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  line-height: 1.3;
}

.cookie-category-desc {
  font-size: 0.8rem;
  color: #a0a0a0;
  line-height: 1.4;
  margin: 0;
}

/* Toggle switch styling */
.cookie-toggle {
  position: relative;
  width: 48px;
  height: 24px;
  flex-shrink: 0;
}

.cookie-toggle input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #666;
  border-radius: 24px;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Checked state - electric blue gradient */
input:checked + .toggle-slider {
  background: linear-gradient(135deg, #29b5ed 0%, #6366f1 100%);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.15),
    0 0 12px rgba(41, 181, 237, 0.3);
}

input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* Disabled state (for required cookies) */
input:disabled + .toggle-slider {
  opacity: 0.6;
  cursor: not-allowed;
  background: #4caf50;
}

input:disabled + .toggle-slider:before {
  transform: translateX(24px);
}

.cookie-category.required {
  opacity: 0.9;
}

.cookie-category.required .cookie-category-desc::after {
  content: " (Required)";
  font-weight: 600;
  color: #4caf50;
}

/* Focus state for accessibility */
.cookie-toggle input:focus-visible + .toggle-slider {
  outline: 2px solid #29b5ed;
  outline-offset: 2px;
}

/* Preferences modal toggle */
.cookie-preferences-toggle {
  background: transparent;
  color: #a0a0a0;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.85rem;
  padding: 0.5rem 0;
  transition: color 0.2s ease;
}

.cookie-preferences-toggle:hover {
  color: #29b5ed;
}

.cookie-preferences-toggle:focus-visible {
  outline: 2px solid #29b5ed;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ========================================================================
   AGE GATE MODAL - COPPA COMPLIANCE
   ======================================================================== */

.age-gate-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
  padding: 1rem;
}

.age-gate-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  padding: 3rem;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(41, 181, 237, 0.15);
  border: 1px solid rgba(41, 181, 237, 0.2);
  position: relative;
}

.age-gate-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #29b5ed 0%, #6366f1 100%);
  border-radius: 16px 16px 0 0;
}

.age-gate-content h2 {
  color: #29b5ed;
  margin-bottom: 1rem;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0;
}

.age-gate-content p {
  color: #a0a0a0;
  margin-bottom: 2rem;
  line-height: 1.6;
  font-size: 1rem;
}

.age-gate-content label {
  display: block;
  color: #e0e0e0;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.age-gate-content input[type="date"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 1rem;
  margin-bottom: 1.5rem;
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  transition: all 0.2s ease;
}

.age-gate-content input[type="date"]:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.age-gate-content input[type="date"]:focus {
  outline: none;
  border-color: #29b5ed;
  box-shadow: 0 0 0 3px rgba(41, 181, 237, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

.age-gate-content .btn-verify {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #29b5ed 0%, #6366f1 100%);
  color: white;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: 0 4px 12px rgba(41, 181, 237, 0.3);
}

.age-gate-content .btn-verify:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgba(41, 181, 237, 0.4),
    0 0 30px rgba(41, 181, 237, 0.2);
}

.age-gate-content .btn-verify:active {
  transform: translateY(0);
}

.age-gate-content .btn-verify:focus-visible {
  outline: 2px solid #29b5ed;
  outline-offset: 2px;
}

.age-gate-content .btn-verify:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Age gate error message */
.age-gate-error {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
  animation: shake 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* ========================================================================
   RESPONSIVE UPDATES FOR NEW COMPONENTS
   ======================================================================== */

@media (max-width: 768px) {
  .cookie-categories {
    gap: 0.75rem;
  }

  .cookie-category {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .cookie-category-info {
    margin-right: 0;
  }

  .cookie-toggle {
    align-self: flex-end;
  }

  .age-gate-content {
    padding: 2rem 1.5rem;
    max-width: 90%;
  }

  .age-gate-content h2 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .age-gate-content {
    padding: 1.5rem 1.25rem;
  }

  .age-gate-content h2 {
    font-size: 1.375rem;
  }

  .age-gate-content p {
    font-size: 0.9rem;
  }
}

/* ========================================================================
   REDUCED MOTION - AGE GATE
   ======================================================================== */

@media (prefers-reduced-motion: reduce) {
  .age-gate-modal {
    animation: none;
  }

  .age-gate-content .btn-verify:hover {
    transform: none;
  }

  .age-gate-error {
    animation: none;
  }
}

/* ========================================================================
   END OF STYLES
   ======================================================================== */
