/**
 * Module: Homepage Intro Styles
 * Updated: Column reordering for mobile
 */

/* ===================================
   HOMEPAGE INTRO MODULE
   =================================== */

.mod-homepage-intro {
  margin: var(--tcp-space-12) 0;
}

/* Grid Layout */
.homepage-intro-grid {
  align-items: start;
  border-bottom: 1px solid var(--tcp-gray-200);
  display: grid;
  gap: var(--tcp-space-8);
  grid-template-columns: 1fr 2fr 1fr;
  padding-bottom: var(--tcp-space-4);
}

.homepage-intro-grid > * {
  position: relative;
}

.homepage-intro-grid > *:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 0;
  right: calc(var(--tcp-space-8) / -2);
  width: 1px;
  height: 100%;
  background-color: var(--tcp-gray-200);
}

/* ===================================
   COLUMN 1: NEWS SECTION
   =================================== */

/* News Item - Featured (First Post) */
.news-item-featured {
  border-bottom: 1px solid var(--tcp-gray-200);
  padding-bottom: var(--tcp-space-3);
}

.news-thumbnail {
  margin-bottom: var(--tcp-space-4);
  overflow: hidden;
}

.news-thumbnail img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.news-thumbnail a:hover img {
  transform: scale(1.05);
}

.news-item-featured .news-title {
  font-size: var(--tcp-text-base);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--tcp-space-1);
}

.news-item-featured .news-title a {
  color: var(--tcp-dark);
  text-decoration: none;
  transition: color 0.3s ease;
}

.news-item-featured .news-title a:hover {
  color: var(--tcp-primary);
}

.news-date {
  font-family: var(--tcp-font-primary);
  font-size: var(--tcp-text-sm);
  color: var(--tcp-gray-500);
  font-style: italic;
  display: block;
}

/* News Item - Compact (Posts 2-4) */
.news-item-compact {
  border-bottom: 1px solid var(--tcp-gray-200);
  padding: var(--tcp-space-3) 0;
}

.news-item-compact:last-child {
  border-bottom: none;
}

.news-item-compact .news-title {
  font-size: var(--tcp-text-sm);
  font-weight: 600;
  margin-bottom: var(--tcp-space-1);
}

.news-item-compact .news-title a {
  color: var(--tcp-dark);
  text-decoration: none;
  transition: color 0.3s ease;
}

.news-item-compact .news-title a:hover {
  color: var(--tcp-primary);
}

/* ===================================
   COLUMN 2: FEATURED CAROUSEL
   =================================== */

.carousel-column {
  height: 100%;
  position: relative;
  max-width: 100%;
}

.featured-carousel {
  position: relative;
  overflow: hidden;
  background: var(--tcp-white);
}

.carousel-wrapper {
  position: relative;
  width: 100%;
}

.carousel-slides {
  position: relative;
  width: 100%;
}

.carousel-slide {
  display: none;
  width: 100%;
}

.carousel-slide.active {
  display: block;
  animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.carousel-image {
  aspect-ratio: 16 / 9;
  background: var(--tcp-gray-200);
  overflow: hidden;
  position: relative;
  width: 100%;
}

.carousel-image img {
  aspect-ratio: 16 / 9;
  display: block;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  width: 100%;
}

.carousel-image a:hover img {
  transform: scale(1.05);
}

.carousel-content {
  padding: var(--tcp-space-4) 0;
}

.carousel-category {
  background: var(--tcp-primary);
  bottom: var(--tcp-space-4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  color: var(--tcp-white);
  display: inline-block;
  font-family: var(--tcp-font-secondary);
  font-size: var(--tcp-text-sm);
  font-weight: 600;
  left: var(--tcp-space-4);
  letter-spacing: -0.03px;
  padding: 0 var(--tcp-space-2);
  position: absolute;
  transition: 0.3s ease;
  z-index: 5;
}

.carousel-category a {
  color: var(--tcp-white);
  text-decoration: none;
}

.carousel-category:hover {
  background: var(--tcp-dark);
}

.carousel-title {
  font-family: var(--tcp-font-display);
  font-size: var(--tcp-text-2xl);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--tcp-space-2);
}

.carousel-title a {
  color: var(--tcp-dark);
  text-decoration: none;
  transition: color 0.3s ease;
}

.carousel-title a:hover {
  color: var(--tcp-primary);
}

.carousel-meta {
  display: flex;
  align-items: center;
  gap: var(--tcp-space-2);
  font-family: var(--tcp-font-primary);
  font-size: var(--tcp-text-sm);
  color: var(--tcp-gray-500);
  font-style: italic;
}

.carousel-author a {
  color: var(--tcp-gray-700);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease;
}

.carousel-author a:hover {
  color: var(--tcp-primary);
}

.carousel-separator {
  color: var(--tcp-gray-400);
}

/* Carousel Indicators */
.carousel-indicators {
  display: flex;
  justify-content: center;
  gap: var(--tcp-space-2);
  padding: var(--tcp-space-1);
  background: var(--tcp-white);
}

.carousel-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tcp-gray-300);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
  opacity: 0.5;
}

.carousel-indicator:hover {
  background: var(--tcp-gray-500);
  opacity: 0.8;
}

.carousel-indicator.active {
  background: var(--tcp-primary);
  width: 24px;
  border-radius: 4px;
  opacity: 1;
}

/**
 * News Ticker Styles with Marquee Animation
 */

.news-ticker-wrapper {
  display: flex;
  align-items: center;
  gap: var(--tcp-space-2);
  background: var(--tcp-gray-100);
  padding: var(--tcp-space-2);
  margin-top: var(--tcp-space-8);
  margin-bottom: var(--tcp-space-6);
  position: relative;
  overflow: hidden;
  width: calc(100% - var(--tcp-space-4));
}

.news-ticker-label {
  font-family: var(--tcp-font-secondary, sans-serif);
  font-size: 0.7rem;
  font-weight: 600;
  color: #ffffff;
  background: #dc2626;
  padding: 4px 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
  z-index: 2;
}

.news-ticker {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 24px;
  width: 100%;
}

.news-ticker-content {
  display: block;
  position: relative;
  max-width: 400px;
  height: 100%;
}

.ticker-item {
  width: 100%;
  opacity: 0;
  position: absolute;
  left: 0;
  top: 0;
  transition: opacity 0.5s ease-in-out;
  overflow: hidden;
}

.ticker-item.active {
  opacity: 1;
  position: relative;
}

/* Inner wrapper for marquee */
.ticker-item-inner {
  display: inline-block;
  padding-right: 50px;
  white-space: nowrap;
}

/* Marquee animation for overflowing text */
.ticker-item.active .ticker-item-inner.overflow {
  animation: marquee-scroll 15s linear infinite;
}

/* Pause marquee on hover */
.news-ticker-wrapper:hover .ticker-item-inner.overflow {
  animation-play-state: paused;
}

@keyframes marquee-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

.ticker-item a,
.ticker-item span {
  font-family: var(--tcp-font-primary, sans-serif);
  font-size: 1rem;
  font-weight: 500;
  color: #1a1a1a;
  text-decoration: none;
  display: inline;
  transition: color 0.3s ease;
}

.ticker-item a:hover {
  color: #0066cc;
}

.news-ticker-nav {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  z-index: 2;
}

.ticker-prev,
.ticker-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
}

.ticker-prev:hover,
.ticker-next:hover {
  background: #e5e7eb;
  border-color: #aaaeb4;
}

.ticker-prev:active,
.ticker-next:active {
  transform: scale(0.95);
}

.ticker-prev svg,
.ticker-next svg {
  color: #374151;
}

/* Responsive */
@media (max-width: 768px) {
  .news-ticker-wrapper {
    padding: 10px 12px;
    gap: 12px;
    width: calc(100vw - var(--tcp-space-8));
  }

  .news-ticker-label {
    font-size: 0.75rem;
    padding: 4px 12px;
  }

  .ticker-item a,
  .ticker-item span {
    font-size: 0.875rem;
  }

  .ticker-prev,
  .ticker-next {
    width: 28px;
    height: 28px;
  }

  .ticker-prev svg,
  .ticker-next svg {
    width: 16px;
    height: 16px;
  }

  /* Faster marquee on mobile */
  .ticker-item.active .ticker-item-inner.overflow {
    animation-duration: 10s;
  }
}

/* ===================================
   COLUMN 3: ADVERTISEMENT
   =================================== */

.ad-column {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--tcp-space-4);
}

/* Internal Ad */
.internal-ad {
  width: 100%;
  height: 100%;
  flex: 1;
}

.internal-ad a,
.internal-ad .ad-link {
  display: block;
  width: 100%;
  height: 100%;
  transition: opacity 0.3s ease;
}

.internal-ad a:hover,
.internal-ad .ad-link:hover {
  opacity: 0.9;
}

.ad-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Desktop/Mobile Image Toggle */
.ad-image-desktop {
  display: block;
}

.ad-image-mobile {
  display: none;
}

/* Show mobile image on mobile devices */
@media (max-width: 768px) {
  .ad-image-desktop {
    display: none;
  }

  .ad-image-mobile {
    display: block;
  }
}

/* If no mobile image, keep showing desktop */
.internal-ad:not(:has(.ad-image-mobile)) .ad-image-desktop {
  display: block !important;
}

/* Google Ads */
.google-ads-wrapper {
  width: 100%;
  min-height: 600px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 992px) {
  .homepage-intro-grid {
    grid-template-columns: 1fr;
    gap: var(--tcp-space-8);
  }

  /* ========== REORDER COLUMNS ========== */
  /* Mobile order: Featured (1) → News (2) → Ad (3) */

  .news-column {
    order: 2; /* News second */
    max-width: 100%;
  }

  .carousel-column {
    order: 1; /* Featured carousel first */
    max-width: 100%;
  }

  .ad-column {
    order: 3; /* Advertisement third */
    max-width: 100%;
  }

  /* Remove separators on mobile */
  .homepage-intro-grid > *::after {
    display: none;
  }

  .carousel-title {
    font-size: var(--tcp-text-2xl);
  }
}

@media (max-width: 768px) {
  .carousel-content {
    padding: var(--tcp-space-4);
  }

  .carousel-title {
    font-size: var(--tcp-text-xl);
  }

  .carousel-meta {
    font-size: var(--tcp-text-xs);
  }

  .carousel-category {
    bottom: var(--tcp-space-3);
    left: var(--tcp-space-3);
    font-size: var(--tcp-text-xs);
    padding: var(--tcp-space-1) var(--tcp-space-3);
  }

  .section-title {
    font-size: var(--tcp-text-2xl);
  }

  .news-item-featured .news-title {
    font-size: var(--tcp-text-lg);
  }
}

@media (max-width: 480px) {
  .mod-homepage-intro {
    margin: var(--tcp-space-8) 0;
  }

  .homepage-intro-grid {
    gap: var(--tcp-space-6);
  }

  .carousel-title {
    font-size: var(--tcp-text-lg);
  }

  .carousel-category {
    font-size: var(--tcp-text-xs);
    padding: var(--tcp-space-1) var(--tcp-space-3);
  }

  .section-title {
    font-size: var(--tcp-text-xl);
  }

  .news-item-compact .news-title {
    font-size: var(--tcp-text-sm);
  }
}
