/**
 * 圖片燈箱樣式
 * 全螢幕圖片顯示，支援左右滑動
 */

.image-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-lightbox.active {
  display: block;
  opacity: 1;
}

/* 半透明背景遮罩 */
.lightbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  cursor: pointer;
}

/* 燈箱容器 */
.lightbox-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 圖片包裝器 */
.lightbox-image-wrapper {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  transition: transform 0.3s ease;
  user-select: none;
}

.lightbox-image-wrapper:active {
  cursor: grabbing;
}

/* 圖片本身 */
.lightbox-image {
  max-width: 100%;
  max-height: calc(90vh - 60px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* 圖片說明文字 */
.lightbox-caption {
  margin-top: 15px;
  color: #fff;
  font-size: 16px;
  text-align: center;
  max-width: 600px;
  line-height: 1.5;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 圖片計數器 */
.lightbox-counter {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  background-color: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 500;
}

/* 關閉按鈕 */
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.lightbox-close:hover {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  transform: rotate(90deg);
}

/* 上一張按鈕 */
.lightbox-prev {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.lightbox-prev:hover {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-50%) translateX(-5px);
}

/* 下一張按鈕 */
.lightbox-next {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.lightbox-next:hover {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-50%) translateX(5px);
}

/* 手機版樣式調整 */
@media (max-width: 768px) {
  .lightbox-image {
    max-height: calc(90vh - 100px);
  }
  
  .lightbox-caption {
    font-size: 14px;
    max-width: 90%;
    padding: 0 15px;
  }
  
  .lightbox-counter {
    bottom: 20px;
    font-size: 12px;
    padding: 6px 12px;
  }
  
  .lightbox-close {
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 20px;
  }
  
  .lightbox-prev,
  .lightbox-next {
    width: 45px;
    height: 45px;
    font-size: 20px;
  }
  
  .lightbox-prev {
    left: 10px;
  }
  
  .lightbox-next {
    right: 10px;
  }
}

/* 極小螢幕 */
@media (max-width: 480px) {
  .lightbox-image-wrapper {
    max-width: 95%;
    max-height: 95%;
  }
  
  .lightbox-image {
    max-height: calc(85vh - 80px);
  }
  
  .lightbox-caption {
    font-size: 13px;
    margin-top: 10px;
  }
  
  .lightbox-counter {
    bottom: 15px;
    font-size: 11px;
    padding: 5px 10px;
  }
  
  .lightbox-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .lightbox-prev,
  .lightbox-next {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .lightbox-prev {
    left: 5px;
  }
  
  .lightbox-next {
    right: 5px;
  }
}

/* 載入動畫 */
@keyframes lightboxFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.image-lightbox.active .lightbox-image-wrapper {
  animation: lightboxFadeIn 0.3s ease;
}

/* 防止背景滾動 */
body.lightbox-active {
  overflow: hidden;
}

/* 按鈕的通用樣式重置 */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  padding: 0;
  outline: none;
}

.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* 觸控裝置優化 */
@media (hover: none) and (pointer: coarse) {
  .lightbox-close:hover,
  .lightbox-prev:hover,
  .lightbox-next:hover {
    transform: none;
  }
  
  .lightbox-close:active {
    background-color: rgba(255, 255, 255, 0.4);
  }
  
  .lightbox-prev:active {
    background-color: rgba(255, 255, 255, 0.4);
  }
  
  .lightbox-next:active {
    background-color: rgba(255, 255, 255, 0.4);
  }
}
