/* Trending Page Styles - cards, tabs, Daily Top 10, accessible modal
   Class names match views/trending.erb and public/js/trending.js exactly. */

.trending-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1rem;
}

.trending-header h1 {
  font-size: 2rem;
  margin: 0;
  text-align: center;
}

.time-window-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.tab-button {
  padding: 0.5rem 1rem;
  border: 2px solid #ddd;
  background: white;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.tab-button:hover {
  border-color: #4169e1;
  color: #4169e1;
}

.tab-button.active {
  background: #4169e1;
  color: white;
  border-color: #4169e1;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-controls label {
  font-weight: 500;
}

.sort-controls select {
  padding: 0.5rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.trending-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.meme-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  width: 280px;
  text-align: center;
  transition: transform 0.2s;
  cursor: pointer;
}

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

.meme-image {
  width: 100%;
  height: 280px;
  object-fit: cover;
  background: #f0f0f0;
}

.meme-card .meme-info {
  padding: 0.75rem;
}

.meme-card .meme-title {
  margin: 0;
  font-weight: 500;
  font-size: 0.95rem;
  word-wrap: break-word;
  max-height: 2.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meme-card .meme-meta {
  color: #777;
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.loading-state {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.scroll-observer {
  height: 1px;
  margin-top: 2rem;
}

/* Daily Top 10 pack surfaces */
.trending-rank-badge {
  background: #312e81;
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.75rem;
}

.trending-daily-banner {
  width: 100%;
  max-width: 860px;
  background: #eef2ff;
  color: #312e81;
  padding: 12px 18px;
  border-radius: 10px;
  text-align: center;
  font-weight: 600;
  margin-bottom: 8px;
}

.trending-daily-done {
  width: 100%;
  max-width: 860px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  margin-top: 12px;
}

.trending-daily-done a {
  margin-left: 12px;
  color: #e52e71;
  font-weight: 700;
  text-decoration: underline;
}

.trending-error {
  text-align: center;
  color: #666;
}

/* Accessible lightbox modal (focus-trapped, scroll-locked by trending.js) */
.trending-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  cursor: pointer;
  padding: 1rem;
}

.trending-modal-content {
  max-width: 90%;
  max-height: 90%;
  position: relative;
  cursor: default;
}

.trending-modal-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
}

.trending-modal-info {
  color: #fff;
  text-align: center;
  margin-top: 15px;
}

.trending-modal-info h3 {
  margin: 10px 0;
}

.trending-modal-meta {
  opacity: 0.8;
}

.trending-modal-nav {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.trending-modal-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #fff;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

.trending-modal-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.trending-modal-btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.trending-modal-links {
  margin-top: 12px;
}

.trending-modal-links a {
  text-decoration: underline;
  margin-right: 16px;
}

.trending-modal-links a:last-child {
  margin-right: 0;
}

.trending-modal-link-viewer {
  color: #86efac;
  font-weight: 700;
}

.trending-modal-link-community {
  color: #93c5fd;
}

.trending-modal-link-random {
  color: #f9a8d4;
}

.trending-modal-hint {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 10px;
}

/* Dark theme */
html.dark-mode .meme-card {
  background: #1e1e1e;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

html.dark-mode .meme-card .meme-title {
  color: #f5f5f5;
}

html.dark-mode .meme-card .meme-meta {
  color: #aaa;
}

html.dark-mode .meme-image {
  background: #2a2a2a;
}

html.dark-mode .tab-button {
  background: #1e1e1e;
  border-color: #444;
  color: #e0e0e0;
}

html.dark-mode .tab-button.active {
  background: #4169e1;
  color: #fff;
  border-color: #4169e1;
}

html.dark-mode .sort-controls select {
  background: #1e1e1e;
  color: #e0e0e0;
  border-color: #444;
}

html.dark-mode .loading-state,
html.dark-mode .trending-error {
  color: #aaa;
}

html.dark-mode .trending-daily-banner {
  background: #1e1b4b;
  color: #c7d2fe;
}

html.dark-mode .trending-daily-done {
  background: #052e16;
  border-color: #166534;
  color: #86efac;
}

@media (max-width: 768px) {
  .meme-card {
    width: 45%;
    min-width: 150px;
  }

  .trending-header h1 {
    font-size: 1.5rem;
  }

  .time-window-tabs {
    gap: 0.25rem;
  }

  .tab-button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .meme-card {
    width: 100%;
    max-width: 280px;
  }

  .trending-header {
    gap: 1rem;
  }

  .time-window-tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
    min-width: 80px;
  }
}
