/* Modal Scrolling Fix for Project/Case Study Modals */
/* This fixes the issue where case study content is not scrollable to the end */

/* Fix for all modal content containers */
.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--card-bg, white);
    border-radius: 12px;
    overflow-y: auto !important; /* CRITICAL: Allow scrolling */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    /* Ensure smooth scrolling */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Ensure modal body/info can also scroll */
.modal-info,
.modal-body,
.case-study-modal .modal-content,
.project-modal .modal-content {
    overflow-y: auto !important;
    max-height: 100%;
}

/* Fix for case study modal specifically */
.case-study-modal .modal-content {
    max-height: 90vh;
    overflow-y: auto !important;
}

/* Ensure modal body sections can scroll */
.case-study-section,
.modal-body > div,
.results-grid,
.case-study-tech {
    flex-shrink: 0; /* Don't compress content */
}

/* Make sure text content wraps properly */
.case-study-modal .modal-body p,
.case-study-modal .modal-body ul,
.case-study-modal .modal-body li {
    max-width: 100%;
    word-wrap: break-word;
}

/* Ensure scrollbar is visible and styled */
.modal-content::-webkit-scrollbar {
    width: 10px;
}

.modal-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* For Firefox */
.modal-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.1);
}

/* Ensure modal image doesn't block scrolling */
.modal-image {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    display: block;
    flex-shrink: 0; /* Don't shrink image */
}

/* Modal info section should be scrollable */
.modal-info {
    padding: 1.5rem;
    background: var(--card-bg, white);
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* Allow flex item to shrink */
}

/* Dark mode support */
body.dark-mode .modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
}

body.dark-mode .modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .modal-content {
        max-height: 85vh;
        width: 95vw;
    }
    
    .modal-image {
        max-height: 50vh;
    }
    
    .modal-info {
        padding: 1rem;
    }
}

/* Ensure content is fully scrollable on both modes */
html body .modal-content {
    overflow-y: auto !important;
}

html body .case-study-modal .modal-content,
html body .project-modal .modal-content {
    overflow-y: auto !important;
    max-height: 90vh !important;
}
