/* Fix for E-formation card image text overlap issue */

/* Ensure formation card has strict boundaries */
.formation-card {
    display: flex !important;
    flex-direction: column !important;
    position: relative;
    overflow: hidden !important;
    isolation: isolate;
}

/* Strict containment for image container - FORCE FIXED HEIGHT WITH CLIP */
.formation-card > div:first-child {
    position: relative;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    isolation: isolate;
    background: #f3f4f6;
    height: 192px !important;
    max-height: 192px !important;
    min-height: 192px !important;
    clip-path: inset(0 0 0 0);
}

/* Add white separator bar after image */
.formation-card > div:first-child::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: white;
    z-index: 100;
}

/* Ensure image is properly contained */
.formation-card img {
    display: block;
    width: 100%;
    height: 192px !important;
    max-height: 192px !important;
    object-fit: cover;
    object-position: center top;
}

/* Create clear separation between image and content */
.formation-card .p-6 {
    position: relative;
    z-index: 101;
    background: white !important;
    isolation: isolate;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 0 !important;
    padding-top: 1.5rem !important;
    border-top: 2px solid white;
}

/* Force content wrapper to be below image */
.formation-card > div:first-child + div {
    position: relative;
    z-index: 101;
    background: white !important;
    margin-top: 0 !important;
}

/* Ensure title doesn't overlap with image */
.formation-card h3 {
    position: relative;
    z-index: 3;
    background: white !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.4 !important;
    word-wrap: break-word;
    word-break: break-word;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Ensure excerpt doesn't overflow */
.formation-card p {
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.5 !important;
    word-wrap: break-word;
    word-break: break-word;
}

/* Mobile specific fixes */
@media (max-width: 768px) {
    .formation-card > div:first-child {
        height: 192px;
        max-height: 192px;
        min-height: 192px;
    }
    
    .formation-card img {
        max-height: 192px;
    }
}

/* Tablet and desktop */
@media (min-width: 769px) {
    .formation-card > div:first-child {
        height: 192px;
        max-height: 192px;
        min-height: 192px;
    }
    
    .formation-card img {
        max-height: 192px;
    }
}

/* Force content section to stay below image */
.formation-card > div:first-child + div {
    margin-top: 0 !important;
    position: relative;
    z-index: 2;
}
