/* ==========================================================================
   Blog — journal listing (/blog, /blog/<category>) and the story cards and
   closing band shared with the posts (post-a.css adds the post page).
   Type, spacing and buttons come from the system in main.css (SYSTEM.md):
   headings inherit the h1/h2 B1 cut, sections use --section-y, cards use
   --card-pad / --gap-cards, buttons are .btn-primary / .link-cta.
   ========================================================================== */

/* ---------- Hero (listing + category pages) ---------- */
.journal-hero { min-height: 460px; }
.journal-hero .hero-body {
  margin-block: auto;
  padding-top: var(--space-5);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.journal-hero__title { max-width: 18ch; margin-top: var(--gap-eyebrow); }
.journal-hero__intro { margin-top: var(--gap-heading); }

/* The B&W photo has a high-contrast woven pattern right behind the intro text,
   so it gets a plum wash (lighter at the top so the hand and bracelets still
   read). White text stays at 7:1 or more over the darkest-to-lightest pixels. */
.page-blog .journal-hero.hero-card--scrim::after {
  background: linear-gradient(180deg, rgba(62, 30, 72, .55) 0%, rgba(62, 30, 72, .7) 35%, rgba(62, 30, 72, .82) 100%);
}

/* Category pages: breadcrumb instead of the eyebrow */
.page-blog .breadcrumbs ol {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  margin: 0; padding: 0; list-style: none;
  font-family: var(--font-text); font-weight: 600; font-size: var(--fs-eyebrow);
  letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--white);
}
.page-blog .breadcrumbs li { display: inline-flex; align-items: center; }
.page-blog .breadcrumbs li + li::before { content: "›"; margin: 0 var(--space-3); }
.page-blog .breadcrumbs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--white); text-decoration: none; }
.page-blog .breadcrumbs a:hover { text-decoration: underline; text-underline-offset: 4px; }
.page-blog .breadcrumbs + .journal-hero__title { margin-top: var(--space-2); }

/* ---------- Listing ---------- */
.latest__head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-5) var(--space-6);
  flex-wrap: wrap;
  margin-bottom: var(--gap-head-content);
}
.latest__tools { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }

.blog-filter { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.blog-filter__btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 44px; padding: 0 18px;
  border: 1.5px solid var(--purple); border-radius: 999px;
  background: transparent; color: var(--purple);
  font-family: var(--font-text); font-weight: 500; font-size: var(--fs-ui); line-height: var(--lh-ui);
  cursor: pointer; transition: background-color .2s, color .2s;
}
.blog-filter__btn:hover { background: rgba(120, 53, 136, .08); }
a.blog-filter__btn { text-decoration: none; }
.blog-filter__btn[aria-pressed="true"],
.blog-filter__btn[aria-current] { background: var(--purple); color: var(--white); }
.blog-filter__n { font-size: var(--fs-small); opacity: .85; }

.latest__search { position: relative; width: 236px; flex: none; }
.latest__search input {
  width: 100%; height: 44px;
  border: 1.5px solid var(--purple); border-radius: 999px;
  background: var(--white); color: var(--purple);
  font-family: var(--font-text); font-size: var(--fs-ui);
  padding: 0 44px 0 18px;
  -webkit-appearance: none; appearance: none;
}
.latest__search input::placeholder { color: #7a6580; opacity: 1; }
.latest__search input::-webkit-search-cancel-button { display: none; }
.latest__search svg {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--purple); pointer-events: none;
}

.latest__panel {
  border-radius: var(--radius-lg);
  background: linear-gradient(0deg, #fff 21%, var(--blush) 100%);
  padding: var(--card-pad);
}
.post-list__empty { text-align: center; color: var(--purple); padding: var(--space-7) 0; }
.post-list__empty[hidden] { display: none; }
.post-list__empty p + p { margin-top: 1em; }

/* ---------- Story cards (listing + related) ----------
   A .card--butter: --radius-md, --card-pad, 16px gap, eyebrow → .card__title look → meta → text.
   Cards in a row share the row height (grid stretch). */
.story-grid {
  display: grid; gap: var(--gap-cards);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.story-card {
  position: relative;
  display: flex; flex-direction: column;
  border-radius: var(--radius-md); overflow: hidden;
  background: var(--butter);
  transition: transform .25s ease, box-shadow .25s ease;
}
.story-card[hidden] { display: none; }
.story-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -18px rgba(58, 35, 66, .45); }
.story-card__img { aspect-ratio: 4 / 3; overflow: hidden; background: var(--lavender); }
.story-card__img img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.story-card:hover .story-card__img img { transform: scale(1.03); }
.story-card__body { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--card-pad); flex: 1; }
.story-card__cat {
  align-self: flex-start; justify-self: start;
  font-family: var(--font-text); font-weight: 600; font-size: var(--fs-eyebrow); line-height: 1.3;
  letter-spacing: var(--ls-eyebrow); text-transform: uppercase; color: var(--purple);
  padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .75);
}
.story-card__title {
  font-family: var(--font-display); font-weight: var(--fw-display); font-variation-settings: var(--display-axes); letter-spacing: var(--ls-display);
  font-size: var(--fs-h4); line-height: var(--lh-h4);
  color: var(--plum); text-wrap: balance;
}
.story-card__title a { text-decoration: none; }
.story-card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.story-card__title a:focus-visible { outline: none; }
.story-card:has(a:focus-visible) { outline: 2px solid var(--purple); outline-offset: 3px; }
.story-card:hover .story-card__title a { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.story-card__meta { font-size: var(--fs-small); line-height: 1.5; color: var(--purple); }
.story-card__desc { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--purple); }

/* Desktop listing: the newest story spans two columns as a lead card. This
   gives the grid a clear entry point and turns 14 cards into 5 full rows
   instead of leaving 2 orphans on the last row. Off while filtering/searching. */
@media (min-width: 1101px) {
  .story-grid:not(.story-grid--related):not(.is-filtered) > .story-card:first-child {
    grid-column: span 2;
    display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  }
  .story-grid:not(.story-grid--related):not(.is-filtered) > .story-card:first-child .story-card__img { aspect-ratio: auto; min-height: 100%; }
  .story-grid:not(.story-grid--related):not(.is-filtered) > .story-card:first-child .story-card__body { justify-content: center; gap: var(--space-4); }
  .story-grid:not(.story-grid--related):not(.is-filtered) > .story-card:first-child .story-card__title { font-size: var(--fs-h3); line-height: var(--lh-h3); }
  /* Category pages: the lead card spans the full row so 1 + 3n cards fill every row. */
  .story-grid.story-grid--lead-full:not(.is-filtered) > .story-card:first-child { grid-column: 1 / -1; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
}

/* ---------- Closing band with the loop doodle (listing pages) ---------- */
/* Same white background as the listing above it: one --section-y between them, not two. */
.blog-cta { padding-top: 0; }
.loop-cta {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center;
  gap: var(--space-6) var(--space-8);
}
.loop-cta__curve { width: min(100%, 320px); justify-self: end; color: var(--mauve); transform: rotate(-2deg); }
.loop-cta__text { max-width: 36rem; }
.loop-cta__title { max-width: var(--measure-heading); }
.loop-cta__sub { margin-top: var(--gap-heading); font-size: var(--fs-h3); line-height: var(--lh-h3); }

/* ---------- Related posts (post pages) ---------- */
.related-posts__all { margin-top: var(--gap-head-content); }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .story-grid--related { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .story-grid--related { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 761px) and (max-width: 900px) {
  /* 3 related cards in 2 columns: the third runs full width (photo left, text right), no orphan */
  .story-grid--related > .story-card:nth-child(3):last-child { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--gap-cards); }
  .story-grid--related > .story-card:nth-child(3):last-child .story-card__body { padding-left: calc(var(--card-pad) - var(--gap-cards)); }
  .story-grid--related > .story-card:nth-child(3):last-child .story-card__img { aspect-ratio: auto; min-height: 100%; }
}
@media (max-width: 900px) {
  .loop-cta { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .loop-cta__curve { justify-self: center; width: 200px; }
  .loop-cta__text > * { margin-inline: auto; }
  .loop-cta__actions { justify-content: center; }
}

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .journal-hero { min-height: 0; }
  .latest__head { flex-direction: column; align-items: stretch; }
  .latest__tools { flex-direction: column; align-items: stretch; }
  .blog-filter__btn { flex: 1 1 auto; justify-content: center; min-height: 48px; padding: 0 12px; }
  .latest__search { width: 100%; }
  .latest__panel { padding: var(--space-3); border-radius: var(--radius-md); }
  .story-grid, .story-grid--related { grid-template-columns: 1fr; gap: var(--space-3); }
  /* compact row cards on phones: thumbnail left of label, title and meta; the description runs full width below */
  .story-card { display: grid; grid-template-columns: 88px minmax(0, 1fr); grid-auto-rows: auto; gap: var(--space-2) var(--space-4); padding: var(--space-4); align-items: start; align-content: start; }
  .story-card__img { grid-column: 1; grid-row: 1 / span 3; aspect-ratio: 1; border-radius: var(--radius-sm); }
  .story-card__body { display: contents; }
  .story-card__body > * { grid-column: 2; }
  .story-card__cat { padding: 2px 8px; }
  .story-card__desc { grid-column: 1 / -1; margin-top: var(--space-1); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .loop-cta__curve { width: 140px; }
  .loop-cta__actions { flex-direction: column; }
  .loop-cta__actions .btn { width: 100%; }
}
