/* ===================================
   Mobile Experience Enhancements
   =================================== */

/* Swipe Gestures for Categories - MOBILE ONLY */
/* touch-action: auto allows both vertical scroll AND horizontal swipe - neither interferes */
.swipe-container {
  position: relative;
  overflow: clip;
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
}

/* Disable swipe on desktop - allow normal scrolling */
@media (min-width: 769px) {
  .swipe-container {
    overflow: visible;
    touch-action: auto;
  }
  
  .swipe-wrapper {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    transform: none !important;
    transition: none !important;
  }
  
  .swipe-item {
    width: auto;
    flex: none;
  }
}

/* Resources homepage categories: use scrollable grid on mobile - NO swipe carousel.
   Swipe carousel blocks vertical scroll; grid lets page scroll naturally.
   Desktop: 4-col bento grid from resources-bento-grid.css.
   Mobile: 2-col grid below. */
.categories-bento-grid .swipe-container {
  overflow: visible;
  touch-action: auto;
}

.categories-bento-grid .swipe-item {
  width: auto;
  flex: none;
}

@media (max-width: 768px) {
  /* Swipe carousel layout - only for non-categories swipe containers */
  .swipe-wrapper {
    display: flex;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }
  
  .swipe-item {
    flex: 0 0 auto;
    width: 100%;
    scroll-snap-align: start;
  }
  
  /* Categories: keep grid (not carousel) for natural scroll */
  .categories-bento-grid .swipe-wrapper {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    transform: none !important;
    transition: none !important;
  }
  
  .categories-bento-grid .swipe-item {
    width: auto !important;
    flex: none !important;
  }
}

.swipe-indicators {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: var(--youth-spacing-md);
  padding: 0 var(--youth-spacing-sm);
}

.swipe-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--resources-coral-light);
  transition: all 0.3s ease;
  cursor: pointer;
}

.swipe-indicator.active {
  background: var(--resources-coral);
  transform: scale(1.2);
}

/* Disable native pull-to-refresh (Chrome Android, Safari iOS) */
html, body {
  overscroll-behavior-y: none;
}

/* Bottom Sheet Modals */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  max-height: 80vh;
  overflow-y: auto;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--youth-spacing-md);
  border-bottom: 1px solid var(--resources-coral-light);
}

.bottom-sheet-title {
  font-family: var(--resources-font-heading);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--resources-text-warm);
  margin: 0;
}

.bottom-sheet-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--resources-text-warm-secondary);
  cursor: pointer;
  padding: var(--youth-spacing-xs);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.bottom-sheet-close:hover {
  background: var(--resources-bg-warm-secondary);
  color: var(--resources-text-warm);
}

.bottom-sheet-content {
  padding: var(--youth-spacing-md);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--resources-coral-light);
  border-radius: 2px;
  margin: 8px auto;
  cursor: grab;
}

.bottom-sheet-handle:active {
  cursor: grabbing;
}

/* Adaptive Mobile Layouts */
.adaptive-grid {
  display: grid;
  gap: var(--youth-spacing-md);
  grid-template-columns: 1fr;
}

@media (min-width: 480px) and (max-width: 768px) {
  .adaptive-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .adaptive-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Context-Aware Mobile Cards */
.mobile-card {
  background: white;
  border-radius: 16px;
  padding: var(--youth-spacing-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  position: relative;
  overflow: clip;
}

.mobile-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--category-color) 0%, var(--category-color-light) 100%);
}

.mobile-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Mobile Navigation Enhancements */
.mobile-nav-enhanced {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--resources-bg-warm);
  border-top: 1px solid var(--resources-coral-light);
  padding: var(--youth-spacing-sm) 0;
  z-index: 999;
  backdrop-filter: blur(10px);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--youth-spacing-xs);
  color: var(--resources-text-warm-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.mobile-nav-item.active {
  color: var(--resources-coral);
}

.mobile-nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--resources-coral);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-nav-item.active::before {
  opacity: 1;
}

.mobile-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.mobile-nav-label {
  font-family: var(--resources-font-base);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

/* Mobile Touch Feedback */
.touch-feedback {
  position: relative;
  overflow: clip;
}

.touch-feedback::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 123, 107, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
  pointer-events: none;
}

.touch-feedback:active::after {
  width: 200px;
  height: 200px;
}

/* Mobile Filter Enhancements */
.mobile-filter-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-filter-drawer.open {
  opacity: 1;
  visibility: visible;
}

.mobile-filter-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  padding: var(--youth-spacing-lg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 70vh;
  overflow-y: auto;
}

.mobile-filter-drawer.open .mobile-filter-panel {
  transform: translateY(0);
}

/* Mobile Search Enhancements */
.mobile-search-trigger {
  display: none;
  position: fixed;
  bottom: 90px;
  left: 16px;
  min-width: 48px;
  min-height: 48px;
  padding: 12px;
  background: var(--resources-coral);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  transition: all 0.2s ease;
}

.mobile-search-trigger:hover {
  background: var(--resources-amber);
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .mobile-search-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (min-width: 769px) {
  .mobile-search-trigger {
    display: none !important;
  }
}

.mobile-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: white;
  z-index: 1002;
  padding: var(--youth-spacing-md);
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.mobile-search-overlay.open {
  transform: translateY(0);
}

.mobile-search-input {
  width: 100%;
  padding: var(--youth-spacing-md);
  border: 2px solid var(--resources-coral-light);
  border-radius: 12px;
  font-family: var(--resources-font-base);
  font-size: 1rem;
  background: var(--resources-bg-warm);
  color: var(--resources-text-warm);
}

.mobile-search-close {
  position: absolute;
  top: var(--youth-spacing-md);
  right: var(--youth-spacing-md);
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--resources-text-warm-secondary);
  cursor: pointer;
}

/* Responsive Typography for Mobile */
@media (max-width: 768px) {
  .text-hierarchy-primary {
    font-size: clamp(1.5rem, 4vw, 2rem);
  }
  
  .text-hierarchy-secondary {
    font-size: clamp(1rem, 2vw, 1.125rem);
  }
  
  .text-hierarchy-tertiary {
    font-size: clamp(0.8125rem, 1.25vw, 0.875rem);
  }
}

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
  .swipe-wrapper,
  .bottom-sheet,
  .mobile-filter-panel {
    transform: translateZ(0);
    backface-visibility: hidden;
  }
  
  .mobile-card,
  .mobile-nav-item {
    will-change: transform;
  }
}

/* Dark Mode Mobile Adjustments */
html.dark-mode .bottom-sheet,
html.dark-mode .mobile-filter-panel,
html.dark-mode .mobile-search-overlay {
  background: var(--resources-bg-warm);
}

html.dark-mode .mobile-card {
  background: var(--resources-bg-warm-secondary);
  border-color: var(--resources-coral);
}

html.dark-mode .mobile-search-input {
  background: var(--resources-bg-warm-secondary);
  border-color: var(--resources-coral);
  color: var(--resources-text-warm);
}

/* Reduced Motion for Mobile */
@media (prefers-reduced-motion: reduce) and (max-width: 768px) {
  .swipe-wrapper,
  .bottom-sheet,
  .mobile-filter-panel,
  .mobile-search-overlay {
    transition: none;
  }
  
  .touch-feedback::after {
    display: none;
  }
}

/* High Contrast Mobile */
@media (prefers-contrast: high) and (max-width: 768px) {
  .mobile-card {
    border: 2px solid var(--resources-text-warm);
  }
  
  .mobile-nav-item.active {
    outline: 2px solid var(--resources-coral);
    outline-offset: 2px;
  }
}
