/* Gallery styles */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em; /* Increase gap to prevent overlap */
  width: 80%;
  max-width: 1200px;
  margin: 150px 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;
  }
}

.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(0, 0, 0, 0.9);
  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;
}

.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
}

.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

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

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

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

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

body.dark .close {
  color: #e0e0e0;
}

body.dark #caption,
body.dark #exif-info {
  color: #e0e0e0;
}

#loading {
  /* ... existing code ... */
  background: rgba(255, 255, 255, 0.8); /* 添加半透明背景 */
  padding: 20px;
  border-radius: 10px;
}

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

.tag {
    padding: 5px 15px;
    border: none;
    border-radius: 15px;
    background-color: #e1e1e1; 
    cursor: pointer;
    transition: all 0.3s ease;
}

.tag:hover {
    background: #45a049; /* 更深的绿色 */
}

body.dark .tag-filter {
    background: rgba(0, 0, 0, 0.9);
}

body.dark .tag {
    background: #333;
    color: #fff;
}

body.dark .tag:hover {
    background: #388E3C; /* 深色模式下的绿色 */
}

.tag-filter-vertical {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    max-height: 150px;
    overflow-y: auto;
    gap: 10px;
    padding: 10px;
    background: rgba(250, 250, 250, 0.9);
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tag-filter-vertical::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Webkit */
}
.tag-filter-vertical::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 10px;
}

/* 基础图片样式 */
.gallery img {
  width: 100%;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  opacity: 0;
  transform: translateY(30px); /* 修改为与flyIn动画一致的值 */
  position: relative;
  z-index: 1;
}

/* 已加载图片的基本样式 */
.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), 
              box-shadow 0.3s cubic-bezier(0.19, 1, 0.22, 1),
              z-index 0.1s;
  will-change: transform, box-shadow;
  opacity: 1; /* 确保图片可见，不依赖动画 */
}

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

/* 深色模式下的效果 */
body.dark .gallery img.loaded:hover,
body.dark .gallery img.loaded.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 img:hover,
body.modal-open .gallery img.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 img.loaded:hover,
body:not(.modal-open) .gallery img.loaded.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;
}

/* 置底按钮样式 */
.scroll-to-bottom {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(250, 250, 250, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(100px);
}

.scroll-to-bottom.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-to-bottom:hover {
    background: rgba(240, 240, 240, 0.95);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.scroll-to-bottom:active {
    transform: scale(0.95);
}

.scroll-to-bottom svg {
    width: 24px;
    height: 24px;
    fill: #666;
    transition: fill 0.3s ease;
}

.scroll-to-bottom:hover svg {
    fill: #333;
}

/* 深色模式样式 */
body.dark .scroll-to-bottom {
    background: rgba(50, 50, 50, 0.9);
}

body.dark .scroll-to-bottom:hover {
    background: rgba(60, 60, 60, 0.95);
}

body.dark .scroll-to-bottom svg {
    fill: #ccc;
}

body.dark .scroll-to-bottom:hover svg {
    fill: #fff;
}

/* 自动滚动指示器 */
.auto-scroll-indicator {
    position: fixed;
    bottom: 80px;
    right: 20px;
    padding: 8px 12px;
    background: rgba(250, 250, 250, 0.9);
    border-radius: 15px;
    font-size: 12px;
    color: #666;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

.auto-scroll-indicator.visible {
    opacity: 1;
    transform: translateX(0);
}

body.dark .auto-scroll-indicator {
    background: rgba(50, 50, 50, 0.9);
    color: #ccc;
}
