.ap-post-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--ap-space-xl);
}

@media (min-width: 1024px) {
  .ap-post-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }
}

.ap-post-card {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  padding: var(--ap-space-xl);
}

.ap-post-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ap-space-md);
  margin-bottom: var(--ap-space-lg);
}

.ap-post-card__tags {
  display: flex;
  gap: var(--ap-space-xs);
  flex-wrap: wrap;
}

.ap-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--ap-radius-sm);
  background: var(--ap-surface-alt);
  color: var(--ap-text);
  font-size: var(--ap-fs-sm);
  font-weight: 600;
}

.ap-tag:hover { color: var(--ap-primary); }

.ap-post-card__title {
  font-size: var(--ap-fs-h1);
}

.ap-post-card__byline {
  color: var(--ap-text-muted);
  font-size: var(--ap-fs-sm);
  margin-top: var(--ap-space-xs);
  margin-bottom: var(--ap-space-lg);
}

.ap-post-card__media {
  position: relative;
  border-radius: var(--ap-radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 8;
}

.ap-post-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ap-post-card__badge {
  position: absolute;
  left: var(--ap-space-lg);
  bottom: var(--ap-space-lg);
  background: rgba(10, 10, 10, 0.85);
  color: var(--ap-overlay-text);
  font-size: var(--ap-fs-sm);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 16px;
}

/* Lead paragraph reads as an italic dek, matching the reference layout. */
.ap-blog-body > p:first-of-type {
  font-style: italic;
  color: var(--ap-text-muted);
}

.ap-post-sidebar {
  position: sticky;
  top: calc(var(--ap-topbar-height) + var(--ap-topbar-gap) + var(--ap-header-height) + var(--ap-subnav-height) + var(--ap-space-md));
  display: flex;
  flex-direction: column;
  gap: var(--ap-space-lg);
}

/* h3, not h2 — a sidebar widget title (Table of Contents), one level below
   the post's own h2 sections, not a page-level section itself. */
.ap-post-sidebar h3 {
  font-size: var(--ap-fs-h3);
  margin-bottom: var(--ap-space-xs);
}

.ap-post-related-list {
  display: flex;
  flex-direction: column;
  gap: var(--ap-space-md);
}

/* Compact horizontal card — small thumbnail + text side by side, so the
   sidebar stays narrow and the article column keeps most of the width. */
.ap-post-related-card {
  display: flex;
  gap: var(--ap-space-sm);
  align-items: flex-start;
}

.ap-post-related-card__media {
  position: relative;
  flex-shrink: 0;
  width: 84px;
  border-radius: var(--ap-radius-sm);
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

.ap-post-related-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ap-post-related-card__badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(10, 10, 10, 0.85);
  color: var(--ap-overlay-text);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 5px;
}

.ap-post-related-card__date {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--ap-text-muted);
  margin-bottom: 2px;
}

.ap-post-related-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 700;
  font-size: var(--ap-fs-sm);
  line-height: 1.3;
  color: var(--ap-text);
}

.ap-share-icons {
  display: flex;
  gap: var(--ap-space-sm);
}

.ap-share-icons a {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--ap-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ap-share-icons a:hover { border-color: var(--ap-primary); color: var(--ap-primary); }

/* Admin-authored post body content (post_des) can contain any heading level
   via the rich-text editor — margin-bottom on all of them already comes from
   03-base.css; this just adds the margin-top a heading needs when it's
   preceded by a paragraph rather than being the first thing in its box. */
.ap-blog-body h2 { margin-top: var(--ap-space-lg); }
.ap-blog-body h3 { margin-top: var(--ap-space-md); }
.ap-blog-body h4,
.ap-blog-body h5,
.ap-blog-body h6 { margin-top: var(--ap-space-sm); }
.ap-blog-body p { margin-top: var(--ap-space-sm); }
.ap-blog-body img { border-radius: var(--ap-radius-md); }
.ap-blog-body figure { margin: var(--ap-space-md) 0; }
.ap-blog-body figcaption { font-size: var(--ap-fs-sm); color: var(--ap-text-muted); text-align: center; margin-top: var(--ap-space-xs); }

.ap-author-box {
  display: flex;
  gap: var(--ap-space-md);
  align-items: center;
  padding: var(--ap-space-md);
  background: var(--ap-surface-alt);
  border-radius: var(--ap-radius-md);
  margin-top: var(--ap-space-xl);
}

.ap-author-box__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ap-primary);
  color: var(--ap-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--ap-fs-h3);
  flex-shrink: 0;
}

/* ---------- Blog listing page (blogs.php) ---------- */

.ap-blog-catnav {
  display: flex;
  gap: var(--ap-space-lg);
  overflow-x: auto;
  padding-block: var(--ap-space-md);
}

.ap-blog-catnav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ap-space-xs);
  flex-shrink: 0;
  min-width: 72px;
  text-align: center;
  font-size: var(--ap-fs-sm);
  font-weight: 700;
  color: var(--ap-text);
}

.ap-blog-catnav__item:hover .ap-logo-badge { box-shadow: var(--ap-shadow-md); }

.ap-blog-catnav__item[aria-current="page"] { color: var(--ap-primary); }
.ap-blog-catnav__item[aria-current="page"] .ap-logo-badge {
  outline: 2px solid var(--ap-primary);
  outline-offset: 2px;
}

.ap-blog-feature {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--ap-space-xl);
}

@media (min-width: 1024px) {
  .ap-blog-feature { grid-template-columns: 2fr 1fr; }
}

.ap-blog-feature__media {
  position: relative;
  display: block;
  border-radius: var(--ap-radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--ap-shadow-md);
}

.ap-blog-feature__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ap-blog-feature__caption {
  position: absolute;
  inset: auto 0 0 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  padding: var(--ap-space-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* h2, not h1 — this is the featured post's own title, a subsection of the
   blog listing page (whose real h1 is the visually-hidden one at the top of
   blogs.php), not the page title itself. Kept at the full h1 SIZE though —
   it's still the largest, most visually prominent element on the page (a
   hero-style photo caption), just not semantically the page's h1. */
.ap-blog-feature__caption h2 {
  color: var(--ap-overlay-text);
  font-size: var(--ap-fs-h1);
  /* .ap-blog-feature__caption (parent) already spaces its children via flex
     `gap` — without this, the h2's own base margin-bottom (03-base.css)
     would stack on top of that gap. */
  margin-bottom: 0;
}

.ap-blog-feature__caption p {
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--ap-fs-sm);
}

.ap-blog-trending__heading {
  font-size: var(--ap-fs-sm);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ap-text);
  margin-bottom: var(--ap-space-md);
}

.ap-blog-trending__list {
  display: flex;
  flex-direction: column;
  gap: var(--ap-space-lg);
}

.ap-blog-trending__item {
  display: flex;
  gap: var(--ap-space-md);
  align-items: flex-start;
}

.ap-blog-trending__thumb {
  position: relative;
  flex-shrink: 0;
  width: 88px;
  height: 72px;
  border-radius: var(--ap-radius-md);
  overflow: visible;
}

.ap-blog-trending__thumb img {
  width: 100%;
  height: 100%;
  border-radius: var(--ap-radius-md);
  object-fit: cover;
  display: block;
}

.ap-blog-trending__badge {
  position: absolute;
  bottom: -8px;
  left: -8px;
}

.ap-blog-trending__title {
  display: block;
  font-weight: 700;
  font-size: var(--ap-fs-sm);
  line-height: 1.35;
  color: var(--ap-text);
}

.ap-blog-trending__date {
  display: block;
  margin-top: var(--ap-space-xs);
  font-size: 0.75rem;
  color: var(--ap-text-muted);
}

.ap-blog-latest-heading {
  font-size: var(--ap-fs-sm);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ap-text);
  margin-bottom: var(--ap-space-lg);
}

.ap-blog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--ap-space-xl);
}

@media (min-width: 768px) {
  .ap-blog-grid { grid-template-columns: repeat(2, 1fr); }
}

.ap-blog-card {
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  overflow: hidden;
  background: var(--ap-surface);
  transition: box-shadow var(--ap-transition), transform var(--ap-transition);
}

.ap-blog-card:hover {
  box-shadow: var(--ap-shadow-md);
  transform: translateY(-2px);
}

.ap-blog-card__media {
  position: relative;
}

.ap-blog-card__media .ap-media-ratio {
  border-radius: 0;
}

.ap-blog-card__badge {
  position: absolute;
  bottom: -16px;
  left: var(--ap-space-md);
}

.ap-blog-card__body {
  padding: var(--ap-space-lg);
  padding-top: calc(var(--ap-space-lg) + 14px);
  display: flex;
  flex-direction: column;
}

.ap-blog-card__category {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ap-primary);
  margin-bottom: var(--ap-space-xs);
}

.ap-blog-card__title {
  font-weight: 700;
  font-size: var(--ap-fs-h3);
  line-height: 1.3;
  color: var(--ap-text);
}

.ap-blog-card__date {
  margin-top: var(--ap-space-sm);
  font-size: var(--ap-fs-sm);
  color: var(--ap-text-muted);
}
