/* ============================================================
 * IT LEARN — Gallery + Lightbox (reusable)
 *   Dùng được trên trang chủ + các trang khóa học.
 *   Yêu cầu: page-nav.css đã load (dùng chung CSS variables).
 *
 *   Markup:
 *     <section class="gallery-section">
 *       <div class="gallery-grid">
 *         <figure class="gallery-item"><img …><figcaption>…</figcaption></figure>
 *         …
 *       </div>
 *     </section>
 *
 *   JS lightbox: assets/js/gallery.js (auto-injects modal vào body)
 * ============================================================ */

.gallery-section {
  padding: 70px 24px;
}
.gallery-section .head {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 40px;
}

/* Compact grid — fixed 4:3 tiles, multi-column responsive */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 1240px;
  margin: 0 auto;
}
@media (min-width: 640px)  { .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 980px)  { .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
@media (min-width: 1280px) { .gallery-grid { grid-template-columns: repeat(5, 1fr); gap: 16px; } }

.gallery-item {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  border-radius: var(--r, 16px);
  cursor: zoom-in;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line, rgba(255,255,255,.08));
  transition: transform .35s ease, border-color .25s, box-shadow .35s;
}
.gallery-item:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong, rgba(255,255,255,.14));
  box-shadow: 0 25px 55px -20px rgba(0,0,0,.5);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .55s ease, filter .35s ease;
}
.gallery-item:hover img { transform: scale(1.04); }

/* Featured tile (đầu tiên) span 2 cột × 2 hàng — chỉ áp dụng khi grid có >=4 ảnh */
@media (min-width: 640px) {
  .gallery-grid.has-featured > .gallery-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
  }
}

/* Variant compact — cho course pages (6 ảnh) — cap ở 3 cột */
@media (min-width: 980px) {
  .gallery-grid.is-compact { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1280px) {
  .gallery-grid.is-compact { grid-template-columns: repeat(3, 1fr); max-width: 1080px; }
}

.gallery-item figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 50px 16px 14px;
  background: linear-gradient(180deg, transparent 0%, rgba(8,13,31,.85) 70%, rgba(8,13,31,.95) 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .01em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.gallery-item:hover figcaption { opacity: 1; transform: translateY(0); }

/* Zoom-in icon góc phải khi hover */
.gallery-item::after {
  content: "";
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(8,13,31,.7);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23f1f5f9' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/><path d='M11 8v6'/><path d='M8 11h6'/></svg>");
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .25s, transform .25s;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.gallery-item:hover::after { opacity: 1; transform: scale(1); }

/* ============ LIGHTBOX ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 18, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 60px 24px;
  animation: lbFadeIn .25s ease-out;
}
.lightbox.is-open { display: flex; }
@keyframes lbFadeIn { from { opacity: 0; } to { opacity: 1; } }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 40px 80px -10px rgba(0,0,0,.6);
}
.lightbox-cap {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: #f1f5f9;
  font-size: 14px;
  font-weight: 500;
  background: rgba(8,13,31,.7);
  border: 1px solid var(--line-strong, rgba(255,255,255,.14));
  padding: 8px 16px;
  border-radius: 999px;
  max-width: calc(100% - 48px);
  text-align: center;
  backdrop-filter: blur(8px);
}
.lightbox-counter {
  position: absolute;
  top: 22px;
  left: 24px;
  color: var(--text-dim, #94a3b8);
  font-family: var(--mono, monospace);
  font-size: 12px;
  letter-spacing: .12em;
}
.lb-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line-strong, rgba(255,255,255,.14));
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.lb-btn:hover { background: rgba(255,255,255,.18); transform: scale(1.05); }
.lb-close { top: 18px; right: 18px; }
.lb-prev  { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-next  { right: 18px; top: 50%; transform: translateY(-50%); }
.lb-prev:hover, .lb-next:hover { transform: translateY(-50%) scale(1.05); }
@media (max-width: 640px) {
  .lb-btn { width: 40px; height: 40px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}
