/**
 * K12 Mobile Card Carousel - Airbnb-Style Horizontal Scroll
 * ==========================================================
 *
 * Mobile-optimized card display with:
 * - Horizontal scroll carousel in bottom sheet preview
 * - Snap scrolling for smooth card navigation
 * - Touch-friendly navigation arrows
 * - Image carousel dots
 *
 * Reference: Airbnb mobile search results
 */

/* ==========================================================================
   Horizontal Card Carousel (Preview Mode)
   ========================================================================== */

@media (max-width: 767px) {

  /* Preview carousel container */
  .k12-mobile-carousel {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 16px 16px;
  }

  .k12-mobile-carousel::-webkit-scrollbar {
    display: none;
  }

  /* Carousel card */
  .k12-mobile-carousel__card {
    flex-shrink: 0;
    width: 280px;
    scroll-snap-align: start;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

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

  /* Card image */
  .k12-mobile-carousel__card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
  }

  .k12-mobile-carousel__card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Heart button on card */
  .k12-mobile-carousel__card-heart {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
  }

  .k12-mobile-carousel__card-heart:active {
    transform: scale(0.9);
  }

  .k12-mobile-carousel__card-heart svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #222222;
    stroke-width: 2;
  }

  .k12-mobile-carousel__card-heart.is-favorited svg {
    fill: #289a96;
    stroke: #289a96;
  }

  /* Card info */
  .k12-mobile-carousel__card-info {
    padding: 12px;
  }

  .k12-mobile-carousel__card-name {
    font-size: 14px;
    font-weight: 600;
    color: #222222;
    margin: 0 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .k12-mobile-carousel__card-type {
    font-size: 12px;
    color: #717171;
    margin: 0 0 4px;
  }

  .k12-mobile-carousel__card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #222222;
    margin: 0 0 4px;
  }

  .k12-mobile-carousel__card-rating svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
  }

  .k12-mobile-carousel__card-price {
    font-size: 14px;
    font-weight: 600;
    color: #222222;
    margin: 0;
  }

  .k12-mobile-carousel__card-price-suffix {
    font-weight: 400;
    color: #717171;
  }


  /* ==========================================================================
     Pagination Arrows (Carousel Navigation)
     ========================================================================== */

  .k12-mobile-carousel__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
  }

  .k12-mobile-carousel__nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #dddddd;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .k12-mobile-carousel__nav-btn:active:not(:disabled) {
    background: #f7f7f7;
    border-color: #222222;
  }

  .k12-mobile-carousel__nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
  }

  .k12-mobile-carousel__nav-btn svg {
    width: 14px;
    height: 14px;
    stroke: #222222;
    stroke-width: 3;
    fill: none;
  }

  .k12-mobile-carousel__nav-info {
    font-size: 14px;
    color: #222222;
  }


  /* ==========================================================================
     Image Carousel Dots (within cards)
     ========================================================================== */

  .k12-mobile-image-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
  }

  .k12-mobile-image-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
  }

  .k12-mobile-image-dot.is-active {
    background: white;
    transform: scale(1.2);
  }

  /* Hide dots if only 1 image */
  .k12-mobile-image-dots:has(.k12-mobile-image-dot:only-child) {
    display: none;
  }


  /* ==========================================================================
     Mobile Card List (Full View in Expanded Sheet)
     ========================================================================== */

  .k12-mobile-card-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  /* Full-width card in list view */
  .k12-mobile-card-list .loveform-listing-card {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }

  /* Image in list card */
  .k12-mobile-card-list .loveform-listing-card__image {
    aspect-ratio: 16 / 10;
    border-radius: 12px 12px 0 0;
  }

  /* Content padding in list card */
  .k12-mobile-card-list .loveform-listing-card__content {
    padding: 12px 16px 16px;
  }


  /* ==========================================================================
     Touch Swipe Indicators
     ========================================================================== */

  .k12-swipe-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    color: #717171;
    font-size: 12px;
  }

  .k12-swipe-indicator svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    animation: k12-swipe-hint 1.5s ease-in-out infinite;
  }

  @keyframes k12-swipe-hint {
    0%, 100% {
      transform: translateX(0);
    }
    50% {
      transform: translateX(8px);
    }
  }


  /* ==========================================================================
     Smart Carousel Mobile Overrides
     ========================================================================== */

  /* Make existing smart carousel touch-friendly on mobile */
  .k12-smart-carousel {
    /* Let vertical scroll win; JS handles horizontal swipe when intent is clear. */
    touch-action: pan-y;
  }

  .k12-smart-carousel__btn {
    /* Increase touch target on mobile */
    width: 32px;
    height: 32px;
    min-width: 44px;
    min-height: 44px;
    margin: 0 4px;
  }

  /* Show dots more prominently on mobile */
  .k12-smart-carousel__dots {
    bottom: 12px;
    gap: 8px;
  }

  .k12-smart-carousel__dot {
    width: 8px;
    height: 8px;
  }

  .k12-smart-carousel__dot.active {
    width: 8px;
    height: 8px;
    background: white;
  }

}
