/* ==========================================================================
   Blog — archive (index.php), single post (single.php), post card.
   Spec: notes/design-system.md §12. Tokens only; light/dark come from :root.

   1. Archive
   2. Post card
   3. Single post: layout + header
   4. Table of contents
   5. Article typography
   6. After the article: disclaimer, products, quiz card, related
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Archive
   -------------------------------------------------------------------------- */
.blog__header {
  margin-bottom: var(--spacing-lg);
}

.blog__title {
  font-size: clamp(1.8rem, 5vw, 2.75rem);
}

.blog__lead {
  max-width: 40rem;
  margin: var(--spacing-sm) 0 0;
  color: var(--color-text-muted);
}

/* Category chips: same chip as .shop__filter-chip, scrolls sideways on phones
   instead of wrapping into a tall block. */
.blog__cats {
  display: flex;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-md);
  overflow-x: auto;
  scrollbar-width: none;
}

.blog__cats::-webkit-scrollbar {
  display: none;
}

.blog__cat {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  min-height: 44px;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--color-text);
  font-size: 0.9375rem;
  font-weight: 500;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease;
}

.blog__cat:hover,
.blog__cat:focus-visible {
  color: var(--color-text);
  border-color: var(--color-accent);
}

.blog__cat[aria-current='page'] {
  color: var(--color-on-accent);
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.blog__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-lg);
}

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

@media (min-width: 900px) {
  .blog__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* the_posts_pagination(): main.css styles .pagination; the links sit in
   .nav-links, which needs the row layout and 44px tap targets. */
.blog .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
}

.blog .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--color-text);
}

.blog .page-numbers.current {
  color: var(--color-on-accent);
}

.blog .page-numbers.dots {
  border-color: transparent;
}

.blog__empty {
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   2. Post card — same surface as .product-card (design-system §08).
   -------------------------------------------------------------------------- */
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 26px var(--color-shadow);
  transition: box-shadow 0.4s var(--ease-soft);
}

.post-card__media {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--media-bg);
}

.post-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-soft);
}

.post-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--spacing-xs);
  padding: var(--spacing-md);
}

.post-card__cat {
  color: var(--color-accent-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.post-card__title {
  margin: 0;
  font-size: 1.1875rem;
  line-height: 1.3;
}

.post-card__title a {
  color: var(--color-text);
}

/* Whole card is the click target; the title link stays the accessible one. */
.post-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.post-card__excerpt {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.post-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin: auto 0 0;
  padding-top: var(--spacing-sm);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .post-card:hover {
    box-shadow: 0 0 34px var(--color-shadow-strong);
  }

  .post-card:hover .post-card__image {
    transform: scale(1.04);
  }

  .post-card:hover .post-card__title a {
    color: var(--color-accent-text);
  }
}

/* Featured: newest post on page 1, full row, image beside text from 900px. */
.post-card--featured {
  grid-column: 1 / -1;
}

.post-card--featured .post-card__title {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
}

.post-card--featured .post-card__excerpt {
  font-size: 1rem;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

@media (min-width: 900px) {
  .post-card--featured {
    display: grid;
    grid-template-columns: 3fr 2fr;
  }

  .post-card--featured .post-card__body {
    justify-content: center;
    padding: var(--spacing-lg);
  }

  .post-card--featured .post-card__meta {
    margin-top: var(--spacing-sm);
  }
}

/* --------------------------------------------------------------------------
   3. Single post: layout + header
   -------------------------------------------------------------------------- */

/* Reading column: about 68 characters per line at the article size. */
.blog-post__narrow {
  width: min(100% - 2 * var(--spacing-md), 45rem);
  margin-inline: auto;
}

.blog-post__header {
  margin-bottom: var(--spacing-lg);
}

.blog-post__title {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.75rem);
  line-height: 1.15;
}

.blog-post__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin: var(--spacing-sm) 0 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Image a bit wider than the text column, so the page has some shape. */
.blog-post__image {
  width: min(100% - 2 * var(--spacing-md), 60rem);
  margin: 0 auto var(--spacing-lg);
}

.blog-post__image img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

/* --------------------------------------------------------------------------
   4. Table of contents — <details>, collapsed, no JS.
   -------------------------------------------------------------------------- */
.blog-toc {
  margin-bottom: var(--spacing-lg);
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.blog-toc__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: var(--spacing-sm) var(--spacing-md);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.blog-toc__summary::-webkit-details-marker {
  display: none;
}

.blog-toc__summary::after {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--icon-chevron) center / contain no-repeat;
  transition: transform 0.2s ease;
}

.blog-toc[open] .blog-toc__summary::after {
  transform: rotate(180deg);
}

.blog-toc__list {
  margin: 0;
  padding: 0 var(--spacing-md) var(--spacing-md) calc(var(--spacing-md) + 1.25em);
  list-style: decimal;
}

.blog-toc__list li + li {
  margin-top: var(--spacing-xs);
}

.blog-toc__list a {
  color: var(--color-text);
}

.blog-toc__list a:hover,
.blog-toc__list a:focus-visible {
  color: var(--color-accent-text);
}

/* --------------------------------------------------------------------------
   5. Article typography — scoped here so it never reaches page.php,
      cart or account (they share .entry-content).
   -------------------------------------------------------------------------- */
.blog-post__content {
  font-size: 1.0625rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.blog-post__content > * {
  margin-top: 0;
  margin-bottom: 1.25em;
}

.blog-post__content h2,
.blog-post__content h3,
.blog-post__content h4 {
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  line-height: 1.25;
  /* TOC jumps land below the sticky header. */
  scroll-margin-top: calc(var(--header-height) + var(--spacing-lg));
}

.blog-post__content h2 {
  font-size: clamp(1.4rem, 3.5vw, 1.75rem);
}

.blog-post__content h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.blog-post__content h4 {
  font-size: 1.0625rem;
}

.blog-post__content > :first-child {
  margin-top: 0;
}

/* Links stay underlined in running text, so they read as links. */
.blog-post__content a {
  color: var(--color-accent-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.blog-post__content a:hover,
.blog-post__content a:focus-visible {
  text-decoration-thickness: 2px;
}

/* main.css resets list styles globally; articles need them back. */
.blog-post__content ul,
.blog-post__content ol {
  padding-left: 1.4em;
}

.blog-post__content ul {
  list-style: disc;
}

.blog-post__content ol {
  list-style: decimal;
}

.blog-post__content li + li {
  margin-top: 0.35em;
}

.blog-post__content li::marker {
  color: var(--color-accent-text);
}

.blog-post__content blockquote {
  margin-inline: 0;
  padding: var(--spacing-sm) 0 var(--spacing-sm) var(--spacing-md);
  font-size: 1.125rem;
  border-left: 3px solid var(--color-accent);
}

.blog-post__content blockquote > :last-child {
  margin-bottom: 0;
}

.blog-post__content blockquote cite {
  display: block;
  margin-top: var(--spacing-sm);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-style: normal;
}

.blog-post__content img {
  height: auto;
  border-radius: var(--radius-md);
}

.blog-post__content figure {
  margin-inline: 0;
}

.blog-post__content figcaption {
  margin-top: var(--spacing-sm);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  text-align: center;
}

.blog-post__content hr {
  margin-block: var(--spacing-lg);
  border: 0;
  border-top: 1px solid var(--color-border);
}

/* Tables scroll sideways on phones instead of widening the page. */
.blog-post__content .wp-block-table {
  overflow-x: auto;
}

.blog-post__content table {
  width: 100%;
  font-size: 0.9375rem;
  border-collapse: collapse;
}

.blog-post__content th,
.blog-post__content td {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border: 1px solid var(--color-border);
}

.blog-post__content th,
.blog-post__content thead td {
  font-weight: 600;
  background-color: var(--color-bg-surface);
}

.blog-post__content iframe {
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   6. After the article
   -------------------------------------------------------------------------- */
.blog-post__disclaimer {
  margin: var(--spacing-lg) 0 0;
  padding-top: var(--spacing-md);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--color-border);
}

.blog-section-title {
  margin-bottom: var(--spacing-md);
  font-size: clamp(1.4rem, 4vw, 1.75rem);
}

.blog-products,
.blog-related {
  margin-top: var(--spacing-xl);
}

/* Product cards keep the catalog's 2-up phone grid. */
.blog-products__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 900px) {
  .blog-products__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.blog-products__item {
  display: flex;
}

.blog-products__item > .product-card {
  width: 100%;
}

.blog-quiz {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
  padding: var(--spacing-lg);
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-lg);
}

.blog-quiz__copy {
  flex: 1 1 18rem;
}

.blog-quiz__title {
  margin: 0;
  font-size: 1.375rem;
}

.blog-quiz__lead {
  margin: var(--spacing-xs) 0 0;
  color: var(--color-text-muted);
}

.blog-quiz__button {
  flex-shrink: 0;
}

.blog-related__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spacing-lg);
}

/* Two cards at tablet width (the third would be too narrow), three from 900px. */
@media (min-width: 600px) {
  .blog-related__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .blog-related__grid > :nth-child(3) {
    display: none;
  }
}

@media (min-width: 900px) {
  .blog-related__grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .blog-related__grid > :nth-child(3) {
    display: flex;
  }
}
