/* ================================================
   JUEGOS DE JUAN — Estilo cómic/cartoon
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bangers&family=Fredoka:wght@400;600&display=swap');

/* ---- Variables ---- */
:root {
  --rojo:    #ff3b3b;
  --azul:    #1e90ff;
  --amarillo:#ffe135;
  --verde:   #00c853;
  --rosa:    #ff4fa3;
  --morado:  #7c3aed;
  --naranja: #ff7200;
  --cyan:    #00d4e8;

  --negro:   #111111;
  --blanco:  #ffffff;
  --fondo:   #fffbe6;

  --borde:   4px solid var(--negro);
  --shadow:  8px 8px 0 var(--negro);
  --shadow-lg: 12px 12px 0 var(--negro);
  --radius:  16px;

  --font-title: 'Bangers', cursive;
  --font-body:  'Fredoka', sans-serif;
}

/* ---- Reset básico ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--fondo);
  font-family: var(--font-body);
  color: var(--negro);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ================================================
   DECORACIÓN DE FONDO
   ================================================ */
.bg-deco {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.deco {
  position: absolute;
  font-family: var(--font-title);
  font-size: 2rem;
  opacity: 0.12;
  user-select: none;
  animation: float-spin 8s linear infinite;
}

.deco-star  { color: var(--negro); font-size: 2.5rem; }
.deco-pow   { color: var(--rojo);  font-size: 1.6rem; letter-spacing: 2px; }
.deco-dot   { color: var(--azul);  font-size: 3rem; }

.deco-1  { top: 5%;  left: 3%;  animation-duration: 7s;  }
.deco-2  { top: 15%; right: 5%; animation-duration: 9s; animation-direction: reverse; }
.deco-3  { top: 30%; left: 8%;  animation-duration: 11s; }
.deco-4  { top: 60%; right: 3%; animation-duration: 6s;  animation-direction: reverse; }
.deco-5  { top: 80%; left: 5%;  animation-duration: 10s; }
.deco-6  { top: 10%; left: 50%; animation-duration: 13s; animation-direction: reverse; }
.deco-7  { top: 45%; right: 8%; animation-duration: 8s;  }
.deco-8  { top: 70%; right: 15%;animation-duration: 12s; animation-direction: reverse; }
.deco-9  { top: 90%; left: 40%; animation-duration: 9s;  }
.deco-10 { top: 50%; left: 20%; animation-duration: 14s; }

@keyframes float-spin {
  0%   { transform: translateY(0)   rotate(0deg); }
  50%  { transform: translateY(-18px) rotate(180deg); }
  100% { transform: translateY(0)   rotate(360deg); }
}

/* ================================================
   HEADER
   ================================================ */
header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
  padding: 32px 48px 24px;
  background: var(--amarillo);
  border-bottom: var(--borde);
  box-shadow: 0 6px 0 var(--negro);
}

/* Logo JJ */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 90px;
  background: var(--rojo);
  border: var(--borde);
  border-radius: 50%;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  animation: wobble 3s ease-in-out infinite;
}

.logo-jj {
  font-family: var(--font-title);
  font-size: 2.8rem;
  color: var(--blanco);
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 var(--negro);
  line-height: 1;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-4deg) scale(1);   }
  25%       { transform: rotate(4deg)  scale(1.05); }
  50%       { transform: rotate(-2deg) scale(1);   }
  75%       { transform: rotate(3deg)  scale(1.04); }
}

.header-text { display: flex; flex-direction: column; gap: 4px; }

.site-title {
  font-family: var(--font-title);
  font-size: clamp(2.4rem, 6vw, 4rem);
  color: var(--negro);
  letter-spacing: 3px;
  text-shadow: 4px 4px 0 var(--rojo);
  line-height: 1;
}

.site-subtitle {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 600;
  color: var(--negro);
  background: var(--azul);
  display: inline-block;
  padding: 4px 12px;
  border: 3px solid var(--negro);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--negro);
  margin-top: 4px;
  color: var(--blanco);
}

/* ================================================
   MAIN / GRID
   ================================================ */
main {
  position: relative;
  z-index: 10;
  padding: 48px 40px;
  max-width: 1300px;
  margin: 0 auto;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 32px;
}

/* ================================================
   TARJETA DE JUEGO
   ================================================ */
.game-card {
  background: var(--blanco);
  border: var(--borde);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  transition:
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* animación de entrada */
  opacity: 0;
  animation: pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.game-card:hover {
  transform: rotate(-2deg) translateY(-8px);
  box-shadow: var(--shadow-lg);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.6) rotate(-6deg); }
  to   { opacity: 1; transform: scale(1)   rotate(0deg);  }
}

/* Zona de imagen/color */
.card-image {
  height: 170px;
  background-size: cover;
  background-position: center;
  border-bottom: var(--borde);
  position: relative;
  overflow: hidden;
}

.card-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 10px,
    rgba(0,0,0,0.04) 10px,
    rgba(0,0,0,0.04) 12px
  );
}

/* Badge (NUEVO, BETA…) */
.card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--amarillo);
  color: var(--negro);
  font-family: var(--font-title);
  font-size: 0.95rem;
  letter-spacing: 1px;
  padding: 3px 10px;
  border: 3px solid var(--negro);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--negro);
  z-index: 2;
  transform: rotate(3deg);
}

/* Indicador externo */
.card-ext-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--azul);
  color: var(--blanco);
  font-family: var(--font-title);
  font-size: 0.85rem;
  padding: 3px 8px;
  border: 3px solid var(--negro);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--negro);
  z-index: 2;
  transform: rotate(-2deg);
}

/* Contenido de la tarjeta */
.card-body {
  padding: 20px 20px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title {
  font-family: var(--font-title);
  font-size: 1.7rem;
  letter-spacing: 1px;
  line-height: 1.1;
  color: var(--negro);
}

.card-desc {
  font-size: 1rem;
  color: #333;
  line-height: 1.4;
  flex: 1;
}

/* Botón JUGAR */
.card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-title);
  font-size: 1.2rem;
  letter-spacing: 2px;
  color: var(--blanco);
  background: var(--verde);
  border: var(--borde);
  border-radius: 10px;
  padding: 10px 22px;
  box-shadow: 4px 4px 0 var(--negro);
  text-decoration: none;
  align-self: flex-start;
  margin-top: 6px;
  transition:
    transform 0.1s ease,
    box-shadow 0.1s ease;
  user-select: none;
}

.card-btn:hover {
  background: var(--naranja);
}

.card-btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--negro);
}

.card-btn .btn-icon { font-size: 1rem; }

/* ================================================
   MENSAJE DE ERROR / VACÍO
   ================================================ */
.grid-message {
  grid-column: 1 / -1;
  background: var(--amarillo);
  border: var(--borde);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 40px;
  text-align: center;
}

.grid-message h2 {
  font-family: var(--font-title);
  font-size: 2rem;
  margin-bottom: 12px;
}

.grid-message p {
  font-size: 1.05rem;
  line-height: 1.6;
}

.grid-message code {
  background: var(--negro);
  color: var(--amarillo);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: monospace;
}

/* ================================================
   REDES SOCIALES EN EL HEADER
   ================================================ */
.header-socials {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-title);
  font-size: 1rem;
  letter-spacing: 1px;
  color: var(--blanco);
  text-decoration: none;
  padding: 7px 14px;
  border: 3px solid var(--negro);
  border-radius: 10px;
  box-shadow: 4px 4px 0 var(--negro);
  transition:
    transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.1s ease;
  white-space: nowrap;
}

.social-btn:hover {
  transform: rotate(-3deg) translateY(-3px);
  box-shadow: 6px 6px 0 var(--negro);
}

.social-btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--negro);
}

.social-icon {
  display: flex;
  align-items: center;
  line-height: 1;
}

.social-github  { background: #24292e; }
.social-linkedin { background: #0077b5; }
.social-email   { background: var(--rojo); }
.social-coffee  { background: var(--naranja); }

/* ================================================
   BARRA DE CATEGORÍAS
   ================================================ */
.category-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 48px;
  background: var(--negro);
  border-bottom: 4px solid var(--negro);
  overflow-x: auto;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar { display: none; }

.cat-btn {
  font-family: var(--font-title);
  font-size: 1.05rem;
  letter-spacing: 1px;
  color: var(--negro);
  background: var(--blanco);
  border: 3px solid var(--blanco);
  border-radius: 10px;
  padding: 7px 18px;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(255,255,255,0.3);
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.15s ease,
    background 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.cat-btn:hover {
  transform: rotate(-2deg) translateY(-3px);
  box-shadow: 6px 6px 0 rgba(255,255,255,0.4);
}

.cat-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 transparent;
}

.cat-btn.active {
  color: var(--blanco);
  border-color: var(--amarillo);
  box-shadow: 4px 4px 0 var(--amarillo);
  transform: rotate(-1deg);
}

.cat-btn[data-cat="Todos"].active    { background: var(--rojo); }
.cat-btn[data-cat="Acción"].active   { background: var(--naranja); }
.cat-btn[data-cat="Memoria"].active  { background: var(--morado); }
.cat-btn[data-cat="Puzzle"].active   { background: var(--azul); }
.cat-btn[data-cat="Plataformas"].active { background: var(--verde); }

/* Tarjeta oculta por filtro */
.game-card.hidden {
  display: none;
}

/* Mensaje "sin resultados" */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  font-family: var(--font-title);
  font-size: 1.8rem;
  color: var(--negro);
  padding: 40px 0;
  opacity: 0.5;
}

/* ================================================
   FOOTER
   ================================================ */
footer {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 24px;
  background: var(--negro);
  color: var(--blanco);
  font-family: var(--font-body);
  font-size: 1rem;
  border-top: var(--borde);
}

footer a {
  color: var(--amarillo);
  text-decoration: none;
  font-weight: 600;
}

footer a:hover { text-decoration: underline; }

.heart {
  color: var(--rojo);
  display: inline-block;
  animation: heartbeat 1.2s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.3); }
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 20px 20px;
    gap: 16px;
  }

  .logo { width: 72px; height: 72px; }
  .logo-jj { font-size: 2.2rem; }

  .header-socials {
    margin-left: 0;
    width: 100%;
  }

  .social-btn { font-size: 0.9rem; padding: 6px 11px; }

  .category-bar { padding: 12px 16px; gap: 8px; }

  main { padding: 32px 16px; }
  .games-grid { gap: 24px; }
}

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