/* Project Modal Styles */
.project-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.project-modal {
    background: #fff;
    border-radius: 8px;
    max-width: 600px;
    width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    position: relative;
    animation: fadeInModal 0.3s;
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: #333;
    cursor: pointer;
}

.modal-carousel {
    position: relative;
    margin-bottom: 1rem;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.carousel-img {
    display: none;
    max-width: 420px;
    width: 100%;
    max-height: 380px;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    object-fit: contain;
}

.carousel-img.active {
    display: block;
}

.carousel-prev, .carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #eee;
    border: none;
    font-size: 1.5rem;
    padding: 0.5em 0.8em;
    border-radius: 50%;
    cursor: pointer;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }

.modal-info h2 {
    margin-top: 0;
    font-size: 1.5rem;
    color: #222;
}

.modal-info p {
    margin: 0.3em 0;
    color: #444;
}

/* Actions */
.modal-actions {
    display: flex;
    justify-content: center;
    align-items: center;            /* fixes the "Return sits slightly higher" */
    gap: 0;
    margin-top: 2em;
    position: relative;
    min-height: 60px;
    overflow: hidden;
}

/* Shared baseline for both buttons */
.modal-contact,
.modal-actions .modal-return {
    font-size: 1rem !important;
    height: 44px !important;
    padding: 0 18px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    border: none !important;
    outline: none !important;
    line-height: 1 !important;
    font-weight: 600 !important;
    box-sizing: border-box !important;
    text-align: center !important;
    white-space: nowrap !important;
    text-decoration: none !important;
}

/* Contact button stays centered */
.modal-contact {
    background: #c1272d !important;
    color: #fff !important;
    margin: 0 auto !important;
}

.modal-contact:hover,
.modal-contact:focus {
    background: #9a1f24 !important;
    color: #fff !important;
}

/* Return button on right, same line */
.modal-actions .modal-return {
    background: #111 !important;
    color: #fff !important;
    cursor: pointer !important;
    margin-left: auto !important;   /* pushes it to the right */
    margin-right: 18px !important;
}

.modal-actions .modal-return:hover,
.modal-actions .modal-return:focus {
    background: #333 !important;
    color: #fff !important;
}

/* THE "STOP TELEPORTING" RULE:
   If Return is being absolutely positioned by other CSS, this cancels it. */
.project-modal .modal-return,
.project-modal a.modal-return,
.project-modal button.modal-return {
    position: static !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    inset: auto !important;
}

/* Close button overrides */
.modal-close {
    position: absolute !important;
    top: 0.5rem !important;
    right: 0.5rem !important;
    z-index: 10001 !important;
    background: none !important;
    border: none !important;
    font-size: 2.2rem !important;
    color: #333 !important;
    cursor: pointer !important;
}

@media (max-width: 600px) {
    .project-modal {
        max-width: 98vw;
        padding: 0.5rem 0.2rem 1rem 0.2rem;
        margin: 0 auto;
        position: relative;
    }

    .modal-actions {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        margin-top: 1.5em !important;
        padding: 0 0.5rem !important;
        box-sizing: border-box !important;
        position: static !important;
        min-height: unset !important;
        overflow: visible !important;
        z-index: 1 !important;
    }

    .modal-contact,
    .modal-actions .modal-return {
        width: 48% !important;
        min-width: 100px !important;
        margin: 0 !important;
        padding: 0 12px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
        text-decoration: none !important;
        position: static !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        inset: auto !important;
    }

    .modal-contact {
        background: #c1272d !important;
        color: #fff !important;
    }

    .modal-actions .modal-return {
        background: #111 !important;
        color: #fff !important;
    }

    .modal-close {
        position: absolute !important;
        top: 0.5rem !important;
        right: 0.5rem !important;
        z-index: 10001 !important;
        background: none !important;
        border: none !important;
        font-size: 2.2rem !important;
        color: #333 !important;
        cursor: pointer !important;
    }
}
/* Image stage always reserves space */
.modal-carousel {
    position: relative;
    width: 100%;
    min-height: 380px;            /* 👈 match your max image height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Real images still behave normally */
.carousel-img {
    max-height: 380px;
    width: 100%;
    object-fit: contain;
}

/* Placeholder when no image exists */
.modal-carousel .no-image {
    width: 100%;
    height: 380px;               /* same as image height */
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f4;
    color: #666;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px #ddd;
    text-align: center;
}

/* Arrows stay vertically centered no matter what */
.carousel-prev,
.carousel-next {
    top: 50%;
    transform: translateY(-50%);
}

/* Gallery Overlay - always visible */
.gallery-overlay {
    background: rgba(30,30,30,0.55);
    color: #fff;
    padding: 1em;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    transition: transform 0.2s, background 0.2s;
    z-index: 2;
    font-size: 1em;
    display: block;
}
.gallery-item:hover .gallery-overlay,
.gallery-item:focus .gallery-overlay {
    transform: translateY(-12px);
    background: rgba(30,30,30,0.7);
}
.gallery-hover-text {
    display: none;
    text-align: center;
    font-size: 0.9em;
    margin-top: 0.5em;
    opacity: 0.95;
}
.gallery-item:hover .gallery-hover-text,
.gallery-item:focus .gallery-hover-text {
    display: block;
}
