/**
 * Animated Heading for Elementor - Styles
 * 
 * Includes:
 * - Base layout styles
 * - SVG underline positioning
 * - Draw, Fade, Slide, Bounce animations
 * - Circle/highlight and strikethrough variants
 * - Responsive adjustments & mobile text wrapping
 * - Elementor editor preview overrides
 *
 * @since 1.0.0
 */

/* ===========================================
   BASE LAYOUT
   =========================================== */

.ahe-animated-heading {
    position: relative;
    display: block;
    max-width: 100%;
}

.ahe-animated-heading a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.ahe-animated-heading a:hover {
    color: inherit;
}

.ahe-heading {
    margin: 0;
    padding: 0;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: break-word;
}

.ahe-first-line,
.ahe-second-line {
    display: block;
    margin-bottom: 4px;
}

.ahe-second-line:last-child {
    margin-bottom: 0;
}

.ahe-before-text,
.ahe-after-text {
    display: inline;
}

.ahe-highlighted-text {
    display: inline-block;
    position: relative;
    vertical-align: baseline;
    white-space: nowrap; /* Keep highlighted text together on mobile */
    max-width: 100%;
}

.ahe-highlight-inner {
    display: inline-block;
    position: relative;
    z-index: 1;
}

/* ===========================================
   SVG UNDERLINE - POSITIONING
   =========================================== */

.ahe-underline-svg {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: auto;
    max-height: 35px;
    overflow: visible;
    pointer-events: none;
    z-index: 0;
}

/* Circle/Highlight variant - wraps around the text */
.ahe-underline-svg.ahe-underline-circle {
    bottom: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: calc(100% + 16px);
    width: calc(100% + 24px);
    max-height: none;
}

/* Strikethrough variant - sits in the middle */
.ahe-underline-svg.ahe-underline-strike {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* ===========================================
   ANIMATION: DRAW (SVG stroke-dasharray)
   =========================================== */

.ahe-animated-heading[data-animation="draw"] .ahe-underline-path {
    stroke-dasharray: var(--ahe-path-length, 3000);
    stroke-dashoffset: var(--ahe-path-length, 3000);
    transition: stroke-dashoffset var(--ahe-speed, 1.5s) ease-in-out;
    transition-delay: var(--ahe-delay, 0.3s);
}

.ahe-animated-heading[data-animation="draw"].ahe-animated .ahe-underline-path {
    stroke-dashoffset: 0;
}

/* ===========================================
   ANIMATION: FADE IN
   =========================================== */

.ahe-animated-heading[data-animation="fade"] .ahe-underline-svg {
    opacity: 0;
    transition: opacity var(--ahe-speed, 1.5s) ease-in-out;
    transition-delay: var(--ahe-delay, 0.3s);
}

.ahe-animated-heading[data-animation="fade"].ahe-animated .ahe-underline-svg {
    opacity: 1;
}

/* ===========================================
   ANIMATION: SLIDE IN
   =========================================== */

.ahe-animated-heading[data-animation="slide"] .ahe-underline-svg {
    opacity: 0;
    transform: translateX(-60%);
    transition: opacity var(--ahe-speed, 1.5s) cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform var(--ahe-speed, 1.5s) cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition-delay: var(--ahe-delay, 0.3s);
}

.ahe-animated-heading[data-animation="slide"].ahe-animated .ahe-underline-svg {
    opacity: 1;
    transform: translateX(-50%);
}

/* Slide: circle variant */
.ahe-animated-heading[data-animation="slide"] .ahe-underline-svg.ahe-underline-circle {
    transform: translate(-60%, -50%);
}

.ahe-animated-heading[data-animation="slide"].ahe-animated .ahe-underline-svg.ahe-underline-circle {
    transform: translate(-50%, -50%);
}

/* ===========================================
   ANIMATION: BOUNCE
   =========================================== */

.ahe-animated-heading[data-animation="bounce"] .ahe-underline-svg {
    opacity: 0;
    transform: translateX(-50%) scaleX(0);
    transform-origin: center;
    transition: opacity var(--ahe-speed, 1.5s) cubic-bezier(0.68, -0.55, 0.265, 1.55),
                transform var(--ahe-speed, 1.5s) cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition-delay: var(--ahe-delay, 0.3s);
}

.ahe-animated-heading[data-animation="bounce"].ahe-animated .ahe-underline-svg {
    opacity: 1;
    transform: translateX(-50%) scaleX(1);
}

/* Bounce: circle variant */
.ahe-animated-heading[data-animation="bounce"] .ahe-underline-svg.ahe-underline-circle {
    transform: translate(-50%, -50%) scale(0);
}

.ahe-animated-heading[data-animation="bounce"].ahe-animated .ahe-underline-svg.ahe-underline-circle {
    transform: translate(-50%, -50%) scale(1);
}

/* ===========================================
   ANIMATION: NONE
   =========================================== */

.ahe-animated-heading[data-animation="none"] .ahe-underline-path {
    stroke-dashoffset: 0 !important;
}

.ahe-animated-heading[data-animation="none"] .ahe-underline-svg {
    opacity: 1 !important;
}

/* ===========================================
   RESPONSIVE (TABLET & MOBILE)
   =========================================== */

@media (max-width: 767px) {
    .ahe-heading {
        line-height: 1.3;
    }

    .ahe-first-line,
    .ahe-second-line {
        margin-bottom: 6px;
    }

    .ahe-highlighted-text {
        white-space: normal; /* Allow graceful wrap if screen is very narrow */
        display: inline-block;
    }

    .ahe-underline-svg {
        bottom: -3px;
        max-height: 25px;
    }

    .ahe-underline-svg.ahe-underline-circle {
        height: calc(100% + 10px);
        width: calc(100% + 16px);
    }
}

@media (max-width: 480px) {
    .ahe-heading {
        line-height: 1.25;
    }

    .ahe-underline-svg {
        bottom: -2px;
        max-height: 20px;
    }
}

/* ===========================================
   ELEMENTOR EDITOR PREVIEW
   Always show underlines in editor for easy editing.
   =========================================== */

.elementor-editor-active .ahe-animated-heading .ahe-underline-path {
    stroke-dashoffset: 0 !important;
    transition: none !important;
}

.elementor-editor-active .ahe-animated-heading .ahe-underline-svg {
    opacity: 1 !important;
    transition: none !important;
}

/* Editor: standard underline position */
.elementor-editor-active .ahe-animated-heading .ahe-underline-svg:not(.ahe-underline-circle):not(.ahe-underline-strike) {
    transform: translateX(-50%) !important;
}

/* Editor: circle variant */
.elementor-editor-active .ahe-animated-heading .ahe-underline-svg.ahe-underline-circle {
    transform: translate(-50%, -50%) !important;
}

/* Editor: strike variant */
.elementor-editor-active .ahe-animated-heading .ahe-underline-svg.ahe-underline-strike {
    transform: translate(-50%, -50%) !important;
}
