/**
 * MLP Videoplayer Widget Styles
 *
 * Styles for the MLP Videoplayer Elementor Widget
 * Supports video embeds (YouTube, Vimeo, self-hosted) and images
 *
 * @package LandingPageAI_Child
 * @since 1.0.0
 */

/* ==========================================================================
   Container Styles
   ========================================================================== */

.mlp-videoplayer {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Verhindert dass Elementor Flex-Layouts den Videoplayer zusammenstauchen */
    flex-shrink: 0;
    /* Erlaubt Grid-Items unter ihre Content-Groesse zu schrumpfen (CSS Grid Gotcha) */
    min-width: 0;
    /* overflow:hidden entfernt — schneidet Box-Shadow auf .mlp-video-wrapper ab.
       .mlp-video-wrapper hat eigenes overflow:hidden fuer iframe/video Clipping. */
}

/* ==========================================================================
   Video Wrapper
   ========================================================================== */

.mlp-video-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    /* Sicherstellen dass aspect-ratio in Flex-Layouts korrekt berechnet wird */
    flex-shrink: 0;
    /* Grid-Kompatibilitaet: verhindert dass aspect-ratio den Grid-Track sprengt */
    min-width: 0;
}

/* position:absolute entfernt - kollidiert mit aspect-ratio auf dem Wrapper.
   Der Container nutzt aspect-ratio (inline-style), iframes/videos fuellen ihn mit width/height: 100%.
   Siehe auch: css/video-page-widget.css fuer das gleiche Pattern. */
.mlp-video-wrapper iframe,
.mlp-video-wrapper video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* ==========================================================================
   Image Wrapper
   ========================================================================== */

.mlp-image-wrapper {
    position: relative;
    overflow: hidden;
}

.mlp-image-wrapper img,
.mlp-videoplayer-image {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   Elementor Grid Container Fix
   Elementor's frontend.js setzt nachtraeglich display:flex inline auf .e-con-inner,
   was das CSS-Grid ueberschreibt. Dieser Fix stellt sicher, dass .e-grid Container
   korrekt als Grid gerendert werden.
   ========================================================================== */

.e-grid > .e-con-inner {
    display: grid !important;
    grid-template-columns: var(--e-con-grid-template-columns, repeat(1, 1fr));
    grid-template-rows: var(--e-con-grid-template-rows, auto);
    gap: var(--gap, 20px);
    grid-auto-flow: var(--grid-auto-flow, row);
}

/* Mobile: Grid auf 1 Spalte */
@media (max-width: 767px) {
    .e-grid > .e-con-inner {
        grid-template-columns: var(--e-con-grid-template-columns, repeat(1, 1fr));
    }
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .mlp-videoplayer {
        max-width: 100%;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .mlp-videoplayer {
        max-width: 100%;
        margin: 0 auto;
    }

    /* Video-Wrapper mobil nie über Container hinaus */
    .mlp-video-wrapper {
        max-width: 100%;
    }

    .mlp-video-wrapper iframe,
    .mlp-video-wrapper video {
        max-width: 100%;
    }
}

/* ==========================================================================
   Elementor Editor Specific
   ========================================================================== */

.elementor-editor-active .mlp-videoplayer-widget {
    /* Ensure widget is always visible in editor */
    min-height: 50px;
}

.elementor-editor-active .mlp-video-wrapper iframe,
.elementor-editor-active .mlp-video-wrapper video {
    /* Prevent interaction issues in editor */
    pointer-events: none;
}

/* Ensure mlp-videoplayer also gets editor treatment */
.elementor-editor-active .mlp-videoplayer {
    min-height: 50px;
}

/* ==========================================================================
   Video Overlay
   Wird per inject_overlay() innerhalb von .mlp-video-wrapper / .mlp-image-wrapper
   platziert. Positioniert sich relativ zum Media-Wrapper (position:relative).
   ========================================================================== */

.mlp-video-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    border-radius: inherit;
}

/* ==========================================================================
   HLS Video Player
   ========================================================================== */

.mlp-hls-video {
    width: 100%;
    height: 100%;
    background: #000;
}

/* ==========================================================================
   Error States
   ========================================================================== */

.mlp-video-error {
    padding: 20px;
    text-align: center;
    color: #B83B3B;
    background: #FDF0F0;
    border: 1px solid rgba(184,59,59,0.3);
    border-radius: 4px;
}

.mlp-video-error p {
    margin: 0;
}

/* ==========================================================================
   Thumbnail Wrapper (Click-to-Play)
   ========================================================================== */

.mlp-video-thumbnail-wrapper {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    width: 100%;
    min-width: 0;
    background: #000;
}

.mlp-video-thumbnail-wrapper > .mlp-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.mlp-video-thumbnail-wrapper:hover > .mlp-thumbnail-image {
    transform: scale(1.02);
}


/* ==========================================================================
   Play Button Overlay
   ========================================================================== */

.mlp-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 57, 78, 0.05);
    transition: background 0.3s ease;
    z-index: 2;
}

.mlp-video-thumbnail-wrapper:hover .mlp-play-overlay {
    background: rgba(10, 57, 78, 0.15);
}

/* ==========================================================================
   Play Button SVG
   ========================================================================== */

.mlp-play-button-svg {
    width: 72px;
    height: 72px;
    filter: drop-shadow(0 4px 12px rgba(10, 57, 78, 0.35));
    transition: transform 0.25s ease;
}

.mlp-video-thumbnail-wrapper:hover .mlp-play-button-svg {
    transform: scale(1.08);
    animation-play-state: paused;
}

/* ==========================================================================
   Custom Play Button Image
   ========================================================================== */

.mlp-play-button-custom {
    width: auto;
    height: auto;
    max-width: 120px;
    max-height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(10, 57, 78, 0.35));
    transition: transform 0.25s ease;
}

.mlp-video-thumbnail-wrapper:hover .mlp-play-button-custom {
    transform: scale(1.08);
    animation-play-state: paused;
}

/* Animationen auch fuer Custom Play-Button */
.mlp-play-animation--pulse_light .mlp-play-button-custom {
    animation: mlp-pulse-light 3s ease-in-out infinite;
}
.mlp-play-animation--pulse_medium .mlp-play-button-custom {
    animation: mlp-pulse-medium 2.5s ease-in-out infinite;
}
.mlp-play-animation--pulse_strong .mlp-play-button-custom {
    animation: mlp-pulse-strong 2s ease-in-out infinite;
}
.mlp-play-animation--wiggle .mlp-play-button-custom {
    animation: mlp-wiggle 4s ease-in-out infinite;
}
.mlp-play-animation--none .mlp-play-button-custom {
    animation: none;
}

/* Mobile: kleinerer Play-Button */
@media (max-width: 767px) {
    .mlp-play-button-svg {
        width: 56px;
        height: 56px;
    }
    .mlp-play-button-custom {
        max-width: 80px;
        max-height: 80px;
    }
}

/* ==========================================================================
   Play Button Animationen (CSS-only)
   ========================================================================== */

/* Keine Animation */
.mlp-play-animation--none .mlp-play-button-svg {
    animation: none;
}

/* Pulse Light — sanft */
.mlp-play-animation--pulse_light .mlp-play-button-svg {
    animation: mlp-pulse-light 3s ease-in-out infinite;
}

@keyframes mlp-pulse-light {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Pulse Medium — mittel */
.mlp-play-animation--pulse_medium .mlp-play-button-svg {
    animation: mlp-pulse-medium 2.5s ease-in-out infinite;
}

@keyframes mlp-pulse-medium {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

/* Pulse Strong — stark */
.mlp-play-animation--pulse_strong .mlp-play-button-svg {
    animation: mlp-pulse-strong 2s ease-in-out infinite;
}

@keyframes mlp-pulse-strong {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Wiggle — wackeln */
.mlp-play-animation--wiggle .mlp-play-button-svg {
    animation: mlp-wiggle 4s ease-in-out infinite;
}

@keyframes mlp-wiggle {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(12deg); }
    20% { transform: rotate(-10deg); }
    30% { transform: rotate(8deg); }
    40% { transform: rotate(-6deg); }
    50% { transform: rotate(4deg); }
    60% { transform: rotate(-2deg); }
    70% { transform: rotate(0deg); }
}

/* Barrierefreiheit: Animationen deaktivieren */
@media (prefers-reduced-motion: reduce) {
    .mlp-play-button-svg,
    .mlp-play-button-custom {
        animation: none !important;
    }
}

/* ==========================================================================
   Video Modal (Enhanced — neue Klassen mit mlp- Prefix)
   ========================================================================== */

.mlp-video-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mlp-video-modal.mlp-video-modal--active {
    display: flex;
    opacity: 1;
}

.mlp-video-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 57, 78, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.mlp-video-modal-content {
    position: relative;
    width: 90%;
    max-width: 960px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(10, 57, 78, 0.14), 0 4px 8px rgba(10, 57, 78, 0.09);
    z-index: 1;
}

.mlp-video-modal-content iframe,
.mlp-video-modal-content video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.mlp-video-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(252, 252, 252, 0.15);
    color: #FCFCFC;
    font-size: 18px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 2;
    padding: 0;
}

.mlp-video-modal-close:hover {
    background: rgba(252, 252, 252, 0.3);
}

/* Mobile Modal: breiterer Content */
@media (max-width: 767px) {
    .mlp-video-modal-content {
        width: 95%;
    }

    .mlp-video-modal-close {
        top: -36px;
        width: 28px;
        height: 28px;
        font-size: 16px;
        line-height: 28px;
    }
}

