/**
 * Hero Grid Component Styles
 * Layout: 2 hàng trên mọi breakpoint.
 *   - Mobile  (<640px): 1 cột × 2 hàng, scroll ngang theo từng cặp
 *   - Tablet  (640–1023px): 2 cột × 2 hàng, scroll ngang ẩn phần thừa
 *   - Desktop (≥1024px): 3 cột × 2 hàng, không scroll
 * Text luôn hiển thị overlay trên nền ảnh (mọi breakpoint).
 */

/* ── Shared: mọi hero block (áp dụng mọi breakpoint) ── */
/* Dùng .hero-grid .hero-block để thắng specificity của premium_blocks.css (.hero-block) */
.hero-grid .hero-block {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  background: transparent;
  aspect-ratio: 16 / 9;
  text-decoration: none;
  margin: 0;
  /* Reset premium_blocks.css margin-bottom: var(--block-spacing) */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.hero-grid .hero-block:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Ảnh / video cover toàn bộ block */
.hero-block-image,
.hero-block-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: var(--z-index-base);
}

/* <picture> wrapper từ {% responsive_image %} — phải absolute để không chiếm flow */
.hero-grid .hero-block>picture,
.hero-block-video-facade>picture {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-index-base);
}

.hero-grid .hero-block>picture img,
.hero-block-video-facade>picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-block-video-poster {
  z-index: calc(var(--z-index-base) - 1);
}

.hero-block-video-embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-index-base);
  border: none;
}

/* ── Video Facade: poster + play button (click-to-load iframe) ── */
.hero-block-video-facade {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: var(--z-index-base);
}

.hero-video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: calc(var(--z-index-base) + 1);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  opacity: 0.85;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hero-video-play-btn:hover,
.hero-video-play-btn:focus-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

.hero-video-play-btn svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Khi facade đã activated (iframe loaded) → ẩn poster + button */
.hero-block-video-facade.is-active .hero-block-video-poster,
.hero-block-video-facade.is-active .hero-video-play-btn,
.hero-block-video-facade.is-active picture {
  display: none;
}

/* Gradient overlay nhẹ để text dễ đọc — MỌI breakpoint */
.hero-grid .hero-block::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65%;
  background: linear-gradient(to top,
      rgba(0, 0, 0, 0.75) 0%,
      rgba(0, 0, 0, 0.5) 40%,
      rgba(0, 0, 0, 0.2) 70%,
      transparent 100%);
  z-index: calc(var(--z-index-base) + 1);
  pointer-events: none;
}

/* Text overlay — MỌI breakpoint */
.hero-block-content {
  position: relative;
  z-index: calc(var(--z-index-base) + 2);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.75rem;
  padding-bottom: 0.875rem;
}

.hero-block-content h3 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: white;
  margin: 0 0 0.25rem 0;
  line-height: 1.3;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 1px 3px rgba(0, 0, 0, 0.7);
}

.hero-block-description {
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.95);
  margin: 0 0 0.25rem 0;
  line-height: 1.4;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.7);
}

.hero-block-count {
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* ── Mobile (<640px): 1 cột × 2 hàng, scroll ngang theo từng cặp ── */
@media (max-width: 639px) {
  .hero-grid {
    display: grid;
    grid-template-rows: 1fr 1fr;
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
    padding-bottom: 0.25rem;
  }

  .hero-grid::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
  }

  .hero-grid .hero-block {
    scroll-snap-align: start;
    min-width: 0;
    will-change: transform;
  }
}

/* ── Tablet (640–1023px): 2 cột × 2 hàng, scroll ngang ── */
@media (min-width: 640px) and (max-width: 1023px) {
  .hero-grid {
    display: grid;
    grid-template-rows: 1fr 1fr;
    grid-auto-flow: column;
    grid-auto-columns: calc(50% - 0.375rem);
    gap: 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }

  .hero-grid::-webkit-scrollbar {
    display: none;
  }

  .hero-grid .hero-block {
    scroll-snap-align: start;
    min-width: 0;
    will-change: transform;
  }

  .hero-block-content {
    padding: 1rem;
    padding-bottom: 1rem;
  }

  .hero-block-content h3 {
    font-size: var(--font-size-base);
    margin: 0 0 0.375rem 0;
  }

  .hero-block-description {
    font-size: var(--font-size-sm);
  }
}

/* ── Desktop (≥1024px): 3 cột × 2 hàng, không scroll ── */
@media (min-width: 1024px) {
  .hero-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    grid-auto-rows: minmax(0, auto);
    gap: 1rem;
  }

  /* Đặt vị trí cho các blocks - hàng 1 */
  .hero-block-1 {
    grid-row: 1;
    grid-column: 1;
  }

  .hero-block-2 {
    grid-row: 1;
    grid-column: 2;
  }

  .hero-block-3 {
    grid-row: 1;
    grid-column: 3;
  }

  /* Đặt vị trí cho các blocks - hàng 2 */
  .hero-block-4 {
    grid-row: 2;
    grid-column: 1;
  }

  .hero-block-5 {
    grid-row: 2;
    grid-column: 2;
  }

  .hero-block-6 {
    grid-row: 2;
    grid-column: 3;
  }

  .hero-block-content {
    padding: 1rem;
    padding-bottom: 1.25rem;
  }

  /* Typography desktop lớn hơn */
  .hero-block-content h3 {
    font-size: var(--font-size-lg);
    margin: 0 0 0.5rem 0;
  }

  .hero-block-description {
    font-size: var(--font-size-sm);
    margin: 0 0 0.375rem 0;
  }

  .hero-block-cta h3 {
    font-size: var(--font-size-h3);
    margin-bottom: 0.5rem;
    line-height: var(--line-height-tight);
  }

  .hero-block-cta p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
  }
}
