/* Professional News Ticker Styles */

:root {
  --nt-padding-desktop: 24px 40px;
  --nt-padding-tablet: 14px 28px;
  --nt-padding-mobile: 10px 14px;
  --nt-item-height-desktop: 160px;
  --nt-item-height-tablet: 140px;
  --nt-item-height-mobile: auto;
  --nt-media-width-desktop: 240px;
  --nt-media-width-tablet: 180px;
  --nt-media-height-desktop: 150px;
  --nt-media-height-tablet: 120px;
  /* Fixed card body height to keep news cards uniform in lists/ticker */
  --nt-card-body-height-desktop: 120px;
  --nt-card-body-height-tablet: 100px;
}

/* News Ticker Container */
.news-ticker-container {
  background: linear-gradient(135deg, #0a0a0b 0%, #1a1b23 50%, #0f1419 100%);
  border-top: 2px solid #2d3748;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.news-ticker-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(34, 211, 238, 0.02),
    rgba(34, 211, 238, 0.04) 50%,
    rgba(34, 211, 238, 0.02)
  );
  pointer-events: none;
}

/* Wrapper */
.news-ticker-wrapper {
  display: flex;
  align-items: center;
  padding: var(--nt-padding-desktop);
  position: relative;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Title */
.news-ticker-title {
  background: linear-gradient(135deg, #22d3ee 0%, #0891b2 100%);
  color: #0f1419;
  padding: 10px 20px;
  border-radius: 22px;
  font-weight: 800;
  min-width: 150px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  box-shadow: 0 8px 25px rgba(34, 211, 238, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.news-ticker-title:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(34, 211, 238, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.news-ticker-title::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: rotate(45deg);
  transition: all 0.5s;
  opacity: 0;
}

.news-ticker-title:hover::before {
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
    opacity: 0;
  }
}

/* Main Ticker */
.news-ticker {
  flex: 1 1 auto;
  min-height: var(--nt-item-height-desktop);
  position: relative;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Viewport */
.news-ticker-viewport {
  width: 100%;
  height: auto;
  overflow: hidden;
  position: relative;
  border-radius: 15px;
  display: flex;
  align-items: stretch;
}

/* Content Container */
.news-ticker-content {
  display: flex;
  height: auto;
  align-items: stretch;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  will-change: transform; /* hint for smoother animations on mobile */
  flex-wrap: nowrap; /* keep items in a single row for horizontal rotation */
}

/* News Items */
.news-item {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  min-height: var(--nt-item-height-desktop);
  display: flex;
  align-items: stretch; /* allow children to stretch vertically so equalizeHeights can apply */
  padding: 16px 20px;
  position: relative;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.03) 100%
  );
  border-radius: 12px;
  margin: 0;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.news-item:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.06) 100%
  );
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.news-item.loading {
  opacity: 0.7;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* News Icon */
.news-icon {
  font-size: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: rgba(34, 211, 238, 0.08);
  border-radius: 50%;
  border: 2px solid rgba(34, 211, 238, 0.18);
}

/* News Text */
.news-text {
  flex: 1 1 auto;
  color: #ffffff;
  overflow: hidden;
}

/* Make body fill available vertical space so cards can be equalized */
.news-body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex: 1 1 auto;
}

/* If a card has no media, hide the media container and allow text to occupy full width */
.news-item.no-media .news-media {
  display: none !important;
}
.news-item.no-media .news-body {
  width: 100%;
}

/* Ensure media containers don't collapse and media fills them */
.news-media {
  min-width: 0;
  width: var(--nt-media-width-desktop);
  height: auto;
}
.news-media img,
.news-media video,
.news-media iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Ensure news card bodies have a consistent height so cards line up */
.news-body {
  min-height: var(--nt-card-body-height-desktop);
  max-height: var(--nt-card-body-height-desktop);
  overflow: hidden;
}

.news-title {
  font-size: clamp(14px, 1.8vw, 16px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 6px;
  color: #22d3ee;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  white-space: normal; /* allow wrapping */
  overflow-wrap: anywhere;
}

.news-content {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* News Media */
.news-media {
  flex-shrink: 0;
  width: var(--nt-media-width-desktop);
  height: auto;
  aspect-ratio: 16 / 9;
  max-height: var(--nt-media-height-desktop);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.34);
  background: #000;
}

.news-media img,
.news-media video,
.news-media iframe {
  width: 100%;
  height: 100%;
  object-fit: cover; /* ensure coverage without distortion */
  display: block;
  border: 0;
}

/* Responsive, centered iframe embed styling for YouTube */
.news-media .youtube-embed-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.news-media .youtube-embed-wrapper::before {
  /* 16:9 aspect ratio placeholder */
  content: "";
  display: block;
  padding-top: 56.25%;
}

.news-media .youtube-embed-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  display: block;
}
.news-media .youtube-embed-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.48);
  display: block;
}
.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-play-overlay {
  position: absolute;
  z-index: 30;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

/* Specific nav button placement for left/right to avoid overlapping media on narrow screens */
.news-nav-btn.news-nav-prev {
  left: 12px;
}
.news-nav-btn.news-nav-next {
  right: 12px;
}

/* Increase touch target without visually enlarging the button */
.news-nav-btn {
  padding: 6px;
}
.news-nav-btn .btn-inner-hotspot {
  display: inline-block;
  width: 100%;
  height: 100%;
}

/* Ensure nav buttons sit above media on small screens and are reachable */
@media (max-width: 768px) {
  .news-nav-btn.news-nav-prev {
    left: 8px;
  }
  .news-nav-btn.news-nav-next {
    right: 8px;
  }
  .news-nav-btn {
    width: 46px;
    height: 46px;
  }

  /* Strong override to ensure media inside the news ticker are visible on small phones.
     Uses high specificity and !important to defeat accidental rules that collapse
     media to height:0 or display:none on some devices or cascades. */
  @media (max-width: 640px) {
    .news-ticker .news-media,
    .news-ticker-viewport .news-media,
    .news-ticker-wrapper .news-media,
    .news-item .news-media {
      display: block !important;
      width: 100% !important;
      height: auto !important;
      max-height: 220px !important;
      aspect-ratio: 16/9 !important;
      overflow: hidden !important;
      visibility: visible !important;
    }

    .news-ticker .news-media img,
    .news-ticker .news-media video,
    .news-ticker .news-media iframe,
    .news-ticker-viewport .news-media img,
    .news-ticker-viewport .news-media video,
    .news-ticker-viewport .news-media iframe {
      display: block !important;
      width: 100% !important;
      height: auto !important;
      max-height: 220px !important;
      object-fit: cover !important;
      visibility: visible !important;
    }

    /* On small screens use a smaller fixed body height for consistent stacking */
    .news-body {
      min-height: var(--nt-card-body-height-tablet) !important;
      max-height: var(--nt-card-body-height-tablet) !important;
      overflow: hidden !important;
    }
  }
}

@media (max-width: 480px) {
  /* Move nav buttons slightly inside the ticker so they don't overlap page edges */
  .news-nav-btn.news-nav-prev {
    left: 6px;
  }
  .news-nav-btn.news-nav-next {
    right: 6px;
  }
  .news-nav-btn {
    width: 44px;
    height: 44px;
  }
  /* When stacked, keep media full-width and nav buttons vertically centered relative to the visible item */
  .news-item {
    align-items: flex-start;
  }
  .news-media {
    width: 100%;
    aspect-ratio: 16/9;
    height: auto;
  }
}

.video-play-overlay:hover {
  transform: scale(1.06);
}

.news-item:hover .news-media img {
  transform: scale(1.1);
}

/* Navigation Buttons */
.news-nav-btn {
  background: linear-gradient(
    135deg,
    rgba(34, 211, 238, 0.9) 0%,
    rgba(8, 145, 178, 1) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.25);
  color: #ffffff;
  font-size: 18px;
  position: absolute; /* position inside viewport */
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: rgba(12, 18, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.news-nav-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #22d3ee 0%, #0891b2 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 50%;
}

.news-nav-btn:hover {
  transform: scale(1.1) translateY(-2px);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 12px 30px rgba(34, 211, 238, 0.5);
}

.news-nav-btn:hover::before {
  opacity: 1;
}

.news-nav-btn i,
.news-nav-btn span {
  position: relative;
  z-index: 1;
}

.news-nav-btn:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

.news-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Indicators */
.news-indicators {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}

/* Position navigation buttons inside the viewport */
.news-ticker-viewport > .news-nav-btn.news-nav-prev {
  left: 10px;
}

.news-ticker-viewport > .news-nav-btn.news-nav-next {
  right: 10px;
}

/* Slightly increase hit area for nav buttons while keeping them visually compact */
.news-nav-btn .btn-inner-hotspot {
  display: inline-block;
  width: 100%;
  height: 100%;
}

/* Ensure content has appropriate min-height on small devices so translateX works correctly */
.news-ticker-viewport .news-ticker-content {
  min-height: 80px;
}

.news-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.news-indicator.active {
  background: #22d3ee;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.5);
  transform: scale(1.2);
}

.news-indicator:hover:not(.active) {
  background: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .news-ticker-wrapper {
    padding: var(--nt-padding-tablet);
    gap: 16px;
  }

  .news-ticker-title {
    min-width: 150px;
    font-size: 12px;
    padding: 10px 20px;
  }

  .news-ticker {
    min-height: calc(var(--nt-item-height-tablet) + 8px);
  }

  .news-nav-btn {
    width: 45px;
    height: 45px;
    font-size: 18px;
  }
}

@media (max-width: 768px) {
  .news-ticker-wrapper {
    padding: var(--nt-padding-tablet);
    gap: 14px;
  }

  .news-ticker-title {
    min-width: 120px;
    font-size: 11px;
    padding: 8px 16px;
    border-radius: 20px;
  }

  .news-ticker {
    min-height: calc(var(--nt-item-height-tablet) + 8px);
    width: 100%;
  }

  .news-item {
    padding: 10px 12px;
    gap: 12px;
    align-items: flex-start;
    min-height: var(--nt-item-height-tablet);
  }

  .news-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .news-title {
    font-size: 14px;
  }

  .news-content {
    font-size: 12px;
  }

  /* Make media more visible on small screens: stack and allow larger display */
  .news-media {
    width: 100%;
    height: var(--nt-media-height-tablet);
    border-radius: 8px;
    order: 2;
    margin-top: 8px;
  }

  /* ensure video wrapper is visible and height adjusts */
  .video-wrapper {
    height: var(--nt-media-height-tablet);
  }

  .news-text {
    order: 1;
  }

  .news-nav-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
    position: absolute;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  }
}

@media (max-width: 480px) {
  .news-ticker-wrapper {
    padding: var(--nt-padding-mobile);
    gap: 10px;
    flex-direction: column;
  }

  .news-ticker-title {
    min-width: 100px;
    font-size: 10px;
    padding: 6px 12px;
    order: -1;
  }

  /* Allow ticker to grow vertically and place media under text */
  .news-ticker {
    height: auto;
    order: 1;
    width: 100%;
  }

  .news-nav-btn {
    width: 40px;
    height: 40px;
    font-size: 14px;
    position: absolute;
    background: rgba(12, 18, 20, 0.7);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.34);
  }

  .news-indicators {
    bottom: 5px;
  }

  .news-indicator {
    width: 6px;
    height: 6px;
  }

  .news-item {
    padding: 8px 15px;
    gap: 10px;
  }

  /* Mobile-friendly news item: stack content vertically, larger readable title and clearer spacing */
  .news-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    min-height: auto !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  }

  .news-media {
    order: 1;
    width: 100% !important;
    height: auto !important;
    max-height: 220px !important;
    margin: 0 0 10px 0 !important;
    border-radius: 8px !important;
  }

  .news-text {
    order: 2;
  }

  .news-title {
    font-size: 16px !important;
    color: #22d3ee !important;
    margin-bottom: 8px !important;
    line-height: 1.2 !important;
  }

  .news-content {
    -webkit-line-clamp: 3;
    line-clamp: 3;
    font-size: 13px !important;
  }

  /* Hide decorative icon on mobile to save space */
  .news-icon {
    display: none !important;
  }

  /* Reserve space for timestamp and place it bottom-right inside the card */
  .news-item {
    padding-bottom: 44px !important;
  }
  .news-card-date {
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.25);
    padding: 4px 8px;
    border-radius: 6px;
  }

  /* Stack media under text and make full-width for readability */
  .news-media {
    display: block;
    width: 100%;
    height: 140px;
    margin-top: 6px;
    border-radius: 8px;
    order: 2;
  }

  .video-wrapper {
    height: 140px;
  }

  .news-text {
    order: 1;
  }
}

/* Dark Theme Support */
body.dark-theme .news-ticker-container,
.dark-theme .news-ticker-container {
  background: linear-gradient(135deg, #1a202c 0%, #2d3748 50%, #4a5568 100%);
  border-top-color: #4a5568;
}

body.dark-theme .news-ticker-title,
.dark-theme .news-ticker-title {
  background: linear-gradient(135deg, #63b3ed 0%, #3182ce 100%);
  color: #1a202c;
}

body.dark-theme .news-ticker,
.dark-theme .news-ticker {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

body.dark-theme .news-item,
.dark-theme .news-item {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.05) 100%
  );
}

body.dark-theme .news-title,
.dark-theme .news-title {
  color: #63b3ed;
}

/* Animation Classes */
.news-ticker-fade-in {
  animation: fadeIn 0.5s ease-out;
}

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

.news-ticker-slide-in {
  animation: slideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .news-ticker-content,
  .news-nav-btn,
  .news-item,
  .news-indicator {
    transition: none;
  }

  .news-ticker-fade-in,
  .news-ticker-slide-in {
    animation: none;
  }

  @keyframes pulse {
    0%,
    100% {
      opacity: 1;
    }
  }
}

/* Focus styles for accessibility */
.news-nav-btn:focus,
.news-indicator:focus {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
}

/* cleanup accidental trailing token removed */

/* Compact ticker item styles (used inside the horizontal ticker) */
.ticker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  min-width: 260px;
  box-sizing: border-box;
  cursor: pointer;
}
.ticker-thumb {
  width: 84px;
  height: 56px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #0b0b0b;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ticker-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ticker-no-thumb {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #111, #222);
}
.ticker-text {
  font-weight: 700;
  color: #e6f9fb;
  font-size: 14px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .ticker-item {
    min-width: 180px;
    padding: 8px;
  }
  .ticker-thumb {
    width: 64px;
    height: 48px;
  }
  .ticker-text {
    font-size: 13px;
  }
}
