/**
 * 懒加载图片样式
 * 提供加载状态的视觉反馈
 */

/* 懒加载图片基础样式 */
img[data-src] {
  transition: opacity 0.3s ease-in-out, filter 0.3s ease-in-out;
}

/* 加载中状态 */
.lazy-loading {
  opacity: 0.6;
  filter: blur(2px);
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
}

/* 加载完成状态 */
.lazy-loaded {
  opacity: 1;
  filter: none;
}

/* 加载失败状态 */
.lazy-error {
  opacity: 0.5;
  filter: grayscale(100%);
  border: 2px dashed #ccc;
}

/* 加载动画 */
@keyframes loading-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* 图片容器样式 */
.image-container {
  position: relative;
  overflow: hidden;
  background-color: #f8f9fa;
  border-radius: 8px;
}

.image-container::before {
  content: '';
  display: block;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 宽高比 */
}

.image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* 加载指示器 */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lazy-loading .loading-indicator {
  opacity: 1;
}

.loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 响应式图片网格 */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

@media (max-width: 768px) {
  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .image-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* 图片卡片样式 */
.image-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.image-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.image-card .image-container {
  border-radius: 0;
}

.image-card-content {
  padding: 15px;
}

.image-card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: #333;
  line-height: 1.4;
}

.image-card-description {
  font-size: 14px;
  color: #666;
  margin: 0;
  line-height: 1.5;
}

/* 缩略图样式 */
.thumbnail {
  width: 100px;
  height: 75px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.thumbnail:hover {
  transform: scale(1.05);
}

/* 全屏图片查看器 */
.image-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-viewer.active {
  opacity: 1;
  visibility: visible;
}

.image-viewer img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
}

.image-viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 图片优化提示 */
.webp-support {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #28a745;
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1000;
}

.webp-support.show {
  opacity: 1;
  transform: translateY(0);
}

/* 性能监控指示器 */
.performance-indicator {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.performance-indicator.show {
  opacity: 1;
}

/* 无障碍支持 */
@media (prefers-reduced-motion: reduce) {
  .lazy-loading,
  .lazy-loaded,
  .image-card,
  .thumbnail {
    transition: none;
    animation: none;
  }
  
  .loading-shimmer {
    animation: none;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .image-card {
    border: 2px solid #000;
  }
  
  .lazy-error {
    border-color: #000;
  }
}

/* 打印样式 */
@media print {
  .loading-indicator,
  .image-viewer,
  .webp-support,
  .performance-indicator {
    display: none !important;
  }
  
  .image-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}