/* Dynamic Homepage Manager Frontend Styles - Enhanced */

.dhm-homepage-grid {
    margin: 0px auto;
    max-width: 1200px;
    padding: 0 15px;
}

/* Post tile layouts */
.dhm-post-tile {
    position: relative;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dhm-post-tile:hover {
    /* Removed moving hover effect */
}

.dhm-post-tile-image {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
}

.dhm-post-tile-image img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.dhm-post-tile-content {
    flex: 1 1 auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Meta row with category badge and views */
.dhm-post-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dhm-category-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dhm-post-metrics {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
}

.dhm-eye-icon {
    color: #6b7280;
    stroke: currentColor;
}

/* Featured post tile styling */
.dhm-featured-post-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    height: 100%;
}

.dhm-featured-post-tile:hover {
    /* Removed moving hover effect */
}

.dhm-featured-content-wrapper {
    display: flex;
    height: 100%;
    flex: 1 1 auto;
}

.dhm-featured-image {
    flex: 0 0 50%;
    position: relative;
    overflow: hidden;
}

.dhm-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dhm-featured-text-content {
    flex: 1 1 50%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #1c478d;
    color: white;
    position: relative;
}

.dhm-featured-text-content .dhm-tile-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 12px 0;
    line-height: 1.3;
    color: white;
}

.dhm-featured-text-content .dhm-tile-excerpt {
    font-size: 16px;
    line-height: 1.5;
    color: white;
    margin: 0;
}

.dhm-featured-views {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.6);
    padding: 4px 8px;
    border-radius: 12px;
    z-index: 20;
    backdrop-filter: blur(4px);
}

.dhm-featured-views .dhm-eye-icon {
    color: rgba(255,255,255,0.9);
}

/* Featured layout structure */
.dhm-featured-layout {
    display: flex;
    flex-direction: column;
    gap: 16px; /* Reduced gap between rows */
}

.dhm-row-1 {
    display: grid;
    grid-template-columns: 3.1fr 1fr; /* Featured tile 2/3, second tile 1/3 */
    gap: 16px; /* Reduced gap */
    height: 320px; /* Fixed height for consistency */
}

.dhm-row-2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 equal tiles */
    gap: 16px; /* Reduced gap */
    height: 320px; /* Fixed height matching row 1 */
}

/* Ensure all row 2 tiles have consistent content areas */
.dhm-row-2 .dhm-tile-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%; /* Fill available tile height */
    box-sizing: border-box;
}

.dhm-row-2 .dhm-tile-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 6px 0;
    line-height: 1.3;
    flex-shrink: 0;
}

.dhm-row-2 .dhm-tile-excerpt {
    font-size: 12px;
    line-height: 1.3;
    color: #4a5568;
    flex-grow: 1;
    margin: 0 0 8px 0;
    /* Allow full excerpt to show */
}

.dhm-row-2 .dhm-post-type {
    margin-top: 6px;
    padding: 2px 6px;
    font-size: 10px;
    flex-shrink: 0;
}

.dhm-row-2 .dhm-case-study-footer {
    margin-top: 6px;
    flex-shrink: 0;
}

.dhm-row-2 .dhm-case-study-metrics {
    font-size: 10px;
}

.dhm-row-2 .dhm-case-study-view-btn {
    font-size: 11px;
}

/* All row 2 cards inherit the same height from grid container */
.dhm-row-2 .dhm-custom-card,
.dhm-row-2 .dhm-custom-card-content,
.dhm-row-2 .dhm-template-card {
    height: 100%; /* Use full grid cell height */
    box-sizing: border-box;
}

.dhm-row-2 .dhm-custom-card .dhm-tile-title,
.dhm-row-2 .dhm-template-card .dhm-tile-title {
    font-size: 14px;
    margin-bottom: 6px;
}

.dhm-row-2 .dhm-custom-card .dhm-tile-excerpt,
.dhm-row-2 .dhm-template-card .dhm-tile-excerpt {
    font-size: 12px;
    line-height: 1.3;
}

.dhm-row-2 .dhm-custom-card .dhm-card-button {
    padding: 4px 8px;
    font-size: 10px;
    margin: 4px auto 0;
}

/* Legacy grid layout (if needed) */
.dhm-grid-layout {
    display: grid;
    gap: 20px;
}

.dhm-columns-2 { grid-template-columns: repeat(2, 1fr); }
.dhm-columns-3 { grid-template-columns: repeat(3, 1fr); }
.dhm-columns-4 { grid-template-columns: repeat(4, 1fr); }

/* Base tile styles */
.dhm-tile {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%; /* Fill parent container height */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-height: 100%; /* Prevent overflow */
}

/* Remove cursor pointer for template cards that aren't clickable */
.dhm-tile:has(.dhm-template-card) {
    cursor: default;
}

/* Alternative for browsers that don't support :has() */
.dhm-tile.dhm-template-card-container {
    cursor: default;
}

/* Ensure all interactive elements in template cards have pointer cursor */
.dhm-template-card a,
.dhm-template-card button,
.dhm-template-card [role="button"],
.dhm-template-card .dhm-card-button {
    cursor: pointer !important;
}

.dhm-tile:hover {
    text-decoration: none;
    border-color: #d1d5db;
}

/* Featured tile specific styling */
.dhm-tile-position-1,
.dhm-featured-tile {
    /* Dark background for better contrast */
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: white;
    border: none;
    height: 100%; /* Use full row height */
}

.dhm-tile-position-1 .dhm-tile-excerpt,
.dhm-featured-tile .dhm-tile-excerpt {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    line-height: 1.3;
    /* Limit featured card excerpt to prevent overflow */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dhm-tile-position-1 .dhm-tile-title,
.dhm-featured-tile .dhm-tile-title {
    color: white;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.3;
}


/* Tile image handling */
.dhm-tile-image {
    position: relative;
    height: 140px; /* Consistent height for all standard tiles */
    overflow: hidden;
    background: #f8f9fa;
    flex-shrink: 0; /* Prevent shrinking */
}

.dhm-tile-position-1 .dhm-tile-image,
.dhm-featured-tile .dhm-tile-image {
    height: 240px;
}

/* .dhm-tile-position-2 .dhm-tile-image {
    height: 240px;
} */

.dhm-tile-image img,
.dhm-tile-image-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.dhm-tile:hover .dhm-tile-image img,
.dhm-tile:hover .dhm-tile-image-img {
    transform: scale(1.05);
}

.dhm-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #718096;
    font-style: italic;
    font-size: 14px;
    font-weight: 500;
}

/* Tile content */
.dhm-tile-content {
    padding: 20px;
    flex: 1; /* Take remaining height */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dhm-tile-position-1 .dhm-tile-content,
.dhm-featured-tile .dhm-tile-content {
    padding: 24px;
    overflow: hidden; /* Prevent overflow */
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%; /* Fill available space */
}

.dhm-tile-position-2 .dhm-tile-content {
    /* height: calc(100% - 240px); */
    padding: 24px;
}


/* Tile titles */
.dhm-homepage-grid .dhm-tile-title {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.4;
    color: #2d3748;
}

/* big card tile title  */
.dhm-tile-position-1 .dhm-tile-title,
.dhm-featured-tile .dhm-tile-title {
    color: white;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.3;
}

.dhm-custom-card .dhm-tile-title {
    font-size: 24px;
    margin-bottom: 14px;
}

.dhm-tile-excerpt {
    margin: 0;
    color: #4a5568;
    line-height: 1.6;
    font-size: 14px;
    flex-grow: 1;
    /* display: none; */
}


/* Post type badge */
.dhm-post-type {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 10px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    align-self: flex-start;
}

/* Post type specific colors */
.dhm-post-type-post {
    background: #e6f3ff;
    color: #2563eb;
}

.dhm-post-type-page {
    background: #f0fdf4;
    color: #16a34a;
}

.dhm-post-type-case-study {
    background: #fef3c7;
    color: #d97706;
}

/* Custom card base styling - match all card heights */
.dhm-custom-card {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    background: var(--e-global-color-primary);
    color: var(----e-global-color-secondary);
    overflow: hidden; /* Prevent content overflow */
    box-sizing: border-box;
}

.dhm-custom-card .dhm-tile-content {
    height: auto;
    padding: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.dhm-custom-card .dhm-tile-title {
    color: white;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.3;
}

.dhm-custom-card .dhm-tile-excerpt {
    color: white;
    font-size: 12px;
    line-height: 1.3;
    margin-bottom: 8px;
    /* Limit excerpt to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Specific custom card themes */
.dhm-card-newsletter,
.dhm-card-newsletter-bg,
.dhm-card-contact,
.dhm-card-contact-bg
 {
    /* background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); */
    background: var( --e-global-color-c4109ce );
}

/* .dhm-card-contact,
.dhm-card-contact-bg {
} */

.dhm-card-welcome {
    /* background: linear-gradient(180deg, #1A1A2C 0%, #000043 100%); */
    /* background: var(--e-global-color-primary); */
    /* color: #8b4513; */
    color: #fff;
}

.dhm-card-workshop-3 {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.dhm-card-group-1 {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Custom card button */
.dhm-card-button {
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer !important; /* Ensure buttons always have pointer cursor */
    margin-top: 20px;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dhm-card-button:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Custom Card Content Styling - responsive to container */
.dhm-custom-card-content {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 12px;
    box-sizing: border-box;
    text-align: center;
    overflow: hidden; /* Prevent content overflow */
}

/* When custom card has image, adjust layout */
.dhm-custom-card-content:has(.dhm-tile-image) {
    justify-content: flex-start;
    align-items: stretch;
}

/* Alternative approach for browsers that don't support :has() */
.dhm-custom-card-content.has-image {
    justify-content: flex-start;
    align-items: stretch;
}

/* Custom card with image styling - very compact for row 2 */
.dhm-custom-card-content .dhm-tile-image {
    height: 60px; /* Standard image size for custom cards */
    margin-bottom: 8px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

/* Much smaller images for row 2 custom cards to prevent height issues */
.dhm-row-2 .dhm-custom-card-content .dhm-tile-image {
    height: 24px; /* Very small for row 2 to match card proportions */
    margin-bottom: 4px;
}

/* Ensure custom cards in row 2 maintain proper proportions */
.dhm-row-2 .dhm-custom-card-content {
    padding: 8px; /* Reduce padding in row 2 */
}

.dhm-row-2 .dhm-custom-card-content .dhm-tile-title {
    font-size: 12px; /* Smaller title in row 2 */
    margin-bottom: 4px;
}

.dhm-row-2 .dhm-custom-card-content .dhm-tile-excerpt {
    font-size: 10px; /* Smaller text in row 2 */
    line-height: 1.2;
    margin-bottom: 6px;
    -webkit-line-clamp: 2; /* Limit to 2 lines */
}

.dhm-custom-card-content .dhm-tile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dhm-card-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    text-align: center;
}

/* When card has image, adjust text alignment */
.dhm-custom-card-content.has-image .dhm-card-text {
    justify-content: flex-start;
    align-items: stretch;
    text-align: center;
}

.dhm-custom-card-content .dhm-tile-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.3;
}

.dhm-custom-card-content .dhm-tile-excerpt {
    font-size: 12px;
    line-height: 1.3;
    margin-bottom: 8px;
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dhm-custom-card-content .dhm-card-button {
    margin: 6px auto 0;
    align-self: center;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer !important; /* Ensure buttons always have pointer cursor */
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    line-height: 1;
}

.dhm-custom-card-content .dhm-card-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Button tracking class for analytics */
.dotank-button-tracker {
    cursor: pointer;
    transition: all 0.3s ease;
}

.dotank-button-tracker:hover {
    opacity: 0.8;
}

/* Template Card Styles */
.dhm-template-card {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    background: var(--e-global-color-primary, #2196F3);
    color: var(--e-global-color-secondary, #ffffff);
    overflow: hidden; /* Prevent content overflow */
    box-sizing: border-box;
}

.dhm-template-card .dhm-tile-content {
    max-width: 100%;
    height: auto;
    padding: 0; /* Remove extra padding */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.dhm-template-card .dhm-tile-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.3;
}

.dhm-template-card .dhm-tile-excerpt {
    font-size: 13px;
    line-height: 1.4;
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive adjustments for custom cards */
@media (max-width: 768px) {
    .dhm-row-1, .dhm-row-2 {
        grid-template-columns: 1fr;
        height: auto; /* Allow natural height on mobile */
        gap: 15px;
    }
    
    .dhm-tile {
        min-height: 200px; /* Minimum height on mobile */
    }
    
    .dhm-custom-card-content {
        padding: 15px;
    }
    
    .dhm-custom-card-content .dhm-card-button {
        font-size: 14px;
        padding: 8px 16px;
    }
    
    .dhm-featured-layout {
        gap: 15px;
    }
}

/* Default/placeholder tiles */
.dhm-default-tile,
.dhm-placeholder-tile {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 2px dashed #cbd5e0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #718096;
    cursor: default;
}

.dhm-placeholder-tile {
    opacity: 0.6;
}

.dhm-default-tile:hover,
.dhm-placeholder-tile:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dhm-default-tile .dhm-tile-content,
.dhm-placeholder-tile .dhm-tile-content {
    height: 100%;
    justify-content: center;
    padding: 30px;
}

/* Error styling */
.dhm-error {
    padding: 20px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 8px;
    color: #c00;
    text-align: center;
    margin: 20px 0;
}

/* Debug info styling */
.dhm-debug-info {
    background: #f0f0f0;
    border: 2px dashed #999;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.dhm-debug-tile {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 3px;
    font-family: monospace;
    z-index: 10;
}

/* Animation for rule-based content changes */
.dhm-tile[data-rule-id] {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus states for accessibility */
.dhm-tile:focus {
    outline: 3px solid #4299e1;
    outline-offset: 2px;
}

/* Loading state */
.dhm-tile-loading {
    opacity: 0.6;
    pointer-events: none;
}

.dhm-tile-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #4299e1;
    border-radius: 50%;
    animation: dhm-spin 1s linear infinite;
}

@keyframes dhm-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (min-width: 1025px) {
    .dhm-featured-tile, .dhm-tile-position-1, .dhm-tile-position-2 {
        min-height: fit-content;
    }
    .dhm-featured-tile {
        display: flex;
        flex-direction: row;
    }
    .dhm-featured-tile .dhm-tile-image {
        height: 100%;
        width: 50%;
    }
    
    .dhm-featured-tile .dhm-tile-content {
        /* flex-grow: 1; */
        width: 50%;
        height: fit-content;
    }
    /* featured custom card */
    .dhm-featured-tile .dhm-custom-card {
        width: 100%;
    }
}
@media (max-width: 1024px) {
    .dhm-row-1,
    .dhm-row-2 {
        height: 280px; /* Slightly smaller on tablets */
    }
    
    .dhm-featured-layout .dhm-row-1 {
        grid-template-columns: 1fr;
    }
    
    .dhm-featured-layout .dhm-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .dhm-homepage-grid {
        margin: 20px auto;
    }
    
    .dhm-row-1,
    .dhm-row-2 {
        height: 250px; /* Smaller on mobile but still consistent */
        gap: 12px; /* Smaller gaps on mobile */
    }
    
    .dhm-featured-layout {
        gap: 12px; /* Smaller row gap on mobile */
    }

    .dhm-featured-layout .dhm-row-2 {
        grid-template-columns: 1fr;
    }
    
    .dhm-grid-layout {
        grid-template-columns: 1fr;
    }
    
    .dhm-tile {
        min-height: 200px;
    }
    
    .dhm-tile-position-1,
    .dhm-tile-position-2,
    .dhm-featured-tile {
        min-height: 280px;
    }
    
    .dhm-tile-image,
    .dhm-tile-position-1 .dhm-tile-image,
    .dhm-tile-position-2 .dhm-tile-image {
        height: 140px;
    }
    
    .dhm-tile-content,
    .dhm-tile-position-1 .dhm-tile-content,
    .dhm-tile-position-2 .dhm-tile-content {
        padding: 16px;
        height: calc(100% - 140px);
    }
    
    .dhm-tile-title,
    .dhm-tile-position-1 .dhm-tile-title,
    .dhm-tile-position-2 .dhm-tile-title {
        font-size: 16px;
    }
    
    .dhm-tile-excerpt,
    .dhm-tile-position-1 .dhm-tile-excerpt {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .dhm-homepage-grid {
        gap: 15px;
        margin: 15px 0;
    }
    
    .dhm-featured-layout {
        gap: 15px;
    }
    
    .dhm-row-1,
    .dhm-row-2 {
        gap: 15px;
    }
}

/* Case Study Card Styles */
.dhm-case-study-tile {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 100%; /* Respect container height */
}

.dhm-tile-image-wrapper {
    position: relative;
    height: 45%; /* Proportional height - about 45% of card */
    overflow: hidden;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Add underline border matching category badge color */
.dhm-tile-image-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background-color: var(--category-color, #e5e7eb); /* Default fallback */
    z-index: 1;
}

/* Ensure row 2 image wrapper respects proportions */
.dhm-row-2 .dhm-tile-image-wrapper {
    height: 45%; /* Same proportion for row 2 */
}

.dhm-case-study-tile .dhm-tile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.dhm-case-study-tile .dhm-tile-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.dhm-case-study-tile:hover .dhm-tile-image img {
    transform: scale(1.05);
}

/* Year badge - top right corner */
.dhm-year-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
}

/* Category badge - above title in content area */
.dhm-category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: normal;
    margin-bottom: 8px;
    width: fit-content;
}

/* Regular case study content */
.dhm-case-study-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow content to shrink */
    overflow: hidden; /* Prevent overflow */
}

.elementor-shortcode .dhm-case-study-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 8px 0;
    color: #1a202c;
    flex-shrink: 0; /* Title doesn't shrink */
}

.dhm-case-study-excerpt {
    color: #4a5568;
    line-height: 1.4;
    font-size: 13px;
    margin-bottom: 12px;
    flex-grow: 1;
    overflow: hidden;
    /* Limit to 3 lines maximum */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.dhm-case-study-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

/* Header row with category badge and views icon */
.dhm-case-study-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dhm-case-study-header .dhm-category-badge {
    margin-bottom: 0; /* Remove bottom margin when in header */
}

.dhm-case-study-header .dhm-case-study-metrics {
    margin-top: 0; /* Align with category badge */
}

.dhm-case-study-metrics {
    font-size: 12px;
    color: #718096;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dhm-eye-icon {
    width: 14px;
    height: 14px;
}

.dhm-case-study-view-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #2563eb;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.dhm-case-study-view-btn:hover {
    color: #1d4ed8;
}

.dhm-arrow-icon {
    transition: transform 0.2s ease;
}

.dhm-case-study-view-btn:hover .dhm-arrow-icon {
    /* Removed moving arrow effect */
}

/* Featured Case Study Styles */
.dhm-featured-case-study {
    min-height: 400px;
    width: 100%;
}

.dhm-featured-case-study .dhm-tile-image-wrapper {
    height: 100%;
    position: relative;
}

.dhm-featured-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #667eea;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dhm-featured-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    padding: 32px 24px 24px;
    color: white;
    z-index: 2;
}

.dhm-featured-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 12px 0;
    color: white;
}

.dhm-featured-excerpt {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    font-size: 16px;
    margin-bottom: 20px;
}

.dhm-featured-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.dhm-featured-view-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Color system for category badges */
.dhm-color-purple {
    background: #8b5cf6;
    color: white;
}

.dhm-color-blue {
    background: #3b82f6;
    color: white;
}

.dhm-color-green {
    background: #10b981;
    color: white;
}

.dhm-color-orange {
    background: #f59e0b;
    color: white;
}

.dhm-color-red {
    background: #ef4444;
    color: white;
}

.dhm-color-teal {
    background: #14b8a6;
    color: white;
}

.dhm-color-pink {
    background: #ec4899;
    color: white;
}

.dhm-color-yellow {
    background: #eab308;
    color: #000;
}

.dhm-color-indigo {
    background: #6366f1;
    color: white;
}

.dhm-color-gray {
    background: #6b7280;
    color: white;
}

.dhm-color-default {
    background: #e5e7eb;
    color: #374151;
}

/* Color accent for tile borders when hovered */
.dhm-tile:hover .dhm-category-badge.dhm-color-purple {
    box-shadow: 0 0 0 2px #8b5cf6;
}

.dhm-tile:hover .dhm-category-badge.dhm-color-blue {
    box-shadow: 0 0 0 2px #3b82f6;
}

.dhm-tile:hover .dhm-category-badge.dhm-color-green {
    box-shadow: 0 0 0 2px #10b981;
}

.dhm-tile:hover .dhm-category-badge.dhm-color-orange {
    box-shadow: 0 0 0 2px #f59e0b;
}

.dhm-tile:hover .dhm-category-badge.dhm-color-red {
    box-shadow: 0 0 0 2px #ef4444;
}

.dhm-tile:hover .dhm-category-badge.dhm-color-teal {
    box-shadow: 0 0 0 2px #14b8a6;
}

.dhm-tile:hover .dhm-category-badge.dhm-color-pink {
    box-shadow: 0 0 0 2px #ec4899;
}

.dhm-tile:hover .dhm-category-badge.dhm-color-yellow {
    box-shadow: 0 0 0 2px #eab308;
}

/* Responsive adjustments for case studies */
@media (max-width: 768px) {
    .dhm-case-study-title {
        font-size: 16px;
    }
    
    .dhm-featured-title {
        font-size: 24px;
    }
    
    .dhm-featured-excerpt {
        font-size: 14px;
    }
    
    .dhm-featured-overlay {
        padding: 24px 16px 16px;
    }
    
    .dhm-case-study-content {
        padding: 12px;
    }
    
    .dhm-tile-image-wrapper {
        height: 160px;
    }
    
    .dhm-featured-case-study {
        min-height: 300px;
    }
    
    .dhm-featured-case-study .dhm-tile-image-wrapper {
        height: 100%;
    }
}

/* Print styles */
@media print {
    .dhm-tile {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .dhm-debug-info,
    .dhm-debug-tile {
        display: none;
    }
}