
/* -----------------------------
   MODAL OVERLAY
----------------------------- */

.wiki-modal-wrapper {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    padding: var(--behnke-basic);
    box-sizing: border-box;
}

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

/* -----------------------------
   MODAL BOX
----------------------------- */

.wiki-modal {
    position: relative;
    background-color: var(--behnke-white);
    border-radius: var(--behnke-basic);
    padding: calc(2 * var(--behnke-basic));
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
}

/* On mobile, anchor the modal below the wiki header (top) and above the
   floating AX / cookie / scroll-to-top icon column (bottom 20–124px), so
   it never overlaps either.
   100dvh tracks the *visible* viewport on iOS (excludes Safari's dynamic
   address bar / bottom toolbar); env(safe-area-inset-bottom) keeps clear
   of the iPhone home-indicator strip. */
@media (max-width: 700px) {
    .wiki-modal-wrapper {
        align-items: flex-start;
        padding-top:    calc(5 * var(--behnke-basic));
        /* fallback for browsers without env() / very old iOS */
        padding-bottom: 140px;
        padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
        /* Use the dynamic viewport so the wrapper itself doesn't extend
           behind iOS Safari's address bar / bottom toolbar. */
        height:     100vh;       /* fallback */
        height:     100dvh;
        max-height: 100vh;
        max-height: 100dvh;
    }

    .wiki-modal {
        max-height: calc(100vh  - 5 * var(--behnke-basic) - 140px);
        max-height: calc(100dvh - 5 * var(--behnke-basic) - 140px - env(safe-area-inset-bottom, 0px));
    }
}

/* In embed mode the header is hidden — the modal can sit higher again. */
body.wiki-embed .wiki-modal-wrapper {
    align-items: center;
    padding-top: var(--behnke-basic);
}

body.wiki-embed .wiki-modal {
    max-height: 80vh;
}

.wiki-modal-close {
    position: absolute;
    top: calc(0.75 * var(--behnke-basic));
    right: calc(0.75 * var(--behnke-basic));
    background: none;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: #222;
    padding: calc(0.25 * var(--behnke-basic));
}

.wiki-modal-close:hover {
    color: var(--link-color);
}

.wiki-modal-title {
    margin: 0 0 calc(var(--behnke-basic)) 0;
    font-size: var(--behnke-font-size, 1rem);
    font-weight: bold;
    padding-right: calc(2 * var(--behnke-basic));
}

.wiki-modal-body {
    font-size: var(--behnke-smaller-font-size, 0.875rem);
}

/* -----------------------------
   MODAL BODY ELEMENTS
----------------------------- */

.modal-description {
    margin: 0 0 calc(var(--behnke-basic)) 0;
    line-height: 1.5;
}

.modal-note-label {
    margin: 0 0 calc(0.25 * var(--behnke-basic)) 0;
    font-weight: bold;
    color: #c0392b;
}

/* Share URL row */

.modal-url-row {
    display: flex;
    gap: calc(0.5 * var(--behnke-basic));
    margin-bottom: calc(0.75 * var(--behnke-basic));
}

.modal-url-input {
    flex: 1;
    min-width: 0;
    padding: calc(0.4 * var(--behnke-basic)) calc(0.6 * var(--behnke-basic));
    border: 1px solid var(--behnke-light-black);
    border-radius: calc(0.4 * var(--behnke-basic));
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    background: var(--behnke-white);
    color: var(--behnke-light-black);
    cursor: text;
}

/* Buttons */

.modal-btn {
    display: inline-block;
    padding: calc(0.4 * var(--behnke-basic)) calc(0.8 * var(--behnke-basic));
    border: 1px solid var(--link-color);
    border-radius: calc(0.4 * var(--behnke-basic));
    background: none;
    color: var(--link-color);
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.modal-btn:hover {
    background-color: var(--link-color);
    color: var(--behnke-white);
}

.modal-btn--primary {
    margin-top: calc(0.5 * var(--behnke-basic));
}

/* Copy feedback */

.modal-copy-feedback {
    margin: 0;
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    color: var(--link-color);
}

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

.modal-copy-feedback--error {
    color: #c0392b;
}

/* -----------------------------
   REPORT FORM
----------------------------- */

.modal-form {
    display: flex;
    flex-direction: column;
    gap: calc(0.75 * var(--behnke-basic));
}

.modal-form-group {
    display: flex;
    flex-direction: column;
    gap: calc(0.3 * var(--behnke-basic));
}

.modal-form-group--center {
    align-items: center;
    margin-top: calc(0.25 * var(--behnke-basic));
}

.modal-form-group--checkbox {
    flex-direction: row;
    align-items: flex-start;
}

.modal-form-label {
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    font-weight: 600;
}

.modal-form-field,
.modal-form-select,
.modal-form-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: calc(0.4 * var(--behnke-basic)) calc(0.6 * var(--behnke-basic));
    border: 1px solid #ccc;
    border-radius: calc(0.3 * var(--behnke-basic));
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    font-family: inherit;
    background: var(--behnke-white);
    color: inherit;
}

.modal-form-field:focus,
.modal-form-select:focus,
.modal-form-textarea:focus {
    outline: none;
    border-color: var(--link-color);
}

.modal-form-field[readonly] {
    background: #f5f5f5;
    color: #555;
    cursor: default;
}

.modal-form-textarea {
    resize: vertical;
    min-height: 100px;
}

.modal-form-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: calc(0.4 * var(--behnke-basic));
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    cursor: pointer;
}

.modal-form-checkbox-label input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.modal-required {
    color: #c0392b;
    font-weight: bold;
    transition: color 0.2s;
}

.modal-required--ok {
    color: #16a34a;
}

.modal-required-info {
    margin: calc(0.25 * var(--behnke-basic)) 0 0 0;
    font-size: 0.75rem;
    color: #888;
}

/* -----------------------------
   REPORT FORM – VALIDATION STATES
----------------------------- */

.modal-form-field--invalid,
.modal-form-select.modal-form-field--invalid,
.modal-form-textarea.modal-form-field--invalid {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}

.modal-form-field--valid,
.modal-form-select.modal-form-field--valid,
.modal-form-textarea.modal-form-field--valid {
    border-color: #16a34a !important;
    background-color: #f0fdf4 !important;
}

/* Per-field error messages */

.modal-field-error {
    display: none;
    font-size: 0.75rem;
    color: #dc2626;
    margin-top: calc(0.2 * var(--behnke-basic));
}

.modal-field-error:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    animation: modal-err-fade-in 0.15s ease;
}

.modal-field-error:not([hidden])::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    flex-shrink: 0;
}

@keyframes modal-err-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* Privacy policy link */

.modal-privacy-link {
    color: var(--link-color);
    text-decoration: underline;
}

.modal-privacy-link:hover {
    text-decoration: none;
}

/* -----------------------------
   REPORT FORM – STATUS MESSAGES
----------------------------- */

.modal-msg {
    margin-top: calc(0.5 * var(--behnke-basic));
    padding: calc(0.5 * var(--behnke-basic)) calc(0.75 * var(--behnke-basic));
    border-radius: calc(0.3 * var(--behnke-basic));
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    line-height: 1.4;
}

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

.modal-msg--ok {
    background-color: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.modal-msg--error {
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.modal-msg--warning {
    background-color: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}

/* -----------------------------
   SECURITY MODAL
----------------------------- */

.modal-security-section {
    margin-bottom: calc(0.75 * var(--behnke-basic));
}

.modal-security-heading {
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    font-weight: 700;
    margin: 0 0 calc(0.3 * var(--behnke-basic)) 0;
    color: inherit;
}

.modal-security-note {
    margin: 0 0 calc(0.3 * var(--behnke-basic)) 0;
    font-size: var(--behnke-smaller-font-size, 0.875rem);
}

.modal-security-list {
    margin: 0;
    padding-left: calc(1.2 * var(--behnke-basic));
    font-size: var(--behnke-smaller-font-size, 0.875rem);
}

.modal-security-list li {
    margin-bottom: calc(0.2 * var(--behnke-basic));
}

.modal-security-contact {
    display: inline-block;
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    font-weight: 600;
    color: var(--link-color);
    word-break: break-all;
}

.modal-security-responsible {
    margin-top: calc(0.75 * var(--behnke-basic));
    padding: calc(0.5 * var(--behnke-basic)) calc(0.75 * var(--behnke-basic));
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: calc(0.3 * var(--behnke-basic));
    font-size: var(--behnke-smaller-font-size, 0.875rem);
    color: #92400e;
    line-height: 1.5;
}

/* -----------------------------
   BOOKMARKS ("Merkliste")
----------------------------- */

.modal-bm-toggle {
    width: 100%;
    text-align: center;
    margin-bottom: var(--behnke-basic);
}

.modal-bm-toggle.is-on {
    background-color: var(--link-color);
    color: var(--behnke-white);
}

.modal-bm-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: calc(0.25 * var(--behnke-basic));
}

.modal-bm-empty {
    color: #888;
    line-height: 1.5;
    text-align: center;
    padding: var(--behnke-basic) 0;
}

.modal-bm-item {
    display: flex;
    align-items: center;
    gap: calc(0.5 * var(--behnke-basic));
    padding: calc(0.4 * var(--behnke-basic)) calc(0.5 * var(--behnke-basic));
    border: 1px solid var(--behnke-light-gray, #e5e7eb);
    border-radius: calc(0.4 * var(--behnke-basic));
}

.modal-bm-link {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
}

.modal-bm-link:hover { text-decoration: underline; }

.modal-bm-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    line-height: 1;
    padding: calc(0.2 * var(--behnke-basic));
    border-radius: 50%;
}

.modal-bm-remove:hover { color: #dc2626; background: rgba(0, 0, 0, 0.05); }

/* -----------------------------
   BODY SCROLL LOCK
----------------------------- */

body.modal-open {
    overflow: hidden;
}
