.text-with-image {
    position: relative; 
    overflow: visible;
    padding-top: 4rem; /* Reduced padding for mobile */
    padding-bottom: 4rem; /* Padding for mobile */
    margin-bottom: 8rem; /* Add margin to create space for image overflow */
    
    @media (min-width: 992px) {
        padding-top: 9.6rem;
        padding-bottom: 9.6rem;
        margin-bottom: 8rem;
    }
}

.text-with-image .content-wrapper {
    display: flex;
    flex-direction: column-reverse; /* Always show content first on mobile */
    position: relative;
    
    @media (min-width: 992px) {
        flex-direction: row; /* Reset to row on desktop */
        align-items: flex-start; /* Align items to top */
        
        .image-right & {
            flex-direction: row-reverse;
        }
    }

    .image-content {
        aspect-ratio: 1/1;
        width: 100%;
        margin-top: 2rem; /* Space between content and image on mobile */
        
        @media (min-width: 992px) {
            flex-basis: 450px;
            position: relative;
            z-index: 2;
            margin-bottom: -30%; /* Increase overlap effect */
            margin-top: 3rem; /* Add top margin to align with text */
        }
        
        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: center center;
        }
    }
}

/* Apply background color to the section element instead of the content */
.text-with-image.has-background-color {
    background-color: var(--color-primary-pac, #FFF2E3); /* Added direct fallback color */
}

.side-text {

    margin: 0px;
    
    @media (min-width: 992px) {
        flex-basis: calc(100% - 450px);
        padding: 6rem !important; /* Override mobile padding on desktop */
    }
    
    h2 {
        margin: 0 0 2rem 0;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid #CC2E3F !important; /* Match brand color */
    }
}

/* These specific padding rules are only applied on desktop */
@media (min-width: 992px) {
    .image-right .side-text {
        padding-right: 3rem !important;
    }

    .image-left .side-text {
        padding-left: 3rem !important;
    }
}
