/* Jabir Insurance Category Grid - Improved Responsive 3/2/1 Columns */
.jabir-insurance-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Desktop: 3 equal columns */
    align-items: stretch; /* Ensures children stretch to full height */
    gap: 20px;
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0; /* Bottom spacing */
    box-sizing: border-box;
    min-height: 230px !important; /* Fallback if no cards */
}

.jabir-category-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    height: 300px; /* Fallback height; overridden by Elementor controls */
    box-sizing: border-box;
    background-color: #f8f9fa; /* Light fallback if no image */
}

.jabir-category-card a {
    display: block !important; /* Force block for full coverage */
    position: relative;
    color: inherit;
    text-decoration: none;
    width: 100%;
    height: 100%; /* Inherit full height from parent */
    min-height: inherit; /* Propagate min-height */
    background-size: cover !important; /* Ensure cover; !important for overrides */
    background-position: center !important;
    background-repeat: no-repeat !important;
    transition: filter 0.3s ease; /* For hover dim/brighten */
    z-index: 1;
    height: 300px;
}

/* Fallback if no background image (e.g., empty URL) */
.jabir-category-card a[style*="background-image: url()"], /* Empty URL */
.jabir-category-card a:not([style*="background-image"]) {
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%) !important; /* Subtle placeholder gradient */
    background-size: cover;
}

/* Show foreground image as fallback (full-width, covers background) */
.jabir-category-card img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Scales image to fill without distortion */
    display: block; /* Show it now for better fallback */
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0; /* Behind overlay */
}

/* Overlay for Title, Posts, and Arrow */
.jabir-cat-overlay {
    /*position: absolute;*/
    /*bottom: 0;*/
    /*left: 0;*/
    /*right: 0;*/
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.7); /* Dark semi-transparent; overridden by controls */
    z-index: 2;
    box-sizing: border-box;
    min-height: 60px; /* Ensures overlay has space even if text is short */
}

.jabir-cat-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    color: white; /* Default; overridden by controls */
    max-width: 100%;
    position: relative;
    z-index: 3;
}

.jabir-cat-title {
    margin: 0 0 4px 0;
    font-size: 1.3em; /* Slightly larger for prominence */
    font-weight: bold;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8); /* Better readability over images */
    word-wrap: break-word;
}

.jabir-cat-posts {
    font-size: 0.95em;
    opacity: 0.95;
    margin-bottom: 6px;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    background: rgba(255,255,255,0.2); /* Subtle badge-like background */
    padding: 4px 8px;
    border-radius: 4px;
}

.jabir-cat-arrow {
    margin-left: auto;
    align-self: flex-end;
    font-size: 1.1em;
    transition: transform 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* Hover Effects */
.jabir-category-card:hover {
    transform: translateY(-8px); /* Slightly more lift */
    box-shadow: 0 12px 30px rgba(0,0,0,0.2); /* Deeper shadow */
    will-change: transform; /* Optimize animation */
}

.jabir-category-card:hover a {
    filter: brightness(1.05); /* Brighten image on hover */
}

.jabir-category-card:hover .jabir-cat-arrow {
    transform: translateX(8px); /* Arrow slides further */
}

/* Focus for Accessibility */
.jabir-category-card a:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Tablet: 2 Columns */
@media (max-width: 1024px) and (min-width: 768px) {
    .jabir-insurance-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns */
        gap: 16px;
    }
    .jabir-cat-overlay {
        padding: 16px;
        min-height: 55px;
    }
    .jabir-cat-title {
        font-size: 1.2em;
    }
    .jabir-cat-posts {
        font-size: 0.9em;
        padding: 3px 6px;
    }
}

/* Mobile: 1 Column */
@media (max-width: 767px) {
    .jabir-insurance-grid {
        grid-template-columns: 1fr; /* 1 full-width column */
        gap: 16px;
        margin-bottom: 20px;
    }
    .jabir-category-card {
        min-height: 200px; /* Slightly shorter on mobile */
    }
    .jabir-cat-overlay {
        padding: 16px;
        min-height: 50px;
        text-align: center; /* Center content */
    }
    .jabir-cat-content {
        align-items: center;
        gap: 4px; /* Space between title/posts/arrow */
    }
    .jabir-cat-title {
        font-size: 1.15em;
    }
    .jabir-cat-posts {
        font-size: 0.88em;
        padding: 3px 6px;
    }
    .jabir-cat-arrow {
        margin-left: 8px;
        font-size: 1em;
    }
    .jabir-category-card:hover {
        transform: none; /* Disable lift on mobile for touch */
    }
}

/* High-DPI/Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .jabir-cat-title, .jabir-cat-posts, .jabir-cat-arrow {
        text-shadow: 2px 2px 4px rgba(0,0,0,0.9); /* Stronger shadow */
    }
}
