/* ==========================================================================
   lightbox.css
   สไตล์ตัวดูภาพแบบเลื่อนซ้าย-ขวา (js/lightbox.js) พื้นมืด ภาพอยู่กลางจอ ลูกศรสองข้าง แถบภาพย่อด้านล่าง
   ========================================================================== */

/* รูปย่อที่กดแล้วเปิดตัวดูภาพได้: เมาส์เป็นรูปแว่นขยาย */
a[data-lightbox] { cursor: zoom-in; }

/* เปิดตัวดูภาพอยู่: ไม่ให้หน้าหลังเลื่อนตาม */
html.lb-lock { overflow: hidden; }

.lb {
  --lb-gold: #f4ce14;
  position: fixed;
  inset: 0;
  z-index: 3000;                       /* เหนือแถบหัวหน้าเว็บ (sticky) ทุกชนิด */
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(6, 14, 32, 0.95);
  color: #fff;
  animation: lb-fade 0.18s ease-out;
}
.lb[hidden] { display: none; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }

/* แถบบน: ตัวนับรูป / เปิดภาพเต็ม / ปุ่มปิด */
.lb-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
}
.lb-count { font-weight: 700; letter-spacing: 0.04em; margin-right: auto; }
.lb-open {
  color: #cfe0ff;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.lb-open:hover, .lb-open:focus-visible { color: #fff; }

.lb-btn {
  border: 0;
  cursor: pointer;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.15s ease, transform 0.15s ease;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.28); }
.lb-btn:focus-visible,
.lb-open:focus-visible,
.lb-thumb:focus-visible { outline: 3px solid var(--lb-gold); outline-offset: 2px; }
.lb-close {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ลูกศรซ้าย-ขวา ลอยกลางความสูงของจอ */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.lb-nav:hover { transform: translateY(-50%) scale(1.08); }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }

/* พื้นที่แสดงภาพ */
.lb-stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 4.5rem;
  position: relative;
}
.lb-img {
  max-width: 100%;
  max-height: calc(100vh - 250px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: #111;
  transition: opacity 0.2s ease;
}
.lb.lb-loading .lb-img { opacity: 0.25; }
.lb.lb-error .lb-img { display: none; }
.lb-cap {
  margin-top: 0.75rem;
  max-width: 900px;
  text-align: center;
  color: #d4e2fb;
  font-size: 0.95rem;
  min-height: 1.4em;
}

/* ตัวหมุนตอนกำลังโหลดภาพ */
.lb-spin {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--lb-gold);
  border-radius: 50%;
  animation: lb-spin 0.8s linear infinite;
  opacity: 0;
  pointer-events: none;
}
.lb.lb-loading .lb-spin { opacity: 1; }
@keyframes lb-spin { to { transform: rotate(360deg); } }

/* แถบภาพย่อด้านล่าง เลื่อนแนวนอนได้ รูปที่ดูอยู่มีขอบทอง */
.lb-strip {
  width: 100%;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0.75rem 1rem 1rem;
  justify-content: safe center;
  scrollbar-width: thin;
}
.lb-thumb {
  flex: none;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: #222;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.lb-thumb:hover { opacity: 0.9; }
.lb-thumb.active { opacity: 1; border-color: var(--lb-gold); }
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* รูปเดียว: ไม่มีอะไรให้เลื่อน ซ่อนลูกศร ตัวนับ และแถบภาพย่อ */
.lb.lb-single .lb-nav,
.lb.lb-single .lb-strip,
.lb.lb-single .lb-count { display: none; }
.lb.lb-single .lb-img { max-height: calc(100vh - 150px); }

/* มือถือ: ภาพเต็มความกว้าง ลูกศรเล็กลง (ปัดนิ้วเป็นหลัก) ภาพย่อเล็กลง */
@media (max-width: 767.98px) {
  .lb-stage { padding: 0 0.5rem; }
  .lb-nav { width: 40px; height: 40px; }
  .lb-prev { left: 0.4rem; }
  .lb-next { right: 0.4rem; }
  .lb-img { max-height: calc(100vh - 220px); border-radius: 6px; }
  .lb-thumb { width: 48px; height: 48px; }
}
/* จอเตี้ย (มือถือแนวนอน): ตัดแถบภาพย่อเพื่อให้ภาพใหญ่ที่สุด */
@media (max-height: 520px) {
  .lb-strip { display: none; }
  .lb-img { max-height: calc(100vh - 110px); }
}

@media (prefers-reduced-motion: reduce) {
  .lb, .lb-img, .lb-btn, .lb-thumb { animation: none !important; transition: none !important; }
  .lb-spin { animation-duration: 2s; }
}
