/*
 * Ticker — module stylesheet
 *
 * A full-width bar: one <a> holding a marquee (the text repeated in two
 * identical groups, the track translated by -50% in a loop) and a static
 * pill button; optionally a close <button> beside the link.
 *
 * Placement is done by the module JS: --header variant lives INSIDE
 * Salient's fixed #header-outer (after header#top) and therefore needs
 * no positioning of its own; --bottom variant is fixed to the viewport.
 *
 * The text fades into the bar background at both ends of the marquee via
 * a mask (so it works for any background colour); the fade before the
 * button is long, which lifts the button out of the text visually
 * (operator's request).
 *
 * HOW TO RESTYLE
 * --------------
 * Same contract as the sibling modules: PALETTE tokens (colours, fonts,
 * radii, timing) and ELEMENTS tokens (one per element) on .ea-ticker; the
 * rules below only consume tokens. The five editable values (bar colours,
 * button colours, font size) arrive as inline custom properties set by the
 * shortcode and override the PALETTE defaults.
 *
 * Salient hardening: the close <button> carries !important on background /
 * border / border-radius / box-shadow / color because the theme styles
 * button globally. Text colour sits on the spans, not on the <a>, so the
 * theme's link-colour rules have nothing to override.
 */

/* 1. PALETTE ----------------------------------------------------------- */

.ea-ticker {
    --ea-tk-bg: #d42d68;
    --ea-tk-text: #ffffff;
    --ea-tk-button-bg: #ffffff;
    --ea-tk-button-text: #d42d68;
    --ea-tk-font-size: 15px;

    --ea-tk-font: inherit;              /* theme body font */
    --ea-tk-weight-text: 500;
    --ea-tk-weight-button: 600;

    --ea-tk-radius: 999px;
    --ea-tk-duration: 20s;              /* overwritten per instance by the JS (track width / speed) */
    --ea-tk-reveal: 350ms;
    --ea-tk-z: 9990;                    /* bottom variant: under Salient's header (9999) and the cookie bar */
}

/* 2. ELEMENTS ---------------------------------------------------------- */

.ea-ticker {
    --ea-tk-bar-pad-y: 9px;
    --ea-tk-bar-pad-x: 24px;
    --ea-tk-bar-gap: 20px;              /* marquee → button */
    --ea-tk-bar-shadow: 0 -1px 0 rgba(255, 255, 255, 0.12) inset;

    --ea-tk-text-gap: 40px;             /* between repeated copies */
    --ea-tk-text-dot: 5px;              /* separator dot */
    --ea-tk-text-dot-opacity: 0.55;
    --ea-tk-fade-start: 40px;           /* left edge */
    --ea-tk-fade-end: 180px;            /* before the button — long, lifts the button out of the text */
    --ea-tk-fade-mobile: 28px;

    --ea-tk-button-pad: 0.5em 1.15em 0.5em 1.3em;
    --ea-tk-button-size: calc(var(--ea-tk-font-size) * 0.93);
    --ea-tk-button-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    --ea-tk-button-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.18);
    --ea-tk-button-arrow: 0.9em;

    --ea-tk-close-size: 30px;
    --ea-tk-close-bg: rgba(255, 255, 255, 0.16);
    --ea-tk-close-hover-bg: rgba(255, 255, 255, 0.3);
    --ea-tk-close-color: var(--ea-tk-text);
}

/* 3. BAR --------------------------------------------------------------- */

.ea-ticker {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    background: var(--ea-tk-bg);
    color: var(--ea-tk-text);
    font-family: var(--ea-tk-font);
    font-size: var(--ea-tk-font-size);
    line-height: 1.35;
    box-shadow: var(--ea-tk-bar-shadow);
    -webkit-font-smoothing: antialiased;
}

.ea-ticker[hidden] {
    display: none !important;
}

.ea-ticker *,
.ea-ticker *::before,
.ea-ticker *::after {
    box-sizing: border-box;
}

/* Reveal: the JS un-hides, forces a reflow, then adds .is-shown */
.ea-ticker--header {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity var(--ea-tk-reveal) ease, transform var(--ea-tk-reveal) ease;
}

.ea-ticker--bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--ea-tk-z);
    opacity: 0;
    transform: translateY(100%);
    transition: opacity var(--ea-tk-reveal) ease, transform var(--ea-tk-reveal) cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ea-ticker.is-shown {
    opacity: 1;
    transform: none;
}

/* Bottom variant: yield to the cookie bar while it is visible */
.ea-ticker--bottom.is-yielding {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

/* Salient ships `#header-outer .container` etc. with `position: relative`
   — the ticker lives beside them and only needs to stay in flow. */
#header-outer > .ea-ticker--header {
    display: block;
}

/* Bottom variant: Salient's "to top" button sits at bottom/right 17px and
   would land on the bar (and on the close button). The JS sets the bar
   height on <html>; a margin lifts the button without touching the
   theme's own bottom/transform animation. */
html.ea-ticker-has-bottom #to-top {
    margin-bottom: var(--ea-ticker-bottom-height, 0px);
}

/* 4. LINK -------------------------------------------------------------- */

.ea-ticker__link,
.ea-ticker__link:hover,
.ea-ticker__link:focus {
    display: flex;
    align-items: center;
    gap: var(--ea-tk-bar-gap);
    width: 100%;
    padding: var(--ea-tk-bar-pad-y) var(--ea-tk-bar-pad-x);
    color: var(--ea-tk-text);
    text-decoration: none;
    border: 0;
    outline: none;
}

.ea-ticker--closable .ea-ticker__link {
    padding-right: calc(var(--ea-tk-bar-pad-x) + var(--ea-tk-close-size) + 12px);
}

.ea-ticker__link:focus-visible .ea-ticker__button {
    outline: 2px solid var(--ea-tk-button-text);
    outline-offset: 2px;
}

/* 5. MARQUEE ----------------------------------------------------------- */

.ea-ticker__marquee {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 var(--ea-tk-fade-start),
        #000 calc(100% - var(--ea-tk-fade-end)),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 var(--ea-tk-fade-start),
        #000 calc(100% - var(--ea-tk-fade-end)),
        transparent 100%
    );
}

.ea-ticker__track {
    display: flex;
    width: max-content;
    will-change: transform;
    animation: ea-ticker-scroll var(--ea-tk-duration) linear infinite;
}

.ea-ticker.is-measuring .ea-ticker__track,
.ea-ticker.is-static .ea-ticker__track {
    animation: none;
}

.ea-ticker__link:hover .ea-ticker__track {
    animation-play-state: paused;
}

.ea-ticker__group {
    display: flex;
    flex: 0 0 auto;
}

/* block, not inline-flex: flex layout would drop the whitespace text nodes
   around inline children such as <strong> */
.ea-ticker__item {
    display: block;
    flex: 0 0 auto;
    white-space: nowrap;
    font-weight: var(--ea-tk-weight-text);
    letter-spacing: 0.01em;
    color: var(--ea-tk-text);
}

.ea-ticker__item strong,
.ea-ticker__item b {
    font-weight: 700;
}

/* separator dot after every copy */
.ea-ticker__item::after {
    content: '';
    display: inline-block;
    vertical-align: middle;
    width: var(--ea-tk-text-dot);
    height: var(--ea-tk-text-dot);
    margin: -0.1em var(--ea-tk-text-gap) 0;
    border-radius: 50%;
    background: currentColor;
    opacity: var(--ea-tk-text-dot-opacity);
}

@keyframes ea-ticker-scroll {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(-50%, 0, 0); }
}

/* Static fallback (reduced motion, or JS decided not to animate):
   one copy, no clone group, no separator, text clipped by the mask */
.ea-ticker.is-static .ea-ticker__group--clone,
.ea-ticker.is-static .ea-ticker__item:not(:first-child) {
    display: none;
}

.ea-ticker.is-static .ea-ticker__item::after {
    display: none;
}

/* 6. BUTTON ------------------------------------------------------------ */

.ea-ticker__button {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    flex: 0 0 auto;
    padding: var(--ea-tk-button-pad);
    border-radius: var(--ea-tk-radius);
    background: var(--ea-tk-button-bg);
    color: var(--ea-tk-button-text);
    font-size: var(--ea-tk-button-size);
    font-weight: var(--ea-tk-weight-button);
    line-height: 1.2;
    letter-spacing: 0.01em;
    white-space: nowrap;
    box-shadow: var(--ea-tk-button-shadow);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.ea-ticker__button::after {
    content: '';
    flex: 0 0 auto;
    width: var(--ea-tk-button-arrow);
    height: var(--ea-tk-button-arrow);
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform 180ms ease;
}

.ea-ticker__link:hover .ea-ticker__button {
    transform: translateY(-1px);
    box-shadow: var(--ea-tk-button-shadow-hover);
}

.ea-ticker__link:hover .ea-ticker__button::after {
    transform: translateX(3px);
}

/* 7. CLOSE ------------------------------------------------------------- */

.ea-ticker__close {
    position: absolute;
    top: 50%;
    right: var(--ea-tk-bar-pad-x);
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ea-tk-close-size);
    height: var(--ea-tk-close-size);
    margin: 0;
    padding: 0 !important;
    transform: translateY(-50%);
    background: var(--ea-tk-close-bg) !important;
    color: var(--ea-tk-close-color) !important;
    border: 0 !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    line-height: 1 !important;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.ea-ticker__close:hover,
.ea-ticker__close:focus-visible {
    background: var(--ea-tk-close-hover-bg) !important;
}

.ea-ticker__close:focus-visible {
    outline: 2px solid var(--ea-tk-text);
    outline-offset: 2px;
}

.ea-ticker__close-icon {
    display: block;
    width: 12px;
    height: 12px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* 8. ERROR ------------------------------------------------------------- */

.ea-ticker-error {
    padding: 8px 12px;
    border-left: 3px solid #d42d68;
    background: #fdf1f5;
    color: #7a1a3d;
    font-size: 14px;
}

/* 9. MOBILE ------------------------------------------------------------ */

@media (max-width: 690px) {
    .ea-ticker {
        --ea-tk-bar-pad-y: 10px;
        --ea-tk-bar-pad-x: 16px;
        --ea-tk-bar-gap: 10px;
    }

    .ea-ticker__link,
    .ea-ticker__link:hover,
    .ea-ticker__link:focus {
        flex-direction: column;
        align-items: stretch;
    }

    .ea-ticker--closable .ea-ticker__link {
        padding-right: var(--ea-tk-bar-pad-x);
    }

    /* symmetric fade — the button is no longer beside the text */
    .ea-ticker__marquee {
        -webkit-mask-image: linear-gradient(
            to right,
            transparent 0,
            #000 var(--ea-tk-fade-mobile),
            #000 calc(100% - var(--ea-tk-fade-mobile)),
            transparent 100%
        );
        mask-image: linear-gradient(
            to right,
            transparent 0,
            #000 var(--ea-tk-fade-mobile),
            #000 calc(100% - var(--ea-tk-fade-mobile)),
            transparent 100%
        );
    }

    .ea-ticker__button {
        align-self: center;
    }

    /* close button moves to the top-right corner, clear of the text row */
    .ea-ticker__close {
        top: 8px;
        right: 8px;
        transform: none;
        width: 26px;
        height: 26px;
    }

    .ea-ticker--closable .ea-ticker__marquee {
        margin-right: 30px;
    }
}

/* 10. REDUCED MOTION --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .ea-ticker--header,
    .ea-ticker--bottom,
    .ea-ticker__button,
    .ea-ticker__button::after,
    .ea-ticker__close {
        transition: none;
    }

    .ea-ticker__track {
        animation: none;
    }

    .ea-ticker__group--clone,
    .ea-ticker__item:not(:first-child),
    .ea-ticker__item::after {
        display: none;
    }
}
