/* Enhanced Case Studies Styling with Modern Design */
.case-study-item {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    box-shadow:
        0 8px 32px rgba(25, 11, 38, 0.08),
        0 2px 8px rgba(242, 80, 123, 0.05);
    height: 580px; /* Increased height for brand name and better spacing */
 
    border: 1px solid rgba(242, 80, 123, 0.08);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transform: translateZ(0); /* Enable hardware acceleration */
    will-change: transform, box-shadow; /* Optimize for animations */
}

/* Only apply hover effects on devices that support hover (desktop/laptop) */
@media (hover: hover) and (pointer: fine) {
    .case-study-item:hover {
        transform: translateY(-20px) scale(1.02);
        box-shadow:
            0 32px 64px rgba(25, 11, 38, 0.15),
            0 8px 24px rgba(242, 80, 123, 0.1);
        height: 580px; /* Maintain fixed height on hover */
        border-color: rgba(242, 80, 123, 0.15);
    }
}

/* Make the entire case study item clickable */
.grid-item a.case-study-full-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.case-study-image {
    position: relative;
    overflow: hidden;
    height: 260px; /* Fixed height for image area */
}

.case-study-image img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    filter: brightness(0.95);
}

@media (hover: hover) and (pointer: fine) {
    .case-study-item:hover .case-study-image img {
        transform: scale(1.05);
        filter: brightness(1.05);
    }
}

.case-study-category {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.95);
    color: #190B26;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    z-index: 3;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
 
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Service Type Badges */
.case-study-service-types {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 3;
}

.service-type-badge {
    background: rgba(255, 255, 255, 0.95);
    color: #190B26;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
 
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 4px;
}

.service-type-badge.ppc {
    border-left: 3px solid #4285f4;
}

.service-type-badge.social {
    border-left: 3px solid #1877f2;
}

.service-type-badge.ltv {
    border-left: 3px solid #28a745;
}

.service-type-badge i {
    font-size: 9px;
}

.case-study-content {
    padding: 20px 24px 16px 24px;
    background: #ffffff;
    position: relative;
    z-index: 2;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Hover overlay that animates from bottom to top - only on hover-capable devices */
@media (hover: hover) and (pointer: fine) {
    .case-study-content::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(25, 11, 38, 0.95);
       
        transform: translateY(100%);
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 5;
    }
}

/* Make content white on hover - only on hover-capable devices */
.case-study-content > * {
    position: relative;
    z-index: 10;
    transition: color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .case-study-item:hover .case-study-content::before {
        transform: translateY(0);
    }

    .case-study-item:hover .case-study-content * {
        color: #F2F2F2 !important;
        transition-delay: 0.2s;
    }

    .case-study-item:hover .case-study-brand {
        color: #BD6DF2 !important;
    }
}

/* Brand/Industry name styling */
.case-study-brand {
    font-size: 12px;
    font-weight: 600;
    color: #F2507B;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    position: relative;
    z-index: 10;
    transition: color 0.3s ease;
}

.case-study-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #190B26;
    line-height: 1.3;
    letter-spacing: -0.3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 52px; /* Fixed height for exactly 2 lines */
    transition: color 0.3s ease;
}

/* .case-study-description {
    font-size: 14px;
    line-height: 1.5;
    color: #64748b;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 42px;
} */

.case-study-metrics {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.05);
    flex: 1;
    position: relative;
    min-height: 120px;
    transition: all 0.3s ease;
}

.metric {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: all 0.3s ease;
    opacity: 1;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(242, 80, 123, 0.05);
    border: 1px solid rgba(242, 80, 123, 0.1);
}

/* Enhanced hover effects for metrics - only on hover-capable devices */
@media (hover: hover) and (pointer: fine) {
    .case-study-item:hover .metric {
        background: rgba(189, 109, 242, 0.1);
        border-color: rgba(189, 109, 242, 0.2);
        transform: translateY(-2px);
    }

    .case-study-item:hover .metric:nth-child(1) {
        transition-delay: 0s;
    }

    .case-study-item:hover .metric:nth-child(2) {
        transition-delay: 0.1s;
    }

    .case-study-item:hover .metric:nth-child(3) {
        transition-delay: 0.2s;
    }
}

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

.metric-value {
    font-size: 28px;
    font-weight: 900;
    color: #F2507B;
    line-height: 1;
    letter-spacing: -1px;
    transition: color 0.3s ease;
    margin: 0;
    flex-shrink: 0;
}

.metric-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.2;
    text-transform: none;
    transition: color 0.3s ease;
    margin: 0;
    text-align: right;
    flex: 1;
}

/* Override metric value color on hover to maintain AdZeta purple - only on hover-capable devices */
@media (hover: hover) and (pointer: fine) {
    .case-study-item:hover .metric-value {
        color: #BD6DF2 !important;
    }
}

/* Read Story Button - Hidden by default, appears on hover */
.read-story-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F2507B 0%, #BD6DF2 100%);
    color: #ffffff;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    margin-top: auto;
    transition: all 0.3s ease;
    position: relative;
    z-index: 20;
    box-shadow: 0 4px 16px rgba(242, 80, 123, 0.3);
    opacity: 0;
    transform: translateY(20px);
    border: none;
    flex-shrink: 0; /* Prevent button from shrinking */
    height: 40px; /* Fixed height */
}

/* Read story button hover effects - only on hover-capable devices */
@media (hover: hover) and (pointer: fine) {
    .case-study-item:hover .read-story-btn {
        opacity: 1;
        transform: translateY(0);
        transition-delay: 0.3s;
    }

    .read-story-btn:hover {
        background: linear-gradient(135deg, #BD6DF2 0%, #3F1940 100%);
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(189, 109, 242, 0.4);
        color: #ffffff;
        text-decoration: none;
    }

    .read-story-btn:hover::after {
        transform: translateX(4px);
    }
}

.read-story-btn::after {
    content: '→';
    margin-left: 8px;
    transition: transform 0.3s ease;
}

/* Make the entire case study item clickable */
.grid-item a.case-study-full-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.case-study-logo {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@media (hover: hover) and (pointer: fine) {
    .case-study-logo:hover {
        transform: scale(1.1);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    }
}

.case-study-logo img {
    width: 30px;
    height: auto;
}

/* Modern Filter Navigation */
.portfolio-filter.nav-tabs {
    border-bottom: none;
    margin-bottom: 50px;
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: visible;
}

.portfolio-filter li {
    padding: 0;
    margin: 0;
}

.portfolio-filter.nav-tabs .nav a {
    position: relative;
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid transparent;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.portfolio-filter.nav-tabs .nav a i {
    font-size: 16px;
    transition: transform 0.3s ease;
}

/* Count badges styling */
.portfolio-filter.nav-tabs .nav a .filter-count {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    margin-left: 4px;
    transition: all 0.3s ease;
}

/* Hover Effects */
@media (hover: hover) and (pointer: fine) {
    .portfolio-filter.nav-tabs .nav a:hover {
        color: #ffffff;
        background: linear-gradient(135deg, #e958a1, #bd6df2);
        border-color: rgba(233, 88, 161, 0.3);
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(233, 88, 161, 0.3);
    }

    .portfolio-filter.nav-tabs .nav a:hover i {
        transform: scale(1.1);
    }

    .portfolio-filter.nav-tabs .nav a:hover .filter-count {
        background: rgba(255, 255, 255, 0.2);
        color: #ffffff;
    }
}

/* Active State */
.portfolio-filter.nav-tabs .nav.active a {
    color: #ffffff;
    background: linear-gradient(135deg, #e958a1, #bd6df2);
    border-color: rgba(233, 88, 161, 0.5);
    box-shadow: 0 6px 20px rgba(233, 88, 161, 0.4);
}

.portfolio-filter.nav-tabs .nav.active a i {
    transform: scale(1.05);
}

.portfolio-filter.nav-tabs .nav.active a .filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Special styling for "All Case Studies" */
.portfolio-filter.nav-tabs .nav a[data-filter="*"] {
    background: linear-gradient(135deg, #3f1940, #190b26);
    color: #ffffff;
    border-color: rgba(63, 25, 64, 0.3);
}

.portfolio-filter.nav-tabs .nav a[data-filter="*"]:hover {
    background: linear-gradient(135deg, #5a2459, #2d1a3d);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(63, 25, 64, 0.4);
}

.portfolio-filter.nav-tabs .nav.active a[data-filter="*"] {
    background: linear-gradient(135deg, #3f1940, #190b26);
    box-shadow: 0 8px 25px rgba(63, 25, 64, 0.5);
}

/* Filter loading animation */
.filter-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.filter-loading-content {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.filter-loading-content .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

.filter-loading-content p {
    color: #6c757d;
    font-weight: 500;
    margin-top: 15px;
}

/* Smooth animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Enhanced filter container */
.portfolio-filter.nav-tabs::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: linear-gradient(135deg, rgba(233, 88, 161, 0.1), rgba(189, 109, 242, 0.1));
    border-radius: 30px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.portfolio-filter.nav-tabs:hover::before {
    opacity: 1;
}

/* Service type specific colors */
.portfolio-filter.nav-tabs .nav a[data-filter=".ppc"] {
    border-color: rgba(66, 133, 244, 0.2);
}

.portfolio-filter.nav-tabs .nav a[data-filter=".ppc"]:hover,
.portfolio-filter.nav-tabs .nav.active a[data-filter=".ppc"] {
    background: linear-gradient(135deg, #4285f4, #34a853);
    box-shadow: 0 6px 20px rgba(66, 133, 244, 0.4);
}

.portfolio-filter.nav-tabs .nav a[data-filter=".social"] {
    border-color: rgba(24, 119, 242, 0.2);
}

.portfolio-filter.nav-tabs .nav a[data-filter=".social"]:hover,
.portfolio-filter.nav-tabs .nav.active a[data-filter=".social"] {
    background: linear-gradient(135deg, #1877f2, #42a5f5);
    box-shadow: 0 6px 20px rgba(24, 119, 242, 0.4);
}

.portfolio-filter.nav-tabs .nav a[data-filter=".ltv"] {
    border-color: rgba(76, 175, 80, 0.2);
}

.portfolio-filter.nav-tabs .nav a[data-filter=".ltv"]:hover,
.portfolio-filter.nav-tabs .nav.active a[data-filter=".ltv"] {
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

/* Page title enhancements */
.case-studies-header {
    position: relative;
}

.case-studies-header h1 {
    font-weight: 700;
    letter-spacing: -2px;
}

.case-studies-header p {
    max-width: 700px;
    margin: 0 auto;
}

/* Animation for down arrow */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.animate-bounce {
    animation: bounce 2s infinite;
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .case-study-image img {
        height: 220px;
    }

    .case-study-content {
        padding: 25px;
    }

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

    .metric-value {
        font-size: 24px;
    }

    .case-study-logo {
        width: 44px;
        height: 44px;
        bottom: 25px;
        right: 25px;
    }
}

@media (max-width: 991px) {
    .portfolio-filter.nav-tabs {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        padding: 15px 10px;
        gap: 8px;
        margin-bottom: 40px;
        border-radius: 15px;
        overflow: visible;
    }

    .portfolio-filter.nav-tabs .nav a {
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 18px;
        min-width: auto;
        flex-shrink: 0;
    }

    .portfolio-filter.nav-tabs .nav a i {
        font-size: 14px;
    }

    .portfolio-filter.nav-tabs .nav a .filter-count {
        font-size: 11px;
        padding: 1px 6px;
    }
}

@media (max-width: 767px) {
    .portfolio-filter.nav-tabs {
        padding: 12px 8px;
        gap: 6px;
        margin-bottom: 30px;
        border-radius: 12px;
    }

    .portfolio-filter.nav-tabs .nav a {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 16px;
        gap: 6px;
    }

    .portfolio-filter.nav-tabs .nav a i {
        font-size: 13px;
    }

    .portfolio-filter.nav-tabs .nav a .filter-count {
        font-size: 10px;
        padding: 1px 5px;
        margin-left: 2px;
    }
}

@media (max-width: 480px) {
    .portfolio-filter.nav-tabs {
        padding: 10px 5px;
        gap: 4px;
        margin-bottom: 25px;
    }

    .portfolio-filter.nav-tabs .nav a {
        padding: 6px 10px;
        font-size: 11px;
        border-radius: 14px;
        gap: 4px;
    }

    .portfolio-filter.nav-tabs .nav a i {
        font-size: 12px;
    }

    .portfolio-filter.nav-tabs .nav a .filter-count {
        font-size: 9px;
        padding: 1px 4px;
    }

    /* Hide icons on very small screens to save space */
    .portfolio-filter.nav-tabs .nav a i {
        display: none;
    }

    /* Ensure proper text wrapping */
    .portfolio-filter.nav-tabs .nav a {
        word-break: keep-all;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(50vw - 20px);
    }
}

/* Additional mobile safety for very small screens */
@media (max-width: 360px) {
    .portfolio-filter.nav-tabs {
        padding: 8px 4px;
        gap: 3px;
    }

    .portfolio-filter.nav-tabs .nav a {
        padding: 5px 8px;
        font-size: 10px;
        border-radius: 12px;
        max-width: calc(50vw - 15px);
    }

    .portfolio-filter.nav-tabs .nav a .filter-count {
        font-size: 8px;
        padding: 0px 3px;
    }
}

@media (max-width: 767px) {
    .case-study-item {
        height: auto; /* Allow flexible height on mobile */
        min-height: 520px;
        border-radius: 20px;
        overflow: hidden; /* Ensure no content bleeds out */
        border: 1px solid rgba(242, 80, 123, 0.08); /* Consistent border */
    }

    /* Ensure no hover overlay artifacts on mobile */
    .case-study-content::before {
        display: none !important;
    }

    .case-study-content {
        padding: 16px 20px;
        background: #ffffff; /* Ensure solid background on mobile */
        position: relative;
        z-index: 1;
    }

    .case-study-brand {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .case-study-title {
        font-size: 18px;
        margin-bottom: 8px;
        height: auto; /* Allow flexible height on mobile */
        -webkit-line-clamp: 3; /* Allow more lines on mobile */
        line-clamp: 3;
    }

    /* .case-study-description {
        font-size: 14px;
        margin-bottom: 16px;
        height: auto;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    } */

    .case-study-metrics {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
        min-height: auto;
        padding-top: 16px;
    }

    .metric {
        opacity: 1 !important; /* Always show metrics on mobile */
        max-height: none !important;
        overflow: visible !important;
        background: rgba(242, 80, 123, 0.08);
        border: 1px solid rgba(242, 80, 123, 0.15);
        padding: 12px 16px;
        border-radius: 10px;
        flex-direction: column; /* Stack vertically on mobile */
        text-align: center;
        gap: 4px;
    }

    .metric-value {
        font-size: 24px;
        color: #F2507B;
        text-align: center;
    }

    .metric-label {
        font-size: 12px;
        color: #64748b;
        text-align: center;
    }

    /* Show read story button on mobile without hover */
    .read-story-btn {
        opacity: 1 !important;
        transform: translateY(0) !important;
        margin-top: 16px;
        font-size: 13px;
        padding: 8px 16px;
        height: 36px;
    }


}
