/* Custom Article Grid Styles */

/* Target ALL post templates on the homepage, archives, and search results */
.home .wp-block-post-template .wp-block-post,
.archive .wp-block-post-template .wp-block-post,
.search .wp-block-post-template .wp-block-post {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}

/* Hover Effect */
.home .wp-block-post-template .wp-block-post:hover,
.archive .wp-block-post-template .wp-block-post:hover,
.search .wp-block-post-template .wp-block-post:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    border-color: #cdcdcd;
}

/* Featured Image - Force Height and Fit */
.home .wp-block-post-template .wp-block-post-featured-image,
.archive .wp-block-post-template .wp-block-post-featured-image,
.search .wp-block-post-template .wp-block-post-featured-image {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    width: 100%;
    background-color: #f7f7f7;
    /* Placeholder background */
}

.home .wp-block-post-template .wp-block-post-featured-image img,
.archive .wp-block-post-template .wp-block-post-featured-image img,
.search .wp-block-post-template .wp-block-post-featured-image img {
    border-radius: 0 !important;
    width: 100% !important;
    height: 220px !important;
    /* Force fixed height */
    object-fit: contain !important;
    /* Force contain */
    display: block;
}

/* Content Container & Text Elements */
/* 1. If there is a Group wrapper (standard), give it full padding */
.home .wp-block-post-template .wp-block-post>.wp-block-group,
.archive .wp-block-post-template .wp-block-post>.wp-block-group,
.search .wp-block-post-template .wp-block-post>.wp-block-group {
    padding: 2rem !important;
    /* Generous padding */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
}

/* 2. Fallback: If text elements are direct children (no Group), give them side padding */
.home .wp-block-post-template .wp-block-post> :not(.wp-block-post-featured-image):not(.wp-block-group),
.archive .wp-block-post-template .wp-block-post> :not(.wp-block-post-featured-image):not(.wp-block-group),
.search .wp-block-post-template .wp-block-post> :not(.wp-block-post-featured-image):not(.wp-block-group) {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
    background-color: #ffffff;
    /* Ensure background is white */
}

/* 3. Ensure space at the bottom of the card if no group is used */
.home .wp-block-post-template .wp-block-post,
.archive .wp-block-post-template .wp-block-post,
.search .wp-block-post-template .wp-block-post {
    padding-bottom: 0 !important;
    /* Reset, let children handle spacing */
}

/* Mobile Responsiveness */
@media (max-width: 600px) {

    .home .wp-block-post-template .wp-block-post>.wp-block-group,
    .archive .wp-block-post-template .wp-block-post>.wp-block-group,
    .search .wp-block-post-template .wp-block-post>.wp-block-group {
        padding: 1.5rem !important;
    }

    .home .wp-block-post-template .wp-block-post> :not(.wp-block-post-featured-image):not(.wp-block-group),
    .archive .wp-block-post-template .wp-block-post> :not(.wp-block-post-featured-image):not(.wp-block-group),
    .search .wp-block-post-template .wp-block-post> :not(.wp-block-post-featured-image):not(.wp-block-group) {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
}

/* Title */
.home .wp-block-post-template .wp-block-post-title,
.archive .wp-block-post-template .wp-block-post-title,
.search .wp-block-post-template .wp-block-post-title {
    font-family: var(--wp--preset--font-family--heading);
    font-weight: 700;
    font-size: 1.3rem !important;
    margin-top: 0;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.home .wp-block-post-template .wp-block-post-title a,
.archive .wp-block-post-template .wp-block-post-title a,
.search .wp-block-post-template .wp-block-post-title a {
    text-decoration: none;
    color: #111111;
}

.home .wp-block-post-template .wp-block-post-title a:hover,
.archive .wp-block-post-template .wp-block-post-title a:hover,
.search .wp-block-post-template .wp-block-post-title a:hover {
    color: var(--wp--preset--color--accent-3);
    text-decoration: underline;
}

/* Meta Data (Date, Categories) */
.home .wp-block-post-template .wp-block-post-date,
.home .wp-block-post-template .wp-block-post-terms,
.archive .wp-block-post-template .wp-block-post-date,
.archive .wp-block-post-template .wp-block-post-terms,
.search .wp-block-post-template .wp-block-post-date,
.search .wp-block-post-template .wp-block-post-terms {
    font-size: 0.8rem;
    color: #757575;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

/* Excerpt (if present) */
.home .wp-block-post-template .wp-block-post-excerpt,
.archive .wp-block-post-template .wp-block-post-excerpt,
.search .wp-block-post-template .wp-block-post-excerpt {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #444444;
    margin-top: auto;
    /* Push to bottom if needed */
}

/* --- SIDEBAR STYLES --- */

/* 1. Make the sidebar column sticky and reset its background */
/* We target the last column. We MUST use !important to override inline styles set by the Block Editor */
main .wp-block-columns .wp-block-column:last-child {
    position: sticky;
    top: 2rem;
    align-self: start;
    background-color: transparent !important;
    /* Override inline grey background */
    border: none !important;
    box-shadow: none !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* 2. Style ALL widgets in the sidebar as cards */

/* A) Generic Rule: Direct children of the column */
/* This targets the Search form, Latest Posts list, etc. directly */
main .wp-block-columns .wp-block-column:last-child>* {
    background-color: #ffffff !important;
    /* Override inline grey background */
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 1.5rem !important;
    /* Override inline padding */
    margin-bottom: 1.5rem !important;
    /* Ensure spacing */
    margin-top: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box;
    width: 100%;
    /* Ensure full width */
}

/* B) Exception for Nested Pattern Structure (Column > Aside > Group > Widgets) */
/* Reset the outer wrapper if it exists */
main .wp-block-columns .wp-block-column:last-child>.wp-block-group,
main .wp-block-columns .wp-block-column:last-child aside>.wp-block-group {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
}

/* Style the inner widgets of the nested group */
main .wp-block-columns .wp-block-column:last-child>.wp-block-group>*,
main .wp-block-columns .wp-block-column:last-child aside>.wp-block-group>* {
    background-color: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 1.5rem !important;
    margin-bottom: 1.5rem !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box;
}

/* Hide separators in the sidebar */
main .wp-block-columns .wp-block-column:last-child .wp-block-separator,
main .wp-block-columns .wp-block-column:last-child aside .wp-block-separator {
    display: none !important;
}

/* 3. Style Headings inside these cards */
main .wp-block-columns .wp-block-column:last-child h2,
main .wp-block-columns .wp-block-column:last-child .wp-block-heading {
    font-family: var(--wp--preset--font-family--heading);
    font-size: 1.3rem;
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--wp--preset--color--accent-3);
    padding-bottom: 0.5rem;
    display: inline-block;
}

/* 4. Style Links */
main .wp-block-columns .wp-block-column:last-child ul {
    padding-left: 0;
    list-style: none;
}

main .wp-block-columns .wp-block-column:last-child ul li {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

main .wp-block-columns .wp-block-column:last-child ul li:last-child {
    border-bottom: none;
}

main .wp-block-columns .wp-block-column:last-child a {
    text-decoration: none;
    color: var(--wp--preset--color--contrast-2);
    font-weight: 500;
}

main .wp-block-columns .wp-block-column:last-child a:hover {
    color: var(--wp--preset--color--accent-3);
}