/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.98);
    z-index: 2000;
    overflow-y: auto;
    padding: 40px;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: 30px;
    right: 40px;
    font-size: 2rem;
    cursor: pointer;
    background: none;
    border: none;
    z-index: 2001;
    transition: transform 0.1s ease-out;
}

.modal-close:active {
    transform: scale(0.9);
}

.modal-content {
    width: 100%;
    max-width: 1200px;
    display: flex;
    gap: 40px;
    background: white;
}

/* Vertical Layout: Image Left, Text Right */
.modal-content.vertical {
    flex-direction: row;
    align-items: flex-start;
}

.modal-content.vertical .modal-image-container {
    flex: 1;
    max-height: 80vh;
}

.modal-content.vertical .modal-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-height: 80vh;
}

.modal-content.vertical .modal-info {
    flex: 1;
    padding-top: 20px;
}

/* Horizontal Layout: Image Top, Text Bottom */
.modal-content.horizontal {
    flex-direction: column;
}

.modal-content.horizontal .modal-image-container {
    width: 100%;
    max-height: 70vh;
    display: flex;
    justify-content: center;
}

.modal-content.horizontal .modal-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-content.horizontal .modal-info {
    width: 100%;
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
}

.modal-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.modal-description {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #555;
}

.modal-description p {
    white-space: pre-line;
}

@media (min-width: 769px) {
    .modal {
        overflow: hidden; /* Disable modal wrapper scroll */
    }

    .modal-content {
        max-height: 90vh; /* Constrain modal height */
        overflow: hidden; /* Prevent content overflow */
        padding-right: 0; /* Adjust padding if needed */
    }

    /* Vertical Layout Adjustments */
    .modal-content.vertical {
        align-items: stretch;
    }

    .modal-content.vertical .modal-image-container {
        display: flex;
        align-items: center;
        justify-content: center;
        height: auto;
        max-height: none; /* Override base CSS */
    }

    .modal-content.vertical .modal-image-container img {
        max-height: 100%;
        width: auto;
        max-width: 100%;
    }

    .modal-content.vertical .modal-info {
        display: flex;
        flex-direction: column;
        max-height: 100%;
        overflow: hidden;
        padding-top: 0;
    }

    /* Horizontal Layout Adjustments */
    .modal-content.horizontal .modal-image-container {
        flex-shrink: 0; /* Prevent image from shrinking */
    }

    .modal-content.horizontal .modal-info {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
        flex: 1;
    }

    /* Common for both layouts: Fixed Title, Scrollable Description */
    .modal-title {
        flex-shrink: 0;
        margin-top: 0;
        padding-right: 20px; /* Avoid overlap with close button if close */
    }

    .modal-description {
        overflow-y: auto;
        flex-grow: 1;
        padding-right: 15px; /* Space for scrollbar */
    }

    /* Custom Scrollbar */
    .modal-description::-webkit-scrollbar {
        width: 6px;
    }

    .modal-description::-webkit-scrollbar-track {
        background: transparent;
    }

    .modal-description::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
    }

    .modal-description::-webkit-scrollbar-thumb:hover {
        background-color: rgba(0, 0, 0, 0.4);
    }
}
