/* Container */
.case-studies {
    display: flex;
    gap: 20px;
    padding: 10px;
    height: 65vh;
    overflow: hidden;
    position: relative;
}

/* Wrapper to control flex expansion */
.case-wrapper {
    flex: 1;
    min-width: 0;
    transition: flex 0.5s ease;
    cursor: pointer;
    position: relative;
}

/* Expanded flex state */
.case-wrapper.expanded {
    flex: 5;
}

/* REMOVE this block so tiles don't dim or shrink on dimmed */
/*
.case-wrapper:not(.expanded).dimmed {
    flex: 0.1;
    opacity: 0.3;
    pointer-events: none;
}
*/

/* Panel styling */
.case-study {
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Hover zoom (when not expanded) */
.case-wrapper:not(.expanded) .case-study:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* Overlay for darken effect */
.overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
    transition: background 0.3s ease;
}


/* Title styling & default centered placement */
.case-title {
    position: absolute;
    z-index: 2;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    text-align: center;
    padding: 10px;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
    transition: top 0.4s ease, transform 0.4s ease, opacity 0.3s ease;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
}

/* Fade out only header text on dimmed tiles */
.case-wrapper.dimmed .case-title {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Reset title opacity for expanded or normal tiles */
.case-wrapper.expanded .case-title,
.case-wrapper:not(.dimmed):not(.expanded) .case-title {
    opacity: 1;
}

/* Details: clipped via max-height and faded */
.case-details {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    color: var(--text-color);
    font-size: 1rem;
    text-align: center;
    line-height: 1.6;
    padding: 0 20px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition:
        max-height 0.5s ease 0.2s,
        opacity 0.2s ease 0s;
    z-index: 2;
}


/* On expand: move title up, reveal details */
.case-wrapper.expanded .case-title {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}
.case-wrapper.expanded .case-details {
    max-height: 400px;
    opacity: 1;
    transition-delay: 0.3s, 0.3s;
}

/* Example backgrounds */
.case-wrapper:nth-child(1) .case-study {
    background-image: url('/images/BarleyMow.png');
}
.case-wrapper:nth-child(2) .case-study {
    background-image: url('/images/Quizpacks_Charities.png');
}

/* Mobile & small windows */
@media (max-width: 768px) {
    .case-studies {
        flex-direction: column;
        height: auto;
    }
    .case-wrapper {
        width: 100%;
        transition: height 0.5s ease;
        flex: none !important;
        cursor: pointer;
        height: 20vh;
    }
    .case-wrapper.expanded {
        height: 70vh;
    }
    .case-study {
        height: 100%;
    }
    .case-title {
        font-size: 1.8rem;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
    }
    .case-details {
    width: 90%;
    bottom: auto;
    top: 50%;
    left: 50%;               /* Add this */
	margin-top: 30px;
    transform: translate(-50%, -50%);  /* Adjust transform */
    max-height: 0;
    opacity: 0;
    transition:
        max-height 0.5s ease 0.2s,
        opacity 0.3s ease 0s;
	}

    .case-wrapper.expanded .case-details {
        max-height: 400px;
        opacity: 1;
        transition-delay: 0.2s, 0.2s;
    }
}
