/* MichF Blog Grid
   Reuses --la-* design tokens when present on the page, falls back to
   brand defaults otherwise, same convention as MichF Blog Carousel. */

.michf-grid-wrap {
  --mg-bg: var(--la-bg, #0C0B09);
  --mg-surface: var(--la-surface, #151411);
  --mg-text: var(--la-text, #F5F0E6);
  --mg-body: var(--la-body, #C4BDB0);
  --mg-dim: var(--la-dim, #8F887C);
  --mg-line: var(--la-line, rgba(245, 240, 230, 0.12));
  --mg-accent: var(--la-accent, #4ade80);
  --mg-serif: var(--la-serif, "Newsreader", Georgia, "Times New Roman", serif);
  --mg-sans: var(--la-sans, "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --mg-header-h: var(--la-header-h, 0px);

  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: clamp(40px, 7vw, 96px);
  background: var(--mg-bg);
  color: var(--mg-text);
  font-family: var(--mg-sans);
}

/* ---------- Sidebar ---------- */
.michf-grid-toc {
  flex: 0 0 220px;
  width: 220px;
  max-width: 220px;
  align-self: flex-start;
}
.michf-grid-filter-label {
  margin: 0 0 18px;
  color: var(--mg-dim);
  font: 600 12px/1.4 var(--mg-sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.michf-grid-filter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--mg-line);
}
.michf-grid-filter-list li {
  margin: 0;
  padding: 0;
}
.michf-grid-filter-btn {
  display: block;
  width: 100%;
  text-align: left;
  margin-left: -1px;
  padding: 8px 0 8px 18px;
  border: 0;
  border-left: 2px solid transparent;
  background: none;
  cursor: pointer;
  color: var(--mg-dim);
  font: 400 14px/1.4 var(--mg-sans);
  transition: color 0.15s, border-color 0.15s;
}
.michf-grid-filter-btn:hover {
  color: var(--mg-text);
}
.michf-grid-filter-btn:focus-visible {
  outline: 2px solid var(--mg-accent);
  outline-offset: 3px;
}
.michf-grid-filter-btn.is-active {
  color: var(--mg-text);
  border-left-color: var(--mg-accent);
}

/* ---------- Grid ---------- */
.michf-grid-content {
  flex: 1 1 0%;
  min-width: 0;
}
.michf-grid {
  --mg-cols: 3;
  display: grid;
  grid-template-columns: repeat(var(--mg-cols), 1fr);
  gap: 40px 32px;
}
.michf-grid-card {
  display: flex;
  flex-direction: column;
}
.michf-grid-card--no-photo .michf-grid-tag {
  margin-top: 4px;
}
.michf-grid-card[hidden] {
  display: none;
}
.michf-grid-thumb-link {
  display: block;
  text-decoration: none;
}
.michf-grid-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  border: 1px solid var(--mg-line);
  background: linear-gradient(135deg, var(--mg-surface), var(--mg-bg));
  background-size: cover;
  background-position: center;
  overflow: hidden;
  margin-bottom: 20px;
}
.michf-grid-thumb::before {
  content: "";
  position: absolute;
  right: -20%;
  top: -20%;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 222, 128, 0.16), transparent 70%);
  pointer-events: none;
}
.michf-grid-tag {
  display: inline-block;
  margin: 0 0 12px;
  color: var(--mg-accent);
  font: 600 11px/1.4 var(--mg-sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.michf-grid-title {
  margin: 0 0 10px;
  color: var(--mg-text);
  font-family: var(--mg-serif);
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.michf-grid-title a {
  color: inherit;
  text-decoration: none;
}
.michf-grid-title a:hover {
  color: var(--mg-accent);
}
.michf-grid-excerpt {
  margin: 0 0 16px;
  color: var(--mg-body);
  font: 400 15px/1.65 var(--mg-sans);
}
.michf-grid-meta {
  margin: 0;
  color: var(--mg-dim);
  font: 400 13px/1.4 var(--mg-sans);
}
.michf-grid-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  color: var(--mg-accent);
  text-decoration: none;
  font: 600 14px/1.4 var(--mg-sans);
  transition: gap 0.15s;
}
.michf-grid-link:hover {
  gap: 10px;
}
.michf-grid-link:focus-visible,
.michf-grid-title a:focus-visible,
.michf-grid-thumb-link:focus-visible {
  outline: 2px solid var(--mg-accent);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .michf-grid-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .michf-grid-toc {
    flex: none;
    width: auto;
    max-width: none;
  }
  .michf-grid-filterbox {
    display: block;
    padding: 16px 0;
  }
  .michf-grid-filter-label {
    display: none;
  }
  .michf-grid-filter-list {
    display: block;
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 0;
  }
  .michf-grid-filter-list li {
    display: block;
    margin: 0 0 8px;
  }
  .michf-grid-filter-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    white-space: normal;
    border: 1px solid var(--mg-line);
    border-radius: 999px;
    padding: 12px 20px;
    margin-left: 0;
  }
  .michf-grid-filter-btn.is-active {
    background: var(--mg-accent);
    border-color: var(--mg-accent);
    color: #0d0d0d;
    font-weight: 600;
  }
  .michf-grid-content {
    padding-top: 24px;
  }
  /* Tablet tier: 2 columns. Layout is already stacked (sidebar above
     content) at this width, but there's still enough room for a pair
     of cards side by side down to the mobile breakpoint below. */
  .michf-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
  }
}

@media (max-width: 640px) {
  /* Mobile tier: 1 column. */
  .michf-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Very wide screens ---------- */
/* Past this point, keep the 3 columns at a comfortable width instead of
   letting them stretch to fill an ultrawide monitor. The grid is capped
   and centered within the content area rather than growing edge to edge. */
@media (min-width: 1680px) {
  .michf-grid {
    max-width: 1680px;
    margin: 0 auto;
  }
}
