/* ==========================================================
   Roof Area Measurement Modal
   Opens on first focus of #roof_area or via "Wie messe ich?"-Button
   ========================================================== */

.roof-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overscroll-behavior: contain;
}

.roof-modal[hidden] {
    display: none;
}

.roof-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

/* Modal box */
.roof-modal__content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius-large);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2.5rem;
    animation: roofModalIn 0.3s ease;
}

@keyframes roofModalIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Close X button */
.roof-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--text-light);
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.roof-modal__close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-dark);
}

/* Title + intro */
.roof-modal__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 0.5rem;
    padding-right: 2.5rem;
}

.roof-modal__intro {
    color: var(--text-light);
    font-size: 0.95rem;
    margin: 0 0 2rem;
    line-height: 1.5;
}

/* Steps list */
.roof-modal__steps {
    list-style: none;
    counter-reset: roof-step;
    padding: 0;
    margin: 0 0 2rem;
}

.roof-modal__step {
    counter-increment: roof-step;
    margin-bottom: 1.75rem;
    padding-left: 3rem;
    position: relative;
}

.roof-modal__step:last-child {
    margin-bottom: 0;
}

.roof-modal__step::before {
    content: counter(roof-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.roof-modal__step-text strong {
    display: block;
    font-size: 1.05rem;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.roof-modal__step-text p {
    margin: 0;
    color: var(--text-medium);
    font-size: 0.95rem;
    line-height: 1.5;
}

.roof-modal__step-text em {
    color: var(--primary-color);
    font-style: normal;
    font-weight: 600;
}

.roof-modal__step-img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
    margin-top: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Action buttons */
.roof-modal__actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.roof-modal__btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1.5rem;
    min-height: 44px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1 1 auto;
}

.roof-modal__btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 112, 166, 0.3);
    color: white;
    text-decoration: none;
}

.roof-modal__btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1.5rem;
    min-height: 44px;
    background: transparent;
    color: var(--text-medium);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.roof-modal__btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.25);
}

/* "Wie messe ich?" help trigger in label */
.roof-help-trigger {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    margin-left: 0.5rem;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s;
    font-family: inherit;
    vertical-align: middle;
}

.roof-help-trigger:hover {
    color: var(--accent-color);
}

/* Mobile */
@media (max-width: 768px) {
    .roof-modal {
        align-items: flex-start;
        padding: 1rem 0.5rem;   /* einheitlich: oben+unten je 1rem, links+rechts 0.5rem */
    }

    .roof-modal__content {
        padding: 1.5rem;
        /* Nur eigenes Overlay-Padding abziehen (1rem oben + 1rem unten = 2rem).
           Kein CTA-Abzug nötig: Modal z-index 10000 > Sticky-CTA z-index 1000. */
        max-height: calc(100vh - 2rem);
        max-height: calc(100svh - 2rem);
        max-height: calc(100dvh - 2rem);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .roof-modal__title {
        font-size: 1.25rem;
    }

    .roof-modal__step {
        padding-left: 2.75rem;
    }

    .roof-modal__step::before {
        width: 2rem;
        height: 2rem;
        font-size: 0.9rem;
    }

    .roof-modal__actions {
        flex-direction: column;
    }

    .roof-modal__btn-primary,
    .roof-modal__btn-secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .roof-modal {
        padding: 0.5rem;   /* einheitlich: je 0.5rem */
    }

    .roof-modal__content {
        padding: 1.25rem;
        max-height: calc(100vh - 1rem);
        max-height: calc(100svh - 1rem);
        max-height: calc(100dvh - 1rem);
    }

    .roof-modal__step-text strong {
        font-size: 0.95rem;
    }

    .roof-modal__step-text p {
        font-size: 0.88rem;
    }
}
