/* Estilos de la pantalla única (index.html): filtro, grid, FAB, modal, toast */

/* ── Filtro sticky de equipos ─────────────────────────────────────────── */
.team-filter {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm);
  overflow-x: auto;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--color-border);
  scrollbar-width: none;
}

.team-filter::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  border: none;
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.filter-chip.is-active {
  background: var(--color-accent);
  color: #000000;
}

.filter-chip__logo {
  width: 16px;
  height: 16px;
  object-fit: contain;
  border-radius: 50%;
}

/* ── Grid de memes (masonry vía CSS Columns, sin librerías) ─────────────── */
.memes-grid {
  columns: 2;
  column-gap: 8px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 8px 96px;
}

@media (min-width: 768px) {
  .memes-grid {
    columns: 3;
  }
}

@media (min-width: 1280px) {
  .memes-grid {
    columns: 4;
  }
}

.meme-card {
  position: relative;
  display: block;
  width: 100%;
  break-inside: avoid;
  margin-bottom: 8px;
  border-radius: 16px;
  overflow: hidden;
  background: #141414;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  /* Firefox tiene un bug conocido: los hijos position:absolute (acá el
     overlay de lupa y la barra de likes/dislikes) no se pintan bien
     dentro de un contenedor con "columns" (el masonry de .memes-grid).
     Forzar un nuevo contexto de composición saca a la card de ese
     problema de fragmentación. No afecta a Chrome/Safari. */
  transform: translateZ(0);
}

.meme-card:hover {
  transform: translateZ(0) scale(1.02);
  opacity: 0.92;
}

.meme-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.meme-card img.is-loaded {
  opacity: 1;
}

.meme-card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #ffffff;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.meme-card:hover .meme-card__overlay,
.meme-card:focus-visible .meme-card__overlay {
  opacity: 1;
  background: rgba(0, 0, 0, 0.35);
}

.meme-card__votes {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 6px;
  padding: 8px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.75), transparent);
}

.meme-card__vote-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.4);
  color: #ffffff;
  font-size: 0.75rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.meme-card__vote-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.meme-card__vote-btn[disabled] {
  cursor: default;
}

.meme-card__vote-btn.is-active {
  border-color: var(--color-accent);
  background: rgba(0, 255, 66, 0.25);
  color: var(--color-accent);
}

.meme-card__vote-btn--dislike.is-active {
  border-color: #ff5c5c;
  background: rgba(255, 92, 92, 0.25);
  color: #ff5c5c;
}

.meme-card--skeleton {
  background: linear-gradient(90deg, #1a1a1a 25%, #232323 37%, #1a1a1a 63%);
  background-size: 400% 100%;
  animation: mf-shimmer 1.4s ease infinite;
  cursor: default;
}

/* Alturas variables para simular el masonry antes de que carguen las
   imágenes reales — el patrón se repite cada 4 cards. */
.meme-card--skeleton:nth-child(4n + 1) {
  height: 200px;
}

.meme-card--skeleton:nth-child(4n + 2) {
  height: 280px;
}

.meme-card--skeleton:nth-child(4n + 3) {
  height: 180px;
}

.meme-card--skeleton:nth-child(4n + 4) {
  height: 320px;
}

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

.grid-status,
.grid-empty-state {
  column-span: all;
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-xl) var(--space-sm);
}

.grid-empty-state p {
  font-size: var(--fs-lg);
  margin-bottom: var(--space-md);
}

.grid-sentinel {
  break-inside: avoid;
  height: 1px;
}

/* ── FAB ───────────────────────────────────────────────────────────────── */
#fab-upload {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-accent);
  color: #000000;
  border-radius: 50px;
  padding: 14px 24px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 0 20px rgba(0, 255, 66, 0.4);
  z-index: 100;
  cursor: pointer;
  border: none;
  font-family: var(--font-heading);
}

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 95vh;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  padding: var(--space-md);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

@media (min-width: 600px) {
  .modal {
    align-items: center;
  }

  .modal__panel {
    border-radius: var(--radius-card);
    transform: translateY(16px);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.2s ease;
  }
}

.modal.is-open .modal__backdrop {
  opacity: 1;
}

.modal.is-open .modal__panel {
  transform: translateY(0);
  opacity: 1;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.modal__header h2 {
  margin: 0;
}

.modal__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal__close:hover {
  color: var(--color-text);
}

.modal-state {
  text-align: center;
}

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  color: var(--color-text);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 300;
}

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

/* ── Visor fullscreen ──────────────────────────────────────────────────── */
.viewer-modal {
  align-items: stretch;
  justify-content: stretch;
}

.viewer-modal .modal__backdrop {
  background: rgba(0, 0, 0, 0.95);
  transition: opacity 0.15s ease;
}

.viewer-modal__content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.viewer-modal.is-open .viewer-modal__content {
  opacity: 1;
}

.viewer-modal__header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.65), transparent);
}

.viewer-modal__header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.viewer-modal__icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.viewer-modal__icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.viewer-modal__vote-btn {
  height: 40px;
  padding: 0 var(--space-xs);
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.viewer-modal__vote-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.viewer-modal__vote-btn[disabled] {
  opacity: 0.6;
  cursor: default;
}

.viewer-modal__vote-btn.is-active {
  border-color: var(--color-accent);
  background: rgba(0, 255, 66, 0.15);
  color: var(--color-accent);
}

.viewer-modal__vote-btn--dislike.is-active {
  border-color: #ff5c5c;
  background: rgba(255, 92, 92, 0.15);
  color: #ff5c5c;
}

.viewer-modal__image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  opacity: 1;
  transition: opacity 0.1s ease;
}

.viewer-modal__image.is-switching {
  opacity: 0;
}

.viewer-modal__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.viewer-modal__nav--prev {
  left: var(--space-sm);
}

.viewer-modal__nav--next {
  right: var(--space-sm);
}

.viewer-modal__nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.viewer-modal__nav[disabled] {
  opacity: 0 !important;
  pointer-events: none;
}

@media (hover: hover) {
  .viewer-modal__content:hover .viewer-modal__nav:not([disabled]) {
    opacity: 1;
  }
}

@media (hover: none) {
  .viewer-modal__nav:not([disabled]) {
    opacity: 1;
  }
}

.viewer-modal__footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: var(--space-md) var(--space-sm);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.7), transparent);
  color: #ffffff;
}

.viewer-modal__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 4px;
}

.viewer-modal__team-logo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: contain;
}

.viewer-modal__team-logo--emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.viewer-modal__team-logo[hidden],
.viewer-modal__team-logo--emoji[hidden] {
  display: none;
}

.viewer-modal__sub {
  display: flex;
  gap: 8px;
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.7);
}

.viewer-modal__sub span:not(:last-child)::after {
  content: "·";
  margin-left: 8px;
}

/* ── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  padding: var(--space-md) var(--space-sm);
  background: linear-gradient(180deg, #0d0d0d, #000000);
  text-align: center;
}

@media (min-width: 700px) {
  .hero {
    text-align: left;
    padding: var(--space-lg) var(--space-sm);
  }
}

.hero-emojis {
  font-size: 1.5rem;
  margin: 0 0 4px;
}

.hero-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(28px, 5vw, 48px);
  color: #ffffff;
  margin: 0 0 8px;
  animation: fadeSlideUp 0.5s ease forwards;
}

.hero-title__accent {
  color: var(--color-accent);
}

.hero-subtitle {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: #888888;
  margin: 0;
  animation: fadeSlideUp 0.5s ease 0.15s forwards;
  opacity: 0;
}

@media (min-width: 500px) {
  .hero-subtitle {
    font-size: 1rem;
  }
}

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