/* =========================================================
   MCCD FINALIZER — load last
   Purpose:
   1) Force grids on .cards/.grid/#shortcut-grid (beats overrides.css)
   2) Remove wrapper background/frames around grids
   3) Keep card styling on children only (works with/without .card)
   4) Outrank inline <style> rule targeting #shortcut-grid.cards
   ========================================================= */

/* --- Force grid & wrapping (raise specificity via body + doubled selectors) --- */
body .cards.cards,
body .grid.grid,
body #shortcut-grid#shortcut-grid {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem; /* 20px */
  white-space: normal; /* neutralize nowrap ancestors */
}

/* Also catch single-class usage */
body .cards,
body .grid,
body #shortcut-grid {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  white-space: normal;
}

/* Explicitly beat an inline <style> rule like "#shortcut-grid.cards" */
body #shortcut-grid#shortcut-grid.cards.cards {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  white-space: normal;
}

/* --- Remove frames/halos on grid containers themselves --- */
body .cards,
body .grid,
body #shortcut-grid {
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* --- Remove frames on common wrappers that hold the grids (uses :has) --- */
body section.panel:has(.cards),
body section.panel:has(.grid),
body section.panel:has(#shortcut-grid),
body .panel:has(.cards),
body .panel:has(.grid),
body .panel:has(#shortcut-grid) {
  background: transparent;
  border: 0;
  box-shadow: none;
}

/* --- Grid items (support both ".card" children and direct children) --- */
body .cards .card,
body .grid .card,
body #shortcut-grid .card,
body .cards > *:not(.card):not(style),
body .grid > *:not(.card):not(style),
body #shortcut-grid > *:not(.card):not(style){
  display: block;
  min-width: 0;
  background: var(--mccd-card-bg);
  padding: var(--mccd-card-pad);
  border: var(--mccd-card-border);
  border-radius: var(--mccd-card-radius);
  color: inherit;
  text-decoration: none;
  box-shadow: none;
  margin: 0;
}

/* --- Typography inside cards (keeps the homepage metrics) --- */
body .cards .card h1, body .cards .card h2, body .cards .card h3,
body .grid  .card h1, body .grid  .card h2, body .grid  .card h3,
body #shortcut-grid .card h1, body #shortcut-grid .card h2, body #shortcut-grid .card h3,
body .cards > * h1, body .cards > * h2, body .cards > * h3,
body .grid  > * h1, body .grid  > * h2, body .grid  > * h3,
body #shortcut-grid > * h1, body #shortcut-grid > * h2, body #shortcut-grid > * h3{
  font-size: var(--mccd-h-size, 24px);
  font-weight: var(--mccd-h-weight, 700);
  line-height: var(--mccd-h-lh, 1.6);
  color: var(--mccd-h-color, rgb(19, 94, 59));
  font-family: var(--mccd-h-family, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif);
  margin: 0 0 .5rem;
}

body .cards .card p,
body .grid  .card p,
body #shortcut-grid .card p,
body .cards > * p,
body .grid  > * p,
body #shortcut-grid > * p{
  font-size: var(--mccd-p-size, 16px);
  font-weight: var(--mccd-p-weight, 400);
  line-height: var(--mccd-p-lh, 1.6);
  color: var(--mccd-p-color, rgb(59, 59, 59));
  font-family: var(--mccd-p-family, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif);
  margin: 0;
}

/* --- 3→2→1 helper (kept for pages that use .cards-3) --- */
body .cards.cards-3,
body .grid.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 980px){
  body .cards.cards-3, body .grid.cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px){
  body .cards.cards-3, body .grid.cards-3 { grid-template-columns: 1fr; }
}

/* ===== Legacy item width/float neutralizers (grid children) ===== */
body .cards > * ,
body .grid > * ,
body #shortcut-grid > * {
  width: auto;
  max-width: 100%;
  float: none;
  /* kill any legacy flex leftovers on children */
  flex: none;
}

/* If some older CSS set inline-block on tiles/items */
body .cards > * ,
body .grid > * ,
body #shortcut-grid > * {
  display: block;
}

/* ===== Resources grid: ignore fixed column helpers ===== */
body #shortcut-grid#shortcut-grid,
body #shortcut-grid#shortcut-grid.cards-3,
body #shortcut-grid#shortcut-grid[class*="cards-"]{
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Unify all grids to homepage's 240px auto-fit columns */
body .cards,
body .grid,
body #shortcut-grid,
body .cards.cards-3,
body .grid.cards-3,
body #shortcut-grid.cards-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
/* === Sticky footer unifier (2025-10-09) === */
html { height: 100%; }
body { min-height: 100vh; display: flex; flex-direction: column; }
#site-header { flex: 0 0 auto; }
main, main#main { flex: 1 0 auto; }
#site-footer, footer#site-footer { flex: 0 0 auto; margin-top: auto; }
/* === end sticky footer unifier === */
