/**
 * Decks View Styles
 * Beautiful deck list and builder UI matching the Cardboard design system
 */

/* Deck View Container */
#deckView {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Deck Controls Header */
.deck-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* Sort Cycle Button */
.deck-sort-cycle-btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.deck-sort-cycle-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.deck-sort-cycle-btn:active {
  transform: translateY(0);
}

/* Search Input */
.deck-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 300px;
  min-width: 120px;
}

.deck-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.deck-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 14px;
  font-family: var(--font-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.deck-search-input::placeholder {
  color: var(--text-tertiary);
}

.deck-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

/* Login Button */
.deck-login-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-primary);
  background: linear-gradient(135deg, var(--accent-board), var(--accent-deck));
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.deck-login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

.deck-login-btn:active {
  transform: translateY(0);
}

/* Deck List Scroll Container */
.deck-list-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* Deck Grid */
.deck-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

/* Deck Card - Compact List Item */
.deck-card {
  position: relative;
  background: transparent;
  padding: 16px 0;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid transparent;
}

/* Active Deck Indicator (Mine Mode) */
.deck-card-active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.05) 0%, rgba(124, 58, 237, 0.1) 100%);
  border-bottom-color: var(--accent);
}

.deck-card-active::after {
  background: linear-gradient(
    90deg,
    var(--accent-board) 0%,
    var(--accent) 50%,
    var(--accent-deck) 100%
  );
  height: 2px;
  opacity: 0.6;
}

.deck-active-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: white;
  border-radius: 6px;
  margin-left: auto;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
  animation: pulse-active 2s ease-in-out infinite;
}

@keyframes pulse-active {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
  }
  50% {
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.6);
  }
}

/* Animated Gradient Separator */
.deck-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent-board) 20%,
    var(--accent-deck) 50%,
    var(--accent-game) 80%,
    transparent 100%
  );
  background-size: 300% 100%;
  opacity: 0.25;
  animation: gradient-slide 12s ease-in-out infinite;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

@keyframes gradient-slide {
  0% {
    background-position: 0% 50%;
    opacity: 0.25;
  }
  25% {
    opacity: 0.4;
  }
  50% {
    background-position: 100% 50%;
    opacity: 0.25;
  }
  75% {
    opacity: 0.35;
  }
  100% {
    background-position: 0% 50%;
    opacity: 0.25;
  }
}

.deck-card:hover {
  background: rgba(255, 255, 255, 0.02);
}

.deck-card:hover::after {
  opacity: 0.7;
  filter: brightness(1.3);
  animation: gradient-slide-fast 6s ease-in-out infinite, shimmer 2s ease-in-out infinite;
}

@keyframes gradient-slide-fast {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes shimmer {
  0%, 100% {
    filter: brightness(1.3) drop-shadow(0 0 2px var(--accent-board));
  }
  50% {
    filter: brightness(1.5) drop-shadow(0 0 4px var(--accent-deck));
  }
}

.deck-card:active {
  background: rgba(255, 255, 255, 0.03);
}

/* Deck Header - Name + Vote Controls Inline */
.deck-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

/* Score Badge - Just the number */
.deck-score {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  padding: 3px 7px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.deck-score.positive {
  color: #6fbd7f;
  background: rgba(77, 155, 95, 0.12);
}

.deck-score.negative {
  color: #ff8270;
  background: rgba(241, 91, 62, 0.12);
}

/* Deck Title */
.deck-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Card Thumbnails Scroll Container */
.deck-cards-scroll {
  position: relative;
  margin-bottom: 8px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  cursor: grab;
}

.deck-cards-scroll:active {
  cursor: grabbing;
}

.deck-cards-track {
  display: flex;
  gap: 6px;
  padding: 4px 0;
  /* Ensure cards extend beyond viewport */
  width: max-content;
  max-width: none;
}

.deck-cards-scroll::-webkit-scrollbar {
  height: 4px;
}

.deck-cards-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.deck-cards-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.deck-cards-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Hide scrollbar on mobile */
@media (max-width: 700px) {
  .deck-cards-scroll {
    scrollbar-width: none;
  }

  .deck-cards-scroll::-webkit-scrollbar {
    display: none;
  }
}

/* Card Thumbnail - Stamp Size */
.deck-card-thumb {
  position: relative;
  width: 48px;
  min-width: 48px;
  height: 67px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.deck-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Deck Sprite Card - Uses background image from sprite sheet */
.deck-sprite-card {
  background-size: cover;
  background-position: center;
}

/* Quantity Badge */
.deck-card-qty {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Empty Deck Message */
.deck-empty-message {
  font-size: 13px;
  color: var(--text-tertiary);
  font-style: italic;
  padding: 8px 0;
}

/* Deck Meta - Below Thumbnails */
.deck-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-tertiary);
}

.deck-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.deck-meta-item svg {
  width: 13px;
  height: 13px;
  opacity: 0.6;
}

.deck-format {
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  text-transform: capitalize;
  font-weight: 500;
  font-size: 11px;
}


/* Empty State */
.deck-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.deck-empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.deck-empty-state h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.deck-empty-state p {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 24px 0;
  max-width: 400px;
}

/* Loading State */
.deck-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.deck-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.deck-loading p {
  font-size: 15px;
  color: var(--text-secondary);
}

/* Pagination */
.deck-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Left-aligned */
  gap: 12px;
  padding: 20px 16px;
  margin-top: 8px;
  flex-wrap: wrap; /* Allow wrapping on small screens */
}

.deck-page-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.deck-page-btn:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.deck-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.deck-page-btn svg {
  flex-shrink: 0;
}

.deck-page-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 70px;
  text-align: left;
  flex-shrink: 0;
}

/* Mobile pagination adjustments */
@media (max-width: 500px) {
  .deck-pagination {
    gap: 10px;
    padding: 16px 12px;
  }

  .deck-page-btn {
    padding: 7px 12px;
    font-size: 13px;
  }

  .deck-page-info {
    font-size: 12px;
    min-width: 60px;
  }
}

/* Desktop Layout */
@media (min-width: 700px) {
  .deck-list-container {
    padding: 20px 24px;
  }

  .deck-card {
    padding: 18px 0;
  }
}

/* Mobile adjustments */
@media (max-width: 500px) {
  .deck-controls {
    gap: 8px;
  }

  .deck-list-container {
    padding: 12px;
  }

  .deck-card {
    padding: 14px 0;
  }

  .deck-title {
    font-size: 15px;
  }

  .deck-meta {
    font-size: 11px;
  }

  .deck-card-thumb {
    width: 42px;
    min-width: 42px;
    height: 59px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .deck-card,
  .deck-vote-btn,
  .deck-sort-tab {
    transition: none;
  }

  .deck-card:hover {
    transform: none;
  }
}
