/* ==========================================================================
   Main Sidebar and Sticky Element Styles
   ========================================================================== */

div.sidebar-wrapper {
    pointer-events: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    right: MIN(1%, 20px);
    z-index: 99;
}

div.sidebar-wrapper.modal-open {
    z-index: 9998;
}

aside.sidebar.fixed {
    pointer-events: auto;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 400;
    background: none;
    border: none;
    transition: opacity .3s ease;
}

@media ((max-width: 640px) and (max-height: 700px)) {
    aside.sidebar.fixed {
        bottom: 10%;
        transform: none;
    }
}

aside.sidebar.fixed .stickyElement {
    bottom: 0;
    position: absolute;
    right: 100%;
    transform: translateY(50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 17px 12px 21px 12px;
    transition-property: all;
    transition-timing-function: cubic-bezier(.4, 0, .2, 1);
    transition-duration: .3s;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(12, 12, 12, 0.20);
    box-shadow: 0 0 50px 0 rgba(255, 207, 139, 0.15);
}

aside.sidebar.fixed .stickyElement .head {
    display: flex;
    gap: 24px;
    padding: 6px;
    transition: var(--baseTransition);
}

aside.sidebar.fixed .stickyElement .head .image {
    overflow: hidden;
    width: 31px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: rotate(45deg);
    border: 1px solid #9C7E3D;
}

aside.sidebar.fixed .stickyElement .head .image img {
    width: 40px;
    height: 40px;
    transform: rotate(-45deg);
    object-fit: cover;
}

aside.sidebar.fixed .stickyElement .head .title {
    font-size: 15px;
    font-weight: 400;
    color: var(--themeFontColor);
    line-height: normal;
}

aside.sidebar.fixed .stickyElement .head .title.hidden {
    display: none;
}

aside.sidebar.fixed .stickyElement .options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* @media ((max-width: 640px) and (max-height: 700px)) {
    aside.sidebar.fixed .stickyElement .options:not(.no-hs) {
        display: none;
    }
} */

aside.sidebar.fixed .stickyElement .options .option {
    align-items: center;
    display: flex;
    gap: 12px;
}

aside.sidebar.fixed .stickyElement .options .option.wysiwyg {
    min-width: 300px;
    display: block;
    padding: 15px;
}

aside.sidebar.fixed .stickyElement .options .option:last-child {
    margin-bottom: 5px;
}

aside.sidebar.fixed .stickyElement .options .option>a {
    transition: color .3s ease-in-out;
    font-size: 15px;
    font-weight: 400;
    line-height: normal;
    color: var(--themeFontColor);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}

aside.sidebar.fixed .stickyElement .options .option>a:hover {
    color: var(--main-color);
}

aside.sidebar.fixed .stickyElement .options .option>a:hover .icon img {
    filter: drop-shadow(0px 0px 3px var(--mainColor, #000));
}

aside.sidebar.fixed .stickyElement .options .option .icon {
    padding: 0 12px;
    display: flex;
}

aside.sidebar.fixed .stickyElement .options .option .icon img {
    width: 25px;
    max-height: 25px;
    object-fit: contain;
}

aside.sidebar.fixed .stickyElement .options .option .link.hidden {
    display: none;
}

aside.sidebar.fixed .stickyElement .options .option.divider hr {
    margin: 0;
    background: rgba(255, 255, 255, 0.07);
    width: 100%;
}

aside.sidebar.fixed .stickyElement .options .option.hidden {
    display: none;
}

/* Hover and Focus States */

aside.sidebar.fixed:hover .stickyElement,
aside.sidebar.fixed:focus .stickyElement,
aside.sidebar.fixed:focus-within .stickyElement {
    padding: 16px 24px 21px 22px;
    background: rgba(12, 12, 12, 0.5);
    backdrop-filter: blur(5px);
}

aside.sidebar.fixed:hover .stickyElement,
aside.sidebar.fixed:focus .stickyElement,
aside.sidebar.fixed:focus-within .stickyElement {
    align-items: start;
    gap: 16px;
}

aside.sidebar.fixed:hover .stickyElement .head,
aside.sidebar.fixed:focus .stickyElement .head,
aside.sidebar.fixed:focus-within .stickyElement .head {
    padding: 6px 0 6px 6px;
}

aside.sidebar.fixed:hover .stickyElement .head .image,
aside.sidebar.fixed:focus .stickyElement .head .image,
aside.sidebar.fixed:focus-within .stickyElement .head .image {
    width: 41px;
    height: 40px;
}

aside.sidebar.fixed:hover .stickyElement .head .image img,
aside.sidebar.fixed:focus .stickyElement .head .image img,
aside.sidebar.fixed:focus-within .stickyElement .head .image img {
    width: 50px;
    height: 50px;
}

aside.sidebar.fixed:hover .stickyElement .title.hidden,
aside.sidebar.fixed:focus .stickyElement .title.hidden,
aside.sidebar.fixed:focus-within .stickyElement .title.hidden,
aside.sidebar.fixed:hover .stickyElement .options .option.hidden,
aside.sidebar.fixed:focus .stickyElement .options .option.hidden,
aside.sidebar.fixed:focus-within .stickyElement .options .option.hidden,
aside.sidebar.fixed:hover .stickyElement .options .link.hidden,
aside.sidebar.fixed:focus .stickyElement .options .link.hidden,
aside.sidebar.fixed:focus-within .stickyElement .options .link.hidden {
    display: flex;
    align-items: center;
}

aside.sidebar.fixed:hover .stickyElement .options,
aside.sidebar.fixed:focus .stickyElement .options,
aside.sidebar.fixed:focus-within .stickyElement .options {
    gap: 16px;
}

aside.sidebar.fixed:hover .stickyElement .options .option,
aside.sidebar.fixed:focus .stickyElement .options .option,
aside.sidebar.fixed:focus-within .stickyElement .options .option {
    margin-top: 4px;
}


aside.sidebar.fixed:hover .stickyElement .options .option.hidden.wysiwyg,
aside.sidebar.fixed:focus .stickyElement .options .option.hidden.wysiwyg,
aside.sidebar.fixed:focus-within .stickyElement .options .option.hidden.wysiwyg {
    display: block;
}

@media only screen and (max-width: 768px) {

    /* aside.sidebar.fixed {
        right: 0;
        top: auto;
        bottom: 20%;
    } */
    aside.sidebar.fixed {
        top: auto;
        bottom: 35%;
    }

    aside.sidebar.fixed .stickyElement {
        padding: 0;
        border-width: 0;
        background: transparent;
        box-shadow: none;
    }

    aside.sidebar.fixed .stickyElement .head .image,
    aside.sidebar.fixed .stickyElement .head .image,
    aside.sidebar.fixed .stickyElement .head .image {
        width: 41px;
        height: 40px;
    }

    aside.sidebar.fixed .stickyElement .head .image img,
    aside.sidebar.fixed .stickyElement .head .image img,
    aside.sidebar.fixed .stickyElement .head .image img {
        width: 55px;
        height: 55px;
    }

    aside.sidebar.fixed .stickyElement .options {
        display: none;
        pointer-events: none;
    }

    aside.sidebar.fixed .stickyElement .options .option {
        pointer-events: auto;
    }

    aside.sidebar.fixed:hover .stickyElement,
    aside.sidebar.fixed:focus .stickyElement,
    aside.sidebar.fixed:focus-within .stickyElement {
        padding: 20px;
        background: rgba(12, 12, 12, 0.85);
        box-shadow: 0 0 50px 0 rgba(255, 207, 139, 0.15);
        border-width: 1px;
    }

    aside.sidebar.fixed:hover .stickyElement .options,
    aside.sidebar.fixed:focus .stickyElement .options,
    aside.sidebar.fixed:focus-within .stickyElement .options {
        display: flex;
    }

    aside.sidebar.fixed .stickyElement .head .title.hidden p,
    aside.sidebar.fixed .stickyElement .options .option .link.hidden {
        font-size: 16px;
    }
}

/* Scroll-Hide Behavior */

div.sidebar-wrapper.scroll-hide:not(.modal-open) aside.sidebar.fixed:not(:hover):not(:focus):not(:focus-within) .stickyElement {
    transform: translateY(50%) translateX(calc(98% + 10px));
}

/* ==========================================================================
   Header-Modus: Icon im Header + Modal-Darstellung
   ========================================================================== */

/* Header-Trigger (Icon im Header) - bis zur Einhängung versteckt (gegen FOUC) */
.ssn-header-trigger {
    width: 40px;
    height: 40px;
    padding: 6px;
    border: 1px solid #fffc;
    background-color: white;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: -4px 4px 12px rgba(0, 0, 0, .1);
    transition: box-shadow .2s ease, outline-offset .15s ease;
}

.ssn-header-trigger:focus {
    outline: none;
}

.ssn-header-trigger:focus-visible {
    outline: 3px solid var(--mainColor, #2271b1);
    outline-offset: 3px;
}

.ssn-header-trigger img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ssn-header-trigger:hover {
    box-shadow: -4px 4px 16px rgba(0, 0, 0, .18);
}

/* Header-Modus greift nur auf mobilen Geräten (Theme-Breakpoint: 1200px) */
@media (max-width: 1200px) {

    /* Variante 1: Icon ist im Header eingehängt (vor #site-navigation) */
    .ssn-header-trigger.in-header {
        display: flex;
        position: relative;
        margin-left: auto;
        align-self: center;
        flex-shrink: 0;
        pointer-events: auto;
    }

    /* Variante 2: Fallback - kein #site-navigation gefunden, fixiert oben rechts */
    .ssn-header-trigger.floating {
        display: flex;
        position: fixed;
        top: 15px;
        right: 15px;
        width: 48px;
        height: 48px;
        padding: 8px;
        z-index: 9997;
        pointer-events: auto;
    }

    /* Im Header-Modus: seitliche Sticky Nav komplett ausblenden (außer im Modal) */
    div.sidebar-wrapper.has-header-mode:not(.modal-open) aside.sidebar.fixed {
        display: none;
    }
}

/* Modal-Backdrop */
.ssn-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, .45);
    z-index: 9996;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}

div.sidebar-wrapper.modal-open .ssn-modal-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* Schließen-Button (X) */
.ssn-modal-close {
    pointer-events: auto;
    position: fixed;
    top: 15px;
    right: 15px;
    width: 48px;
    height: 48px;
    border: 1px solid #fffc;
    background-color: white;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: #333;
    box-shadow: -4px 4px 12px rgba(0, 0, 0, .1);
    transition: box-shadow .2s ease;
}

.ssn-modal-close span {
    display: block;
    margin-top: -3px;
}

.ssn-modal-close:hover {
    box-shadow: -4px 4px 16px rgba(0, 0, 0, .18);
}

.ssn-modal-close:focus {
    outline: none;
}

.ssn-modal-close:focus-visible {
    outline: 3px solid var(--mainColor, #2271b1);
    outline-offset: 3px;
}

/* Fokus-Stil für Links im Modal/Sticky Element */
div.sidebar-wrapper aside.sidebar.fixed .stickyElement a:focus {
    outline: none;
}

div.sidebar-wrapper aside.sidebar.fixed .stickyElement a:focus-visible {
    outline: 2px solid var(--mainColor, #2271b1);
    outline-offset: 3px;
    border-radius: 4px;
}

div.sidebar-wrapper.modal-open .ssn-modal-close {
    display: flex;
}

/* Modal-Darstellung der stickyElement */
div.sidebar-wrapper.modal-open aside.sidebar.fixed {
    pointer-events: auto;
    opacity: 1;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: none;
    z-index: 9998;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 80px 15px 15px 15px;
}

div.sidebar-wrapper.modal-open aside.sidebar.fixed .stickyElement {
    position: relative;
    right: auto;
    bottom: auto;
    transform: none;
    border-radius: 20px;
    padding: 24px;
    max-width: 360px;
    width: auto;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    animation: ssnModalIn .3s cubic-bezier(.4, 0, .2, 1);
}

/* Versteckte Elemente im Modal vollständig anzeigen */
div.sidebar-wrapper.modal-open .stickyElement .head .title.hidden,
div.sidebar-wrapper.modal-open .stickyElement .options .option.hidden,
div.sidebar-wrapper.modal-open .stickyElement .options .option .link.hidden {
    display: flex;
    align-items: center;
}

div.sidebar-wrapper.modal-open .stickyElement .options .option.wysiwyg.hidden {
    display: block;
}

div.sidebar-wrapper.modal-open .stickyElement .options {
    display: flex;
}

@keyframes ssnModalIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile: Modal als Slide-Down von oben, volle Breite */
@media (max-width: 640px) {
    div.sidebar-wrapper.modal-open aside.sidebar.fixed {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
    }

    div.sidebar-wrapper.modal-open aside.sidebar.fixed .stickyElement {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        border-radius: 0 0 24px 24px;
        padding: 70px 20px 24px 20px;
        animation: ssnModalSlideDown .35s cubic-bezier(.4, 0, .2, 1);
    }

    @keyframes ssnModalSlideDown {
        from {
            opacity: 0;
            transform: translateY(-100%);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}