:root {
  --bg: #F9FAFB; /* main background for light mode */
  --panel: #FFFFFF; /* card/panel background */
  --muted: #6B7280; /* for meta text / secondary info */
  --text: #111827; /* main text color */
  --accent: #00C982; /* primary brand color */
  --accent-2: #00E4FF; /* secondary gradient color */
  --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --glow: 0 8px 30px rgba(0, 201, 130, 0.12); /* subtle shadow for light theme */
  --radius: 14px; 
  --toc-width: 300px;
  --toc-top: 120px;
}

/* Reset & base */
* {
  box-sizing: border-box;
}

/* Related Articles Section */
.related-articles-section {
  margin: 2.5rem 0;
  width: 100%;
  max-width: var(--max-width);
  -webkit-font-smoothing: antialiased;
}

/* Section Title */
.related-title {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  color: var(--text); /* dark text for light mode */
  line-height: 1.2;
}


/* Spotlight container */
.related-spotlight {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
  align-items: start;
}

/* Featured Card */
.featured-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  border: 1px solid rgba(0,0,0,0.08); /* subtle border for light theme */
  background: #FFFFFF; /* light card background */
  transition: transform 0.28s cubic-bezier(.2,.9,.2,1), box-shadow 0.28s ease;
  will-change: transform;
}

/* Hover effect for featured card */
.featured-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.12); /* subtle shadow for light mode */
}

/* Media / image container */
.media-feature {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

/* Image inside the media */
.media-feature .thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease, opacity 0.35s ease;
  will-change: transform;
}

/* Slight scale on hover */
.featured-card:hover .media-feature .thumb {
  transform: scale(1.04);
}

/* Overlay fade-in */
.media-feature::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(0,0,0,0.05));
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.featured-card:hover .media-feature::after {
  opacity: 1;
}


/* Featured info section */
.related-featured-info {
  padding: 1rem 1.25rem;
  background: #F9FAFB; /* light subtle card section */
  border-radius: var(--radius);
}

/* Kicker (small uppercase text) */
.kicker {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent); /* brand color */
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  margin-bottom: 0.5rem;
}


/* Mini grid container for smaller articles */
.mini-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
  scroll-padding-left: 0.6rem; /* polish for scroll snap */
}

/* Small related cards */
.related-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  text-decoration: none;
  border: 1px solid rgba(0,0,0,0.08); /* subtle border for light mode */
  background: #FFFFFF; /* light card background */
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  box-shadow: var(--glow); /* subtle shadow for depth */
}

/* Hover effect for mini cards */
.related-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

/* Media inside mini card (4:3 ratio) */
.related-card .media {
  width: 42%;
  aspect-ratio: 4 / 3;
  border-radius: 0.6rem;
  overflow: hidden;
  flex-shrink: 0;
}

/* Image inside mini card */
.related-card .media .thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

/* Micro zoom on hover */
.related-card:hover .media .thumb {
  transform: scale(1.04);
}

/* Text info container for mini card */
.related-info {
  flex: 1;
}

/* Article title */
.related-article-title {
  font-size: 1.08rem;
  line-height: 1.28;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.25rem 0;
  color: #111827; /* dark text for readability on light cards */
}

/* Small meta info */
.related-meta {
  font-size: 0.85rem;
  color: #6B7280; /* muted grey for secondary info */
  margin: 0;
}

/* Title underline slide (hover) */
.related-card .related-article-title,
.featured-card .related-article-title {
  position: relative;
}

.related-card .related-article-title::after,
.featured-card .related-article-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -6px;
  height: 3px;
  width: 0%;
  background: var(--accent-gradient);
  transition: width 0.22s cubic-bezier(.2,.8,.2,1);
  border-radius: 2px;
}

.related-card:hover .related-article-title::after,
.featured-card:hover .related-article-title::after {
  width: 36%;
}


/* Responsive layout adjustments */
@media (min-width: 768px) {
  /* Spotlight section splits into main + sidebar */
  .related-spotlight {
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
  }

  /* Mini grid stacked for larger screens */
  .mini-grid {
    margin-top: 0;
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .related-spotlight {
    grid-template-columns: 1fr 320px;
    gap: 2rem;
  }
}

/* Mobile horizontal scroller polish */
@media (max-width: 639px) {
  .related-spotlight {
    display: block;
  }

  .mini-grid {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  /* Each mini card width and snap alignment */
  .related-card {
    flex: 0 0 78%;
    scroll-snap-align: start;
  }

  .related-card .media {
    width: 48%;
  }
}

/* Accessibility / reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .featured-card,
  .related-card,
  .media .thumb,
  .related-article-title::after {
    transition: none !important;
  }
}

/* Force featured image to fill the featured card */
.featured-card .media-feature {
  width: 100%;
  flex-shrink: 0;      /* prevents flex from shrinking the media */
}

.featured-card .media-feature .thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;    /* ensures full cover */
  object-position: center;
  display: block;
}

.featured-card {
  border: none;
  overflow: hidden;
}

.featured-card .media-feature {
  width: 100%;
  flex-shrink: 0;
  max-height: 450px; /* adjust as needed */
  overflow: hidden;
}


@media (max-width: 639px) {
  .related-card {
    flex: 0 0 78%;      /* keeps scroll width */
    display: flex;
    flex-direction: column; /* stack image + info */
  }

  .related-card .media {
    width: 100%;
    aspect-ratio: auto;   /* remove forced 4/3 */
    flex-shrink: 0;
    flex-grow: 1;         /* take available space */
  }

  .related-card .media .thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;    /* fills container */
  }
}



/* Desktop mini grid fix */
@media (min-width: 1024px) {
  .related-card {
    display: flex;
    gap: 1rem;
    align-items: stretch; /* make children stretch to card height */
  }



  .related-card .media .thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;   /* cover full media height */
  }
}


@media (min-width: 1024px) {
  .mini-grid {
    width: 100%;        /* fill the sidebar column */
    max-width: 100%;    /* prevent overflow */
    box-sizing: border-box;
  }

  .related-card {
    width: 100%;        /* each mini card fills the column */
    display: flex;
    gap: 1rem;
    align-items: stretch; /* keeps images filling height */
  }
}


/* Reduce featured card width on desktop */
@media (min-width: 1024px) {
  .featured-card {
    max-width: 70%;       /* adjust percentage as needed */
    margin-right: auto;   /* keep it left-aligned */
  }
}
@media (min-width: 1024px) {
  .related-spotlight {
    grid-template-columns: 2fr 1fr;  /* featured card gets 2/3, mini-grid 1/3 */
    gap: 2rem;
  }

  .featured-card {
    max-width: 100%;  /* now fills its 2fr column */
  }
}
