/* Tablet and down: keep the modal inside the viewport and relax the side-by-side layout. */
@media (max-width: 1024px) {
    #detailsModal {
        width: min(92vw, 56rem);
        max-height: min(88vh, 52rem);
        padding: 1.5rem;
    }

    .details-modal-content {
        gap: 1rem;
    }

    .details-modal-image {
        flex: 0 1 18rem;
        max-width: 18rem;
        width: 100%;
        margin: 0 auto;
    }

    .details-modal-image img {
        width: 100%;
        max-width: 100%;
        max-height: 22rem;
        object-fit: contain;
    }

    #forfaits-modal h2,
    #detailsModal h2,
    #detailsModal h4 {
        font-size: clamp(1.35rem, 2.6vw, 1.85rem);
    }

    #forfaits-modal p,
    #detailsModal #forfait-classique li,
    #detailsModal #forfait-univers li,
    #detailsModal #forfait-guilde li {
        font-size: clamp(1rem, 1.8vw, 1.15rem);
    }
}

/* Phone: stack the modal content and make the modal behave like a centered sheet. */
@media (max-width: 767px) {
    #detailsModal {
        top: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        left: 0.75rem;
        transform: none;
        width: auto;
        height: auto;
        max-width: none;
        max-height: none;
        padding: 1rem;
        border-radius: 12px;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .details-modal-content {
        flex-direction: column;
        align-items: stretch;
        min-height: max-content;
    }

    .details-modal-image {
        flex: none;
        max-width: min(100%, 18rem);
        margin: 0 auto;
    }

    .details-modal-image img {
        max-height: 15rem;
    }

    .details-modal-main {
        width: 100%;
        margin-top: 0;
        margin-bottom: 0;
        overflow: visible;
    }

    .details-modal-main ul,
    .details-modal-main ol {
        padding-left: 1.1rem;
    }

    #forfaits-modal h2,
    #detailsModal h2,
    #detailsModal h4 {
        margin-bottom: 0.9rem;
    }

    #forfaits-modal p {
        font-size: 1rem;
        margin-bottom: 0.85rem;
    }

    #detailsModal #forfait-classique li,
    #detailsModal #forfait-univers li,
    #detailsModal #forfait-guilde li {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .details-modal-main .button-style,
    .button-style,
    .open-details-btn .button-style {
        width: min(100%, 20rem);
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }
}

/* Small phones: trim spacing once more so long copy still fits comfortably. */
@media (max-width: 479px) {
    #detailsModal {
        top: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
        left: 0.5rem;
        padding: 0.85rem;
    }

    .details-modal-content {
        gap: 0.85rem;
    }

    .details-modal-image {
        max-width: min(100%, 14rem);
    }

    .details-modal-image img {
        max-height: 12rem;
    }

    .details-modal-main ul,
    .details-modal-main ol {
        padding-left: 1rem;
    }

    #forfaits-modal h2,
    #detailsModal h2,
    #detailsModal h4 {
        font-size: clamp(1.2rem, 5vw, 1.5rem);
    }
}
