/* =============================================================================
   RELATED-POSTS.CSS — Related Articles Grid
   Hello Elementor Child Theme

   Renders a responsive grid of related post cards below the author box.

   Structure:
     section.hec-related-posts
       div.hec-related-posts__header
         h2.hec-related-posts__heading        ("Keep Reading")
       div.hec-related-posts__grid
         article.hec-related-card (× 3)
           a.hec-related-card__thumb-link
             div.hec-related-card__thumb-wrap
               img.hec-related-card__img
               — OR —
               div.hec-related-card__thumb-fallback
                 span.hec-related-card__thumb-fallback-label
               span.hec-related-card__category-badge
           div.hec-related-card__body
             h3.hec-related-card__title
               a.hec-related-card__title-link
             div.hec-related-card__meta
               time.hec-related-card__date
               span.hec-related-card__sep
               span.hec-related-card__reading-time

   Design intent:
     Three-column grid on desktop. Two on tablet. One on mobile.
     Cards have a distinct thumbnail area with an overlaid category badge.
     On hover, the card lifts and the image scales subtly.
     Staggered entrance animations give the grid life.
     Each card is a complete link target — any click navigates to the post.
   ============================================================================= */


/* =============================================================================
   1. SECTION WRAPPER
   ============================================================================= */

.hec-related-posts {
  width:        100%;
  max-width:    var(--hec-content-width-wide);
  margin:       var(--hec-space-12) auto var(--hec-space-10);
  padding:      0;

  transition:
    color            var(--hec-transition-slow),
    background-color var(--hec-transition-slow);
}


/* =============================================================================
   2. SECTION HEADER
   ============================================================================= */

.hec-related-posts__header {
  margin-bottom: var(--hec-space-8);
}

.hec-related-posts__heading {
  font-family:    var(--hec-font-heading);
  font-size:      var(--hec-text-2xl);
  font-weight:    var(--hec-weight-bold);
  color:          var(--hec-color-text-primary);
  line-height:    var(--hec-leading-tight);
  letter-spacing: var(--hec-tracking-tight);

  /*
   * Accent line before the heading.
   * Amber gradient bar above "Keep Reading".
   */
  display:     flex;
  flex-direction: column;
  gap:         var(--hec-space-3);

  transition:
    color var(--hec-transition-slow);
}

.hec-related-posts__heading::before {
  content:       '';
  display:       block;
  width:         48px;
  height:        3px;
  background:    linear-gradient(
                   90deg,
                   var(--hec-brand-amber) 0%,
                   var(--hec-brand-gold)  100%
                 );
  border-radius: var(--hec-radius-full);
}


/* =============================================================================
   3. GRID
   ============================================================================= */

.hec-related-posts__grid {
  display:               grid;
  grid-template-columns: repeat(3, 1fr);
  gap:                   var(--hec-space-6);
}

@media (max-width: 900px) {
  .hec-related-posts__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .hec-related-posts__grid {
    grid-template-columns: 1fr;
    gap:                   var(--hec-space-5);
  }
}


/* =============================================================================
   4. CARD
   ============================================================================= */

.hec-related-card {
  display:        flex;
  flex-direction: column;
  background:     var(--hec-color-card-bg);
  border:         1px solid var(--hec-color-card-border);
  border-radius:  var(--hec-radius-xl);
  overflow:       hidden;

  box-shadow:     var(--hec-shadow-sm);

  /*
   * Card is its own stacking context.
   * Prevents z-index from leaking between cards.
   */
  isolation:      isolate;

  transition:
    transform     var(--hec-transition-normal),
    box-shadow    var(--hec-transition-normal),
    border-color  var(--hec-transition-normal),
    background    var(--hec-transition-slow);
}

/*
 * Hover lift.
 * The card rises, shadow deepens, and a faint amber
 * glow appears at the bottom for premium depth.
 */
.hec-related-card:hover {
  transform:    translateY(-6px);
  box-shadow:
    var(--hec-shadow-xl),
    0 8px 24px rgba(209, 106, 11, 0.10);
  border-color: var(--hec-color-border-accent);
}

.hec-related-card:active {
  transform:  translateY(-2px);
  box-shadow: var(--hec-shadow-md);
}


/* =============================================================================
   5. THUMBNAIL AREA
   ============================================================================= */

.hec-related-card__thumb-link {
  display:  block;
  overflow: hidden;
}

.hec-related-card__thumb-wrap {
  position:     relative;
  aspect-ratio: 16 / 10;
  overflow:     hidden;
  background:   var(--hec-color-bg-sunken);
}

/*
 * Thumbnail image.
 * Fills the container with object-fit: cover.
 * Subtle scale on card hover for a magazine-quality feel.
 */
.hec-related-card__img {
  width:       100%;
  height:      100%;
  object-fit:  cover;
  display:     block;
  transition:
    transform var(--hec-duration-slow) var(--hec-ease-smooth),
    filter    var(--hec-transition-slow);
}

.hec-related-card:hover .hec-related-card__img {
  transform: scale(1.06);
}

/*
 * Gradient overlay at the bottom of the thumbnail.
 * Ensures the category badge is legible on any image.
 */
.hec-related-card__thumb-wrap::after {
  content:    '';
  position:   absolute;
  bottom:     0;
  left:       0;
  right:      0;
  height:     40%;
  background: linear-gradient(
                to top,
                rgba(21, 3, 3, 0.35) 0%,
                transparent 100%
              );
  pointer-events: none;
  z-index:    1;
}


/* =============================================================================
   6. THUMBNAIL FALLBACK (no featured image)
   ============================================================================= */

.hec-related-card__thumb-fallback {
  width:       100%;
  height:      100%;
  display:     flex;
  align-items: center;
  justify-content: center;

  /*
   * Brand gradient background when no image is available.
   * Uses the warm amber/crimson palette so it still feels on-brand.
   */
  background: linear-gradient(
    135deg,
    var(--hec-brand-brown-deep) 0%,
    var(--hec-brand-crimson)    40%,
    var(--hec-brand-amber-dark) 100%
  );
}

.hec-related-card__thumb-fallback-label {
  font-family:    var(--hec-font-heading);
  font-size:      var(--hec-text-sm);
  font-weight:    var(--hec-weight-bold);
  color:          rgba(255, 255, 255, 0.60);
  text-transform: uppercase;
  letter-spacing: var(--hec-tracking-widest);
}


/* =============================================================================
   7. CATEGORY BADGE ON THUMBNAIL
   ============================================================================= */

.hec-related-card__category-badge {
  position:       absolute;
  bottom:         var(--hec-space-3);
  left:           var(--hec-space-3);
  z-index:        2;

  display:        inline-flex;
  align-items:    center;
  padding:        2px var(--hec-space-3);
  border-radius:  var(--hec-radius-full);

  background:     var(--hec-brand-amber);
  color:          var(--hec-white);
  backdrop-filter: blur(4px);

  font-family:    var(--hec-font-meta);
  font-size:      var(--hec-text-xs);
  font-weight:    var(--hec-weight-semibold);
  letter-spacing: var(--hec-tracking-wider);
  text-transform: uppercase;
  white-space:    nowrap;

  transition:
    background  var(--hec-transition-fast),
    transform   var(--hec-transition-fast),
    box-shadow  var(--hec-transition-fast);
}

.hec-related-card:hover .hec-related-card__category-badge {
  background: var(--hec-brand-amber-light);
  transform:  translateY(-1px);
  box-shadow: var(--hec-shadow-amber);
}


/* =============================================================================
   8. CARD BODY
   ============================================================================= */

.hec-related-card__body {
  display:        flex;
  flex-direction: column;
  flex:           1;
  padding:        var(--hec-space-5) var(--hec-space-5) var(--hec-space-5);
  gap:            var(--hec-space-3);
}


/* =============================================================================
   9. CARD TITLE
   ============================================================================= */

.hec-related-card__title {
  font-family:    var(--hec-font-heading);
  font-size:      var(--hec-text-base);
  font-weight:    var(--hec-weight-semibold);
  line-height:    var(--hec-leading-snug);
  letter-spacing: var(--hec-tracking-tight);
  color:          var(--hec-color-text-primary);
  margin:         0;

  /*
   * Three-line clamp.
   * Ensures uniform card height across the grid.
   */
  display:            -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow:           hidden;

  transition:
    color var(--hec-transition-fast);
}

.hec-related-card__title-link {
  color:           inherit;
  text-decoration: none;

  /*
   * Underline draw on hover.
   */
  background-image:   linear-gradient(
                        var(--hec-color-accent),
                        var(--hec-color-accent)
                      );
  background-size:    0% 1.5px;
  background-repeat:  no-repeat;
  background-position: left bottom;
  padding-bottom:     2px;
  transition:
    background-size var(--hec-transition-normal) var(--hec-ease-out),
    color           var(--hec-transition-fast);
}

.hec-related-card:hover .hec-related-card__title-link {
  color:           var(--hec-color-accent);
  background-size: 100% 1.5px;
}


/* =============================================================================
   10. CARD META — Date + Reading Time
   ============================================================================= */

.hec-related-card__meta {
  display:     flex;
  align-items: center;
  flex-wrap:   wrap;
  gap:         var(--hec-space-2);
  margin-top:  auto;

  font-family: var(--hec-font-meta);
  font-size:   var(--hec-text-xs);
  color:       var(--hec-color-text-tertiary);

  transition:
    color var(--hec-transition-slow);
}

.hec-related-card__date {
  white-space: nowrap;
}

.hec-related-card__sep {
  color:       var(--hec-color-text-disabled);
  user-select: none;
}

.hec-related-card__reading-time {
  white-space:  nowrap;
  font-weight:  var(--hec-weight-medium);
  color:        var(--hec-color-accent);
}


/* =============================================================================
   11. REVEAL ANIMATION
   ============================================================================= */

/*
 * Section-level reveal.
 * The entire related posts section fades in as a block.
 * Individual cards have their own staggered reveal below.
 */
.hec-related-posts[data-reveal="related-section"] {
  opacity:   0;
  transform: translateY(16px);
}

.hec-related-posts[data-reveal="related-section"].hec-revealed {
  opacity:   1;
  transform: translateY(0);
}

/*
 * Card-level staggered reveal.
 * Each card delays its entrance by data-reveal-delay (set in PHP).
 * animations.js reads data-reveal-delay and applies it as
 * transition-delay before adding .hec-revealed.
 *
 * The transition properties are defined in animations.css
 * under [data-reveal="related-card"].
 */


/* =============================================================================
   12. RESPONSIVE
   ============================================================================= */

@media (max-width: 900px) {
  .hec-related-posts {
    margin: var(--hec-space-10) auto;
  }

  .hec-related-posts__heading {
    font-size: var(--hec-text-xl);
  }
}

@media (max-width: 560px) {
  .hec-related-posts {
    margin: var(--hec-space-8) auto;
  }

  .hec-related-posts__heading {
    font-size: var(--hec-text-lg);
  }

  .hec-related-card__thumb-wrap {
    aspect-ratio: 16 / 9;
  }

  .hec-related-card__body {
    padding: var(--hec-space-4);
  }

  .hec-related-card__title {
    font-size: var(--hec-text-sm);
    -webkit-line-clamp: 2;
  }
}


/* =============================================================================
   13. EMPTY STATE
   Rendered when related-posts.php returns early (no related posts).
   The entire section is removed from DOM, so this is a safety net
   in case JS or a filter injects empty markup.
   ============================================================================= */

.hec-related-posts__grid:empty {
  display: none;
}

.hec-related-posts__grid:empty + .hec-related-posts__header {
  display: none;
}


/* =============================================================================
   14. REDUCED MOTION
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  .hec-related-posts[data-reveal="related-section"] {
    opacity:   1;
    transform: none;
    transition:
      color            var(--hec-transition-slow),
      background-color var(--hec-transition-slow);
  }

  .hec-related-card:hover {
    transform: none;
  }

  .hec-related-card:hover .hec-related-card__img {
    transform: none;
  }
}