/* Estilos base para la página de noticias */
body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0f0c29;
  background: linear-gradient(135deg, #0f0c29 0%, #1a1a2e 50%, #24243e 100%);
  color: #fff;
  line-height: 1.6;
  min-height: 100vh;
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
  overflow-x: hidden;
}

.news-page {
  min-height: 100vh;
  padding: 100px 20px 60px;
  position: relative;
  z-index: 1;
}

.news-page::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 30%, rgba(111, 0, 255, 0.15) 0%, transparent 25%),
    radial-gradient(circle at 80% 70%, rgba(111, 0, 255, 0.15) 0%, transparent 25%);
  pointer-events: none;
  z-index: -1;
}

/* Overlay para el fondo oscuro */
.news-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 1; /* Capa base */
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  will-change: opacity;
}

.news-page.has-expanded-card .news-overlay {
  display: block;
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

.news-section {
  position: relative;
  padding: 40px 0;
  overflow: hidden;
  z-index: 1;
}

.news-container {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  padding: 0 20px;
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  justify-content: center;
  gap: 30px;
  margin: 40px auto 0;
  max-width: 1800px;
  padding: 0 20px;
  position: relative;
  transition: all 0.3s ease;
}

.news-card {
  background: #1e1e1e;
  border-radius: 5px;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
  cursor: pointer;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.news-card.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  z-index: 1000;
  box-shadow: 0 15px 50px rgba(255, 0, 255, 0.3);
  overflow-y: auto;
  cursor: default;
  /* Asegurar que la tarjeta no se salga de la pantalla */
  max-height: min(90vh, calc(100vh - 40px));
  margin: 20px 0;
  /* Mejorar el desplazamiento */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  /* Asegurar que el contenido no se desborde */
  overscroll-behavior: contain;
  /* Posicionamiento seguro para móviles */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  width: 90%;
  height: fit-content;
  max-height: 90vh;
  transform: none;
  transform-origin: center;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.news-card:not(.expanded):hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(255, 0, 255, 0.3);
}

.news-image-container {
  position: relative;
  height: 220px;
  overflow: hidden;
  transition: height 0.3s ease;
}

.news-card.expanded .news-image-container {
  height: 300px;
  max-height: 40vh;
}

.news-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.news-card:not(.expanded):hover .news-image {
  transform: scale(1.05);
}

.news-date {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 0, 247, 0.9);
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.news-content {
  padding: 25px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.news-content h3 {
  font-size: 1.4rem;
  margin: 0 0 15px 0;
  line-height: 1.4;
  color: #fff;
}

.news-content p {
  font-size: 1rem;
  line-height: 1.6;
  color: #e0e0e0;
  margin: 0 0 20px 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 4.8em;
  transition: all 0.3s ease;
}

.news-card.expanded .news-content p {
  -webkit-line-clamp: unset !important;
  line-clamp: unset !important;
  max-height: none !important;
  display: block !important;
  overflow: visible !important;
  margin: 1rem 0 !important;
  color: #e0e0e0 !important;
  font-weight: normal !important;
  -webkit-box-orient: vertical !important;
  text-overflow: clip !important;
  white-space: normal !important;
}

.read-more:hover {
  color: #fff;
  text-decoration: none;
  transform: translateX(5px);
}

.read-more .arrow {
  margin-left: 8px;
  transition: transform 0.3s ease;
}

.read-more:hover .arrow {
  transform: translateX(5px);
}

/* Estilos para el contenedor principal - Eliminando duplicados */

/* Contenedor de noticias */
.news-container {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  padding: 0 20px;
}

/* Título de la sección */
.news-page h2 {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 3rem;
  color: #fff;
  position: relative;
  padding-bottom: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.news-page h2::after {
  content: '';
  position: absolute;
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, #6f00ff, #9d4edd);
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 4px;
  transition: all 0.3s ease;
}

.news-page h2:hover::after {
  width: 120px;
  background: linear-gradient(90deg, #9d4edd, #6f00ff);
}

/* Grid de noticias */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2.5rem;
  padding: 1rem 0;
  position: relative;
  z-index: 1;
  padding: 1rem 0;
}

/* Tarjeta de noticia */
/* Tarjeta de noticia normal */
.news-card {
  background: rgba(26, 26, 46, 0.7);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 2; /* Por encima del overlay */
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transform: translateZ(0);
  will-change: transform, box-shadow;
}

/* Tarjeta expandida */
.news-card.expanded {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 90% !important;
  max-width: 900px !important;
  max-height: 85vh !important;
  height: auto !important;
  z-index: 10 !important;
  overflow-y: auto !important;
  cursor: default !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75) !important;
  border: 1px solid #6f00ff !important;
  background: rgba(26, 26, 46, 0.98) !important;
  backdrop-filter: blur(10px) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  will-change: transform, opacity !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Ajustes para el contenido dentro de la tarjeta expandida */
.news-card.expanded .news-content {
  padding: 2rem !important;
  overflow-y: auto !important;
  max-height: none !important;
}

.news-card.expanded .news-image-container {
  max-height: 50vh !important;
  overflow: hidden !important;
}

.news-card.expanded .news-image {
  width: 100% !important;
  height: auto !important;
  max-height: 50vh !important;
  object-fit: cover !important;
}

.news-card.expanded .news-content {
  max-height: none !important;
  overflow: visible !important;
}

.news-card.expanded .news-content p {
  -webkit-line-clamp: unset !important;
  line-clamp: unset !important;
  max-height: none !important;
  display: block !important;
  overflow: visible !important;
  margin: 1rem 0 !important;
  color: #e0e0e0 !important;
  font-weight: normal !important;
  -webkit-box-orient: vertical !important;
  text-overflow: clip !important;
  white-space: normal !important;
}

.news-card.expanded .read-more {
  display: none !important;
}

.news-page.has-expanded-card::before {
  content: '' !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
}

.news-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(111, 0, 255, 0.1), rgba(111, 0, 255, 0.03));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.news-card:hover::before {
  opacity: 1;
}

.news-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(111, 0, 255, 0.25);
  border-color: #6f00ff;
}

.news-card.expanded:hover {
  transform: translate(-50%, -50%);
  box-shadow: 0 12px 60px rgba(111, 0, 255, 0.4);
}

/* Contenedor de imagen */
.news-image-container {
  position: relative;
  width: 100%;
  height: 220px;
  overflow: hidden;
}

.news-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.news-card:hover .news-image {
  transform: scale(1.05);
}

/* Fecha de la noticia */
.news-date {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  backdrop-filter: blur(5px);
  z-index: 2;
}

/* Contenido de la noticia */
.news-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  position: relative;
  z-index: 2;
}

.news-content h3 {
  color: #fff;
  font-size: 1.3rem;
  margin: 0 0 1rem 0;
  font-weight: 600;
  line-height: 1.4;
  transition: all 0.3s ease;
}

.news-card:hover .news-content h3 {
  color: #9d4edd;
}

.news-content p {
  color: #e0e0e0;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 1.5rem 0;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 4.8em;
  transition: all 0.3s ease;
}

/* Categorías */
.news-card[data-category="eventos"] .news-date {
  background: rgba(157, 78, 221, 0.8);
}

.news-card[data-category="logros"] .news-date {
  background: rgba(0, 180, 216, 0.8);
}

.news-card[data-category="tecnologia"] .news-date {
  background: rgba(72, 202, 228, 0.8);
}

/* Efecto de aparición */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.news-card {
  opacity: 0;
  animation: fadeInUp 0.6s ease-out forwards;
}

.news-card:nth-child(1) { animation-delay: 0.1s; }
.news-card:nth-child(2) { animation-delay: 0.2s; }
.news-card:nth-child(3) { animation-delay: 0.3s; }
.news-card:nth-child(4) { animation-delay: 0.4s; }
.news-card:nth-child(5) { animation-delay: 0.5s; }
.news-card:nth-child(6) { animation-delay: 0.6s; }

/* Responsive */
@media (max-width: 1024px) {
  .news-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
  }
}

@media (max-width: 768px) {
  .news-page h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
  }
  
  .news-grid {
    grid-template-columns: 1fr;
    max-width: 600px;
    margin: 0 auto;
  }
  
  .news-image-container {
    height: 200px;
  }
}

@media (max-width: 480px) {
  .news-page {
    padding: 80px 15px 40px;
  }
  
  .news-page h2 {
    font-size: 1.8rem;
  }
  
  .news-content {
    padding: 1.25rem;
  }
  
  .news-content h3 {
    font-size: 1.2rem;
  }
  
  .news-content p {
    font-size: 0.9rem;
  }
}

/* Asegurar que el contenido sea legible sobre el fondo */
.news-content * {
  color: inherit;
}

.news-card {
  color: #e0e0e0;
}

.news-card a {
  color: #9d4edd;
  text-decoration: none;
  transition: color 0.3s ease;
}

.news-card a:hover {
  color: #6f00ff;
  text-decoration: underline;
}

/* Mejoras de accesibilidad */
.news-card:focus-within {
  outline: 3px solid #9d4edd;
  outline-offset: 3px;
}

.news-card h3:focus {
  outline: none;
}

/* Transiciones suaves */
.news-card,
.news-card * {
  transition: all 0.3s ease;
}

/* Asegurar que las imágenes se carguen de forma óptima */
.news-image {
  will-change: transform;
  backface-visibility: hidden;
}

/* Mejorar la legibilidad del texto sobre imágenes */
.news-card h3 {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Ajustes para modo oscuro */
@media (prefers-color-scheme: dark) {
  .news-card {
    background: rgba(30, 30, 50, 0.9);
  }
  
  .news-card:hover {
    background: rgba(40, 40, 60, 0.95);
  }
}

/* Asegurar que el contenedor principal ocupe al menos el alto de la pantalla */
.news-page {
  min-height: calc(100vh - 160px);
}

/* Mejorar el espaciado en pantallas grandes */
@media (min-width: 1600px) {
  .news-container {
    max-width: 1400px;
  }
  
  .news-grid {
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  }
}

/* Estilos responsivos */
@media (max-width: 768px) {
  .news-grid {
    grid-template-columns: 1fr;
  }
  
  .news-card {
    max-width: 100%;
  }
  
  .news-page h2 {
    font-size: 2rem;
  }
}

/* Estilos para el filtro de categorías */
.news-filters {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.filter-btn {
  background: transparent;
  border: 2px solid #ff00f7;
  color: #ff00f7;
  padding: 8px 20px;
  border-radius: 30px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.filter-btn:hover,
.filter-btn.active {
  background: #ff00f7;
  color: #fff;
}