/**
 * Flavor Popups - Frontend Styles
 * 
 * CHANGELOG v1.2.0 (22.01.2026):
 * - FIX: Overflow-X aus html/body ENTFERNT (machte Scroll-Probleme)
 * - FIX: Mobile Popup arbeitet jetzt ohne Body-Manipulation
 * - FIX: Close-Button immer sichtbar
 */

/* ==========================================================================
   BASE STYLES
   ========================================================================== */
.flavor-popup {
    --popup-bg: #ffffff;
    --popup-text: #1f2937;
    --popup-title: #111827;
    --popup-btn-bg: #2563eb;
    --popup-btn-text: #ffffff;
    --popup-overlay: #000000;
    --popup-overlay-opacity: 0.5;
    
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.flavor-popup.is-active {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   OVERLAY
   ========================================================================== */
.flavor-popup__overlay {
    position: absolute;
    inset: 0;
    background: var(--popup-overlay);
    opacity: var(--popup-overlay-opacity);
}

/* ==========================================================================
   CONTAINER
   ========================================================================== */
.flavor-popup__container {
    position: relative;
    width: 100%;
    max-height: 90vh;
    overflow: visible; /* WICHTIG: visible damit Close-Button nicht abgeschnitten wird */
    background: var(--popup-bg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Innerer Scroll-Container */
.flavor-popup__content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow-y: auto;
}

/* Size Variants */
.flavor-popup--small .flavor-popup__container {
    max-width: 400px;
}

.flavor-popup--medium .flavor-popup__container {
    max-width: 550px;
}

.flavor-popup--large .flavor-popup__container {
    max-width: 700px;
}

.flavor-popup--fullscreen .flavor-popup__container {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    border-radius: 0 !important;
}

/* Border Radius */
.flavor-popup--radius-none .flavor-popup__container {
    border-radius: 0;
}

.flavor-popup--radius-small .flavor-popup__container {
    border-radius: 8px;
}

.flavor-popup--radius-medium .flavor-popup__container {
    border-radius: 16px;
}

.flavor-popup--radius-large .flavor-popup__container {
    border-radius: 24px;
}

/* Position Variants */
.flavor-popup--top {
    align-items: flex-start;
    padding-top: 40px;
}

.flavor-popup--bottom {
    align-items: flex-end;
    padding-bottom: 40px;
}

.flavor-popup--bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 20px;
}

.flavor-popup--bottom-left {
    align-items: flex-end;
    justify-content: flex-start;
    padding: 20px;
}

.flavor-popup--bottom-right .flavor-popup__container,
.flavor-popup--bottom-left .flavor-popup__container {
    max-width: 400px;
}

/* ==========================================================================
   CLOSE BUTTON - MAXIMAL SICHTBAR
   WICHTIG: Überschreibt aria-hidden Regeln die Button verstecken!
   ========================================================================== */
.flavor-popup__close,
.flavor-popup .flavor-popup__close,
.flavor-popup[aria-hidden] .flavor-popup__close,
.flavor-popup[aria-hidden="true"] .flavor-popup__close,
[aria-hidden="true"] .flavor-popup__close,
.flavor-popup__container .flavor-popup__close {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    z-index: 99999 !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 3px solid #333 !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
    color: #000000 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

.flavor-popup__close:hover {
    background: #f0f0f0 !important;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.flavor-popup__close:active {
    transform: scale(0.95);
    background: #e0e0e0 !important;
}

.flavor-popup__close:focus {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* SVG Icon - auch aria-hidden Override */
.flavor-popup__close svg,
.flavor-popup[aria-hidden] .flavor-popup__close svg,
.flavor-popup[aria-hidden="true"] .flavor-popup__close svg,
[aria-hidden="true"] .flavor-popup__close svg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 22px !important;
    height: 22px !important;
    stroke: #000000 !important;
    stroke-width: 2.5 !important;
}

/* ==========================================================================
   CONTENT
   ========================================================================== */

.flavor-popup__image {
    position: relative;
    overflow: hidden;
}

.flavor-popup__image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: cover;
}

.flavor-popup--radius-small .flavor-popup__image img,
.flavor-popup--radius-medium .flavor-popup__image img,
.flavor-popup--radius-large .flavor-popup__image img {
    border-radius: inherit;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.flavor-popup__body {
    padding: 24px 28px 28px;
    color: var(--popup-text);
}

.flavor-popup__title {
    margin: 0 0 12px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--popup-title);
    font-family: inherit;
}

.flavor-popup__text {
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.6;
}

.flavor-popup__text p {
    margin: 0 0 12px;
}

.flavor-popup__text p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   BUTTON
   ========================================================================== */
.flavor-popup__actions {
    margin-top: 8px;
}

.flavor-popup__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    color: var(--popup-btn-text);
    background: var(--popup-btn-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.flavor-popup__button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1);
    color: var(--popup-btn-text);
    text-decoration: none;
}

.flavor-popup__button:focus {
    outline: 2px solid var(--popup-btn-bg);
    outline-offset: 2px;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

/* Fade */
.flavor-popup--anim-fade .flavor-popup__container {
    transition: opacity 0.3s ease;
}

/* Slide Up */
.flavor-popup--anim-slide-up .flavor-popup__container {
    transform: translateY(30px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.flavor-popup--anim-slide-up.is-active .flavor-popup__container {
    transform: translateY(0);
}

/* Slide Down */
.flavor-popup--anim-slide-down .flavor-popup__container {
    transform: translateY(-30px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.flavor-popup--anim-slide-down.is-active .flavor-popup__container {
    transform: translateY(0);
}

/* Scale */
.flavor-popup--anim-scale .flavor-popup__container {
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.flavor-popup--anim-scale.is-active .flavor-popup__container {
    transform: scale(1);
}

/* ==========================================================================
   MOBILE RESPONSIVE - v1.2
   ========================================================================== */
@media (max-width: 768px) {
    .flavor-popup {
        padding: 10px;
        /* Auf Mobile: Popup scrollt intern, nicht die Seite */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .flavor-popup__container {
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 40px);
        max-height: calc(100dvh - 40px); /* Dynamic viewport für Mobile */
        margin: auto;
    }
    
    .flavor-popup__body {
        padding: 20px;
        padding-top: 70px; /* Mehr Platz für Close-Button */
    }
    
    .flavor-popup__title {
        font-size: 1.25rem;
    }
    
    .flavor-popup__text {
        font-size: 0.9375rem;
    }
    
    .flavor-popup--bottom-right,
    .flavor-popup--bottom-left {
        justify-content: center;
    }
    
    /* MOBILE CLOSE BUTTON - EXTRA GROSS UND DEUTLICH */
    .flavor-popup__close,
    .flavor-popup[aria-hidden] .flavor-popup__close,
    .flavor-popup[aria-hidden="true"] .flavor-popup__close,
    [aria-hidden="true"] .flavor-popup__close {
        top: 12px !important;
        right: 12px !important;
        width: 50px !important;
        height: 50px !important;
        border-width: 3px !important;
        box-shadow: 0 3px 15px rgba(0, 0, 0, 0.4) !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .flavor-popup__close svg,
    .flavor-popup[aria-hidden] .flavor-popup__close svg,
    [aria-hidden="true"] .flavor-popup__close svg {
        width: 28px !important;
        height: 28px !important;
        stroke-width: 3 !important;
        display: block !important;
        visibility: visible !important;
    }
    
    /* Hide on mobile - komplett entfernen */
    .flavor-popup--hide-mobile {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .flavor-popup,
    .flavor-popup__container,
    .flavor-popup__close,
    .flavor-popup__button {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus trap styling */
.flavor-popup:focus {
    outline: none;
}

/* Screen reader only close button text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
