/**
 * Custom Post Handler - Portfolio Styles
 * Author: Hewa
 * Version: 1.0.0
 */

/* Container */
.cph-portfolio-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

/* Category Tabs */
.cph-tabs-wrapper {
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cph-category-tabs {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 10px;
}

.cph-tab-item {
    margin: 0;
    padding: 0;
}

.cph-tab-link {
    display: inline-block;
    padding: 12px 24px;
    text-decoration: none;
    color: #333333;
    font-size: 16px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.cph-tab-link:hover {
    color: #4AAB3D;
    border-bottom-color: #4AAB3D;
}

.cph-tab-item.active .cph-tab-link {
    color: #4AAB3D;
    border-bottom-color: #4AAB3D;
    font-weight: 600;
}

/* Portfolio Grid - 3 columns on desktop */
.cph-portfolio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 40px;
}

/* Portfolio Item */
.cph-portfolio-item {
    width: 100%;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

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

.cph-portfolio-card {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.cph-portfolio-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(74, 171, 61, 0.25);
}

/* Image Wrapper */
.cph-portfolio-image-wrapper {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4/3;
    background: #f5f5f5;
}

.cph-portfolio-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.cph-portfolio-card:hover .cph-portfolio-image {
    transform: scale(1.1);
}

/* Overlay */
.cph-portfolio-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cph-portfolio-card:hover .cph-portfolio-overlay {
    opacity: 1;
}

.cph-portfolio-link {
    padding: 12px 30px;
    background: #4AAB3D;
    color: #fff !important;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: background 0.3s ease;
}

.cph-portfolio-link:hover {
    background: #3d8f31;
}

/* Content */
.cph-portfolio-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.cph-portfolio-title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.4;
}

.cph-portfolio-title a {
    color: #333333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.cph-portfolio-title a:hover {
    color: #4AAB3D;
}

.cph-portfolio-categories {
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cph-category-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #e8f5e6;
    color: #4AAB3D;
    font-size: 12px;
    border-radius: 20px;
    font-weight: 500;
    border: 1px solid #4AAB3D;
}

.cph-portfolio-excerpt {
    margin-top: auto;
    color: #666666;
    font-size: 14px;
    line-height: 1.6;
}

/* No Posts Message */
.cph-no-posts {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: #666666;
}

/* Loading Indicator */
.cph-loading {
    text-align: center;
    padding: 40px 20px;
}

.cph-loader {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 5px solid rgba(74, 171, 61, 0.1);
    border-top-color: #4AAB3D;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Load More Trigger */
.cph-load-more-trigger {
    height: 1px;
    width: 100%;
    margin-top: 20px;
}

/* Tablet - 2 columns */
@media screen and (max-width: 1024px) {
    .cph-portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }
    
    .cph-tabs-wrapper {
        margin-bottom: 25px;
    }
    
    .cph-tab-link {
        padding: 10px 20px;
        font-size: 15px;
    }
}

/* Mobile - 1 column */
@media screen and (max-width: 768px) {
    .cph-portfolio-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .cph-portfolio-container {
        padding: 15px 0;
    }
    
    .cph-tabs-wrapper {
        margin-bottom: 20px;
    }
    
    .cph-category-tabs {
        gap: 5px;
    }
    
    .cph-tab-link {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .cph-portfolio-title {
        font-size: 18px;
    }
    
    .cph-portfolio-content {
        padding: 15px;
    }
}

/* Small Mobile */
@media screen and (max-width: 480px) {
    .cph-tab-link {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .cph-portfolio-link {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Elementor Compatibility */
.elementor-widget-shortcode .cph-portfolio-container {
    max-width: 100%;
}

/* RTL Support */
[dir="rtl"] .cph-category-tabs {
    direction: rtl;
}

[dir="rtl"] .cph-portfolio-categories {
    direction: rtl;
}
