/* Reset Astra's padding and containers */
.single-case_study #content,
.single-case_study #primary,
.single-case_study .site-content,
.single-case_study .ast-container,
.single-case_study .entry-content,
.single-case_study article.case_study,
.elementor-location-single.case_study,
.elementor[class*="elementor-"],
.ast-article-single.case_study {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
}

.single-case_study .site-content>.ast-container {
    display: block !important;
}

/* Reset Elementor specific containers */
.elementor-location-single .elementor-section-wrap>.elementor-section {
    padding: 0 !important;
    margin: 0 !important;
}

/* Main styles */
.case-study-content-blocks {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.content-block {
    margin-bottom: 100px;
}

.content-block:last-child {
    margin-bottom: 0;
}

.content-block-wrapper {
    display: flex;
    gap: 80px;
    align-items: center;
}

.image-right .content-block-wrapper {
    flex-direction: row-reverse;
}

.content-block-image {
    flex: 0 0 50%;
    max-width: 600px;
}

/* More specific selector to override Elementor styles */
.elementor .content-block-image img,
.content-block-image img.content-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px !important;
    /* Added !important to ensure override */
    transition: transform 0.3s ease;
}

.content-block-image img:hover {
    transform: scale(1.02);
}

.content-block-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.content-block-text h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
    line-height: 1.4;
}

.content-block-text p {
    margin: 0 0 15px;
    font-size: 16px;
    line-height: 1.6;
}

/* Responsive styles */
@media (max-width: 1024px) {
    .content-block-wrapper {
        gap: 40px;
    }
}

@media (max-width: 768px) {
    .content-block {
        margin-bottom: 60px;
    }

    .content-block-wrapper,
    .image-right .content-block-wrapper {
        flex-direction: column !important;
        gap: 30px;
    }

    .content-block-image {
        width: 100% !important;
        max-width: 100%;
        order: -1;
        /* Forces image to top regardless of original order */
    }

    .content-block-text {
        width: 100%;
        text-align: center;
    }
}

/* Case Study Grid Layout */
.case-study-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 0 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Grid Item Base Styles */
.case-study-item {
    background: #FFF6EF;
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
}

/* Grid Layout Patterns */
/* Full width items */
.case-study-item:first-child,
.case-study-item:nth-child(4),
.case-study-item.full-width {
    grid-column: 1 / -1;
}

/* 70/30 split items */
.case-study-item:nth-child(2),
.case-study-item:nth-child(7) {
    grid-column: span 2;
}

/* 30/70 split items */
.case-study-item:nth-child(5) {
    grid-column: 1;
}

.case-study-item:nth-child(6) {
    grid-column: 2 / -1;
}

/* Single column items */
.case-study-item:nth-child(3),
.case-study-item:nth-child(8) {
    grid-column: 3;
}

/* Content Layout Styles */
.case-study-content-wrapper {
    display: flex;
    height: 100%;
}

/* Layout Variations */
/* Horizontal layout (side-by-side) */
.case-study-item.full-width .case-study-content-wrapper,
.case-study-item:nth-child(2) .case-study-content-wrapper,
.case-study-item:nth-child(6) .case-study-content-wrapper,
.case-study-item:nth-child(7) .case-study-content-wrapper {
    flex-direction: row;
}

/* Vertical layout (stacked) */
.case-study-item:nth-child(3) .case-study-content-wrapper,
.case-study-item:nth-child(5) .case-study-content-wrapper,
.case-study-item:nth-child(8) .case-study-content-wrapper {
    flex-direction: column;
}

/* Image Styles */
.case-study-image {
    position: relative;
    overflow: hidden;
}

/* Full width item images */
.case-study-item.full-width .case-study-image {
    flex: 0 0 40%;
}

/* Full height images for specific cards */
.case-study-item:nth-child(2) .case-study-image,
.case-study-item:nth-child(6) .case-study-image,
.case-study-item:nth-child(7) .case-study-image {
    flex: 0 0 40%;
    height: 100%;
    min-height: 300px;
}

.case-study-image img {
    width: 100%;
    height: 100% !important;
    object-fit: cover;
}

/* Meta Content Styles */
.case-study-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    /* Increased padding for more breathing room */
    width: 100%;
}

/* Content wrapper for meta information */
.case-study-meta-inner {
    max-width: 460px;
    /* Constrains content width */
    margin: 0 auto;
    /* Centers the inner container */
    width: 100%;
}

/* Keep all content left-aligned */
.case-study-client-type,
.case-study-title,
.case-study-description,
.case-study-link {
    text-align: left;
    width: 100%;
}

/* Typography */
.case-study-client-type {
    color: #F15A29;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.case-study-title {
    font-size: 30px;
    line-height: 36px;
    font-weight: 700;
    color: #1A1A1A;
}

.case-study-description {
    font-size: 16px;
    line-height: 1.6;
    color: var(--e-global-color-text);
}

/* Link Styles */
.case-study-link {
    align-items: center;
    padding: 12px 32px;
    background: transparent;
    color: var(--e-global-color-accent);
    text-decoration: none;
    border-radius: 100px;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid var(--e-global-color-accent);
    margin-top: auto;
}

.case-study-link:hover {
    background: transparent;
    color: var(--e-global-color-accent);
    opacity: 0.8;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .case-study-grid {
        grid-template-columns: 1fr 1fr;
    }

    .case-study-title {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .case-study-grid {
        grid-template-columns: 1fr;
        gap: 30px;
        /* Consistent gap between cards */
    }

    /* Reset all grid items to single column with consistent styling */
    .case-study-item {
        grid-column: 1 !important;
        height: auto !important;
        background: #FFF6EF;
        border-radius: 12px;
        overflow: hidden;
    }

    /* Force all content wrappers to stack vertically */
    .case-study-content-wrapper {
        flex-direction: column !important;
        height: auto !important;
    }

    /* Standardize image heights and style */
    .case-study-image {
        width: 100% !important;
        height: 300px !important;
        /* Taller image height to match design */
        flex: none;
    }

    .case-study-image img {
        width: 100%;
        height: 100% !important;
        object-fit: cover;
    }

    /* Consistent meta styling */
    .case-study-meta {
        padding: 40px !important;
        /* More padding to match design */
        height: auto !important;
        flex: none !important;
    }

    .case-study-meta-inner {
        height: auto !important;
        max-width: none !important;
        /* Allow content to fill width */
    }

    /* Typography adjustments */
    .case-study-client-type {
        color: #F15A29;
        margin-bottom: 8px;
        /* Add some space after client type */
    }

    .case-study-title {
        font-size: 24px;
        line-height: 1.3;
        margin: 0 0 16px;
        /* Add space after title */
    }

    .case-study-description {
        margin: 0 0 24px;
        /* Add space before button */
    }

    /* Button styling */
    .case-study-link {
        display: inline-flex;
        margin-top: 0;
        /* Remove auto margin */
    }
}