/* Sistema de variables CSS coherente - Wallpari Analytics */
/* Paleta Profesional: Clean Nordic (Inspirada en Stripe, Apple, Vercel) */
:root {
  /* Fondos - Blanco y gris ultra claro */
  --bg-primary: #fcfcfc;        /* Blanco cálido - Fondo principal */
  --bg-secondary: #f8f9fa;      /* Gris ultra claro - Fondo secundario */
  --bg-tertiary: #f1f3f5;       /* Gris muy claro - Fondo terciario */
  --bg-card: #ffffff;           /* Blanco puro para cards */

  /* Paleta de Marca - Azul Cobalto Intenso */
  --brand-primary: #0055ff;     /* Azul cobalto - Principal */
  --brand-secondary: #0066ff;   /* Azul cobalto claro - Secundario */
  --brand-accent: #0044dd;      /* Azul cobalto oscuro - Accent */

  /* Aliases para compatibilidad */
  --cyan-300: #67e8f9;
  --cyan-400: #22d3ee;
  --cyan-500: #06b6d4;
  --cyan-600: #0891b2;
  --cyan-700: #0e7490;

  /* Impacto (semáforo profesional) */
  --impact-5: #dc2626;          /* Red 600 - Crítico */
  --impact-4: #ea580c;          /* Orange 600 - Alto */
  --impact-3: #ca8a04;          /* Yellow 600 - Medio */
  --impact-2: #16a34a;          /* Green 600 - Bajo */
  --impact-1: #059669;          /* Emerald 600 - Muy bajo */

  /* Estados semánticos */
  --error: #dc2626;
  --warning: #ea580c;
  --success: #16a34a;
  --info: #0055ff;

  /* Textos - Negro intenso y grises oscuros (WCAG AAA optimizado) */
  --text-primary: #000000;      /* Negro puro - Principal - Ratio 21:1 */
  --text-secondary: #1a1a1a;    /* Negro suave - Secundario - Ratio 16.54:1 */
  --text-tertiary: #525252;     /* Gris oscuro - Terciario - Ratio 7.09:1 AAA */
  --text-muted: #666666;        /* Gris medio - Muted - Ratio 5.74:1 AAA (mejorado de #737373) */
  --text-disabled: #8a8a8a;     /* Gris claro - Disabled - Ratio 4.52:1 AA (mejorado de #a3a3a3) */

  /* Bordes y divisores */
  --border-primary: #e5e7eb;    /* Gris muy claro */
  --border-secondary: #d1d5db;  /* Gris claro */
  --border-accent: #0055ff;     /* Azul cobalto */

  /* Espaciado (escala 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Sistema de z-index centralizado */
  --z-background: 0;
  --z-content: 1;
  --z-stars-initial: 100;
  --z-tooltip: 1000;
  --z-skip-link: 10000;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  min-height: 100vh;
  padding: var(--space-5);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

/* Gradiente sutil Clean Nordic - Minimalista */
/* Movido a html::before para evitar conflicto con logos decorativos */
html::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-background);
  background: radial-gradient(
    ellipse 100% 60% at 50% 0%,
    rgba(0, 85, 255, 0.03),
    transparent 70%
  );
}

/* Animación de pulsación suave para logos */
@keyframes logoPulse {
  0%, 100% {
    opacity: 0.08;
    transform: scale(1);
  }
  50% {
    opacity: 0.15;
    transform: scale(1.05);
  }
}

@keyframes logoFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Logos decorativos vía pseudo-elementos (solo desktop ≥768px) */
/* Optimización: CSS pseudo-elementos en lugar de 12 divs en HTML */
@media (min-width: 768px) {
  /* Logos izquierdos usando ::before en body */
  body::before {
    content: '';
    position: fixed;
    width: 220px;
    height: 300px;
    pointer-events: none;
    z-index: var(--z-background);
    background-image: url('../../../../assets/images/logo/wallpari-transparent.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.12;
    top: 8%;
    left: 5%;
    animation: logoPulse 4s ease-in-out infinite;
  }

  /* Logo derecho superior usando ::after en header */
  .research-header::before {
    content: '';
    position: fixed;
    width: 220px;
    height: 300px;
    pointer-events: none;
    z-index: var(--z-background);
    background-image: url('../../../../assets/images/logo/wallpari-transparent.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.12;
    top: 12%;
    right: 6%;
    animation: logoPulse 4s ease-in-out infinite 0.3s;
  }

  /* Logo izquierdo medio usando ::after en main */
  main::before {
    content: '';
    position: fixed;
    width: 220px;
    height: 300px;
    pointer-events: none;
    z-index: var(--z-background);
    background-image: url('../../../../assets/images/logo/wallpari-transparent.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.12;
    top: 45%;
    left: 7%;
    animation: logoPulse 4s ease-in-out infinite 1s;
  }

  /* Logo derecho medio usando ::after en main */
  main::after {
    content: '';
    position: fixed;
    width: 220px;
    height: 300px;
    pointer-events: none;
    z-index: var(--z-background);
    background-image: url('../../../../assets/images/logo/wallpari-transparent.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.12;
    top: 48%;
    right: 8%;
    animation: logoPulse 4s ease-in-out infinite 1.3s;
  }

  /* Logo izquierdo inferior usando ::before en footer */
  footer::before {
    content: '';
    position: fixed;
    width: 220px;
    height: 300px;
    pointer-events: none;
    z-index: var(--z-background);
    background-image: url('../../../../assets/images/logo/wallpari-transparent.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.12;
    top: 78%;
    left: 6%;
    animation: logoPulse 4s ease-in-out infinite 2s;
  }

  /* Logo derecho inferior usando ::after en footer */
  footer::after {
    content: '';
    position: fixed;
    width: 220px;
    height: 300px;
    pointer-events: none;
    z-index: var(--z-background);
    background-image: url('../../../../assets/images/logo/wallpari-transparent.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.12;
    top: 82%;
    right: 7%;
    animation: logoPulse 4s ease-in-out infinite 2.3s;
  }
}

/* En móvil (≤768px) los logos simplemente no se renderizan (no hay pseudo-elementos) */

/* Patrón de puntos muy sutil (opcional) */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-background);
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.02) 1px, transparent 0);
  background-size: 24px 24px;
  opacity: 0.5;
}

/* Clean Nordic: Animaciones twinkle y float eliminadas para mantener minimalismo */

/* Estrellas WALLPARI - Inicia por encima del contenido */
#sambi-stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-stars-initial);
  transition: z-index 0s 0.5s;
}

/* Cuando se dispersan, van detrás del contenido */
#sambi-stars.dispersed {
  z-index: var(--z-background);
}

.sambi-star {
  position: absolute;
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  box-shadow:
    0 0 6px white,
    0 0 12px rgba(0, 160, 220, 0.9),
    0 0 18px rgba(0, 160, 220, 0.7),
    0 0 24px rgba(43, 191, 237, 0.4);
  transition: transform 3s cubic-bezier(0.68, -0.55, 0.265, 1.55),
              box-shadow 3s cubic-bezier(0.68, -0.55, 0.265, 1.55),
              opacity 3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  opacity: 1;
}

.sambi-star.dispersed {
  opacity: 0.7;
}

@keyframes sambiPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 6px white,
      0 0 12px rgba(0, 160, 220, 0.9),
      0 0 18px rgba(0, 160, 220, 0.7),
      0 0 24px rgba(43, 191, 237, 0.4);
  }
  50% {
    transform: scale(1.5);
    box-shadow:
      0 0 10px white,
      0 0 20px rgba(0, 160, 220, 1),
      0 0 30px rgba(43, 191, 237, 1),
      0 0 40px rgba(111, 239, 234, 0.8);
  }
}

.research-app {
  max-width: 1800px;
  margin: 0 auto;
  position: relative;
  z-index: var(--z-content);
}

/* Header - Clean Nordic Style */
.research-header {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-bottom: 2px solid var(--border-primary);
  padding: 24px 32px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin-bottom: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.header-left {
  flex: 1;
}

/* Header Branding - WALLPARI + Título integrados */
.header-branding {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.wallpari-logo-img {
  height: 180px;
  width: auto;
  object-fit: contain;
  object-position: left center;
  transition: all 0.3s ease;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.15));
  margin: -20px 0;
  max-width: 500px;
}

.wallpari-logo-img:hover {
  transform: scale(1.02);
  filter: drop-shadow(0 4px 10px rgba(0, 85, 255, 0.25));
}

/* Título principal - Tipografía profesional limpia */
.research-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.3px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Stat badges - Clean Nordic con acentos vibrantes */
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.stat-badge:hover {
  background: rgba(0, 85, 255, 0.08);
  border-color: rgba(0, 85, 255, 0.3);
  transform: translateY(-1px);
}

.stat-badge .stat-number {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-primary);
}

.stat-badge .stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-source-badge {
  background: rgba(0, 85, 255, 0.06);
  border-color: rgba(0, 85, 255, 0.2);
}

.stat-source-badge span {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-separator {
  color: var(--border-secondary);
  font-size: 16px;
  font-weight: 300;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.last-updated {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.last-updated-time {
  color: var(--brand-primary);
  font-weight: 700;
}

/* Language selector - Clean Nordic */
#language-selector {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

#language-selector:hover {
  border-color: var(--border-secondary);
  background: var(--bg-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

#language-selector:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px rgba(0, 85, 255, 0.1);
}

#language-selector option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Filter Bar - Clean Nordic Style */
.filter-bar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
}

/* Filter buttons - Diseño vibrante mejorado */
.filter-btn {
  padding: 12px 24px;
  background: white;
  border: 2px solid var(--border-primary);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.filter-btn:hover {
  background: rgba(0, 85, 255, 0.05);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 85, 255, 0.15);
}

.filter-btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 85, 255, 0.3);
  transform: translateY(-2px);
}

.filter-btn:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 40px;
  /* Fallback: fondo más opaco */
  background: rgba(52, 73, 94, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  margin: var(--space-5) 0;
}

/* Progressive enhancement para loading */
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .loading {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

.loading-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto var(--space-5);
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid var(--cyan-500);
  border-right: 4px solid rgba(43, 191, 237, 0.5);
  border-radius: 50%;
  animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Grid */
.research-grid {
  display: grid;
  gap: var(--space-5);
  margin-bottom: var(--space-10);
}

@media (min-width: 1024px) {
  .research-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .research-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
  }
}

@media (max-width: 767px) {
  .research-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

/* Animación de entrada */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tarjeta de investigación - Clean Nordic Style (Performance Optimized) */
.research-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04),
              0 2px 8px rgba(0, 0, 0, 0.02);
  transition: transform 0.2s ease,
              border-color 0.2s ease;
  will-change: transform;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  position: relative;
  animation: fadeInUp 0.4s ease-out;
  animation-fill-mode: both;
}

/* Pseudo-elemento para sombra (evita transition de box-shadow costoso) */
.research-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08),
              0 8px 24px rgba(0, 0, 0, 0.06);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: -1;
}

/* Hover state - Sombra suave elevada estilo Stripe (optimizado) */
.research-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-secondary);
}

.research-card:hover::after {
  opacity: 1;
}

.research-card:nth-child(1) { animation-delay: 0.05s; }
.research-card:nth-child(2) { animation-delay: 0.1s; }
.research-card:nth-child(3) { animation-delay: 0.15s; }
.research-card:nth-child(4) { animation-delay: 0.2s; }
.research-card:nth-child(5) { animation-delay: 0.25s; }
.research-card:nth-child(6) { animation-delay: 0.3s; }
.research-card:nth-child(7) { animation-delay: 0.35s; }
.research-card:nth-child(8) { animation-delay: 0.4s; }
.research-card:nth-child(9) { animation-delay: 0.45s; }
.research-card:nth-child(10) { animation-delay: 0.5s; }

/* Lazy Rendering con Intersection Observer */
.research-card.lazy-render {
  opacity: 0;
  transform: translateY(20px);
}

.research-card.lazy-loaded {
  animation: fadeInUp 0.4s ease forwards;
}

/* Imagen hero en tarjeta de investigación */
.research-card-image {
  margin: -32px -32px 0 -32px;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg-secondary, #f0f2f5);
}

.research-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 767px) {
  .research-card-image {
    aspect-ratio: 2 / 1;
    margin: -24px -24px 0 -24px;
  }
}

/* Card Header Meta - Timestamp + Wallpari Badge */
.card-header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

/* Timestamp */
.research-timestamp {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Wallpari Badge - Branding profesional en cada card */
.wallpari-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--brand-primary);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 85, 255, 0.2);
  transition: all 0.2s ease;
}

.wallpari-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 85, 255, 0.3);
}

.wallpari-logo {
  font-size: 14px;
  font-weight: 900;
  color: white;
  background: rgba(255, 255, 255, 0.2);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.wallpari-text {
  font-size: 11px;
  font-weight: 800;
  color: white;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Título */
.research-title {
  font-size: 21px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-decoration: none;
  transition: color 0.3s ease,
              transform 0.3s ease;
  position: relative;
  z-index: 1;
  letter-spacing: -0.3px;
}

.research-title:hover {
  color: var(--brand-secondary);
}

.research-title:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 4px;
  color: var(--brand-secondary);
}

/* Autores/Institución - Clean Nordic */
.research-authors {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Academic Metadata */
.academic-metadata {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-primary);
  border-bottom: 1px solid var(--border-primary);
}

.doi-link {
  font-size: 12px;
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 12px;
  background: rgba(0, 85, 255, 0.06);
  border: 1px solid rgba(0, 85, 255, 0.2);
  border-radius: 8px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.doi-link:hover {
  background: rgba(0, 85, 255, 0.12);
  border-color: rgba(0, 85, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 85, 255, 0.15);
}

.doi-link:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.institution-badge {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Abstract/Resumen - Clean Nordic */
.abstract-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.abstract-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
}

.research-abstract {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Metadata card - Clean Nordic */
.metadata-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  z-index: 1;
}

.metadata-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: -4px;
}

.badges-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

/* Badges - Clean Nordic con colores vibrantes */
.badge {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: inline-block;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.badge-area {
  background: rgba(0, 85, 255, 0.08);
  color: var(--brand-primary);
  border-color: rgba(0, 85, 255, 0.2);
}

.badge-area:hover {
  background: rgba(0, 85, 255, 0.12);
  border-color: rgba(0, 85, 255, 0.3);
  transform: translateY(-1px);
}

.badge-type {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-color: var(--border-primary);
}

.badge-type:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-secondary);
}

.badge-impact {
  color: white;
  font-weight: 700;
  position: relative;
  cursor: help;
  border-width: 1px;
  border-style: solid;
}

.badge-impact:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Tooltips */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(0, 0, 0, 0.95);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: var(--z-tooltip);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.95);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: var(--z-tooltip);
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.tooltip:hover::before {
  transform: translateX(-50%) translateY(0);
}

/* Keywords */
.keywords-container {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Keywords - Clean Nordic */
.keyword {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-primary);
  transition: all 0.2s ease;
}

.keyword:hover {
  background: rgba(0, 85, 255, 0.06);
  border-color: rgba(0, 85, 255, 0.3);
  color: var(--brand-primary);
  transform: translateY(-1px);
}

/* Error y No Research */
.error, .no-research {
  /* Fallback: fondo más opaco */
  background: rgba(52, 73, 94, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: var(--space-10);
  border-radius: 16px;
  text-align: center;
  font-size: 16px;
  color: var(--text-secondary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Progressive enhancement para error/no-research */
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
  .error, .no-research {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

.error {
  border-left: 4px solid var(--error);
  color: #fca5a5;
}

.error button {
  margin-top: var(--space-5);
  padding: 12px 28px;
  background: rgba(43, 191, 237, 0.15);
  color: var(--cyan-500);
  border: 2px solid rgba(43, 191, 237, 0.4);
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  /* Performance: Removed box-shadow from transition */
  transition: background 0.3s ease,
              border-color 0.3s ease,
              color 0.3s ease,
              transform 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.error button:hover {
  background: rgba(43, 191, 237, 0.25);
  border-color: var(--cyan-500);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(43, 191, 237, 0.4);
}

.error button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(43, 191, 237, 0.3);
}

/* Footer - Clean Nordic */
.footer {
  text-align: center;
  padding: 40px var(--space-5);
  color: var(--text-muted);
  font-size: 14px;
  margin-top: var(--space-10);
  border-top: 2px solid var(--border-primary);
  background: var(--bg-secondary);
}

.footer a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.footer a:hover {
  color: var(--brand-accent);
  text-decoration: underline;
}

/* Responsive - Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
  .research-header h1 {
    font-size: 26px;
  }
}

/* Responsive - Móvil */
@media (max-width: 768px) {
  body {
    padding: 15px;
  }

  .research-header {
    padding: var(--space-5) var(--space-4);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .header-left {
    width: 100%;
  }

  .research-header h1 {
    font-size: 22px;
  }

  .header-stats {
    gap: var(--space-2);
  }

  .stat-badge {
    padding: 5px 10px;
  }

  .stat-badge .stat-number {
    font-size: 16px;
  }

  .stat-badge .stat-label {
    font-size: 11px;
  }

  .stat-separator {
    font-size: 14px;
  }

  .header-right {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .filter-bar {
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .filter-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .last-updated {
    font-size: 13px;
  }

  #language-selector {
    width: 100%;
    font-size: 14px;
  }

  .research-card {
    padding: var(--space-5);
    gap: var(--space-3);
  }

  .research-title {
    font-size: 18px;
  }

  .research-abstract {
    font-size: 15px;
    line-height: 1.7;
  }

  .metadata-card {
    padding: 10px var(--space-3);
    gap: var(--space-2);
  }

  .badges-row {
    gap: var(--space-1);
  }

  .badge {
    font-size: 11px;
    padding: 3px 8px;
  }

  .keyword {
    font-size: 11px;
    padding: 3px 8px;
  }

  .metadata-title {
    font-size: 11px;
  }
}

/* Responsive - Móviles pequeños */
@media (max-width: 480px) {
  body {
    padding: var(--space-3);
  }

  .research-header {
    padding: var(--space-5) var(--space-4);
  }

  .research-header h1 {
    font-size: 22px;
    line-height: 1.3;
  }

  .last-updated {
    font-size: 12px;
  }

  #language-selector {
    font-size: 13px;
    padding: 10px var(--space-5);
  }

  .research-card {
    padding: 18px;
  }

  .research-timestamp {
    font-size: 11px;
  }

  .research-title {
    font-size: 17px;
  }

  .loading {
    padding: 50px var(--space-5);
  }

  .footer {
    padding: 25px 15px;
    font-size: 13px;
  }
}

/* ========================================
   ACCESIBILIDAD: Respetar preferencia de movimiento reducido
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  /* Deshabilitar todas las animaciones y transiciones no esenciales */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Deshabilitar animaciones de logos (pseudo-elementos) */
  body::before,
  body::after,
  .research-header::before,
  main::before,
  main::after,
  footer::before,
  footer::after {
    animation: none !important;
  }

  /* Deshabilitar animación de estrellas SAMBI */
  .sambi-star,
  #sambi-stars {
    animation: none !important;
    transition: none !important;
    display: none !important;
  }

  /* Simplify card animations */
  .research-card {
    animation: none !important;
  }

  .research-card::before {
    display: none !important;
  }

  /* Mantener solo el loading spinner (esencial para feedback) */
  .loading-spinner {
    animation-duration: 0.8s !important;
    animation-iteration-count: infinite !important;
  }

  /* Permitir transiciones instantáneas para hover (feedback visual) */
  .research-card:hover,
  .filter-btn:hover,
  .badge:hover,
  .keyword:hover {
    transition: none !important;
  }
}

/* Animaciones normales solo para usuarios sin preferencia */
@media (prefers-reduced-motion: no-preference) {
  /* Scroll suave */
  html {
    scroll-behavior: smooth;
  }

  /* Permitir todas las animaciones decorativas */
  body::before {
    opacity: 0.8;
  }

  .tech-decoration {
    animation-duration: 20s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
  }
}

/* ========================================
   Skip Navigation Link (Accesibilidad)
   ======================================== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  text-decoration: none;
  z-index: var(--z-skip-link);
  border-radius: 0 0 8px 0;
  font-weight: 600;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--cyan-500);
  outline-offset: 2px;
}


/* ===================================
   SKELETON LOADING SCREENS
   =================================== */

.skeleton-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  border: 2px solid rgba(0, 160, 220, 0.15);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  border-radius: 8px;
}

.skeleton-title {
  height: 24px;
  width: 80%;
  margin-bottom: 16px;
}

.skeleton-text {
  height: 16px;
  width: 100%;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-badge {
  height: 24px;
  width: 80px;
  display: inline-block;
  margin-right: 8px;
}

.skeleton-metadata {
  background: rgba(0, 160, 220, 0.08);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.skeleton-metadata-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.skeleton-metadata-row:last-child {
  margin-bottom: 0;
}

/* Responsive skeleton */
@media (max-width: 768px) {
  .skeleton-card {
    padding: 16px;
  }

  .skeleton-title {
    height: 20px;
  }
}

/* ===================================
   SPRINT 3.4: BACK TO TOP BUTTON
   =================================== */

.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cyan-600);
  border: 2px solid var(--cyan-400);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 160, 220, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  z-index: var(--z-floating-button, 999);
  will-change: transform;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 160, 220, 0.6);
  background: var(--cyan-500);
}

.back-to-top:active {
  transform: translateY(-2px);
}

.back-to-top:focus {
  outline: 2px solid var(--cyan-400);
  outline-offset: 3px;
}

.back-to-top svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.5;
}

@media (max-width: 768px) {
  .back-to-top {
    width: 48px;
    height: 48px;
    bottom: 20px;
    right: 20px;
  }

  .back-to-top svg {
    width: 20px;
    height: 20px;
  }
}
