/**
 * Make the default WordPress "Read More" excerpt link and the query
 * pagination controls render with the same visual style as Kadence
 * single-button blocks elsewhere on the GPCA site
 * (orange fill, white text, Josefin Sans uppercase). Also lays each
 * archive post out as a horizontal row with the featured image on the
 * left and title / date / excerpt / Read More stacked on the right.
 * Scoped to the CultureWire category archive and the research CPT
 * archive so other listings aren't affected.
 *
 * Also drops the top margin Kadence places on the single content area
 * for press_release and research, so the per-post hero block sits
 * flush against the header instead of behind 80px of empty gray.
 */

/* Press release + research detail pages: no padding above the hero. */
body.single-press_release .content-area,
body.single-research .content-area {
    margin-top: 0;
}

/* Consistent gap between the Interior HERO block and the first body
   element on press_release + research singles. Without this, posts
   whose body leads with a <p> butt up against the hero (0px gap),
   while posts whose body leads with an <h2> have ~54px from the h2's
   natural margin. Normalize to 54px regardless of the leading tag. */
body:is(.single-press_release, .single-research) .entry-content > [class*="kb-row-layout-idcpt_hero_"] + * {
    margin-top: 54px;
}

/* Post-meta row: insert bullets between date, categories, topics only
   when adjacent terms actually rendered (post-terms outputs nothing
   when the post has no terms, so we can't use static bullets). */
.gpca-post-meta {
    align-items: baseline;
}

.gpca-post-meta .wp-block-post-terms:not(:empty)::before,
.gpca-post-meta .wp-block-post-date + .wp-block-post-terms:not(:empty)::before {
    content: "\2022";
    margin: 0 0.6em;
    color: var(--global-palette5, #ff4e00);
}

/* Hide an optional Media Contact / Downloads section + its trailing
   spacer when the dynamic field rendered no content (the heading is
   alone in the group's inner container). */
.gpca-optional-section .wp-block-group__inner-container > h3:only-child,
.gpca-optional-section .wp-block-group__inner-container > h3:only-of-type:last-child {
    /* fallback for browsers without :has — hide just the heading */
}

body.single-press_release .gpca-optional-section:has(.wp-block-group__inner-container > h3.wp-block-heading:only-child),
body.single-research .gpca-optional-section:has(.wp-block-group__inner-container > h3.wp-block-heading:only-child) {
    display: none;
}

/* Hide the trailing spacer that immediately follows a hidden optional
   section (CSS can't address siblings of hidden elements directly, so
   we use :has on the parent + sibling combinator). */
body.single-press_release .gpca-optional-section:has(.wp-block-group__inner-container > h3.wp-block-heading:only-child) + .gpca-optional-spacer,
body.single-research .gpca-optional-section:has(.wp-block-group__inner-container > h3.wp-block-heading:only-child) + .gpca-optional-spacer {
    display: none;
}

/* Row layout for each archive post. Default is a single column;
   when the post has a featured image we promote it to a 320px + 1fr
   grid so posts without images don't leave a 320px gap. */
/* The three GPCA archive listings share one row layout. Grouped with
   :is() so adding a future archive only means extending this one list
   (instead of duplicating ~90 lines). Covers the CultureWire category
   archive, the research CPT archive, and the press_release CPT archive. */
body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    column-gap: 32px;
    row-gap: 0;
    align-items: start;
    margin-bottom: 48px;
    padding-bottom: 48px;
    border-bottom: 1px solid var(--global-palette7, #fcdfd3);
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post:has(.wp-block-post-featured-image) {
    grid-template-columns: 320px 1fr;
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post:last-child {
    border-bottom: 0;
}

/* Featured image: span the full height of the row on the left */
body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post .wp-block-post-featured-image {
    grid-column: 1;
    grid-row: 1 / span 4;
    margin: 0;
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post .wp-block-post-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* When a post has a featured image, the non-image children stack in
   column 2. Without the :has guard, the grid-column would otherwise
   force an implicit second column even on no-image posts. */
body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post:has(.wp-block-post-featured-image) > :not(.wp-block-post-featured-image) {
    grid-column: 2;
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post > * {
    margin: 0;
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post-title {
    margin: 0;
    line-height: 1.2;
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post-date {
    color: var(--global-palette5, #ff4e00);
    margin: 4px 0 0 0;
    line-height: 1.2;
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post-excerpt {
    margin: 8px 0 0 0;
}

body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post-excerpt__excerpt {
    margin: 0 0 12px 0;
}

/* Stack vertically below 768px */
@media (max-width: 767px) {
    body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post {
        grid-template-columns: 1fr;
    }
    body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post .wp-block-post-featured-image {
        grid-column: 1;
        grid-row: auto;
        margin-bottom: 16px;
    }
    body:is(.category-culturewire, .post-type-archive-research, .post-type-archive-press_release) .wp-block-post > :not(.wp-block-post-featured-image) {
        grid-column: 1;
    }
}

/* Shared base used by Read More and pagination links */
.wp-block-post-excerpt__more-link,
.wp-block-query-pagination .page-numbers,
.wp-block-query-pagination-numbers .page-numbers,
.wp-block-query-pagination-previous,
.wp-block-query-pagination-next {
    display: inline-block;
    background-color: var(--global-palette1, #ff4e00);
    color: var(--global-palette9, #ffffff) !important;
    border: 2px solid var(--global-palette1, #ff4e00);
    border-radius: 0;
    padding: 12px 22px;
    font-family: var(--global-heading-font-family, "Josefin Sans", sans-serif);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.wp-block-post-excerpt__more-link:hover,
.wp-block-post-excerpt__more-link:focus,
.wp-block-query-pagination .page-numbers:hover,
.wp-block-query-pagination .page-numbers:focus,
.wp-block-query-pagination-numbers .page-numbers:hover,
.wp-block-query-pagination-numbers .page-numbers:focus,
.wp-block-query-pagination-previous:hover,
.wp-block-query-pagination-previous:focus,
.wp-block-query-pagination-next:hover,
.wp-block-query-pagination-next:focus {
    background-color: var(--global-palette3, #000000);
    border-color: var(--global-palette3, #000000);
    color: var(--global-palette9, #ffffff) !important;
}

/* Read More variant: smaller, sits beneath each excerpt */
.wp-block-post-excerpt__more-link {
    margin-top: 12px;
    padding: 10px 18px;
    font-size: 13px;
}

/* Pagination layout: center the row, add gap between buttons */
.wp-block-query-pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 40px;
}

/* Pagination numbers: highlight the current page */
.wp-block-query-pagination-numbers .page-numbers.current {
    background-color: var(--global-palette3, #000000);
    border-color: var(--global-palette3, #000000);
}
