/* Megh Hero Slider Styles */

.megh-hero-container {
    width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    position: relative;
}

.megh-hero-slider-wrap {
    position: relative;
    width: 100%;
    /*
     * Usando aspect-ratio em vez de height: 60vh.
     * Com aspect-ratio, a altura é sempre proporcional à LARGURA do slider,
     * não à altura do viewport. Assim top: X% representa a mesma posição
     * relativa em qualquer resolução, eliminando o descasamento entre monitores.
     * 16:5 ≈ 3.2:1 (banner largo e baixo, similar ao visual original em 1920px)
     */
    aspect-ratio: 16 / 5;
    min-height: 300px;
    max-height: 700px;
    overflow: hidden;
}

.megh-slides {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.megh-slides.grabbing {
    cursor: grabbing;
}

/* ===== FADE (default) ===== */
.megh-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    will-change: opacity, transform;
}

.megh-hero-container[data-transition="fade"] .megh-slide {
    transition: opacity 1s ease-in-out;
}

.megh-hero-container[data-transition="fade"] .megh-slide.active {
    opacity: 1;
    z-index: 2;
}

/* ===== SLIDE (Carousel Horizontal) ===== */
.megh-hero-container[data-transition="slide"] .megh-slides {
    display: flex;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.megh-hero-container[data-transition="slide"] .megh-slides.no-transition {
    transition: none !important;
}

.megh-hero-container[data-transition="slide"] .megh-slide {
    position: relative;
    flex: 0 0 100%;
    opacity: 1;
}

/* ===== SLIDE VERTICAL ===== */
.megh-hero-container[data-transition="slide-vertical"] .megh-slides {
    display: flex;
    flex-direction: column;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.megh-hero-container[data-transition="slide-vertical"] .megh-slide {
    position: relative;
    flex: 0 0 100%;
    opacity: 1;
}

/* ===== ZOOM ===== */
.megh-hero-container[data-transition="zoom"] .megh-slide {
    transition: opacity 0.8s ease-in-out, transform 0.8s ease-in-out;
    transform: scale(0.85);
}

.megh-hero-container[data-transition="zoom"] .megh-slide.active {
    opacity: 1;
    z-index: 2;
    transform: scale(1);
}

/* ===== FLIP ===== */
.megh-hero-container[data-transition="flip"] .megh-slides {
    perspective: 1200px;
}

.megh-hero-container[data-transition="flip"] .megh-slide {
    transition: opacity 0.6s ease-in-out, transform 0.8s ease-in-out;
    transform: rotateY(90deg);
    backface-visibility: hidden;
}

.megh-hero-container[data-transition="flip"] .megh-slide.active {
    opacity: 1;
    z-index: 2;
    transform: rotateY(0deg);
}

/* ===== KEN BURNS ===== */
.megh-hero-container[data-transition="kenburns"] .megh-slide {
    transition: opacity 1.2s ease-in-out;
    animation: none;
}

.megh-hero-container[data-transition="kenburns"] .megh-slide.active {
    opacity: 1;
    z-index: 2;
    animation: megh-kenburns 8s ease-in-out forwards;
}

@keyframes megh-kenburns {
    0% {
        transform: scale(1) translate(0, 0);
    }
    100% {
        transform: scale(1.15) translate(-2%, -1%);
    }
}

/* ===== Navigation Dots (inside slider) ===== */
.megh-hero-dots {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    z-index: 10;
    pointer-events: none;
}

.megh-hero-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
    outline: none;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.megh-hero-dot:hover {
    background: rgba(255, 255, 255, 0.5);
}

.megh-hero-dot.active {
    background: #ffffff;
}

@media (max-width: 768px) {
    .megh-hero-slider-wrap {
        height: 50vh;
    }
}

/* ===== Slide Media & Content ===== */
.megh-slide-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translateX(-50%) translateY(-50%);
    z-index: 1;
    object-fit: cover;
}

.megh-slide-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4; /* Pushed above the base logo z-index but below the canvas text at z-index: 5 */
    pointer-events: none;
}

.megh-slide-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.megh-layer {
    position: absolute;
    pointer-events: auto;
}

.megh-slide-image {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

.megh-layer-anim {
    opacity: 0;
    animation-fill-mode: forwards;
    will-change: opacity, transform;
}

/* Animation Classes mapped from shortcode */
.megh-slide.active .megh-layer-anim.anim-fade-up {
    animation: megh-fade-in-up 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.megh-slide.active .megh-layer-anim.anim-fade-down {
    animation: megh-fade-in-down 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.megh-slide.active .megh-layer-anim.anim-fade-left {
    animation: megh-fade-in-left 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.megh-slide.active .megh-layer-anim.anim-fade-right {
    animation: megh-fade-in-right 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.megh-slide.active .megh-layer-anim.anim-zoom-in {
    animation: megh-zoom-in 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.megh-slide.active .megh-layer-anim.anim-megh-logo {
    animation: megh-fade-text-delayed 2.5s ease-out forwards;
}
.megh-slide.active .megh-layer-anim.anim-none {
    opacity: 1;
    animation: none;
}

/* Keyframes */
@keyframes megh-fade-in-up {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes megh-fade-in-down {
    0% { opacity: 0; transform: translateY(-30px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes megh-fade-in-left {
    0% { opacity: 0; transform: translateX(-30px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes megh-fade-in-right {
    0% { opacity: 0; transform: translateX(30px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes megh-zoom-in {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes megh-fade-text-delayed {
    0% { opacity: 0; transform: translateY(10px); }
    60% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Megh Logo SVG specific styles and drawing animation */
.megh-bg-logo-svg {
    position: relative;
    /* User request: lock the height to 100% of the viewport slide */
    width: auto;
    height: 100%;
    max-height: 100%;
    /* Anchor to the right center while allowing auto-scaling width */
    object-fit: contain;
    object-position: right center;
    pointer-events: none;
    opacity: 0.8; /* HIGHER OPACITY TO MAKE IT STAND OUT */
    z-index: 10; /* Force the SVG to render ABOVE the .megh-slide-overlay so it is prominent */
}
.megh-bg-logo-outline path {
    fill: none;
    stroke: #ffffff; /* White line for contrast */
    stroke-width: var(--megh-logo-stroke-width, 6px); /* Controlled via admin setting */
    stroke-linecap: round;
    stroke-linejoin: round;
    
    /* Create dashes: 6000px covers the longest path (approx 5000 units) */
    stroke-dasharray: 6000;
    
    /* Make the total path invisible initially by offsetting it */
    stroke-dashoffset: 6000;
}

/* Variant for White Stroke selection (keeping for compatibility) */
.logo-theme-white .megh-bg-logo-outline path {
    stroke: #ffffff;
}

.megh-slide.active .megh-bg-logo-outline path {
    /* Draw animation using the variable for duration, infinite loop. 
       We will control the 3s pause by making the draw phase a portion of the total keyframe time, 
       but since var(--megh-logo-speed) defines the total time, we need a CSS trick. 
       Actually, native CSS animations don't support an exact 'wait 3s before infinite loop repeat'. 
       We can either use animation-delay inside the keyframes, or we can just apply a fixed long 
       stroke-dashoffset hold at the end of the keyframes.
       For a perfect dynamic speed + 3s hold, we would need to calc() inside the keyframes, 
       but keyframe percentages can't be calc()ed. 
       Instead, we will use a set percentage that looks good enough for the pause, 
       OR just rely on the plugin injecting a delay variable.
       Wait, let's keep it simple: draw it, then hold it, then reset.
       Since the user asked for "draws based on the config time... then restarts after 3 seconds", 
       CSS animations don't allow "animation-delay" per loop.
       So we will handle this via PHP setting the total animation duration to (config time + 3s).
       Let's assume the PHP will set --megh-logo-total-time and --megh-logo-draw-percent.
       For now, let's just make the pause at the end of the keyframes. 
       If they want exactly 3 seconds, we'll configure that in the shortcode.php math.
    */
    
    /* We will inject --megh-logo-total-time (e.g. 8s if config is 5s + 3s pause) */
    animation: megh-draw-logo var(--megh-logo-total-time, 8s) cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes megh-draw-logo {
    /* We use the --megh-logo-draw-percent to know when to finish drawing (e.g. 5s out of 8s is 62.5%) */
    /* Fallbacks are hardcoded here to ~60% */
    0% { stroke-dashoffset: 6000; opacity: 0; fill: transparent; }
    5% { opacity: 1; stroke-dashoffset: 6000; }
    var(--megh-logo-draw-percent, 60%) { stroke-dashoffset: 0; fill: transparent; opacity: 1; }
    98% { stroke-dashoffset: 0; fill: transparent; opacity: 1; }
    100% { stroke-dashoffset: 6000; fill: transparent; opacity: 0; }
}

.megh-slide-title {
    /*
     * Tipografia fluida: escala suavemente entre resoluções.
     * clamp(mínimo, ideal fluido, máximo)
     *   - mínimo : 1.25rem  → telas muito pequenas (≤ 360px)
     *   - ideal  : 2.2vw    → escala proporcionalmente à largura
     *   - máximo : 3rem     → para em 1920px (valor original)
     *
     * Fórmula do valor central: queremos 3rem @ 1366px → 3*16/1366 ≈ 3.51vw
     * Usamos 2.5vw para não ultrapassar em telas médias.
     */
    font-size: clamp(1.25rem, 2.5vw, 3rem);
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    color: #ffffff;

    /* Smooth lift transition base */
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: 0.5s;
    will-change: transform;
}

.megh-slide-subtitle {
    /* Subtítulo fluido: metade da proporção do título */
    font-size: clamp(0.85rem, 1.25vw, 1.5rem);
    font-weight: 400;
    line-height: 1.5;
    margin: 0;
    color: #ffffff;

    /* Smooth lift transition base */
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: 0.5s;
    will-change: transform;
}

/* Clariant Style Full-Slider Lift on Hover */
.megh-hero-slider-wrap:hover .megh-hover-active .megh-slide-title,
.megh-hero-slider-wrap:hover .megh-hover-active .megh-slide-subtitle {
    transform: translateY(-40px);
    transition-delay: 0s;
}

/* Breakpoints de segurança para dispositivos muito pequenos */
@media (max-width: 480px) {
    .megh-slide-title {
        font-size: clamp(1rem, 5vw, 1.5rem);
    }
    .megh-slide-subtitle {
        font-size: clamp(0.75rem, 3.5vw, 1rem);
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .megh-slide-title {
        font-size: clamp(1.25rem, 3.5vw, 2rem);
    }
    .megh-slide-subtitle {
        font-size: clamp(0.85rem, 2vw, 1.2rem);
    }
}

/* ===== Preloader Synchronization ===== */
.megh-hero-container.preloader-active .megh-slide {
    animation: none !important;
}

.megh-hero-container.preloader-active .megh-slide .megh-layer-anim {
    animation: none !important;
    opacity: 0 !important;
}

.megh-hero-container.preloader-active .megh-slide .megh-bg-logo-outline path {
    animation: none !important;
}
