/* Portfolio Page Styles */

/* Modal Styles (reused from units.css) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
    /* Prevent touch scrolling on modal */
    touch-action: none;
    -webkit-overflow-scrolling: touch;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    position: relative;
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    transition: transform 0.3s ease;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    /* Ensure image is touch-friendly */
    touch-action: manipulation;
}

.modal.show .modal-content {
    transform: translateY(-50%) scale(1);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    /* Make close button touch-friendly */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.close-modal:hover,
.close-modal:focus {
    color: #fff;
    background-color: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.modal-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: white;
    padding: 20px 0;
    font-size: 18px;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Portfolio Grid Styles */
.portfolio-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: white;
    /* Ensure proper clipping */
    transform: translateZ(0);
    backface-visibility: hidden;
    cursor: pointer;
}

.portfolio-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

.portfolio-item img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    transition: all 0.3s ease;
    border-radius: 12px 12px 0 0;
    /* Ensure image respects container bounds */
    display: block;
    max-width: 100%;
    height: auto;
}

.portfolio-item:hover img {
    /* Removed transform: scale(1.05) to prevent overflow */
}

.portfolio-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.8));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
}

.portfolio-item:hover .portfolio-overlay,
.portfolio-item:active .portfolio-overlay,
.portfolio-item.touch-active .portfolio-overlay {
    opacity: 1;
}

.portfolio-title {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.portfolio-description {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    margin-bottom: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.portfolio-actions {
    display: flex;
    gap: 8px;
}

.portfolio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #374151;
    text-decoration: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    border: none;
    cursor: pointer;
    /* Ensure buttons are touch-friendly */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.portfolio-btn:hover,
.portfolio-btn:active,
.portfolio-btn:focus,
.portfolio-btn.touch-active {
    background: white;
    color: #1d4ed8;
    transform: scale(1.1);
}

.portfolio-btn.view-larger {
    background: rgba(59, 130, 246, 0.9);
    color: white;
}

.portfolio-btn.view-larger:hover,
.portfolio-btn.view-larger:active,
.portfolio-btn.view-larger:focus,
.portfolio-btn.view-larger.touch-active {
    background: #3b82f6;
}

/* Link button specific styles */
.portfolio-btn[href] {
    background: rgba(34, 197, 94, 0.9);
    color: white;
}

.portfolio-btn[href]:hover,
.portfolio-btn[href]:active,
.portfolio-btn[href]:focus,
.portfolio-btn[href].touch-active {
    background: #22c55e;
    transform: scale(1.1);
}

/* Filter Button Styles */
.filter-btn {
    transition: all 0.3s ease;
}

.filter-btn.active {
    background: #2563eb !important;
    color: white !important;
}

/* Portfolio Item Categories */
.portfolio-item[data-category="units"] {
    border-left: 4px solid #3b82f6;
}

.portfolio-item[data-category="tanks"] {
    border-left: 4px solid #10b981;
}

.portfolio-item[data-category="infrastructure"] {
    border-left: 4px solid #f59e0b;
}

/* Animation Classes */
.portfolio-item {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(30px);
}

.portfolio-item:nth-child(1) { animation-delay: 0.1s; }
.portfolio-item:nth-child(2) { animation-delay: 0.2s; }
.portfolio-item:nth-child(3) { animation-delay: 0.3s; }
.portfolio-item:nth-child(4) { animation-delay: 0.4s; }
.portfolio-item:nth-child(5) { animation-delay: 0.5s; }
.portfolio-item:nth-child(6) { animation-delay: 0.6s; }
.portfolio-item:nth-child(7) { animation-delay: 0.7s; }
.portfolio-item:nth-child(8) { animation-delay: 0.8s; }
.portfolio-item:nth-child(9) { animation-delay: 0.9s; }

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

/* Mobile-specific styles for touch devices */
@media (max-width: 768px) {
    .portfolio-item {
        /* Always show overlay on mobile for better UX */
        cursor: pointer;
    }
    
    .portfolio-overlay {
        /* Show overlay by default on mobile */
        opacity: 0.9;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.9));
        /* Ensure overlay is always visible */
        pointer-events: auto;
    }
    
    .portfolio-item:hover .portfolio-overlay {
        opacity: 1;
    }
    
    /* Ensure buttons are always clickable */
    .portfolio-actions {
        pointer-events: auto;
        z-index: 10;
    }
    
    .portfolio-btn {
        pointer-events: auto;
        z-index: 11;
    }
    
    .portfolio-item img {
        height: 240px;
        border-radius: 12px 12px 0 0;
        display: block;
        max-width: 100%;
    }
    
    .portfolio-overlay {
        padding: 16px;
        border-radius: 12px;
    }
    
    .portfolio-title {
        font-size: 1.125rem;
    }
    
    .portfolio-description {
        font-size: 0.8rem;
    }
    
    .portfolio-btn {
        width: 36px;
        height: 36px;
        /* Make buttons more touch-friendly */
        min-width: 44px;
        min-height: 44px;
    }
    
    .close-modal {
        top: 15px;
        right: 20px;
        font-size: 30px;
        width: 40px;
        height: 40px;
    }
    
    .modal-caption {
        font-size: 16px;
        padding: 15px 0;
    }
}

/* Additional mobile-specific styles for very small screens */
@media (max-width: 640px) {
    .portfolio-item img {
        height: 200px;
        border-radius: 12px 12px 0 0;
        display: block;
        max-width: 100%;
    }
    
    .portfolio-overlay {
        padding: 12px;
        border-radius: 12px;
        /* Ensure overlay is visible on small screens */
        opacity: 0.95;
        /* Make sure overlay is always on top */
        z-index: 5;
    }
    
    .portfolio-title {
        font-size: 1rem;
    }
    
    .portfolio-description {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }
    
    .portfolio-actions {
        gap: 6px;
        /* Ensure actions are always clickable */
        position: relative;
        z-index: 10;
    }
    
    .portfolio-btn {
        width: 32px;
        height: 32px;
        /* Ensure touch-friendly size */
        min-width: 44px;
        min-height: 44px;
        /* Ensure buttons are clickable */
        position: relative;
        z-index: 11;
    }
}

/* Touch device specific styles */
@media (hover: none) and (pointer: coarse) {
    .portfolio-overlay {
        /* Always show overlay on touch devices */
        opacity: 0.9 !important;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.9)) !important;
    }
    
    .portfolio-item:hover .portfolio-overlay {
        opacity: 1 !important;
    }
    
    .portfolio-btn {
        /* Ensure buttons are touch-friendly */
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Make link buttons more prominent on touch devices */
    .portfolio-btn[href] {
        background: rgba(34, 197, 94, 0.95) !important;
        color: white !important;
        box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3) !important;
    }
    
    .portfolio-btn[href].touch-active {
        background: #22c55e !important;
        transform: scale(0.95) !important;
        box-shadow: 0 1px 4px rgba(34, 197, 94, 0.5) !important;
    }
}

/* Loading State */
.portfolio-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

.portfolio-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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