/* Tablet and down: reduce the modal chrome so the document body keeps room to breathe. */
@media (max-width: 1024px) {
    #terms-modal {
        width: min(94vw, 64rem);
        height: min(88vh, 54rem);
        max-height: min(88vh, 54rem);
    }

    .termsModal header {
        width: calc(100% - 1rem);
        grid-template-columns: minmax(6.5rem, 1fr) auto minmax(6.5rem, 1fr);
        padding: 0.9rem 1rem 1.2rem;
        height: auto;
        min-height: 5.5rem;
    }

    .termsModal header h1 {
        font-size: clamp(1.45rem, 3vw, 1.9rem);
    }

    .terms-type {
        padding: 1rem 1.25rem 1.5rem;
    }

    .termsModal h2 {
        font-size: clamp(1.45rem, 3vw, 1.85rem);
    }

    .termsModal h3,
    .termsModal h4,
    .termsModal p {
        font-size: clamp(1rem, 1.8vw, 1.15rem);
    }
}

/* Phone: let the modal fill the screen more naturally and simplify the sticky header. */
@media (max-width: 767px) {
    #terms-modal {
        width: calc(100vw - 1rem);
        height: calc(100vh - 1rem);
        max-height: calc(100vh - 1rem);
        border-radius: 12px;
    }

    .termsModal header {
        width: calc(100% - 0.5rem);
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 0.7rem;
        padding: 0.85rem 0.75rem 1rem;
        min-height: 0;
    }

    .termsModal .terms-left,
    .termsModal .terms-center,
    .termsModal .terms-right {
        min-width: 0;
        width: 100%;
        justify-content: center;
        justify-self: center;
        align-self: center;
    }

    .termsModal .terms-left {
        order: 2;
    }

    .termsModal .terms-center {
        order: 1;
    }

    .termsModal .terms-right {
        display: none;
    }

    .close-terms-modal.button-style {
        width: min(100%, 18rem);
    }

    .terms-type {
        padding: 0.9rem 0.85rem 1.25rem;
    }

    .termsModal h1 {
        margin-bottom: 0.75rem;
        font-size: clamp(1.2rem, 5.5vw, 1.55rem);
    }

    .termsModal h2 {
        font-size: clamp(1.2rem, 5vw, 1.5rem);
        margin-bottom: 0.75rem;
    }

    .termsModal h3 {
        font-size: 1.05rem;
        margin-bottom: 0.75rem;
    }

    .termsModal h4,
    .termsModal p {
        font-size: 0.98rem;
        margin-bottom: 0.85rem;
    }

    .terms-content > .cgu-content,
    .terms-content > .cgv-content,
    .terms-content > .politique-content,
    .terms-content > .mentions-content,
    .terms-inline-docs > .cgu-content,
    .terms-inline-docs > .cgv-content,
    .terms-inline-docs > .politique-content,
    .terms-inline-docs > .mentions-content {
        padding: 1rem 0.75rem;
    }
}

/* Small phones: one more reduction for long legal text. */
@media (max-width: 479px) {
    #terms-modal {
        width: calc(100vw - 0.5rem);
        height: calc(100vh - 0.5rem);
        max-height: calc(100vh - 0.5rem);
    }

    .terms-type {
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }

    .termsModal h4,
    .termsModal p {
        font-size: 0.94rem;
    }
}
