/*
 * ============================================================
 * Mi Favorito — assets/css/main.css
 * Hoja de estilos principal del sistema
 *
 * Organización:
 * 1.  Variables CSS (tokens de diseño personalizables)
 * 2.  Reset y base
 * 3.  Tipografía
 * 4.  Layout principal (estructura de página)
 * 5.  Header
 * 6.  Barra de navegación inferior
 * 7.  Botones
 * 8.  Formularios e inputs
 * 9.  Tarjetas (card) — estilos flat / glass / neo
 * 10. Banner de campaña activa
 * 11. Buscador
 * 12. Componentes de ranking (posición, medallas, elemento)
 * 13. Grid de categorías
 * 14. Splash screen / portada
 * 15. Perfil de usuario
 * 16. Badges y etiquetas
 * 17. Utilidades y helpers
 * 18. Animaciones
 * 19. Responsive (tablet y escritorio)
 * ============================================================
 */

/* ============================================================
   1. VARIABLES CSS — Tokens de diseño
   Todas las variables se sobreescriben desde PHP via
   el apartado de apariencia del admin. El script PHP inyecta
   los valores de la BD como un bloque <style> en el <head>.
   ============================================================ */
:root {
  /* Colores principales */
  --color-acento:       #5B50F0;   /* Morado principal */
  --color-acento-rgb:   91, 80, 240;
  --color-acento-claro: #EEF0FF;   /* Fondo muy suave del acento */
  --color-acento-hover: #4840D4;   /* Acento más oscuro para hover */

  /* Fondo general */
  --color-fondo:        #EBEBEB;

  /* Superficies (tarjetas, header, navbar) */
  --color-superficie:   #FFFFFF;
  --color-superficie-2: #F5F5F8;   /* Segunda superficie, inputs */

  /* Textos */
  --color-texto:        #1A1A2E;   /* Texto principal, muy oscuro */
  --color-texto-2:      #6B7280;   /* Texto secundario, gris */
  --color-texto-3:      #9CA3AF;   /* Texto terciario, más suave */
  --color-texto-inv:    #FFFFFF;   /* Texto sobre fondo oscuro */

  /* Bordes */
  --color-borde:        rgba(0, 0, 0, 0.07);
  --color-borde-focus:  var(--color-acento);

  /* Posiciones del ranking */
  --color-oro:          #F59E0B;
  --color-plata:        #9CA3AF;
  --color-bronce:       #D97706;

  /* Estado de éxito / error */
  --color-exito:        #22C55E;
  --color-error:        #EF4444;
  --color-warning:      #F59E0B;
  --color-info:         #3B82F6;

  /* Tipografía */
  --font-heading: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
  --font-serif:   'Playfair Display', serif;
  --font-display: 'Clash Display', 'Syne', sans-serif;

  /* Escala de fuentes (sm por defecto) */
  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-md:   1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */
  --text-3xl:  1.875rem;  /* 30px */
  --text-4xl:  2.25rem;   /* 36px */
  --text-5xl:  3rem;      /* 48px */

  /* Bordes redondeados */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-2xl:  24px;
  --radius-full: 999px;

  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.16);
  --shadow-acento: 0 4px 20px rgba(91, 80, 240, 0.35);

  /* Espaciados */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Transiciones */
  --transition-fast:   0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow:   0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --header-height:   64px;
  --navbar-height:   72px;
  --max-width:       480px;   /* Ancho máximo del contenido en móvil */
  --content-padding: 16px;
}

/* ============================================================
   2. RESET Y BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-texto);
  background-color: var(--color-fondo);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  /* Espacio para header y navbar fijos */
  padding-top: var(--header-height);
  padding-bottom: calc(var(--navbar-height) + 8px);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-acento);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

a:hover { opacity: 0.8; }

ul, ol { list-style: none; }

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, textarea, select {
  font-family: var(--font-body);
  font-size: var(--text-base);
}

/* ============================================================
   3. TIPOGRAFÍA
   ============================================================ */

/* Headings: Syne — impactante, geométrica */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: 1.15;
  color: var(--color-texto);
}

h1 { font-size: var(--text-4xl); letter-spacing: -0.03em; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl);  }
h5 { font-size: var(--text-lg);  }
h6 { font-size: var(--text-md);  }

/* Clases de texto útiles */
.text-accent   { color: var(--color-acento); }
.text-muted    { color: var(--color-texto-2); font-size: var(--text-sm); }
.text-tiny     { font-size: var(--text-xs); color: var(--color-texto-3); }
.text-label    { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-texto-2); }
.text-bold     { font-weight: 700; }
.text-center   { text-align: center; }
.text-italic   { font-style: italic; }

/* Variantes de tipografía según ajuste del admin */
body.font-sans    { --font-body: 'DM Sans', sans-serif; }
body.font-mono    { --font-body: 'JetBrains Mono', monospace; }
body.font-serif   { --font-body: 'Playfair Display', serif; }
body.font-display { --font-body: 'Syne', sans-serif; --font-heading: 'Syne', sans-serif; }

/* Tamaños de texto según ajuste del admin */
body.text-xs   { font-size: 14px; }
body.text-sm   { font-size: 16px; }
body.text-base { font-size: 18px; }

/* ============================================================
   4. LAYOUT PRINCIPAL
   ============================================================ */

/* Contenedor central — limita el ancho y centra el contenido */
.contenedor {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--content-padding);
}

/* Contenido principal de cada página */
.pagina-contenido {
  padding: var(--space-4) 0 var(--space-6);
}

/* Separador visual */
.separador {
  height: 1px;
  background: var(--color-borde);
  margin: var(--space-4) 0;
}

/* ============================================================
   5. HEADER
   ============================================================ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-superficie);
  border-bottom: 1px solid var(--color-borde);
  display: flex;
  align-items: center;
  padding: 0 var(--content-padding);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo de la app */
.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}

.header-logo-icono {
  width: 65px;
  height: 65px;
  background: var(--color-acento);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: var(--text-lg);
  font-family: var(--font-heading);
  flex-shrink: 0;
  transition: transform var(--transition-normal);
}

.header-logo-icono.circulo {
  border-radius: var(--radius-full);
}

.header-logo-icono img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

.header-logo-icono:hover {
  transform: scale(1.05);
}

.header-logo-nombre {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-texto);
}

/* Avatar de usuario en header */
.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--color-acento-claro);
  border: 2px solid var(--color-borde);
  cursor: pointer;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.header-avatar:hover {
  transform: scale(1.08);
}

.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-acento);
  font-weight: 700;
  font-size: var(--text-sm);
}

/* ============================================================
   6. BARRA DE NAVEGACIÓN INFERIOR
   ============================================================ */

.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--navbar-height);
  background: var(--color-superficie);
  border-top: 1px solid var(--color-borde);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-2);
  padding-bottom: env(safe-area-inset-bottom, 0px); /* Safe area iOS */
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.navbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-2) var(--space-1);
  text-decoration: none;
  color: var(--color-texto-3);
  transition: color var(--transition-fast);
  position: relative;
  border-radius: var(--radius-md);
}

.navbar-item:hover {
  color: var(--color-acento);
  opacity: 1;
}

.navbar-item.activo {
  color: var(--color-acento);
}

.navbar-item-icono {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar-item-icono svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-fast);
}

.navbar-item.activo .navbar-item-icono svg {
  stroke-width: 2.4;
}

.navbar-item:active .navbar-item-icono svg {
  transform: scale(0.88);
}

.navbar-item-texto {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

/* Indicador activo (punto) */
.navbar-item.activo::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-acento);
  opacity: 0; /* Se activa con animación al cargar */
}

/* ============================================================
   7. BOTONES
   ============================================================ */

/* Botón base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px var(--space-6);
  border-radius: var(--radius-xl);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all var(--transition-normal);
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

/* Efecto ripple al hacer click */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  opacity: 0;
  border-radius: inherit;
  transition: opacity var(--transition-fast);
}

.btn:active::after { opacity: 1; }

/* Botón primario (morado lleno) */
.btn-primario {
  background: var(--color-acento);
  color: var(--color-texto-inv);
  box-shadow: var(--shadow-acento);
}

.btn-primario:hover {
  background: var(--color-acento-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(var(--color-acento-rgb), 0.45);
  opacity: 1;
  color: white;
}

.btn-primario:active {
  transform: translateY(0);
  box-shadow: var(--shadow-acento);
}

/* Botón secundario (borde) */
.btn-secundario {
  background: transparent;
  color: var(--color-texto-2);
  border: 2px solid var(--color-borde);
}

.btn-secundario:hover {
  border-color: var(--color-acento);
  color: var(--color-acento);
  opacity: 1;
}

/* Botón bloque (ancho completo) */
.btn-bloque {
  width: 100%;
  border-radius: var(--radius-xl);
  padding: 16px;
  font-size: var(--text-base);
}

/* Botón pequeño */
.btn-sm {
  padding: 8px 16px;
  font-size: var(--text-xs);
  border-radius: var(--radius-lg);
}

/* Botón icono (cuadrado) */
.btn-icono {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--color-superficie-2);
  color: var(--color-texto-2);
  flex-shrink: 0;
}

.btn-icono:hover {
  background: var(--color-acento-claro);
  color: var(--color-acento);
  opacity: 1;
}

/* Botón de votar */
.btn-votar {
  background: var(--color-acento);
  color: white;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: 0.03em;
  box-shadow: var(--shadow-acento);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-normal);
}

.btn-votar:hover {
  background: var(--color-acento-hover);
  transform: translateY(-1px);
  opacity: 1;
  color: white;
}

.btn-votar.votado {
  background: var(--color-exito);
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.35);
}

.btn-votar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Botón peligro (eliminar) */
.btn-peligro {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
  border: none;
}

.btn-peligro:hover {
  background: var(--color-error);
  color: white;
  opacity: 1;
}

/* ============================================================
   8. FORMULARIOS E INPUTS
   ============================================================ */

.form-grupo {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-texto-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--color-superficie);
  border: 1.5px solid var(--color-borde);
  border-radius: var(--radius-lg);
  color: var(--color-texto);
  font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-texto-3);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-acento);
  box-shadow: 0 0 0 3px rgba(var(--color-acento-rgb), 0.12);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 44px;
}

/* Input con icono a la izquierda */
.form-input-icono {
  position: relative;
}

.form-input-icono svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-texto-3);
  pointer-events: none;
}

.form-input-icono .form-input {
  padding-left: 44px;
}

/* Toggle / Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #D1D5DB;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-normal);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
  background: var(--color-acento);
}

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

/* ============================================================
   9. TARJETAS (CARD)
   Tres estilos: flat, glass, neo — seleccionable desde admin
   ============================================================ */

/* Base de tarjeta */
.card {
  background: var(--color-superficie);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  position: relative;
}

/* Estilo FLAT (sencillo, borde sutil) */
body.card-flat .card {
  box-shadow: none;
  border: 1.5px solid var(--color-borde);
}

/* Estilo GLASS (glassmorphism, sombra suave) — por defecto */
body.card-glass .card,
.card {
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Estilo NEO (neumorfismo, sombras internas) */
body.card-neo .card {
  box-shadow: 6px 6px 14px rgba(0,0,0,0.08), -6px -6px 14px rgba(255,255,255,0.9);
  border: none;
  background: var(--color-fondo);
}

/* Tarjeta con padding */
.card-body {
  padding: var(--space-5) var(--space-5);
}

/* ============================================================
   10. BANNER DE CAMPAÑA ACTIVA
   ============================================================ */

.banner-campania {
  background: var(--color-acento);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  margin: var(--space-4) var(--content-padding);
  position: relative;
  overflow: hidden;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* Trofeo decorativo de fondo */
.banner-campania::before {
  content: '';
  position: absolute;
  right: -10px;
  bottom: -20px;
  width: 140px;
  height: 140px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-2xl);
  transform: rotate(15deg);
}

.banner-campania-icono {
  position: absolute;
  right: 16px;
  bottom: 16px;
  opacity: 0.18;
  color: white;
}

.banner-campania-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
  width: fit-content;
  backdrop-filter: blur(8px);
}

.banner-campania-titulo {
  color: white;
  font-family: var(--font-campania-titulo, var(--font-heading));
  font-size: var(--size-campania-titulo, clamp(1.6rem, 7vw, 2.4rem));
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.banner-campania-descripcion {
  color: rgba(255,255,255,0.85);
  font-size: var(--text-sm);
  font-style: italic;
  line-height: 1.5;
}

/* ============================================================
   11. BUSCADOR
   ============================================================ */

.buscador-wrapper {
  margin: var(--space-3) var(--content-padding);
}

.buscador {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-superficie);
  border-radius: var(--radius-full);
  padding: 12px 20px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid transparent;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.buscador:focus-within {
  border-color: var(--color-acento);
  box-shadow: 0 0 0 3px rgba(var(--color-acento-rgb), 0.1);
}

.buscador svg {
  width: 18px;
  height: 18px;
  color: var(--color-texto-3);
  flex-shrink: 0;
}

.buscador-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-texto);
  font-size: var(--text-base);
  font-family: var(--font-body);
}

.buscador-input::placeholder {
  color: var(--color-texto-3);
}

/* ============================================================
   12. COMPONENTES DE RANKING
   ============================================================ */

/* Sección "Top 3 Destacados" en inicio */
.top3-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-5) var(--content-padding) var(--space-3);
}

.top3-titulo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
}

.top3-titulo h2 {
  font-size: var(--text-2xl);
  line-height: 1.1;
}

.top3-icono-trofeo {
  font-size: 1.4rem;
  line-height: 1;
}

.top3-badge-actualizado {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-texto-3);
  background: var(--color-superficie);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xs);
}

/* Tarjeta de elemento destacado (usado en inicio, Top 3) */
.elemento-destacado {
  margin: 0 var(--content-padding) var(--space-3);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--color-superficie);
}

.elemento-destacado-imagen {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--color-superficie-2);
  /* Altura fija en móvil, automática en tablet/PC según la imagen */
  height: 240px;
}

.elemento-destacado-imagen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top; /* Prioriza la parte superior (caras, sujetos) */
  display: block;
  transition: transform 0.4s ease;
}

/* Tablet: altura mayor para mostrar más imagen */
@media (min-width: 600px) {
  .elemento-destacado-imagen {
    height: 320px;
  }
}

/* PC: imagen proporcional y completa */
@media (min-width: 1024px) {
  .elemento-destacado-imagen {
    height: auto;
    aspect-ratio: 4 / 3;
  }
  .elemento-destacado-imagen img {
    object-fit: contain;      /* Imagen completa, sin recorte */
    object-position: center;
    background: var(--color-superficie-2);
  }
}

/* Zoom suave al pasar el ratón (solo escritorio) */
@media (hover: hover) and (min-width: 1024px) {
  .elemento-destacado:hover .elemento-destacado-imagen img {
    transform: scale(1.02);
  }
}

/* bloque duplicado eliminado */

/* Badge de posición (1, 2, 3...) */
.posicion-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 900;
  z-index: 2;
}

.posicion-badge-1 {
  background: var(--color-oro);
  color: white;
}

.posicion-badge-2 {
  background: rgba(255,255,255,0.9);
  color: var(--color-texto-2);
  backdrop-filter: blur(8px);
}

.posicion-badge-3 {
  background: rgba(255,255,255,0.9);
  color: var(--color-bronce);
  backdrop-filter: blur(8px);
}

.posicion-badge-otros {
  background: rgba(255,255,255,0.85);
  color: var(--color-texto-3);
  backdrop-filter: blur(8px);
  width: 32px;
  height: 32px;
  font-size: var(--text-sm);
}

/* Badge "EL FAVORITO" / "HOT" */
.badge-favorito {
  position: absolute;
  top: 12px;
  left: 60px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(30,20,60,0.65);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 2;
}

/* Información del elemento sobre la imagen */
.elemento-destacado-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-4);
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
}

.elemento-destacado-categoria {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-acento);
  margin-bottom: 4px;
}

.elemento-destacado-titulo {
  color: white;
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.2;
}

.elemento-destacado-autor {
  color: rgba(255,255,255,0.75);
  font-size: var(--text-sm);
  font-style: italic;
  margin-top: 2px;
}

/* Badge de votos */
.votos-badge {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(30,20,60,0.65);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  color: white;
  font-size: var(--text-sm);
  font-weight: 700;
  z-index: 2;
}

/* Área de botón votar (debajo de la imagen) */
.elemento-destacado-accion {
  padding: var(--space-3) var(--space-4);
  background: var(--color-superficie);
}

/* ============================================================
   Fila de elemento en lista de ranking (ranking.php)
   ============================================================ */

.lista-ranking {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0 var(--content-padding);
}

.fila-ranking {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-superficie);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--color-borde);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
}

.fila-ranking:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

/* Número de posición en la fila */
.fila-ranking-pos {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 900;
  flex-shrink: 0;
}

.fila-ranking-pos.pos-1 { background: var(--color-oro);   color: white; }
.fila-ranking-pos.pos-2 { background: #E5E7EB;             color: var(--color-texto-2); }
.fila-ranking-pos.pos-3 { background: #FDE68A;             color: var(--color-bronce); }
.fila-ranking-pos.pos-n { background: var(--color-superficie-2); color: var(--color-texto-3); }

/* Miniatura del elemento en la fila */
.fila-ranking-thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-superficie-2);
}

/* Info del elemento en la fila */
.fila-ranking-info {
  flex: 1;
  min-width: 0; /* Permite truncar texto con overflow */
}

.fila-ranking-titulo {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--color-texto);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.fila-ranking-autor {
  font-size: var(--text-sm);
  color: var(--color-texto-2);
  margin: 2px 0;
}

.fila-ranking-categoria {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--color-acento-claro);
  color: var(--color-acento);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Área derecha de la fila: votos + botón */
.fila-ranking-derecha {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  flex-shrink: 0;
}

.fila-ranking-votos {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 900;
  color: var(--color-texto);
  line-height: 1;
}

.fila-ranking-btn-votar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--color-acento-claro);
  color: var(--color-acento);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.fila-ranking-btn-votar:hover {
  background: var(--color-acento);
  color: white;
  transform: scale(1.1);
}

.fila-ranking-btn-votar.votado {
  background: var(--color-exito);
  color: white;
}

.fila-ranking-btn-votar svg {
  width: 16px;
  height: 16px;
}

/* Filtros del ranking (Más votados, Menos votados, Recientes) */
.ranking-filtros {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-3) var(--content-padding);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.ranking-filtros::-webkit-scrollbar { display: none; }

.filtro-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--color-borde);
  background: var(--color-superficie);
  color: var(--color-texto-2);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.filtro-btn:hover {
  border-color: var(--color-acento);
  color: var(--color-acento);
}

.filtro-btn.activo {
  background: var(--color-acento);
  color: white;
  border-color: var(--color-acento);
  box-shadow: var(--shadow-acento);
}

/* ============================================================
   13. GRID DE CATEGORÍAS
   ============================================================ */

.categorias-titulo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-5) var(--content-padding) var(--space-3);
  font-family: var(--font-heading);
}

.categorias-subtitulo {
  margin: 0 var(--content-padding) var(--space-4);
  color: var(--color-texto-2);
  font-size: var(--text-sm);
}

.grid-categorias {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin: 0 var(--content-padding);
}

.card-categoria {
  background: var(--color-superficie);
  border-radius: var(--radius-2xl);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--color-borde);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.card-categoria:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  opacity: 1;
}

.card-categoria.destacada {
  background: var(--color-acento);
  border-color: var(--color-acento);
}

/* Icono de la categoría */
.categoria-icono-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.categoria-icono-wrapper svg {
  width: 22px;
  height: 22px;
  stroke: white;
  stroke-width: 1.8;
  fill: none;
}

.card-categoria-nombre {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: var(--text-base);
  letter-spacing: -0.01em;
  color: var(--color-texto);
}

.card-categoria.destacada .card-categoria-nombre {
  color: white;
}

.card-categoria-elementos {
  font-size: var(--text-xs);
  color: var(--color-texto-3);
}

.card-categoria.destacada .card-categoria-elementos {
  color: rgba(255,255,255,0.75);
}

/* Flecha en categoría destacada */
.card-categoria-flecha {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-4);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* ============================================================
   14. SPLASH SCREEN / PORTADA
   ============================================================ */

.portada {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #F0F0F8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.portada.ocultar {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

.portada-trofeo {
  width: 140px;
  height: 140px;
  background: rgba(91, 80, 240, 0.1);
  border-radius: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-6);
  color: var(--color-acento);
  animation: portada-float 3s ease-in-out infinite;
}

.portada-trofeo svg {
  width: 72px;
  height: 72px;
}

@keyframes portada-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.portada-titulo {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 12vw, 4rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.portada-titulo span {
  color: var(--color-acento);
  font-style: italic;
}

/* Línea gradiente bajo el título */
.portada-linea {
  width: 60px;
  height: 3px;
  background: linear-gradient(to right, var(--color-acento), #E34D75);
  border-radius: var(--radius-full);
  margin: var(--space-3) auto;
}

.portada-subtitulo {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.portada-subtitulo em {
  color: var(--color-acento);
  font-style: italic;
}

.portada-descripcion {
  color: var(--color-texto-2);
  font-size: var(--text-base);
  max-width: 300px;
  margin: 0 auto var(--space-10);
  line-height: 1.6;
}

.portada-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
}

.portada-medal {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-superficie-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-acento);
  animation: pulse-suave 2s ease-in-out infinite;
}

.portada-medal svg {
  width: 28px;
  height: 28px;
}

@keyframes pulse-suave {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}

.portada-cta-texto {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-acento);
  font-style: italic;
}

/* Estrellas decorativas */
.portada-estrella {
  position: absolute;
  color: var(--color-oro);
  animation: girar-estrella 6s linear infinite;
}

.portada-estrella-2 {
  color: var(--color-acento);
  animation-duration: 8s;
  animation-direction: reverse;
}

@keyframes girar-estrella {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ============================================================
   15. PERFIL DE USUARIO
   ============================================================ */

.perfil-card {
  margin: var(--space-4) var(--content-padding);
  background: var(--color-superficie);
  border-radius: var(--radius-2xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.perfil-avatar-grande {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-full);
  background: var(--color-acento-claro);
  border: 3px solid var(--color-acento);
  margin: 0 auto var(--space-4);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 900;
  color: var(--color-acento);
}

.perfil-nombre {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  margin-bottom: 4px;
}

.perfil-email {
  color: var(--color-texto-2);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.perfil-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-borde);
  border-bottom: 1px solid var(--color-borde);
}

.perfil-stat {
  text-align: center;
}

.perfil-stat-numero {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 900;
  color: var(--color-acento);
  line-height: 1;
}

.perfil-stat-label {
  font-size: var(--text-xs);
  color: var(--color-texto-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-top: 3px;
}

/* ============================================================
   16. BADGES Y ETIQUETAS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-acento    { background: var(--color-acento-claro); color: var(--color-acento); }
.badge-exito     { background: #DCFCE7; color: #16A34A; }
.badge-error     { background: #FEE2E2; color: #DC2626; }
.badge-warning   { background: #FEF3C7; color: #D97706; }
.badge-gris      { background: var(--color-superficie-2); color: var(--color-texto-2); }

/* ============================================================
   17. UTILIDADES
   ============================================================ */

/* Espaciados */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mx-auto { margin-left: auto; margin-right: auto; }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }

/* Flexbox */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2      { gap: var(--space-2); }
.gap-3      { gap: var(--space-3); }
.gap-4      { gap: var(--space-4); }

/* Visibilidad */
.oculto     { display: none !important; }
.visible    { display: block !important; }
.invisible  { visibility: hidden; }

/* Overflow */
.truncar {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cargando (skeleton loader) */
.skeleton {
  background: linear-gradient(90deg,
    var(--color-superficie-2) 25%,
    #e2e8f0 50%,
    var(--color-superficie-2) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast / Notificación */
.toast-container {
  position: fixed;
  bottom: calc(var(--navbar-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-texto);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.exito { background: var(--color-exito); }
.toast.error { background: var(--color-error); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Estado vacío */
.estado-vacio {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-texto-3);
}

.estado-vacio svg {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  opacity: 0.35;
}

.estado-vacio p {
  font-size: var(--text-sm);
  max-width: 240px;
  margin: 0 auto;
}

/* ============================================================
   18. ANIMACIONES
   ============================================================ */

/* Entrada suave de elementos (stagger con CSS custom property) */
.animar-entrada {
  animation: entrada var(--transition-slow) both;
  animation-delay: calc(var(--indice, 0) * 60ms);
}

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

/* Fade in simple */
.fade-in {
  animation: fade-in 0.4s ease both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Bounce suave al votar */
@keyframes bounce-voto {
  0%  { transform: scale(1); }
  40% { transform: scale(1.3); }
  70% { transform: scale(0.9); }
  100%{ transform: scale(1); }
}

.bounce-voto { animation: bounce-voto 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* Pulso continuo */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.pulse { animation: pulse 2s ease-in-out infinite; }

/* Girar (loading) */
@keyframes girar {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.girar { animation: girar 1s linear infinite; }

/* ============================================================
   19. RESPONSIVE — Tablet y Escritorio
   ============================================================ */

/* Tablet (≥ 640px) */
@media (min-width: 640px) {
  :root {
    --content-padding: 24px;
    --max-width: 600px;
  }

  .grid-categorias {
    grid-template-columns: repeat(3, 1fr);
  }

  .elemento-destacado-imagen {
    height: 280px;
  }
}

/* Escritorio (≥ 1024px) */
@media (min-width: 1024px) {
  :root {
    --max-width: 1200px;
    --content-padding: 32px;
    --header-height: 72px;
  }

  /* En escritorio se mantiene el padding inferior para la navbar fija */
  body {
    padding-top: var(--header-height);
    padding-bottom: calc(var(--navbar-height) + 8px);
  }

  /* La navbar SIEMPRE permanece en la parte inferior — diseño tipo app móvil */
  /* No se convierte en sidebar lateral en ningún tamaño de pantalla */

  .grid-categorias {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Diseño de dos columnas en escritorio */
  .layout-dos-columnas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    align-items: start;
  }
}

/* ============================================================
   IMÁGENES COMPLETAS EN TABLET Y PC
   Añadido al final para que nada lo sobreescriba.
   Móvil no se toca — ya funciona correctamente.
============================================================ */
@media (min-width: 768px) {
  .elemento-destacado-imagen {
    height: auto !important;
    aspect-ratio: 16 / 9 !important;  /* Más apaisado = menos franja vacía */
  }
  .elemento-destacado-imagen img {
    object-fit: contain !important;
    object-position: center !important;
    background: var(--color-superficie-2);
  }
}