/*
 * Blog card (post item) — used by the blog-section pattern; reusable for any
 * post loop (blog archive, related posts). Styles the card itself only.
 * Grid / list layout lives in blog-section.css (or the consuming context).
 * Ported from ui/blog-item.html, grid + column shell only (no stack / featured
 * / highlight / @container row shells — add those when a second layout exists).
 */

/* --- Shell ------------------------------------------------------------- */
.blog-card {
  container-type: inline-size;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.blog-card:hover,
.blog-card:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 6px 20px -8px oklch(15% 0 0 / 0.18);
}

/* --- Media ----------------------------------------------------------- */
.blog-card__media {
  position: relative;
  flex-shrink: 0;
  background: var(--surface);
}

.blog-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- Body ---------------------------------------------------------- */
.blog-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 16px;
  min-width: 0;
  flex: 1;
  margin-top: 0;
}

/* --- Tags (eyebrow) ---------------------------------------------------- */
.blog-card__tags {
  display: flex;
  overflow: hidden;
  flex-wrap: nowrap;
  gap: 0.5rem;
  font-size: 0.6875rem;
  line-height: 1;
  margin-top: 0;
}

.blog-card__tags:empty {
  display: none;
}

.blog-card__tags a {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.175rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.blog-card__tags a:focus,
.blog-card__tags a:focus-visible,
.blog-card__tags a:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--fg);
}

.blog-card__tags a:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

/* --- Title -------------------------------------------------------- */
.blog-card__title {
  font-weight: 700;
  font-size: 1.1875rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--fg);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0;
}

.blog-card__title:empty {
  display: none;
}

/* --- Excerpt -------------------------------------------------- */
.blog-card .wp-block-post-excerpt {
  color: var(--muted);
  font-size: 0.9375rem;
  margin-top: 0;
}

.blog-card .wp-block-post-excerpt:empty,
.blog-card .wp-block-post-excerpt:has(.wp-block-post-excerpt__excerpt:empty) {
  display: none;
}

.blog-card .wp-block-post-excerpt__excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* --- Meta footer -------------------------------------------- */
/* Two-row grid:
 *   avatar   readtime   comment
 *   date              read-more
 * read-more now lives inside .blog-card__meta (last child). */
.blog-card__meta {
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas:
    "avatar readtime comment"
    "date   date     readmore";
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
  margin-top: auto;
  padding-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.blog-card__meta>* {
  min-width: 0;
  margin-top: 0;
}

.blog-card__meta>*:empty {
  display: none;
}

.blog-card__meta .wp-block-avatar          { grid-area: avatar; }
.blog-card__meta .wp-block-post-time-to-read { grid-area: readtime; }
.blog-card__meta .wp-block-post-comments-count { grid-area: comment; justify-self: end; }
.blog-card__meta .wp-block-post-date,
.blog-card__meta .blog-card__date          { grid-area: date; }
.blog-card__meta .blog-card__read-more     { grid-area: readmore; justify-self: end; }

/* author name removed from layout by request — never render it */
.blog-card__meta .wp-block-post-author-name {
  display: none;
}

/* avatar: small round mark, top-left of meta grid */
.blog-card__meta .wp-block-avatar {
  display: inline-flex;
  flex-shrink: 0;
}

.blog-card__meta .wp-block-avatar:empty {
  display: none;
}

.blog-card__meta .wp-block-avatar__image {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
  align-self: center;
}

.blog-card__meta .wp-block-post-time-to-read,
.blog-card__meta .wp-block-post-comments-count,
.blog-card__meta .wp-block-post-date {
  white-space: nowrap;
}

.blog-card__meta .wp-block-post-comments-count::after {
  content: " comments";
}

/* --- Read more ------------------------------------------------- */
/* The real <a> is a second post-title (level 0, isLink) — visually
 * hidden and stretched over the WHOLE card (.blog-card is position:relative),
 * so the entire card is one link. Genuine links (post-terms) sit above it
 * via z-index. The "Read more" label is decorative and sits in the meta grid. */
.blog-card__read-more {
  margin-top: 0;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--fg);
}

.blog-card__read-more-label {
  margin: 0;
}

.blog-card__read-more-label::after {
  content: " \2192";
}

.blog-card:hover .blog-card__read-more-label,
.blog-card:focus-within .blog-card__read-more-label {
  text-decoration: underline;
}

.blog-card__link {
  position: absolute;
  inset: 0;
  margin: 0;
  z-index: 1;
}

.blog-card__link .wp-block-post-title {
  display: block;
  width: 100%;
  height: 100%;
}

.blog-card__link a {
  display: block;
  width: 100%;
  height: 100%;
  color: transparent;
  font-size: 0;
  text-decoration: none;
}

.blog-card__link a:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

  .blog-card,
  .blog-card__tags a {
    transition: none;
  }
}
