/**
 * Case Studies Plugin Styles
 */

/* Case Studies Wrapper */
.case-studies-wrapper {
    margin: 20px 0;
    clear: both;
}

.case-studies-wrapper.case-studies-grid {
    display: grid;
    gap: 30px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.case-studies-wrapper.case-studies-grid[data-columns="1"] {
    grid-template-columns: 1fr;
}

.case-studies-wrapper.case-studies-grid[data-columns="2"] {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.case-studies-wrapper.case-studies-grid[data-columns="3"] {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.case-studies-wrapper.case-studies-grid[data-columns="4"] {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Masonry Layout */
.case-studies-wrapper.case-studies-masonry {
    margin: 0;
    width: 100%;
}

/* Fix to reduce space between items */
.case-studies-wrapper.case-studies-masonry:after {
    content: '';
    display: block;
    clear: both;
}

/* Show masonry after it's loaded */
.case-studies-wrapper.case-studies-masonry.masonry-loaded {
    visibility: visible;
    opacity: 1;
}

/* Base styles for masonry items */
.case-studies-masonry .case-study-item {
    width: 33.333%;
    padding: 5px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
    margin-bottom: 10px;
}

.case-studies-masonry .case-study-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Column size adjustments */
.case-studies-masonry[data-columns="1"] .case-study-item {
    width: 100%;
}

.case-studies-masonry[data-columns="2"] .case-study-item {
    width: 50%;
}

.case-studies-masonry[data-columns="3"] .case-study-item {
    width: 33.333%;
}

.case-studies-masonry[data-columns="4"] .case-study-item {
    width: 25%;
}

.case-studies-masonry[data-columns="5"] .case-study-item {
    width: 20%;
}

.case-studies-masonry[data-columns="6"] .case-study-item {
    width: 16.666%;
}

/* Image and content styling */

/* Image and content styling for Masonry */
.case-studies-masonry .case-study-thumbnail {
    width: 100%;
    display: block;
    background: #f0f0f0;
    overflow: hidden;
    border-radius: 6px 6px 0 0;
    margin: 0;
}

.case-studies-masonry .case-study-thumbnail a {
    display: block;
    width: 100%;
    height: 100%;
}

.case-studies-masonry .case-study-thumbnail img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
}

.case-studies-masonry .case-study-content {
    display: none; /* Hide the title overlay */
}

.case-studies-masonry .case-study-content h3 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
}

.case-studies-masonry .case-study-content h3 a {
    color: white;
    text-decoration: none;
    pointer-events: auto;
}

.case-studies-masonry .case-study-content p {
    margin: 0;
    font-size: 0.9em;
    opacity: 0.9;
}

/* Item Heights for Masonry - different sizes based on class */
.case-studies-masonry .masonry-small .case-study-thumbnail {
    height: 180px;
}

.case-studies-masonry .masonry-medium .case-study-thumbnail {
    height: 280px;
}

.case-studies-masonry .masonry-large .case-study-thumbnail {
    height: 380px;
}

.case-studies-masonry .masonry-wide .case-study-thumbnail {
    height: 220px;
}

.case-studies-masonry .masonry-tall .case-study-thumbnail {
    height: 320px;
}

.case-studies-masonry .case-study-thumbnail {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.case-studies-masonry .case-study-thumbnail a {
    display: block;
    height: 100%;
}

.case-studies-masonry .case-study-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.5s ease;
}

.case-studies-masonry .case-study-item:hover .case-study-thumbnail img {
    transform: scale(1.1);
}

/* Masonry Overlay */
.masonry-overlay-link {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    text-decoration: none;
    color: inherit;
    z-index: 2;
    cursor: pointer;
}

.masonry-overlay-link:hover,
.masonry-overlay-link:focus {
    text-decoration: none;
    color: inherit;
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
}

.masonry-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.15) 70%,
        rgba(0, 0, 0, 0.3) 100%
    );
    display: flex;
    align-items: flex-end;
    padding: 20px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1;
    pointer-events: none; /* Allow clicks to pass through to the link */
}

.case-studies-masonry .case-study-item:hover .masonry-overlay,
.case-studies-masonry .masonry-overlay-link:hover .masonry-overlay {
    opacity: 1;
}

.overlay-content {
    width: 100%;
}

.overlay-title {
    display: none; /* Hide the title since it's in the button now */
}

.overlay-excerpt {
    display: none; /* Hide the excerpt too */
}

.overlay-button {
    display: inline-block;
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    color: #333;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    z-index: 5;
    pointer-events: auto;
}

.case-studies-masonry .case-study-item:hover .overlay-button {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Hover Effects */
.case-studies-masonry[data-hover-effect="fade"] .case-study-item:hover .masonry-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.case-studies-masonry[data-hover-effect="zoom"] .case-study-item:hover .case-study-thumbnail img {
    transform: scale(1.15);
}

.case-studies-masonry[data-hover-effect="slide"] .masonry-overlay {
    transform: translateY(100%);
    opacity: 1;
}

.case-studies-masonry[data-hover-effect="slide"] .case-study-item:hover .masonry-overlay {
    transform: translateY(0);
}

/* Make the button visible on hover */
.masonry-overlay .overlay-button {
    opacity: 1;
    transform: translateY(0);
}

.case-studies-masonry .case-study-item:hover .overlay-button {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* List Layout */
.case-studies-wrapper.case-studies-list .case-study-item {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
}

.case-studies-wrapper.case-studies-list .case-study-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Individual Case Study Items */
.case-study-item {
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.case-study-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.case-studies-list .case-study-item {
    display: flex;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.case-studies-list .case-study-item:hover {
    transform: none;
    box-shadow: none;
}

/* Thumbnail */
.case-study-thumbnail {
    position: relative;
    overflow: hidden;
}

.case-study-thumbnail img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.case-study-thumbnail:hover img {
    transform: scale(1.05);
}

.case-studies-list .case-study-thumbnail {
    flex: 0 0 250px;
    margin-right: 30px;
}

.case-studies-list .case-study-thumbnail img {
    height: 180px;
}

/* Content */
.case-study-content {
    padding: 25px;
}

.case-studies-list .case-study-content {
    flex: 1;
    padding: 0;
}

/* Title */
.case-study-title {
    margin: 0 0 15px 0;
    font-size: 1.4em;
    line-height: 1.3;
}

.case-study-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.case-study-title a:hover {
    color: #0073aa;
}

/* Meta Information */
.case-study-meta {
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #666;
}

.case-study-meta span {
    margin-right: 15px;
}

.case-study-meta span:last-child {
    margin-right: 0;
}

.case-study-date:before {
    content: "📅 ";
    margin-right: 5px;
}

.case-study-author:before {
    content: "👤 ";
    margin-right: 5px;
}

/* Excerpt */
.case-study-excerpt {
    margin-bottom: 20px;
    color: #555;
    line-height: 1.6;
}

/* Categories and Tags */
.case-study-categories,
.case-study-tags {
    margin-bottom: 10px;
    font-size: 0.9em;
}

.case-study-categories .meta-label,
.case-study-tags .meta-label {
    font-weight: bold;
    color: #333;
}

.case-study-categories a,
.case-study-tags a {
    color: #0073aa;
    text-decoration: none;
    transition: color 0.3s ease;
}

.case-study-categories a:hover,
.case-study-tags a:hover {
    color: #005177;
    text-decoration: underline;
}

/* Read More Link */
.case-study-read-more {
    margin-top: 20px;
}

.read-more-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
    font-weight: 500;
}

.read-more-link:hover {
    background-color: #005177;
    color: #fff;
}

/* No Results */
.case-studies-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .case-studies-wrapper.case-studies-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .case-studies-masonry .masonry-small .case-study-thumbnail {
        height: 160px;
    }
    
    .case-studies-masonry .masonry-medium .case-study-thumbnail {
        height: 220px;
    }
    
    .case-studies-masonry .masonry-large .case-study-thumbnail {
        height: 300px;
    }
    
    .overlay-content {
        padding: 15px;
    }
    
    .overlay-title {
        font-size: 1.1em;
    }
    
    .overlay-excerpt {
        font-size: 0.8em;
    }
    
    .case-studies-list .case-study-item {
        flex-direction: column;
    }
    
    .case-studies-list .case-study-thumbnail {
        flex: none;
        margin-right: 0;
        margin-bottom: 20px;
    }
    
    .case-study-content {
        padding: 20px;
    }
    
    .case-studies-list .case-study-content {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .case-studies-masonry .masonry-small .case-study-thumbnail,
    .case-studies-masonry .masonry-medium .case-study-thumbnail,
    .case-studies-masonry .masonry-large .case-study-thumbnail,
    .case-studies-masonry .masonry-auto .case-study-thumbnail {
        height: 180px;
    }
    
    .masonry-overlay {
        padding: 15px;
    }
    
    .overlay-title {
        font-size: 1em;
    }
    
    .case-study-content {
        padding: 15px;
    }
    
    .case-study-title {
        font-size: 1.2em;
    }
    
    .case-study-meta span {
        display: block;
        margin-bottom: 5px;
        margin-right: 0;
    }
}

/* Archive and Single Page Styles */
.post-type-archive-case_study .site-main,
.single-case_study .site-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.case-study-archive-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
    border-bottom: 2px solid #eee;
}

.case-study-archive-title {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #333;
}

.case-study-archive-description {
    font-size: 1.1em;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
}

/* Elementor Compatibility */
.elementor-widget-case-studies .case-studies-wrapper {
    margin: 0;
}

.elementor-widget-case-studies .case-study-item {
    height: 100%;
}

.elementor-widget-case-studies .case-study-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.elementor-widget-case-studies .case-study-read-more {
    margin-top: auto;
}
