/* rr-blog-filters.css
   Blog index: 3-column grid at lg, 2 at md, 1 on mobile, plus topic pills.
   Load this AFTER shared-bundle and rr-linked-cards.css so the stacked card
   layout wins over the single-column 16rem side-by-side rule at 1024px.
   Tokens match the site (accent, border, card, ring). Pill colors follow
   the booking chips: outlined when idle, filled accent when selected. */

/* ---- 1. Show the filter bar only when JS ran before first paint --------- */
.rr-blog-filters {
  display: none;
}

html.rr-blog-filters-js .rr-blog-filters {
  display: block;
  margin: 0 0 1.5rem;
}

.rr-blog-filters__label {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--accent));
}

/* On small screens the row scrolls sideways and does not wrap.
   Padding keeps the focus ring from being clipped. */
.rr-blog-filters__pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0.25rem 0.15rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--accent) / 0.55) transparent;
  overscroll-behavior-x: contain;
}

@media (min-width: 768px) {
  .rr-blog-filters__pills {
    flex-wrap: wrap;
    overflow: visible;
    padding: 0.25rem;
  }
}

.rr-blog-filters__pill {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .rr-blog-filters__pill:hover {
    border-color: hsl(var(--accent));
  }
}

.rr-blog-filters__pill[aria-pressed="true"] {
  border-color: hsl(var(--accent));
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.rr-blog-filters__pill:focus {
  outline: none;
}

.rr-blog-filters__pill:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.rr-blog-filters__count {
  margin: 0.75rem 0 0;
  min-height: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: hsl(var(--muted-foreground));
}

.rr-blog-filters__empty {
  display: none;
  margin: 0.5rem 0 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.95rem;
  line-height: 1.5;
}

.rr-blog-filters__empty.is-visible {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .rr-blog-filters__pill {
    transition: none;
  }
}

/* ---- 2. Card grid ------------------------------------------------------- */
ul.blog-index-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

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

@media (min-width: 1024px) {
  ul.blog-index-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Keep hidden cards out of the grid so gaps do not linger. */
.blog-index-grid > li[hidden],
.blog-index-grid .post-card[hidden] {
  display: none;
}

/* In a multi-column grid, stack the photo on top of the text. The existing
   1024px rule turns each card into a 16rem side-by-side layout, which is
   built for a single full-width column. Colors, borders, type family, and
   hover stay the same. */
@media (min-width: 768px) {
  .blog-index-grid .blog-index-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .blog-index-grid .blog-index-card__media {
    height: auto;
    min-height: 11rem;
    aspect-ratio: 16 / 9;
  }

  .blog-index-grid .blog-index-card > .flex {
    padding: 1.5rem;
  }

  .blog-index-grid .blog-index-card h2 {
    font-size: 1.75rem;
    line-height: 1.15;
  }
}

@media (min-width: 1024px) {
  .blog-index-grid .blog-index-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .blog-index-grid .blog-index-card h2 {
    font-size: 1.65rem;
    line-height: 1.15;
  }
}

/* ---- 3. ?topic= deep links without layout shift -------------------------
   The head script sets html[data-rr-blog-topic] before first paint when the
   URL has a valid ?topic=, so non-matching cards never render and then
   collapse. rr-blog-filters.js removes the attribute once it has applied the
   same filter with hidden attributes. Browsers without :has() skip this. */
html[data-rr-blog-topic="paint"] .blog-index-grid > li:not(:has(> [data-topic="paint"])) {
  display: none;
}
html[data-rr-blog-topic="ceramic"] .blog-index-grid > li:not(:has(> [data-topic="ceramic"])) {
  display: none;
}
html[data-rr-blog-topic="interior"] .blog-index-grid > li:not(:has(> [data-topic="interior"])) {
  display: none;
}
html[data-rr-blog-topic="exterior"] .blog-index-grid > li:not(:has(> [data-topic="exterior"])) {
  display: none;
}
html[data-rr-blog-topic="local"] .blog-index-grid > li:not(:has(> [data-topic="local"])) {
  display: none;
}
