/* ==========================================================================\n   West Mid Page Title Effects v1.0.5\n   Front-end only. Measured last-line underline sweep for .westmid-page-title.\n   Base centring is applied before JavaScript enhancement to prevent layout jump.\n   ========================================================================== */

/*
 * First-paint baseline: keep the native WordPress title visibly centred before
 * JavaScript measures/rebalances it. This prevents the left-to-centre jump.
 */
.westmid-page-title {
    position: relative !important;
    display: block !important;
    width: fit-content !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-bottom: 0 !important;
    padding: 0 0 calc(8px + 2.4rem) !important;
    overflow: visible !important;

    /* Final typography is present from the very first paint.
       JavaScript must never change the title's visible size. */
    font-family: "Manrope", sans-serif !important;
    font-size: clamp(2.4rem, 3.4vw, 3.25rem) !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
    color: #2F5496 !important;
    text-align: center !important;
}

/*
 * Neutralise the former Additional-CSS corner/underline pseudo-elements from
 * the first paint, not only after JavaScript has initialised.
 */
.westmid-page-title::before,
.westmid-page-title::after {
    content: none !important;
    display: none !important;
    animation: none !important;
}

.westmid-page-title.wm-title-effect-ready {
    width: max-content !important;
    max-width: 100% !important;

    /* JS deliberately controls wrapping once enhancement is ready. */
    text-wrap: nowrap !important;
}

.westmid-page-title__line {
    display: block;
    width: max-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    white-space: nowrap;
}

.westmid-page-title__underline {
    position: absolute;
    left: var(--wm-underline-left, 0px);
    bottom: 2.4rem;
    width: var(--wm-underline-width, 0px);
    height: 3px;
    border-radius: 999px;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(
        90deg,
        rgba(252, 211, 38, 0.14) 0%,
        rgba(252, 211, 38, 0.34) 34%,
        rgba(252, 211, 38, 0.68) 68%,
        #FCD326 100%
    );
    pointer-events: none;
    z-index: 1;
}

.westmid-page-title__sweep-point {
    position: absolute;
    left: var(--wm-underline-left, 0px);
    bottom: calc(2.4rem - 1.5px);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #FCD326;
    box-shadow:
        0 0 0 2px rgba(252, 211, 38, 0.14),
        0 0 6px rgba(252, 211, 38, 0.34);
    opacity: 0;
    transform: translateX(-50%) scale(0.7);
    pointer-events: none;
    z-index: 2;
}

/* Deliberate visible one-pass sweep: the point traverses the line rather than flashing. */
.westmid-page-title.wm-title-effect-animate .westmid-page-title__underline {
    animation: wm-title-underline-draw 650ms cubic-bezier(0.32, 0, 0.18, 1) 120ms both;
}

.westmid-page-title.wm-title-effect-animate .westmid-page-title__sweep-point {
    animation: wm-title-point-sweep 650ms cubic-bezier(0.32, 0, 0.18, 1) 120ms both;
}

@keyframes wm-title-underline-draw {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

@keyframes wm-title-point-sweep {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.55);
    }
    6% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    92% {
        opacity: 1;
        transform: translateX(calc(var(--wm-underline-width, 0px) - 50%)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(calc(var(--wm-underline-width, 0px) - 50%)) scale(0.55);
    }
}

@media (prefers-reduced-motion: reduce) {
    .westmid-page-title.wm-title-effect-ready .westmid-page-title__underline {
        animation: none !important;
        transform: scaleX(1) !important;
    }

    .westmid-page-title.wm-title-effect-ready .westmid-page-title__sweep-point {
        display: none !important;
        animation: none !important;
    }
}
