/**
 * Gamepix Integration Styles
 * Matches existing dark theme from styles.css
 */

/* Gamepix Toggle Switch */
.gamepix-toggle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--line-dim);
  animation: rise-in 0.5s ease backwards;
}

.gamepix-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--void-2);
  border: 1px solid var(--line-dim);
  border-radius: 100px;
}

.gamepix-toggle-label {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--arc-fg-mid);
  transition: color 0.2s ease, font-weight 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}

.gamepix-toggle-label[data-mode="local"] {
  font-weight: 700;
  color: var(--arc-accent);
}

.gamepix-toggle {
  position: relative;
  width: 56px;
  height: 28px;
  flex-shrink: 0;
}

.gamepix-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.gamepix-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--line-dim);
  border-radius: 28px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.gamepix-toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--arc-fg-dim);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.3s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.gamepix-toggle input:checked + .gamepix-toggle-slider {
  background: var(--arc-accent);
  box-shadow: 0 0 16px var(--arc-glow-ring);
}

.gamepix-toggle input:checked + .gamepix-toggle-slider::before {
  transform: translateX(28px);
  background: var(--void);
}

.gamepix-toggle input:focus-visible + .gamepix-toggle-slider {
  outline: 2px solid var(--arc-accent);
  outline-offset: 2px;
}

/* Gamepix Controls */
.gamepix-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
  animation: fade-in 0.3s ease;
}

.gamepix-search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.gamepix-search input {
  width: 100%;
  background: var(--void);
  border: 1px solid var(--line-dim);
  color: var(--phosphor);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gamepix-search input:focus {
  border-color: var(--phosphor-dim);
  box-shadow: 0 0 0 1px var(--arc-ring);
}

.gamepix-search input::placeholder {
  color: var(--arc-fg-dim);
  opacity: 0.7;
}

.gamepix-filter {
  min-width: 180px;
}

.gamepix-category-select {
  width: 100%;
  background: var(--void);
  border: 1px solid var(--line-dim);
  color: var(--phosphor);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b8f4e0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.gamepix-category-select:focus {
  border-color: var(--phosphor-dim);
  box-shadow: 0 0 0 1px var(--arc-ring);
}

/* Gamepix Section */
.gamepix-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 40px 80px;
}

.gamepix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  animation: rise-in 0.5s ease backwards;
}

.gamepix-header h2 {
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--arc-fg-bright);
  background: linear-gradient(120deg, var(--arc-fg-bright) 0%, var(--arc-fg-mid) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.gamepix-stats {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--arc-fg-dim);
  letter-spacing: 0.04em;
}

/* Gamepix Grid */
#gamepix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px 20px;
}

/* Gamepix tiles use existing .arc-tile styles from styles.css */
.gamepix-tile .tile-category {
  display: block;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--arc-fg-dim);
  margin-top: 4px;
  opacity: 0.8;
}

/* Gamepix Image Quality Fixes */
.gamepix-tile .tile-thumb {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

.gamepix-tile .tile-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  image-rendering: auto; /* Override pixelated for high-res Gamepix images */
  transition: transform 0.3s ease;
}

.gamepix-tile:hover .tile-icon { 
  transform: scale(1.06); 
}

/* Fallback image styling */
.gamepix-tile .tile-icon[src*="fallback"],
.gamepix-tile .tile-icon[src*="small.png"] {
  image-rendering: crisp-edges;
}

/* Gamepix Pagination */
.gamepix-pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line-dim);
}

.gamepix-load-more-btn {
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 14px 36px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  min-width: 180px;
}

.gamepix-load-more-btn:hover:not(:disabled) {
  background: var(--phosphor-dim);
  color: var(--void);
  box-shadow: 0 0 24px -6px var(--phosphor-dim);
  border-color: var(--phosphor-dim);
}

.gamepix-load-more-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.gamepix-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--arc-fg-mid);
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.gamepix-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-dim);
  border-top-color: var(--arc-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Gamepix Empty State */
.gamepix-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--arc-fg-dim);
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.gamepix-empty p {
  margin: 0;
}

/* Responsive adjustments */
@media (max-width: 720px) {
  .gamepix-toggle-container {
    margin-top: 16px;
    padding: 12px 0;
  }

  .gamepix-toggle-wrapper {
    gap: 12px;
    padding: 6px 12px;
  }

  .gamepix-toggle-label {
    font-size: 10.5px;
  }

  .gamepix-toggle {
    width: 48px;
    height: 24px;
  }

  .gamepix-toggle-slider::before {
    width: 18px;
    height: 18px;
    top: 3px;
    left: 3px;
  }

  .gamepix-toggle input:checked + .gamepix-toggle-slider::before {
    transform: translateX(24px);
  }

  .gamepix-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .gamepix-search,
  .gamepix-filter {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .gamepix-section {
    padding: 0 18px 60px;
  }

  #gamepix-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }

  .gamepix-header {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .gamepix-header h2 {
    font-size: 22px;
  }

  .gamepix-pagination {
    margin-top: 28px;
    padding-top: 18px;
  }
}

@media (max-width: 420px) {
  .gamepix-toggle-label {
    font-size: 9.5px;
  }

  .gamepix-search input,
  .gamepix-category-select {
    padding: 8px 12px;
    font-size: 11.5px;
  }
}

/* Dark theme adjustments */
html[data-theme="mono"] .gamepix-toggle input:checked + .gamepix-toggle-slider {
  background: var(--arc-accent);
}

html[data-theme="mono"] .gamepix-toggle input:checked + .gamepix-toggle-slider::before {
  background: var(--void);
}

html[data-theme="mono"] .gamepix-load-more-btn:hover:not(:disabled) {
  background: var(--arc-accent);
  color: var(--void);
}