/* ===== Photo Album Component ===== */

/* Keyframes - CHỈ dùng khi MỞ (giống footer lightbox) */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.photo-album-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}

.photo-stack {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  cursor: pointer;
  /* KHÔNG có transition khi đóng - chỉ có khi hover */
}

.photo-stack:not(.is-open):hover {
  transform: scale(1.02);
  transition: transform 0.3s ease;
}

/* ===== Photo Items ===== */

.photo-item {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transform-origin: top left;
  /* KHÔNG có transition - để đóng ngay lập tức giống footer lightbox */
  transition: none !important;
  animation: none !important;
}

/* ===== Hidden data container ===== */
.photo-hidden-data {
  display: none !important;
  visibility: hidden !important;
}

/* ===== Ảnh đầu tiên (Front) ===== */

.photo-front {
  background: #1a1a1a;
  border: 3px solid #ffb800;
  overflow: hidden;
}

.photo-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-count-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.85);
  color: #ffb800;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===== Các ảnh sau (Back) - Hiệu ứng xòe ===== */

.photo-back {
  background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
  border: 2px solid #f9a825;
  transform: rotate(calc(var(--photo-index) * 7deg));
}

.photo-back-content {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(249, 168, 37, 0.05) 10px,
    rgba(249, 168, 37, 0.05) 20px
  );
}

/* ===== Trạng thái mở (Grid Layout) - Giống footer lightbox ===== */

.photo-stack.is-open {
  display: grid !important; /* Grid thay vì flex */
  grid-template-columns: repeat(4, 1fr); /* 4 cột */
  grid-template-rows: repeat(2, 1fr); /* 2 hàng */
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 10000 !important;
  width: 85vw !important;
  max-width: 1200px !important;
  height: auto !important;
  aspect-ratio: auto !important;
  gap: 15px;
  padding: 30px;
  cursor: default;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 12px;
  animation: zoomIn 0.3s ease; /* CHỈ animation khi MỞ - đóng thì display:none ngay */
  transition: none !important; /* Không có transition khi đóng */
  overflow: visible; /* Không scroll */
}

.photo-stack.is-open .photo-item {
  position: relative !important; /* Không absolute nữa */
  width: 100% !important;
  height: 250px !important; /* Chiều cao cố định */
  flex: none !important;
  transform: rotate(0deg) scale(1) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  animation: zoomIn 0.3s ease; /* CHỈ animation khi MỞ */
}

/* Ẩn các ảnh vượt quá 8 (sẽ hiển thị qua pagination) */
.photo-stack.is-open .photo-item:nth-child(n+9):not(.photo-hidden-data) {
  display: none;
}

.photo-stack.is-open .photo-back {
  background: #1a1a1a;
  border: 3px solid #ffb800;
  overflow: hidden;
}

.photo-stack.is-open .photo-back-content {
  background: none;
  width: 100%;
  height: 100%;
}

/* Hiển thị ảnh thật khi mở */
.photo-stack.is-open .photo-back::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  z-index: 1;
}

/* ===== Photo Hint ===== */

.photo-hint {
  text-align: center;
  margin-top: 15px;
  color: #999;
  font-size: 0.85rem;
  opacity: 0;
  animation: fadeInHint 0.5s ease 0.5s forwards;
}

@keyframes fadeInHint {
  to {
    opacity: 1;
  }
}

.photo-hint i {
  color: #ffb800;
  margin-right: 5px;
}

/* ===== Empty State ===== */

.photo-album-empty {
  text-align: center;
  padding: 60px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed #444;
  border-radius: 8px;
  color: #999;
}

.photo-album-empty i {
  font-size: 3rem;
  color: #666;
  margin-bottom: 15px;
}

.photo-album-empty p {
  margin: 0;
  font-size: 1rem;
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .photo-album-container {
    max-width: 100%;
    padding: 0;
  }

  .photo-stack.is-open {
    grid-template-columns: repeat(2, 1fr); /* 2 cột trên mobile */
    grid-template-rows: repeat(4, 1fr); /* 4 hàng */
    width: 95vw !important;
    padding: 20px;
  }

  .photo-stack.is-open .photo-item {
    height: 180px !important;
  }
  
  .photo-pagination {
    bottom: 15px;
    padding: 8px 15px;
  }
  
  .photo-pagination-btn {
    width: 35px;
    height: 35px;
    font-size: 16px;
  }
}

/* ===== Close button khi mở - Giống footer lightbox ===== */

.photo-stack.is-open::after {
  content: "×";
  position: fixed;
  top: 30px;
  right: 50px;
  color: #ffb800;
  font-size: 50px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10001;
  line-height: 1;
  user-select: none;
  transition: all 0.3s ease;
}

.photo-stack.is-open::after:hover {
  color: #ffa500;
  transform: rotate(90deg);
}

/* ===== Pagination Controls ===== */

.photo-pagination {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 20px;
  border-radius: 25px;
  backdrop-filter: blur(10px);
}

.photo-pagination-btn {
  background: rgba(255, 184, 0, 0.2);
  border: 2px solid #ffb800;
  color: #ffb800;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 18px;
}

.photo-pagination-btn:hover:not(:disabled) {
  background: #ffb800;
  color: #000;
  transform: scale(1.1);
}

.photo-pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.photo-pagination-info {
  color: #ffb800;
  font-weight: 600;
  font-size: 14px;
  min-width: 80px;
  text-align: center;
}
