/* Gallery styles */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em; /* Increase gap to prevent overlap */
  width: 100%;
  max-width: 1400px;
  margin: 0 auto 20px; /* Adjust for header and tag filter */
  padding: 10px;
  flex-grow: 1; /* Ensure gallery takes up available space */
  align-items: flex-start; /* Align items to the top */
  opacity: 0; /* Start hidden */
  transition: opacity 1s; /* Fade-in effect */
}
   
/* Keyframes for image fly-in effect */
@keyframes flyIn {
  0% {
    transform: translateY(30px); /* 减少初始位移距离，从100px减到30px */
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Loading spinner animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Loading spinner styles */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(212, 175, 55, 0.3);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

.loading-paused {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.spinner-paused {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(212, 175, 55, 0.3);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
  margin-bottom: 10px;
}

/* EXIF info styles */
.exif-info {
  background: var(--bg-card);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  padding: 15px;
  margin: 10px 0;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.exif-info p {
  margin: 5px 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
}

.exif-info strong {
  color: var(--primary-color);
  font-weight: 600;
}

/* Dark theme for EXIF info */
body.dark .exif-info {
  background: var(--bg-card);
  border: 1px solid rgba(212, 175, 55, 0.2);
}

body.dark .exif-info strong {
  color: var(--accent);
}

.gallery .column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  position: relative; /* 确保子元素的z-index正常工作 */
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(15, 17, 23, 0.95);
  opacity: 1;
  transition: opacity 0.3s ease; /* 添加平滑过渡 */
}

.modal-content {
  margin: auto;
  margin-top: 100px; /* Top margin */
  display: block;
  max-width: 90%;
  max-height: 80%; /* Adjust to accommodate caption and exif-info */
  width: auto;
  height: auto;
  border: 1px solid rgba(212, 175, 55, 0.2);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: var(--text-secondary);
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
}

.modal-link {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-secondary);
  font-size: 33px;
  font-weight: bold;
  transition: 0.3s;
  z-index: 1001;
}

.modal-link a {
  color: var(--text-secondary);
  text-decoration: none;
}

.modal-link a:hover {
  color: var(--accent);
}

.close:hover,
.close:focus {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

#caption,
#exif-info {
  margin: auto;
  display: block;
  width: 90%;
  max-width: 700px;
  text-align: center;
  color: var(--text-secondary);
  padding: 10px 0;
}

/* Disable scrolling */
.no-scroll {
  overflow: hidden;
}

/* Dark theme styles */
body.dark .gallery img {
  box-shadow: 0 4px 8px var(--shadow-color); /* Darker shadow for dark mode */
}

body.dark .gallery img.loaded:hover {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.8), 0 0 15px rgba(212, 175, 55, 0.3); /* Darker shadow for hover in dark mode */
}

body.dark .close {
  color: var(--text-secondary);
}

body.dark .modal-link {
  color: var(--text-secondary);
}

body.dark .modal-link a {
  color: var(--text-secondary);
}

body.dark .modal-link a:hover {
  color: var(--accent);
}

body.dark .close:hover,
body.dark .close:focus {
  color: var(--accent);
}

body.dark #caption,
body.dark #exif-info {
  color: var(--text-secondary);
}

#loading {
  /* ... existing code ... */
  background: transparent; /* 去掉背景色 */
  padding: 20px;
  border-radius: 0; /* 去掉圆角 */
  border: none;
}

/* 标签筛选样式 */
.tag-filter {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: nowrap; /* 防止换行，使标签始终在同一行 */
    gap: 10px;
    padding: 10px;
    max-width: 90%;     
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 2px 5px var(--shadow-color);
    z-index: 100;
    overflow-x: auto;     /* 启用横向滚动 */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* 平滑滚动 */
    border: 1px solid rgba(212, 175, 55, 0.2);
    
    /* 隐藏滚动条 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
}
.tag-filter::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Webkit */
}

.tag {
    flex: 0 0 auto;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(212, 175, 55, 0.2);
    padding: 10px 15px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    text-align: center;
}

.tag::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.tag:hover {
    transform: translateY(-3px);
    color: var(--text-primary);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    background: transparent;
    border-color: var(--primary);
}

.tag:hover::before {
    transform: translateX(100%);
}

.tag.active {
    background: transparent;
    color: white;
    box-shadow: var(--glow);
    transform: translateY(-2px);
    border-color: var(--accent);
}

body.dark .tag-filter {
    background: var(--bg-card);
    border: 1px solid rgba(212, 175, 55, 0.2);
}

body.dark .tag {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(212, 175, 55, 0.2);
}

body.dark .tag:hover {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--primary);
}

body.dark .tag.active {
    background: transparent;
    color: white;
    border-color: var(--accent);
    box-shadow: var(--glow);
}

.tag-filter-vertical {
    position: fixed;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    max-width: 150px;
    background: transparent; /* 去掉背景 */
    backdrop-filter: blur(10px); /* 添加毛玻璃效果 */
    -webkit-backdrop-filter: blur(10px); /* Safari支持 */
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border: 1px solid rgba(212, 175, 55, 0.2);
}
.tag-filter-vertical::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Webkit */
}

/* 基础图片样式 */
.gallery img {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  opacity: 0;
  transform: translateY(30px); /* 修改为与flyIn动画一致的值 */
  position: relative;
  top: 0;
  left: 0;
  z-index: 1;
  border: none;
  display: block;
}

/* 图片容器样式 - 用于实现闪亮效果 */
.gallery .column {
  position: relative;
}

.gallery .column > div {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(212, 175, 55, 0.15);
  width: 100%;
  /* 移除固定宽高比，让图片保持原始比例 */
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1), 
              box-shadow 0.3s cubic-bezier(0.19, 1, 0.22, 1),
              z-index 0.1s;
  will-change: transform, box-shadow;
}

/* 添加闪亮效果 */
.gallery .column > div::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.8s ease;
  z-index: 2;
  pointer-events: none;
  border-radius: 10px;
}

/* 已加载图片的基本样式 */
.gallery img.loaded {
  animation: flyIn 0.5s ease-out forwards; /* 将动画时间从0.8s减少到0.5s使动画更快 */
  transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1), 
              z-index 0.1s;
  will-change: transform;
  opacity: 1; /* 确保图片可见，不依赖动画 */
}

/* 悬停样式 - 使用更长的动画时间 */
.gallery .column > div:hover,
.gallery .column > div.hover-active {
  transform: translate(1px, -2px) !important;
  box-shadow: -5px 12px 20px rgba(0, 0, 0, 0.5) !important;
  z-index: 10 !important;
}

/* 悬停时触发闪亮效果 */
.gallery .column > div:hover::before {
  transform: translateX(100%);
  transition-duration: 1s;
}

/* 深色模式下的效果 */
body.dark .gallery .column > div:hover,
body.dark .gallery .column > div.hover-active {
  box-shadow: -5px 12px 20px rgba(0, 0, 0, 0.8) !important;
}

/* 添加悬停区域占位元素样式 */
.hover-guard {
  position: absolute;
  z-index: 9;
  pointer-events: none;
}

/* 当模态窗口打开时禁用悬停效果 */
body.modal-open .gallery .column > div:hover,
body.modal-open .gallery .column > div.hover-active {
  transform: none !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
  z-index: 1 !important;
  transition: none !important;
}

/* 改进悬停效果在模态关闭后的恢复 */
body:not(.modal-open) .gallery .column > div:hover,
body:not(.modal-open) .gallery .column > div.hover-active {
  transition: transform 2s cubic-bezier(0.19, 1, 0.22, 1), 
              box-shadow 2s cubic-bezier(0.19, 1, 0.22, 1) !important;
}
