/* ==========================================================================
   Module: Delivery Gallery Section
   ========================================================================== */
.delivery-gallery__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-10);
}

.delivery-gallery__item {
  background: var(--color-dark-2);
  border: 1px solid var(--color-dark-3);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-base);
  position: relative;
  z-index: 1;
}

/* Hiệu ứng viền chạy */
.delivery-gallery__item::before,
.delivery-gallery__item::after {
  content: '';
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: inherit;
  background: conic-gradient(from var(--angle), transparent, var(--color-primary), var(--color-gold), transparent 30%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: rotate-border 4s linear infinite;
  pointer-events: none;
}

.delivery-gallery__item::after {
  background: conic-gradient(from var(--angle), transparent 50%, var(--color-gold), var(--color-primary), transparent 80%);
}

.delivery-gallery__item:hover {
  transform: translateY(-8px);
  border-color: transparent;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.delivery-gallery__item:hover::before,
.delivery-gallery__item:hover::after {
  opacity: 0;
}

.delivery-gallery__image-wrap {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  cursor: pointer;
}

.delivery-gallery__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
  /* Tối ưu hiển thị Alt text khi lỗi ảnh */
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delivery-gallery__item:hover .delivery-gallery__image-wrap img {
  transform: scale(1.03);
}

.delivery-gallery__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.delivery-gallery__item:hover .delivery-gallery__overlay {
  opacity: 0;
}

.delivery-gallery__info {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.delivery-gallery__name {
  font-family: var(--font-heading);
  font-weight: var(--font-bold);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
}

.delivery-gallery__model {
  font-size: var(--text-xs);
  color: var(--color-gold);
  font-weight: var(--font-medium);
}

.delivery-gallery__date {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.delivery-gallery__footer { text-align: center; }

@media (max-width: 1023px) {
  .delivery-gallery__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* ==========================================================================
     MOBILE RESPONSIVE UPGRADES (SCOPE ISOLATION)
     Tối ưu hóa không gian, nén lề cho phần lưới thẻ (Card Grid)
     ========================================================================== */
  
  .delivery-gallery {
    padding: 2rem 0 !important;
  }

  /* Grid trượt ngang (Horizontal Scroll) */
  .delivery-gallery__grid { 
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-snap-type: x mandatory;
    gap: 0.75rem !important;
    margin-bottom: 1.5rem !important; 
    padding-bottom: 1rem !important; /* Dành chỗ cho viền bóng đổ dưới */
    scrollbar-width: none;
  }
  .delivery-gallery__grid::-webkit-scrollbar {
    display: none;
  }

  /* 2 card 1 dòng - Cố định chiều rộng tương đối */
  .delivery-gallery__item {
    flex: 0 0 calc(50% - 0.375rem) !important;
    scroll-snap-align: start;
    min-width: 0; 
  }

  /* Rút gọn padding header */
  .delivery-gallery .section__header {
    margin-bottom: 1.25rem !important;
  }
  .delivery-gallery .section__header h2 {
    font-size: 1.5rem !important;
  }
  .delivery-gallery .section__header p {
    font-size: 0.85rem !important;
    margin-bottom: 0 !important;
  }

  /* Nén Tab Bàn Giao Xe kịch trần, bẻ dòng không trượt */
  .delivery-tabs {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 6px !important;
    margin-bottom: 0.75rem !important;
    padding-bottom: 0 !important;
  }
  .delivery-tab-btn {
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    height: auto !important;
    border-radius: 50px !important;
  }

  /* Nén thành phần card item sát hơn cho layout chia rưỡi (50% ngang) */
  .delivery-gallery__info {
    padding: 0.5rem !important;
    gap: 0.25rem !important;
  }
  .delivery-gallery__name {
    font-size: 0.95rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .delivery-gallery__model {
    font-size: 0.75rem !important;
  }
  .delivery-gallery__meta-row {
    margin-top: 0.25rem !important;
    flex-direction: column !important;
    gap: 0.25rem !important;
  }
  .delivery-gallery__date, .delivery-gallery__location {
    font-size: 0.65rem !important;
  }
  .delivery-gallery__footer-thanks {
    padding: 0.5rem !important;
    font-size: 0.65rem !important;
    line-height: 1.2 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  /* Phần xem thêm (pagination area) */
  .delivery-gallery__pagination-area {
    margin-top: 1rem !important;
    gap: 0.75rem !important;
  }
  
  .delivery-gallery__pagination-area .btn--view-all {
    font-size: 0.8rem !important;
    padding: 8px 16px !important;
    height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    border-radius: 99px !important;
  }
  
  .delivery-gallery__pagination-area .btn--view-all svg {
    width: 14px !important;
    height: 14px !important;
  }
  
  /* Thu nhỏ phần phân trang */
  .pagination {
    gap: 4px !important;
  }
  .pagination .page-link {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.75rem !important;
  }
}
