/* ============================================================
   GamePics — 游戏截图画廊 · 全站样式
   ============================================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Design Tokens ---------- */
:root {
  /* Backgrounds */
  --bg-primary: #07070b;
  --bg-secondary: #0e0e16;
  --bg-tertiary: #15151f;
  --bg-card: rgba(255, 255, 255, 0.025);
  --bg-card-hover: rgba(255, 255, 255, 0.055);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.14);
  --border-active: rgba(99, 102, 241, 0.5);

  /* Accent */
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-dark: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);

  /* Text */
  --text-primary: #e8eaf0;
  --text-secondary: #9099a8;
  --text-tertiary: #5a6275;
  --text-accent: #a5b4fc;

  /* Glass */
  --glass-bg: rgba(14, 14, 22, 0.82);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-blur: 24px;

  /* Spacing */
  --gap-xs: 4px;
  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 16px;
  --gap-xl: 24px;
  --gap-2xl: 32px;
  --gap-3xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 150ms;
  --t-normal: 280ms;
  --t-slow: 450ms;

  /* Layout */
  --header-h: 64px;
  --category-h: 52px;
  --content-top: calc(var(--header-h) + var(--category-h));
  --side-pad: 16px;
}

@media (min-width: 768px) {
  :root { --side-pad: 24px; }
}
@media (min-width: 1280px) {
  :root { --side-pad: 32px; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------- Selection ---------- */
::selection {
  background: var(--accent);
  color: #fff;
}

/* ============================================================
   Header
   ============================================================ */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border-bottom: 1px solid var(--glass-border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--gap-lg);
  height: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 var(--side-pad);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  text-decoration: none;
  color: var(--text-primary);
  flex-shrink: 0;
  transition: opacity var(--t-fast) ease;
}
.logo:hover { opacity: 0.8; }

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-light);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.logo-accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Search */
.search-wrapper {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color var(--t-fast) ease;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: all var(--t-normal) var(--ease-out);
}
.search-input::placeholder {
  color: var(--text-tertiary);
}
.search-input:focus {
  background: var(--bg-tertiary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-input:focus ~ .search-icon {
  color: var(--accent-light);
}

.search-shortcut {
  position: absolute;
  right: 12px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 0.75rem;
  pointer-events: none;
  transition: opacity var(--t-fast) ease;
}

.search-clear {
  position: absolute;
  right: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast) ease;
}
.search-clear:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.search-clear svg { width: 14px; height: 14px; }

.search-wrapper.has-query .search-shortcut { display: none; }
.search-wrapper.has-query .search-clear { display: flex; }

/* Header Stats */
.header-stats {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.stats-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Mobile header adjustments */
@media (max-width: 639px) {
  .logo-text { display: none; }
  .header-stats { display: none; }
  .search-wrapper { max-width: none; }
}

/* ============================================================
   Category Bar
   ============================================================ */
.category-bar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  z-index: 99;
  height: var(--category-h);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border-bottom: 1px solid var(--glass-border);
}

.category-scroll {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  height: 100%;
  padding: 0 var(--side-pad);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.category-scroll::-webkit-scrollbar { display: none; }

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: start;
  transition: all var(--t-normal) var(--ease-out);
  flex-shrink: 0;
}
.category-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.category-chip.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-glow);
}
.category-chip svg {
  flex-shrink: 0;
}

/* ============================================================
   Main Content Area
   ============================================================ */
.main {
  padding: calc(var(--content-top) + var(--gap-xl)) var(--side-pad) var(--gap-3xl);
  max-width: 1800px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ============================================================
   Masonry Gallery (JS-managed flexbox columns)
   列数由 JS 控制，CSS 只负责布局和间距
   ============================================================ */
.gallery {
  display: flex;
  gap: var(--gap-sm);
  align-items: flex-start;
}

@media (min-width: 640px)  { .gallery { gap: var(--gap-md); } }
@media (min-width: 1024px) { .gallery { gap: var(--gap-lg); } }

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

@media (min-width: 640px)  { .gallery-column { gap: var(--gap-md); } }
@media (min-width: 1024px) { .gallery-column { gap: var(--gap-lg); } }

/* ---------- Gallery Card ---------- */
.gallery-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  position: relative;
  transform: translateY(0);
  transition:
    transform var(--t-normal) var(--ease-out),
    border-color var(--t-normal) ease,
    box-shadow var(--t-normal) ease;
  animation: card-enter var(--t-slow) var(--ease-out) both;
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Image inside card */
.gallery-card img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 150px;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--t-slow) ease;
  background: var(--bg-tertiary);
}
.gallery-card img.loaded {
  opacity: 1;
  min-height: 0;
  aspect-ratio: auto;
  object-fit: initial;
}

/* Card overlay (shows on hover) */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.7) 0%,
    rgba(0, 0, 0, 0.15) 40%,
    transparent 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--gap-md);
  opacity: 0;
  transition: opacity var(--t-normal) ease;
  pointer-events: none;
}
.gallery-card:hover .card-overlay {
  opacity: 1;
}

.card-game {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.card-name {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card skeleton placeholder */
.card-skeleton {
  width: 100%;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}
.card-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.03) 50%,
    transparent 100%
  );
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ============================================================
   Loading / Empty / Error States
   ============================================================ */
.load-more {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-md);
  padding: var(--gap-2xl) 0;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}
.load-more.visible {
  display: flex;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

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



.empty-state,
.error-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-lg);
  padding: 80px var(--gap-xl);
  text-align: center;
  color: var(--text-tertiary);
}
.empty-state.visible,
.error-state.visible {
  display: flex;
}

.empty-state svg,
.error-state svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
}
.empty-state h2,
.error-state h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.empty-state p,
.error-state p {
  font-size: 0.875rem;
  max-width: 320px;
}

.retry-btn {
  padding: 10px 28px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-normal) var(--ease-out);
}
.retry-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

/* Skeleton Grid */
.skeleton-grid {
  column-count: 2;
  column-gap: var(--gap-sm);
  display: none;
}
.skeleton-grid.visible {
  display: block;
}

@media (min-width: 640px)  { .skeleton-grid { column-count: 3; column-gap: var(--gap-md); } }
@media (min-width: 1024px) { .skeleton-grid { column-count: 4; column-gap: var(--gap-lg); } }
@media (min-width: 1440px) { .skeleton-grid { column-count: 5; column-gap: var(--gap-lg); } }

.skeleton-card {
  break-inside: avoid;
  height: var(--h, 260px);
  margin-bottom: var(--gap-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}
@media (min-width: 640px)  { .skeleton-card { margin-bottom: var(--gap-md); } }
@media (min-width: 1024px) { .skeleton-card { margin-bottom: var(--gap-lg); } }

.skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.025) 50%,
    transparent 100%
  );
  animation: shimmer 1.8s ease-in-out infinite;
}

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.lightbox.open {
  display: flex;
  animation: lb-in var(--t-normal) var(--ease-out);
}

@keyframes lb-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Lightbox buttons */
.lightbox-btn {
  position: absolute;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: all var(--t-fast) ease;
}
.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.lightbox-close {
  top: var(--gap-lg);
  right: var(--gap-lg);
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.lightbox-close svg { width: 20px; height: 20px; }

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 72px;
  border-radius: var(--radius-md);
}
.lightbox-nav svg { width: 24px; height: 24px; }
.lightbox-prev { left: var(--gap-lg); }
.lightbox-next { right: var(--gap-lg); }

/* Mobile nav positioning */
@media (max-width: 639px) {
  .lightbox-nav {
    top: auto;
    bottom: 80px;
    transform: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
  }
  .lightbox-prev { left: var(--gap-xl); }
  .lightbox-next { right: var(--gap-xl); }
  .lightbox-close {
    top: var(--gap-md);
    right: var(--gap-md);
  }
}

/* Lightbox content */
.lightbox-content {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 60px 80px 80px;
  pointer-events: none;
}

@media (max-width: 639px) {
  .lightbox-content {
    padding: 56px 8px 140px;
  }
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--t-normal) ease;
  pointer-events: auto;
  user-select: none;
}
.lightbox-image.visible {
  opacity: 1;
}

.lightbox-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
}
.lightbox-spinner.visible {
  display: block;
}

/* Lightbox Info Bar */
.lightbox-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-lg) var(--gap-xl);
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
  pointer-events: none;
}

.lightbox-info-left,
.lightbox-info-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lightbox-info-right {
  align-items: flex-end;
}

.lightbox-game {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lightbox-filename {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.7);
}
.lightbox-counter {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}
.lightbox-size {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
}

@media (max-width: 639px) {
  .lightbox-info {
    padding: var(--gap-md) var(--gap-lg);
    padding-bottom: max(var(--gap-md), env(safe-area-inset-bottom));
  }
  .lightbox-filename {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ============================================================
   Back to Top
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: var(--gap-xl);
  right: var(--gap-xl);
  z-index: 50;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all var(--t-normal) var(--ease-out);
}
.back-to-top svg { width: 20px; height: 20px; }
.back-to-top:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ============================================================
   Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* Body scroll lock when lightbox is open */
body.lightbox-open {
  overflow: hidden;
}
