/* Fix for double-rounded corners on stacked elements */

/* 
 * UNIVERSAL BORDER-RADIUS FIX
 * These rules apply to any container that has a border-radius and contains stacked elements.
 * Examples: .post-card, .widget, .apple-card, etc.
 * The goal is to make the inner elements conform to the parent's rounded corners.
*/

/* Define the containers that need this fix */
.post-card,
.widget,
.sidebar-widget,
.apple-card,
.related-posts-container,
.container-with-header,
.rounded-container,
article.bg-white,
.knowledge-graph-card,
.web-result-card,
.news-card,
.archive-post-card {
    /* Ensure the container clips its children's corners */
    overflow: hidden;
}

/* Target the FIRST child element inside these containers */
.post-card > *:first-child,
.widget > *:first-child,
.sidebar-widget > *:first-child,
.apple-card > *:first-child,
.related-posts-container > *:first-child,
.container-with-header > *:first-child,
.rounded-container > *:first-child,
article.bg-white > *:first-child,
.knowledge-graph-card > *:first-child,
.web-result-card > *:first-child,
.news-card > *:first-child,
.archive-post-card > *:first-child {
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* Target the LAST child element inside these containers */
.post-card > *:last-child,
.widget > *:last-child,
.sidebar-widget > *:last-child,
.apple-card > *:last-child,
.related-posts-container > *:last-child,
.container-with-header > *:last-child,
.rounded-container > *:last-child,
article.bg-white > *:last-child,
.knowledge-graph-card > *:last-child,
.web-result-card > *:last-child,
.news-card > *:last-child,
.archive-post-card > *:last-child {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom-left-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
}

/* Special case: If a container has only ONE child, it should fill the parent's corners */
.post-card > *:only-child,
.widget > *:only-child,
.sidebar-widget > *:only-child,
.apple-card > *:only-child,
.related-posts-container > *:only-child,
.container-with-header > *:only-child,
.rounded-container > *:only-child,
article.bg-white > *:only-child,
.knowledge-graph-card > *:only-child,
.web-result-card > *:only-child,
.news-card > *:only-child,
.archive-post-card > *:only-child {
    border-radius: 8px !important;
}

/* Fix for post thumbnails inside cards */
.post-card .entry-thumbnail,
.post-card .featured-image,
.post-card .post-thumbnail,
.post-card .wp-post-image {
    border-radius: 0 !important; /* Reset individual radius */
}

/* Fix for widget titles */
.widget .widget-title,
.sidebar-widget .widget-title {
    border-radius: 0 !important; /* Reset individual radius */
}
