/* ============================================
   GPT Image 2 Gallery - 暗色沉浸式画廊样式
   ============================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

/* --- CSS Variables / Design Tokens --- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #16161f;
  --bg-card-hover: #1c1c28;
  --bg-overlay: rgba(0, 0, 0, 0.85);
  --bg-lightbox: rgba(0, 0, 0, 0.92);
  
  --text-primary: #e8e8f0;
  --text-secondary: #9898b0;
  --text-muted: #5a5a70;
  --text-accent: #b8a0ff;
  
  --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --accent-gradient-hover: linear-gradient(135deg, #7b8ff0 0%, #8b60b5 100%);
  --accent-blue: #667eea;
  --accent-purple: #764ba2;
  --accent-gold: #f0c040;
  
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(102, 126, 234, 0.3);
  
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 8px 40px rgba(102, 126, 234, 0.15);
  --shadow-lightbox: 0 0 80px rgba(0, 0, 0, 0.5);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  
  --header-height: 64px;
  --max-width: 1440px;
  --gap: 16px;
  --columns: 4;
}

@media (max-width: 1200px) { :root { --columns: 3; } }
@media (max-width: 768px) { :root { --columns: 2; --gap: 10px; } }
@media (max-width: 480px) { :root { --columns: 2; --gap: 8px; } }

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Screen-reader only (SEO + 无障碍) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
}

.header-aibook {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  transition: color var(--transition-fast);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.header-aibook:hover {
  color: var(--accent-gold);
  border-color: rgba(240, 192, 64, 0.2);
  background: rgba(240, 192, 64, 0.05);
}

.header-aibook .arrow {
  transition: transform var(--transition-fast);
  font-size: 11px;
}

.header-aibook:hover .arrow {
  transform: translateX(3px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
  overflow: hidden;
}

.lang-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lang-btn.active {
  background: var(--accent-gradient);
  color: white;
}

.lang-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* --- Hero Section --- */
.hero {
  text-align: center;
  padding: 64px 24px 40px;
  max-width: 720px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #c8c8e0 50%, #9898c0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: clamp(14px, 2vw, 16px);
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 24px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-number {
  font-size: 28px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* --- Category Tags Bar --- */
.categories-bar {
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 0;
}

.categories-scroll {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.categories-scroll::-webkit-scrollbar { display: none; }

.category-tag {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--border-card);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-tag:hover {
  border-color: var(--border-glow);
  color: var(--text-primary);
  background: rgba(102, 126, 234, 0.08);
}

.category-tag.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
}

.category-tag .count {
  font-size: 11px;
  opacity: 0.7;
}

/* --- Gallery Grid (Masonry - 手动分列) --- */
.gallery-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px;
}

.gallery-grid {
  display: flex;
  gap: var(--gap);
  align-items: flex-start;
}

.gallery-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.gallery-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  animation: fadeInUp 0.5s ease both;
}

.gallery-item:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gallery-item-image {
  width: 100%;
  display: block;
  transition: transform var(--transition-smooth);
}

.gallery-item:hover .gallery-item-image {
  transform: scale(1.03);
}

/* --- 多图角标 --- */
.gallery-item-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  z-index: 5;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-item-badge svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  opacity: 0.8;
}

.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 14px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-prompt {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-item-actions {
  display: flex;
  gap: 8px;
}

.btn-copy-small {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-copy-small:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* --- Lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-lightbox);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 10;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.lightbox-content {
  display: flex;
  max-width: 92vw;
  max-height: 92vh;
  gap: 24px;
  align-items: stretch;
}

.lightbox-image-area {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 10;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lightbox-nav:disabled {
  opacity: 0.2;
  cursor: default;
}

.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }

.lightbox-image-wrapper {
  max-width: 60vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lightbox);
  transition: opacity 0.3s ease;
}

/* --- Lightbox 图片圆点指示器 --- */
.lightbox-dots {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.lightbox-dots:empty {
  display: none;
}

.lightbox-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  padding: 0;
}

.lightbox-dot.active {
  background: white;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
  transform: scale(1.2);
}

.lightbox-dot:hover:not(.active) {
  background: rgba(255, 255, 255, 0.6);
}

/* --- Lightbox 信息面板 --- */
.lightbox-info {
  width: 340px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-card);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* --- 提示词标签切换器 --- */
.lightbox-prompt-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.lightbox-prompt-tabs:empty {
  display: none;
  margin-bottom: 0;
}

.prompt-tab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 16px;
  border: 1px solid var(--border-card);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.prompt-tab.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
}

.prompt-tab:hover:not(.active) {
  border-color: var(--border-glow);
  color: var(--text-primary);
}

.lightbox-info-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.lightbox-prompt {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  margin-bottom: 20px;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  overflow-y: auto;
}

.lightbox-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.lightbox-cat-tag {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 12px;
  background: rgba(102, 126, 234, 0.15);
  color: var(--text-accent);
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.btn-copy {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-copy:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.btn-copy.copied {
  background: linear-gradient(135deg, #10b981, #059669);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: rgba(16, 185, 129, 0.95);
  color: white;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 2000;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* --- Loading / Load More --- */
.load-more-area {
  text-align: center;
  padding: 40px 24px;
}

.btn-load-more {
  padding: 14px 40px;
  font-size: 15px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-load-more:hover {
  border-color: var(--border-glow);
  color: var(--text-primary);
  background: rgba(102, 126, 234, 0.08);
}

.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-card);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Footer --- */
.footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 60px 24px 40px;
  text-align: center;
}

.footer-cta {
  max-width: 480px;
  margin: 0 auto 40px;
  padding: 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
}

.footer-cta-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.footer-cta-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.footer-cta-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 16px;
}

.footer-wechat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-accent);
  font-size: 14px;
  font-weight: 500;
}

.footer-disclaimer {
  font-size: 11px;
  color: rgba(90, 90, 112, 0.5);
  margin-top: 24px;
}

/* --- No Results --- */
.no-results {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.no-results-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.no-results-text {
  font-size: 16px;
}

/* --- Responsive for lightbox --- */
@media (max-width: 900px) {
  .lightbox-content {
    flex-direction: column;
    max-width: 95vw;
    max-height: 95vh;
  }
  
  .lightbox-image-area {
    max-height: 55vh;
  }
  
  .lightbox-image-wrapper {
    max-width: 90vw;
    max-height: 50vh;
  }
  
  .lightbox-info {
    width: 100%;
    max-height: 35vh;
    padding: 16px;
  }
  
  .lightbox-nav {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  
  .lightbox-prev { left: 4px; }
  .lightbox-next { right: 4px; }
  
  .lightbox-dots {
    bottom: 8px;
  }
}

@media (max-width: 480px) {
  .header-inner { padding: 0 16px; }
  .header-logo { font-size: 15px; }
  .header-aibook { font-size: 11px; padding: 4px 8px; }
  .header-divider { display: none; }
  
  .hero { padding: 40px 16px 24px; }
  .hero-stats { gap: 24px; }
  .hero-stat-number { font-size: 22px; }
  
  .categories-scroll { padding: 0 16px; }
  .category-tag { padding: 6px 12px; font-size: 12px; }
  
  .gallery-container { padding: 12px; }
  
  .lightbox-close { top: 12px; right: 12px; width: 32px; height: 32px; }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
