/*
 * Blog listing cards (/blog/), markup in _includes/blog_listing_card.html.
 *
 * Mobile / touch: a compact card, no tags, no hover panel.
 * Desktop (fine pointer that can hover, >= 768px): hovering a card opens an
 * expanded version that spans the full width of the card grid, Netflix
 * style, with a large cover and all the details. It overlays the row, so the
 * grid never reflows; moving the mouse off it closes it.
 */

.blog-card {
  position: relative;
}

.blog-card .blog-card-title {
  margin-bottom: 0.5rem;
}

.blog-card .card-img-top {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* Read / Watch line. The Watch pill sits above the stretched link. */
.blog-card-kind {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.blog-card-play {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #e62117;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.blog-card-play:hover,
.blog-card-play:focus {
  background: #c4180f;
  color: #fff;
}

/* The expanded card only exists on hover-capable desktops. */
.blog-card-more {
  display: none;
}

@media (hover: hover) and (pointer: fine) and (min-width: 768px) {
  /* The expanded card is positioned against the whole grid, not the column,
     so it can span the full grid width. The animate-on-scroll transform would
     make each column its containing block, so drop it once the card is in view. */
  .blog-cards {
    position: relative;
  }

  .blog-cards > .blog-card-col.in-view {
    transform: none;
  }

  .blog-card {
    transition: box-shadow 0.2s ease;
  }

  .blog-card-col:hover .blog-card {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  }

  .blog-card-more {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    position: absolute;
    z-index: 40;
    top: 0;
    left: calc(var(--bs-gutter-x) * 0.5);
    right: calc(var(--bs-gutter-x) * 0.5);
    min-height: calc(100% - var(--bs-gutter-y));
    margin-top: var(--bs-gutter-y);
    background: #f8f9fa;
    border-radius: 0.5rem;
    box-shadow: 0 1.25rem 2.5rem rgba(0, 0, 0, 0.25);
    overflow: hidden;
    color: #444;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.96);
    /* Leaving: close straight away. */
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
    pointer-events: none;
  }

  /* Short delay before opening, so sweeping the mouse across the row
     doesn't flash the expanded card. */
  .blog-card-col:hover .blog-card-more,
  .blog-card-col:focus-within .blog-card-more {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
    transition: opacity 0.2s ease 0.35s, transform 0.2s ease 0.35s, visibility 0s linear 0.35s;
  }

  /* Grow out of the hovered card's side of the row. */
  .blog-card-col:nth-child(4n+1) .blog-card-more { transform-origin: left center; }
  .blog-card-col:nth-child(4n+2) .blog-card-more { transform-origin: 35% center; }
  .blog-card-col:nth-child(4n+3) .blog-card-more { transform-origin: 65% center; }
  .blog-card-col:nth-child(4n) .blog-card-more { transform-origin: right center; }

  /* Show the whole cover (no cropping of the thumbnail text). */
  .blog-card-more-media {
    display: block;
    position: relative;
    z-index: 3;
    align-self: start;
    padding: 1rem 0 1rem 1rem;
  }

  .blog-card-more-media img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0.4rem;
  }

  .blog-card-more-body {
    padding: 1.25rem 1.5rem;
  }

  .blog-card-more-title {
    font-size: 1.35rem;
    line-height: 1.25;
    margin-bottom: 0.35rem;
  }

  .blog-card-more-desc {
    margin-bottom: 0.6rem;
  }

  /* Links in the expanded card sit above the compact card's stretched link. */
  .blog-card-more a {
    position: relative;
    z-index: 3;
  }
}

.blog-card-excerpt {
  line-height: 1.45;
  margin-bottom: 0.6rem;
}

.blog-card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  color: #555;
}

.blog-card-topics a {
  color: inherit;
}

.blog-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.blog-card-tags .badge {
  font-weight: 500;
}

.blog-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
  .blog-card,
  .blog-card-more {
    transition: none !important;
    transform: none !important;
  }
}
