/* ==========================================================================
   Blog index (/blog). Page-only styles; the system lives in main.css.
   One enormous word, a search box that answers as you type, the newest
   post featured, then every post in a quiet grid.
   Card markup comes from templates/partials/blog-index-card.html.
   ========================================================================== */

/* ---------- 1. Hero ------------------------------------------------------ */
.blog-hero {
  position: relative;
  background: var(--void);
  padding-top: calc(var(--header-h) + clamp(1.5rem, 5vh, 3.5rem));
  padding-bottom: var(--space-xl);
}
.blog-hero__grid { display: grid; gap: var(--space-l); align-items: end; }
.blog-hero__title {
  font-size: clamp(6.5rem, 1rem + 22vw, 21rem);
  line-height: .78;
  letter-spacing: -.055em;
  margin-left: -.04em;
  padding-bottom: .04em;
}
/* Line-reveal mask: the default .08em pad clips the "g" descender at this size and .78 line-height */
.blog-hero__title .split-line { padding-bottom: .16em; margin-bottom: -.16em; }
.blog-hero__side { display: grid; gap: var(--space-m); padding-bottom: .4rem; }
.blog-hero .lede { max-width: 36ch; }

.blog-search { display: grid; gap: .5rem; }
.blog-search[hidden] { display: none; }
.blog-search__label { font-size: .9375rem; font-weight: 500; color: var(--text-2); }
.blog-search__box {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 60px;
  border-radius: 999px;
  background: var(--night-3);
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: box-shadow var(--dur-fast), background-color var(--dur-fast);
}
.blog-search__box:hover { box-shadow: inset 0 0 0 1px rgba(234, 241, 247, .32); }
.blog-search__box:focus-within { box-shadow: inset 0 0 0 1.5px var(--cyan), 0 0 0 4px rgba(0, 198, 242, .18); background: #1A2635; }
.blog-search__icon { position: absolute; left: 1.2rem; width: 1.25rem; height: 1.25rem; color: var(--muted); pointer-events: none; }
.blog-search__input {
  flex: 1;
  min-width: 0;
  height: 60px;
  padding: 0 3.25rem 0 3.2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 1.0625rem;
}
.blog-search__input:focus-visible { outline: none; }
.blog-search__input::placeholder { color: #8FA0B3; }
.blog-search__input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.blog-search__clear {
  position: absolute;
  right: .55rem;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  color: var(--text-2);
}
.blog-search__clear[hidden] { display: none; }
.blog-search__clear:hover { background: rgba(234, 241, 247, .08); color: #fff; }
.blog-search__clear svg { width: 18px; height: 18px; }
.blog-count { color: var(--muted); font-size: var(--step--1); }
.blog-count strong { color: var(--text); font-weight: 600; }

@media (min-width: 960px) {
  .blog-hero { padding-bottom: var(--space-xl); }
  .blog-hero__grid { grid-template-columns: auto minmax(0, 1fr); column-gap: clamp(2.5rem, 6vw, 7rem); }
  .blog-hero__side { max-width: 34rem; justify-self: end; width: 100%; }
}

/* ---------- 2. Posts ------------------------------------------------------ */
.blog-list { padding-bottom: var(--space-2xl); border-top: 1px solid var(--line); padding-top: var(--space-xl); }
.post-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2.5rem, 4vw, 4rem) clamp(1.25rem, 2.4vw, 2.25rem);
}
@media (min-width: 640px) { .post-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .post-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.post-card { position: relative; display: grid; gap: .8rem; align-content: start; }
.post-card[hidden] { display: none; }
.post-card__media {
  overflow: hidden;
  border-radius: var(--radius);
  aspect-ratio: 16 / 10;
  background: var(--night-2);
  margin-bottom: .35rem;
}
.post-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .9s var(--ease-out); }
.post-card__title {
  font-size: clamp(1.3rem, 1.1rem + .6vw, 1.6rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.025em;
  word-spacing: .03em;
  text-wrap: balance;
}
.post-card__title a { text-decoration: underline; text-decoration-color: transparent; text-decoration-thickness: 2px; text-underline-offset: .16em; transition: text-decoration-color var(--dur-fast), color var(--dur-fast); }
.post-card__meta { order: -1; color: var(--muted); font-size: .875rem; }
.post-card__excerpt {
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
/* The whole card is the link's hit area; focus draws around the card */
.stretched::after { content: ""; position: absolute; inset: -.5rem; border-radius: calc(var(--radius) + 6px); }
.stretched:focus-visible { outline: none; }
.stretched:focus-visible::after { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (hover: hover) {
  .post-card:hover .post-card__title a { text-decoration-color: var(--cyan); }
  .post-card:hover .post-card__media img { transform: scale(1.025); }
}
/* media sits above the meta line visually (meta is ordered first in the text group) */
.post-card__media { order: -2; }

/* Featured: the newest post, while no search is active. A card left alone
   on the last row takes the same wide layout, so the grid always closes clean. */
@media (min-width: 900px) {
  .post-list:not(.is-filtering) > .post-card:first-child,
  .post-list:not(.is-filtering) > .post-card.is-orphan {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: clamp(2rem, 4vw, 4rem);
    row-gap: 1rem;
    align-items: start;
    padding-bottom: clamp(2.5rem, 4vw, 4rem);
    border-bottom: 1px solid var(--line);
  }
  .post-list:not(.is-filtering) > .post-card:first-child .post-card__media,
  .post-list:not(.is-filtering) > .post-card.is-orphan .post-card__media { grid-column: 1; grid-row: 1 / span 3; margin: 0; aspect-ratio: 16 / 9.5; border-radius: var(--radius-l); }
  .post-list:not(.is-filtering) > .post-card:first-child .post-card__meta,
  .post-list:not(.is-filtering) > .post-card.is-orphan .post-card__meta { grid-column: 2; grid-row: 1; align-self: end; padding-top: clamp(1rem, 4vw, 4rem); font-size: .9375rem; }
  .post-list:not(.is-filtering) > .post-card:first-child .post-card__title,
  .post-list:not(.is-filtering) > .post-card.is-orphan .post-card__title { grid-column: 2; grid-row: 2; font-size: var(--step-3); font-weight: 800; line-height: 1; letter-spacing: -.04em; }
  .post-list:not(.is-filtering) > .post-card.is-orphan { border-bottom: 0; padding-bottom: 0; padding-top: clamp(2.5rem, 4vw, 4rem); border-top: 1px solid var(--line); }
  .post-list:not(.is-filtering) > .post-card:first-child .post-card__excerpt,
  .post-list:not(.is-filtering) > .post-card.is-orphan .post-card__excerpt { grid-column: 2; grid-row: 3; font-size: var(--step-1); line-height: 1.5; -webkit-line-clamp: 4; line-clamp: 4; }
}

.blog-empty {
  display: grid;
  gap: var(--space-s);
  justify-items: start;
  max-width: 40rem;
  padding: var(--space-l) 0;
}
.blog-empty[hidden] { display: none; }
.blog-empty__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--step-3);
  line-height: 1;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}
.blog-empty p:not(.blog-empty__title) { color: var(--text-2); }

/* ---------- 3. Finale ----------------------------------------------------- */
.blog-finale .finale__bg img { transform: scaleX(-1); object-position: 30% 40%; }

/* Load check: the inline stylesheet guard re-fetches this file if this rule is missing. Keep it last. */
:root { --css-blog: 1; }
