/*
 * Blog styling — list and detail pages.
 *
 * Palette is derived from the live brand mark (carbsnap-logo-light.png):
 * coral #FF8080 for the wordmark and both accent dots. The rest of the
 * site keeps that coral confined to the logo and uses the theme's stock
 * blue (#4582EC) for everything else — here it's promoted to the blog's
 * accent color (dates, hover states, the dot motif) to give articles their
 * own identity while staying unmistakably Carbsnap. Font stays Rubik
 * (site-wide, see base.html); heading weight/scale follows theme.css.
 */

.blog-page {
  --coral: #FF8080;
  /* Text/icon-safe variant of the brand coral: #FF8080 itself is only
     2.4:1 against white (fails WCAG AA), so anywhere coral carries text
     or a hover fill under white text uses this darker shade instead —
     4.8:1, safely AA. --coral stays reserved for backgrounds/borders/
     decorative dots where the contrast requirement is 3:1, not 4.5:1. */
  --coral-deep: #D43535;
  --coral-tint: #FFECEC;
  --ink: #343a40;
  --body-text: #495057;
  --muted: #6c757d;
  --hairline: #e9ecef;
}

/* ---------- Page header ---------- */

.blog-page__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--hairline);
}

.blog-page__title {
  margin: 0;
  font-weight: 500;
  color: var(--ink);
}

/* ---------- RSS pill ---------- */

.blog-page__rss {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--coral);
  border-radius: 50rem;
  color: var(--coral-deep);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.blog-page__rss:hover,
.blog-page__rss:focus {
  /* coral-deep, not coral: white text needs the AA-safe shade */
  background-color: var(--coral-deep);
  border-color: var(--coral-deep);
  color: #fff;
  text-decoration: none;
}

.blog-page__rss svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* ---------- Post cards (list page) ---------- */

.blog-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-items: stretch;
  gap: 1.75rem;
}

.blog-card {
  /* theme.css has `article + article { margin-top: 3rem }`, written for a
     plain vertical list of posts. It silently applies to every card here
     after the first (same DOM-order logic, wrong context) and breaks grid
     row alignment, since the grid's own `gap` already spaces the cards. */
  margin-top: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 0.5rem;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.blog-card:hover {
  border-color: var(--coral);
  box-shadow: 0 10px 20px -12px rgba(255, 128, 128, 0.4);
  transform: translateY(-2px);
}

.blog-card__cover {
  display: block;
  width: 100%;
  /* A compact thumbnail, not a hero — 16:9 keeps it short regardless of
     the source image's own ratio, so a big cover graphic reads as a
     small preview here instead of dominating the card. */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  background: var(--coral-tint);
}

.blog-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.25rem;
}

.blog-card__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--coral-deep);
}

.blog-card__meta::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
}

.blog-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.35;
  /* Clamp to 2 lines so a long title doesn't unbalance the grid row. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card__title a {
  color: var(--ink);
  text-decoration: none;
}

.blog-card__title a:hover {
  color: var(--coral-deep);
}

.blog-card__summary {
  margin: 0;
  font-size: 0.9rem;
  color: var(--body-text);
  /* Clamp to 3 lines for the same reason as the title. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Empty state ---------- */

.blog-page__empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--hairline);
  border-radius: 0.5rem;
}

/* ---------- Article (detail page) ---------- */

.blog-article {
  max-width: 700px;
  margin: 0 auto;
}

.blog-article__cover {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin-bottom: 2rem;
}

.blog-article__title {
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--ink);
}

.blog-article__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--coral-deep);
}

.blog-article__meta::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral);
}

.blog-post-body {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--body-text);
}

.blog-post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
}

.blog-post-body h2,
.blog-post-body h3 {
  color: var(--ink);
  font-weight: 500;
  margin-top: 2rem;
}

.blog-post-body a {
  color: var(--coral-deep);
}

.blog-post-body blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 1.25rem;
  border-left: 3px solid var(--coral);
  color: var(--muted);
}

.blog-post-body pre,
.blog-post-body code {
  background: #f8f9fa;
  border-radius: 0.25rem;
}

.blog-post-body pre {
  padding: 1rem;
  overflow-x: auto;
}

.blog-post-body code {
  padding: 0.15em 0.4em;
  font-size: 0.9em;
}

.blog-post-body pre code {
  padding: 0;
  background: none;
}

.blog-post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.blog-post-body th,
.blog-post-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--hairline);
  text-align: left;
}

.blog-post-body th {
  background: #f8f9fa;
}

.blog-article__back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--hairline);
  border-radius: 50rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.blog-article__back:hover {
  border-color: var(--coral);
  color: var(--coral-deep);
  text-decoration: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 575.98px) {
  .blog-page__header {
    align-items: flex-start;
  }
}

/* ---------- Accessibility ---------- */

.blog-page a:focus-visible,
.blog-article a:focus-visible {
  outline: 2px solid var(--coral-deep);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .blog-card,
  .blog-page__rss,
  .blog-article__back {
    transition: none;
  }
}
