/* ========================
   News Feed Container
   ======================== */

.news-feed-container {
  width: 100%;
  margin: 3px 0;
  padding: 0;
  box-sizing: border-box;
}

.news-feed-wrapper {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 30px;
  padding: 15px;
  box-shadow:
    0 15px 35px rgba(0, 0, 0, 0.2),
    inset 0 0 20px rgba(255, 255, 255, 0.05);
  position: relative;
}

.news-feed-scroll {
  display: flex;
  flex-wrap: nowrap;
  gap: 15px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 10px 5px;
  scroll-behavior: smooth;
  justify-content: center; /* Always try to center */
  width: 100%;
  box-sizing: border-box;

  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 210, 255, 0.6) rgba(255, 255, 255, 0.1);
}

/* Ensure horizontal scrolling when content overflows */
@media screen and (min-width: 1025px) {
  .news-feed-scroll:has(> .news-feed-item:nth-child(5)) {
    justify-content: flex-start;
  }
}

.news-feed-item {
  flex: 0 0 240px; /* Fixed width for consistency */
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  min-height: 280px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.news-feed-item:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: #00d2ff;
  background: rgba(255, 255, 255, 0.15);
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.4),
    0 0 30px rgba(0, 210, 255, 0.3);
}

.news-feed-item:active {
  transform: translateY(-4px) scale(1.01);
}

/* News Feed Image */
.news-feed-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.3);
  position: relative;
}

.news-feed-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.news-feed-no-image {
  width: 100%;
  height: 180px;
  background: linear-gradient(
    135deg,
    rgba(0, 210, 255, 0.3),
    rgba(255, 0, 255, 0.3)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: rgba(255, 255, 255, 0.4);
}

/* News Feed Content */
.news-feed-body {
  padding: 15px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  justify-content: space-between;
}

.news-feed-title {
  font-size: 16px;
  font-weight: bold;
  color: #ffffff;
  margin: 0 0 8px 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 42px;
}

.news-feed-date {
  font-size: 16px;
  color: #ffffff;
  margin-top: auto;
  text-align: center;
}

/* Counter badge */
.news-feed-counter {
  position: relative; /* Changed from absolute to work with flex layout */
  background: rgba(0, 0, 0, 0.8);
  color: #00f2ff;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid #00f2ff;
  box-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
  text-shadow: 0 0 5px rgba(0, 242, 255, 0.8);
  z-index: 2;
}

.news-feed-hits {
  background: rgba(0, 210, 255, 0.8);
  color: #fff;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  z-index: 2;
}

/* Loading State */
.news-feed-loading {
  text-align: center;
  padding: 40px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  grid-column: 1 / -1;
}

/* ========================
   News Feed Detail Modal
   ======================== */

.news-feed-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.news-feed-modal.active {
  display: flex;
}

.news-feed-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

.news-feed-modal-content {
  position: relative;
  background: linear-gradient(
    135deg,
    rgba(40, 40, 60, 0.95),
    rgba(20, 20, 40, 0.95)
  );
  border: 2px solid rgba(0, 210, 255, 0.5);
  border-radius: 30px;
  max-width: 90%;
  max-height: 90vh;
  width: 700px;
  overflow: hidden;
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.5),
    0 0 50px rgba(0, 210, 255, 0.3);
  animation: modalSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(50px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.news-feed-modal-header {
  background: rgba(0, 210, 255, 0.1);
  border-bottom: 1px solid rgba(0, 210, 255, 0.3);
  padding: 20px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.news-feed-modal-header h2 {
  margin: 0;
  color: #00d2ff;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
  flex: 1;
  padding-right: 20px;
}

.news-feed-modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.news-feed-modal-close:hover {
  background: rgba(255, 100, 100, 0.8);
  border-color: rgba(255, 100, 100, 1);
  transform: rotate(90deg);
}

.news-feed-modal-body {
  padding: 25px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 210, 255, 0.6) rgba(255, 255, 255, 0.1);
}

.news-feed-modal-body::-webkit-scrollbar {
  width: 8px;
}

.news-feed-modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.news-feed-modal-body::-webkit-scrollbar-thumb {
  background: rgba(0, 210, 255, 0.6);
  border-radius: 10px;
}

.news-feed-modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 210, 255, 0.9);
}

#modalNewsImage {
  margin-bottom: 20px;
}

#modalNewsImage img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.news-content {
  color: rgba(255, 255, 255, 0.95);
  font-size: 16px;
  line-height: 1.8;
  margin-bottom: 20px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.news-content p {
  margin-bottom: 15px;
}

.news-date {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  text-align: right;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================
   Mobile Responsive
   ======================== */

@media screen and (max-width: 600px) {
  .news-feed-container {
    margin: 3px 0;
  }

  .news-feed-wrapper {
    padding: 3px;
    border-radius: 15px;
  }

  .news-feed-scroll {
    justify-content: center; /* Center when less than 4 items */
    gap: 3px;
    padding: 5px;
  }

  /* Left align when 4 or more items */
  .news-feed-scroll:has(> .news-feed-item:nth-child(4)) {
    justify-content: flex-start;
  }

  .news-feed-item {
    flex: 0 0 calc(25% - 3px); /* Show 4 items on mobile */
    min-height: auto;
    min-width: 70px;
    border-radius: 8px;
  }

  /* Square image aspect ratio like gallery photos */
  .news-feed-image,
  .news-feed-no-image {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
  }

  .news-feed-image img {
    aspect-ratio: 1 / 1;
  }

  .news-feed-no-image {
    font-size: 24px;
  }

  .news-feed-body {
    padding: 3px;
    gap: 2px;
  }

  .news-feed-title {
    font-size: 9px;
    min-height: auto;
    height: 22px; /* Exactly 2 lines */
    line-height: 1.2;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Move counter and date to bottom */
  .news-feed-meta-top {
    position: relative !important;
    padding: 2px !important;
    margin-top: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
  }

  .news-feed-counter,
  .news-feed-hits {
    font-size: 7px;
    padding: 1px 4px;
    border-radius: 8px;
    position: relative;
    top: auto;
    right: auto;
    left: auto;
  }

  .news-feed-date {
    font-size: 7px;
    margin-top: 0;
    text-align: center;
    width: 100%;
    color: #ffffff;
  }

  .news-feed-modal-content {
    width: 95%;
    max-width: 95%;
    border-radius: 20px;
  }

  .news-feed-modal-header {
    padding: 15px;
  }

  .news-feed-modal-header h2 {
    font-size: 20px;
  }

  .news-feed-modal-body {
    padding: 15px;
  }

  .news-content {
    font-size: 15px;
    line-height: 1.6;
  }
}

@media screen and (max-width: 480px) {
  .news-feed-scroll {
    grid-template-columns: repeat(2, 1fr);
  }

  .news-feed-wrapper {
    border-radius: 20px;
    padding: 10px;
  }
}
