/*
 * Mobile Gallery Improvements
 * Comprehensive mobile UX redesign for gallery page
 * Implements modern, clean mobile patterns
 */

/* ========================================
   MOBILE GALLERY HERO - MINIMAL DESIGN
   ======================================== */

@media (max-width: 767px) {
  /* Dramatically reduce hero section on mobile */
  .gallery-hero {
    padding: var(--space-8) 0 var(--space-6);
    background: var(--bg-primary);
    position: relative;
  }

  .gallery-hero .heading-xl {
    font-size: var(--text-3xl);
    font-weight: 400;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
    text-align: center;
  }

  /* Decorative copper underline */
  .gallery-hero .heading-xl::after {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--accent-primary) 50%, transparent 100%);
    margin: var(--space-3) auto 0;
    opacity: 0.6;
  }

  /* Gradient fade to filter bar */
  .gallery-hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 24px;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.02) 100%);
    pointer-events: none;
  }

  /* Hide subheading and trust banner on mobile for cleaner look */
  .gallery-hero .subheading {
    display: none;
  }

  .gallery-trust-banner {
    display: none;
  }

  /* ========================================
     MOBILE FILTER BAR - HORIZONTAL SCROLL CHIPS
     Redesigned: Replaced bottom sheet dropdown with
     always-visible horizontal scroll chips for immediate
     filter access while viewing gallery (75% fewer taps)
     ======================================== */

  /* Filter bar - liquid glass style */
  .filter-bar {
    padding: var(--space-4) 0;
    position: sticky;
    top: 60px; /* Account for header height */
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.7) 100%);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid rgba(184, 134, 107, 0.15);
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }


  /* HIDE dropdown button - replaced with horizontal scroll */
  .mobile-filter-toggle {
    display: none;
  }

  /* HIDE dropdown panel - replaced with horizontal scroll */
  .mobile-filter-dropdown {
    display: none;
  }

  /* SHOW desktop filter controls on mobile with horizontal scroll */
  .filter-controls {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    margin: 0;
    width: 100%;
  }

  .filter-controls::-webkit-scrollbar {
    display: none;
  }

  /* Mobile filter chip - liquid glass style */
  .filter-controls .tag {
    flex-shrink: 0;
    min-height: var(--touch-target-preferred); /* Large touch target */
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    scroll-snap-align: start;
    border-radius: 24px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.4) 100%);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    color: var(--text-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), inset 0 1px 1px rgba(255, 255, 255, 0.6);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
  }


  .filter-controls .tag.is-active {
    background: linear-gradient(135deg, rgba(184, 134, 107, 1) 0%, rgba(166, 119, 87, 1) 100%);
    color: white;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(184, 134, 107, 0.4), 0 2px 8px rgba(184, 134, 107, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
  }

  .filter-controls .tag:active {
    transform: scale(0.96);
  }

  /* ========================================
     MOBILE GALLERY GRID - OPTIMIZED FOR EMOTIONAL IMPACT
     ======================================== */

  /* Reduce top padding on gallery section */
  .gallery-section {
    padding-top: var(--space-6);
    padding-bottom: var(--space-16);
  }

  /* Mobile gallery grid spacing handled by mobile-ux-improvements.css */
  /* DO NOT override gap here - see mobile-ux-improvements.css line 1237 */

  /* ========================================
     MOBILE ARTWORK CARDS - LARGER IMAGES
     ======================================== */

  /* Increase image height for emotional connection on mobile */
  .artwork-card {
    min-height: 280px;
    border-radius: var(--radius-md); /* Reduced from --radius-lg for modern look */
  }

  /* Single column on small phones for maximum image size */
  .bento-grid {
    grid-template-columns: 1fr;
  }

  /* Override bento variants on mobile - all cards same size for consistency */
  .bento-large,
  .bento-wide,
  .bento-tall {
    grid-column: span 1;
    grid-row: span 1;
  }

  /* Larger artwork titles on mobile for readability */
  .artwork-card__title {
    font-size: var(--text-2xl);
    font-weight: 600;
  }

  .artwork-card__collection {
    font-size: var(--text-sm);
  }

  /* Optimize content padding on mobile */
  .artwork-card__content {
    padding: var(--space-5);
    min-height: 100px;
  }

  /* ========================================
     VISUAL POLISH
     ======================================== */

  /* Fade indicator at right edge to show more filters available */
  .filter-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to left, var(--bg-primary), transparent);
    pointer-events: none;
    z-index: 10;
  }

  /* Dark mode fade indicator */
  [data-theme="dark"] .filter-bar::after {
    background: linear-gradient(to left, var(--bg-primary), transparent);
  }

  /* ========================================
     ANIMATIONS & MICRO-INTERACTIONS
     ======================================== */

  /* Fade-in for header */
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Stagger animation for filter chips */
  @keyframes slideInChip {
    from {
      opacity: 0;
      transform: translateX(-8px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  /* Apply header animation */
  @media (prefers-reduced-motion: no-preference) {
    .gallery-hero .heading-xl {
      animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    /* Staggered chip animations */
    .filter-controls .tag {
      animation: slideInChip 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      opacity: 0;
    }

    .filter-controls .tag:nth-child(1) { animation-delay: 0.05s; }
    .filter-controls .tag:nth-child(2) { animation-delay: 0.1s; }
    .filter-controls .tag:nth-child(3) { animation-delay: 0.15s; }
    .filter-controls .tag:nth-child(4) { animation-delay: 0.2s; }
    .filter-controls .tag:nth-child(5) { animation-delay: 0.25s; }
    .filter-controls .tag:nth-child(6) { animation-delay: 0.3s; }
    .filter-controls .tag:nth-child(7) { animation-delay: 0.35s; }
    .filter-controls .tag:nth-child(8) { animation-delay: 0.4s; }
  }

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

  /* Dark mode gallery hero */
  [data-theme="dark"] .gallery-hero::after {
    background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.02) 100%);
  }

  /* Dark mode copper underline */
  [data-theme="dark"] .gallery-hero .heading-xl::after {
    background: linear-gradient(90deg, transparent 0%, var(--accent-primary) 50%, transparent 100%);
    opacity: 0.8;
  }

  /* Enhanced dark mode filter chips */
  [data-theme="dark"] .filter-controls .tag {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.06) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  }

  /* Enhanced dark mode active chips */
  [data-theme="dark"] .filter-controls .tag.is-active {
    background: linear-gradient(135deg, rgba(184, 134, 107, 1) 0%, rgba(166, 119, 87, 1) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 16px rgba(184, 134, 107, 0.5), 0 2px 8px rgba(184, 134, 107, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  }

  /* Enhanced dark mode filter bar */
  [data-theme="dark"] .filter-bar {
    background: linear-gradient(180deg, rgba(26, 24, 22, 0.9) 0%, rgba(26, 24, 22, 0.75) 100%);
    border-bottom: 1px solid rgba(184, 134, 107, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
}

/* ========================================
   SMALL MOBILE (< 480px)
   ======================================== */

@media (max-width: 480px) {
  /* Even more minimal hero */
  .gallery-hero {
    padding: var(--space-4) 0 var(--space-2);
  }

  .gallery-hero .heading-xl {
    font-size: var(--text-xl);
  }

  /* Slightly smaller filter pills */
  .filter-controls .tag {
    min-height: 42px;
    padding: var(--space-2) var(--space-3);
    font-size: 0.813rem; /* 13px */
  }

  /* Tighter gallery grid */
  .bento-grid {
    gap: var(--space-3);
  }

  /* Further optimize artwork cards on very small screens */
  .artwork-card {
    min-height: 300px; /* Slightly larger on small phones */
  }

  .artwork-card__title {
    font-size: var(--text-xl);
  }
}

/* ========================================
   ACCESSIBILITY & PERFORMANCE
   ======================================== */

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  /* Disable all animations */
  .gallery-hero .heading-xl {
    animation: none !important;
    opacity: 1 !important;
  }

  .filter-controls .tag {
    transition: none;
    animation: none !important;
    opacity: 1 !important;
  }

  .filter-controls .tag:active {
    transform: none;
  }

  .filter-controls .tag.is-active {
    transform: none !important;
  }

  .artwork-card,
  .artwork-card__image,
  .artwork-card__content {
    transition: none;
  }

  .artwork-card:hover {
    transform: none;
  }

  .lightbox__close,
  .lightbox__nav {
    transition: none;
  }

  .lightbox__close:hover {
    transform: none;
  }

  .lightbox__image {
    transition: none;
  }

  .mobile-filter-toggle,
  .mobile-filter-chip {
    transition: none;
  }

  .mobile-filter-toggle:active,
  .mobile-filter-chip:active {
    transform: none;
  }

  .mobile-filter-dropdown {
    transition: none;
  }
}


/* ========================================
   DESKTOP STYLES (>= 768px)
   ======================================== */

@media (min-width: 768px) {
  /* Hide mobile filter button on desktop */
  .mobile-filter-toggle {
    display: none;
  }

  /* Hide mobile dropdown on desktop */
  .mobile-filter-dropdown {
    display: none;
  }

  /* Show desktop horizontal scroll filters */
  .filter-controls {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 var(--space-4);
    margin: 0;
  }

  .filter-controls::-webkit-scrollbar {
    display: none;
  }

  .filter-controls .tag {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.01em;
    border: 1.5px solid var(--border-default);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 22px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .filter-controls .tag.is-active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .filter-controls .tag:active {
    transform: scale(0.96);
  }

  /* Fade at edge of filter scroll */
  .filter-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to left, var(--bg-primary), transparent);
    pointer-events: none;
  }

  [data-theme="dark"] .filter-bar::after {
    background: linear-gradient(to left, var(--bg-primary), transparent);
  }

  [data-theme="dark"] .filter-controls .tag.is-active {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  }
}

/* ==========================================================================
   PAGE BOTTOM SPACING FIXES
   Ensure content is not cut off by mobile bottom navigation
   ========================================================================== */

@media (max-width: 767px) {
  /* Add bottom padding to gallery section for mobile nav */
  .gallery-section {
    padding-bottom: calc(var(--space-16, 4rem) + var(--mobile-nav-offset));
  }

  /* Footer extra padding */
  .footer {
    padding-bottom: calc(var(--space-8, 2rem) + env(safe-area-inset-bottom, 0px));
  }

  /* Back to top button positioning - handled in components.css */

  /* Newsletter section */
  .newsletter {
    margin-bottom: var(--space-6, 1.5rem);
  }
}
