/* OJS homepage: show exactly ONE announcement (the last non-empty one) */

/* 1) Hide all announcement cards by default */
.pkp_page_index .obj_announcement_summary,
.pkp_page_index .obj_announcement {
  display: none !important;
}

/* 2) Modern browsers: show the LAST card that actually has content
   (title or summary not empty). This survives leading/trailing blanks. */
.pkp_page_index .cmp_announcements > *:nth-last-child(1 of .obj_announcement_summary:has(.title:not(:empty), .summary:not(:empty))) {
  display: block !important;
}
.pkp_page_index .cmp_announcements > *:nth-last-child(1 of .obj_announcement:has(.title:not(:empty), .summary:not(:empty))) {
  display: block !important;
}

/* 3) Fallback for older browsers with no :has() support:
   keep only the last card. (If that shows the empty one for your theme,
   change :last-child to :first-child.) */
.pkp_page_index .cmp_announcements > *:last-child {
  display: block !important;
}

/* 4) Prevent grid/flex from reserving space for hidden items */
.pkp_page_index .cmp_announcements,
.pkp_page_index .pkp_announcements {
  display: block !important;
}
.pkp_page_index .cmp_announcements > *,
.pkp_page_index .pkp_announcements > * {
  width: 100% !important;
  max-width: 100% !important;
  flex: 0 0 100% !important;
  margin: 0 0 1rem !important;
}

/* 5) Extra guard: if a “card” has no visible title AND no visible summary, hide it */
.pkp_page_index .obj_announcement_summary:not(:has(.title:not(:empty), .summary:not(:empty))),
.pkp_page_index .obj_announcement:not(:has(.title:not(:empty), .summary:not(:empty))) {
  display: none !important;
}
