/*
 * X4A GLOBAL UI
 *
 * X4A DEPENDENCY CONTRACT
 *
 * Lightweight frontend utility controls that are
 * independent of MarketWire, Article, Research and
 * ticker-specific renderers.
 *
 * Current consumer:
 *
 * - Go Top
 */


/* ==========================================================
 * GO TOP
 * ========================================================== */

.x4a-go-top {
    position: fixed;

    right:
        max(
            20px,
            env(
                safe-area-inset-right
            )
        );

    bottom:
        max(
            22px,
            env(
                safe-area-inset-bottom
            )
        );

    z-index: 9998;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 48px;
    height: 48px;

    padding: 0;

    border:
        1px solid
        rgba(
            145,
            160,
            174,
            0.38
        );

    border-radius: 50%;

    background:
        rgba(
            15,
            24,
            34,
            0.92
        );

    color: #e8eef5;

    box-shadow:
        0 8px 28px
        rgba(
            0,
            0,
            0,
            0.24
        );

    cursor: pointer;

    opacity: 0;

    transform:
        translateY(
            12px
        )
        scale(
            0.94
        );

    pointer-events: none;

    transition:
        opacity 160ms ease,
        transform 160ms ease,
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease;
}


.x4a-go-top.is-visible {
    opacity: 1;

    transform:
        translateY(
            0
        )
        scale(
            1
        );

    pointer-events: auto;
}


.x4a-go-top:hover {
    border-color: #72b7ff;

    background:
        rgba(
            28,
            46,
            64,
            0.98
        );

    color: #ffffff;
}


.x4a-go-top:focus-visible {
    outline:
        2px solid
        #72b7ff;

    outline-offset: 3px;
}


.x4a-go-top svg {
    display: block;

    width: 22px;
    height: 22px;

    fill: none;

    stroke: currentColor;

    stroke-width: 2.2;

    stroke-linecap: round;
    stroke-linejoin: round;
}


/*
 * X4A-controlled Light Mode.
 */
:root[data-x4a-theme="light"]
.x4a-go-top {
    border-color:
        rgba(
            25,
            55,
            80,
            0.20
        );

    background:
        rgba(
            255,
            255,
            255,
            0.95
        );

    color: #15202b;

    box-shadow:
        0 8px 28px
        rgba(
            25,
            50,
            75,
            0.16
        );
}


:root[data-x4a-theme="light"]
.x4a-go-top:hover {
    border-color: #0866c6;

    background: #ffffff;

    color: #0866c6;
}


/*
 * Fallback for public WordPress pages which do not
 * activate the X4A Dark / Light controller.
 */
@media (prefers-color-scheme: light) {

    :root:not([data-x4a-theme])
    .x4a-go-top {
        border-color:
            rgba(
                25,
                55,
                80,
                0.20
            );

        background:
            rgba(
                255,
                255,
                255,
                0.95
            );

        color: #15202b;
    }
}


@media (max-width: 720px) {

    .x4a-go-top {
        right:
            max(
                14px,
                env(
                    safe-area-inset-right
                )
            );

        bottom:
            max(
                16px,
                env(
                    safe-area-inset-bottom
                )
            );

        width: 44px;
        height: 44px;
    }
}


@media (prefers-reduced-motion: reduce) {

    .x4a-go-top {
        transition: none;
    }
}

/* X4A PRODUCT HEADER ISOLATION 70B3 */

/*
 * Twenty Twenty-Five remains the underlying WordPress
 * theme but its responsive navigation overlay is not
 * part of the X4A product UI.
 *
 * Every current X4A product surface already owns its
 * own navigation/control layer.
 */
body.x4a-marketwire-view
header.wp-block-template-part,
body.x4a-marketwire-timeline
header.wp-block-template-part,
body.x4a-frontpage
header.wp-block-template-part,
body.x4a-marketwire-archive-view
header.wp-block-template-part {
    display: none !important;
}

body.x4a-marketwire-view
.wp-block-navigation__responsive-container-open,
body.x4a-marketwire-timeline
.wp-block-navigation__responsive-container-open,
body.x4a-frontpage
.wp-block-navigation__responsive-container-open,
body.x4a-marketwire-archive-view
.wp-block-navigation__responsive-container-open {
    display: none !important;
}

/* X4A UNIFIED PRODUCT NAVIGATION 70B4 */

/*
 * One visual language across X4A product surfaces:
 * compact contextual back control + round icon-only theme toggle.
 */
.x4a-theme-toggle {
    position: relative !important;
    display: inline-grid !important;
    flex: 0 0 38px !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 !important;
    place-items: center !important;
    border-radius: 50% !important;
    font-size: 0 !important;
    line-height: 1 !important;
    overflow: hidden;
}

.x4a-theme-toggle .x4a-theme-icon {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
}

.x4a-theme-toggle [data-x4a-theme-label] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.x4a-context-back {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    min-height: 36px;
    padding: 0 6px;
    color: var(--x4a-muted);
    font-family: var(--x4a-font-ui);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}

.x4a-context-back:hover,
.x4a-context-back:focus-visible {
    color: var(--x4a-accent);
}

.x4a-feed-controls {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

@media (max-width: 520px) {
    .x4a-theme-toggle {
        flex-basis: 36px !important;
        width: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        height: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
    }

    .x4a-context-back {
        min-height: 34px;
        padding: 0 4px;
        font-size: 11px;
    }

    .x4a-feed-controls {
        gap: 5px;
    }
}

/* X4A LAYOUT CONSISTENCY 70B5 */

body.x4a-marketwire-timeline
.x4a-marketwire-shell {
    width: min(1120px, calc(100% - 32px)) !important;
    max-width: 1120px !important;
    margin-inline: auto !important;
}

.x4a-feed-context-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    margin: 0 0 4px;
}

.x4a-feed-context-nav
.x4a-feed-context-back {
    margin: 0;
}

.x4a-feed-topbar {
    width: 100%;
}

.x4a-feed-controls {
    margin-left: auto;
}

@media (max-width: 700px) {
    body.x4a-marketwire-timeline
    .x4a-marketwire-shell {
        width: calc(100% - 16px) !important;
    }

    .x4a-feed-context-nav {
        margin-bottom: 2px;
    }
}

/* X4A GLOBAL PRODUCT TOPBAR 70B8 */

.x4a-product-topbar {
    position: relative;
    z-index: 20;

    display: grid;
    grid-template-columns:
        auto minmax(0, 1fr) auto;

    align-items: center;
    gap: 24px;

    width: 100%;
    min-width: 0;
    min-height: 72px;

    margin:
        0 0 16px;

    padding:
        12px 16px;

    border:
        1px solid
        var(--x4a-border);

    border-radius:
        var(--x4a-radius-lg);

    background:
        color-mix(
            in srgb,
            var(--x4a-surface) 92%,
            transparent
        );

    box-shadow:
        var(--x4a-shadow);

    backdrop-filter:
        blur(16px);

    box-sizing: border-box;
}

body.x4a-frontpage
.x4a-product-topbar {
    margin-bottom: 0;
}

.x4a-product-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    color: var(--x4a-text);
    text-decoration: none;
}

.x4a-product-brand-mark {
    display: grid;
    flex: 0 0 45px;
    width: 45px;
    height: 45px;
    place-items: center;
    border: 1px solid var(--x4a-border-strong);
    border-radius: 10px;
    background: var(--x4a-accent-soft);
    color: var(--x4a-accent);
    font: 800 14px/1 var(--x4a-font-data);
    letter-spacing: .08em;
}

.x4a-product-brand-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.x4a-product-brand-copy strong {
    color: var(--x4a-text);
    font-size: 16px;
    letter-spacing: -.02em;
}

.x4a-product-brand-copy small {
    color: var(--x4a-muted);
    font: 500 10px/1.3 var(--x4a-font-data);
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
}

.x4a-product-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.x4a-product-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 11px;
    border-radius: var(--x4a-radius-sm);
    color: var(--x4a-muted);
    font-family: var(--x4a-font-ui);
    font-size: 13px;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition:
        color var(--x4a-transition-ui),
        background var(--x4a-transition-ui),
        border-color var(--x4a-transition-ui);
}

.x4a-product-nav a:hover,
.x4a-product-nav a:focus-visible,
.x4a-product-nav a.is-active {
    background: var(--x4a-accent-soft);
    color: var(--x4a-accent);
}

.x4a-product-nav
.x4a-product-back {
    padding: 0 11px;
    border: 1px solid var(--x4a-border);
    background: var(--x4a-surface-2);
    color: var(--x4a-text);
    font-size: 12px;
    font-weight: 700;
}

.x4a-product-nav
.x4a-product-back:hover,
.x4a-product-nav
.x4a-product-back:focus-visible {
    border-color: var(--x4a-border-strong);
    background: var(--x4a-accent-soft);
    color: var(--x4a-accent);
}

.x4a-product-theme-toggle {
    justify-self: end;
}

@media (max-width: 980px) {

    .x4a-product-topbar {
        grid-template-columns:
            minmax(0, 1fr) auto;
        gap: 9px 12px;
        padding: 10px 12px;
    }

    .x4a-product-nav {
        grid-column: 1 / -1;
        justify-content: flex-start;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 2px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 700px) {

    .x4a-product-topbar {
        min-height: 0;
        margin-bottom: 12px;
        border-radius: var(--x4a-radius-md);
    }

    body.x4a-frontpage
    .x4a-product-topbar {
        margin-bottom: 0;
    }

    .x4a-product-brand-mark {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
        font-size: 12px;
    }

    .x4a-product-brand-copy strong {
        font-size: 14px;
    }

    .x4a-product-brand-copy small {
        font-size: 9px;
    }

    .x4a-product-nav {
        gap: 3px;
    }

    .x4a-product-nav a,
    .x4a-product-nav
    .x4a-product-back {
        min-height: 35px;
        padding: 0 9px;
        font-size: 12px;
    }
}

@media (max-width: 430px) {

    .x4a-product-brand-copy small {
        display: none;
    }

    .x4a-product-brand {
        gap: 8px;
    }

    .x4a-product-nav a,
    .x4a-product-nav
    .x4a-product-back {
        padding: 0 8px;
        font-size: 11px;
    }
}

/* X4A GLOBAL TOPBAR MOBILE THEME ALIGNMENT 70C3-R6 */

/*
 * 70B8 intentionally kept navigation and theme access available on
 * narrow screens, but its <=980px grid placed:
 *
 * row 1: brand | theme
 * row 2: nav spanning both columns
 *
 * R6 keeps the brand in its own upper row and explicitly pairs the
 * navigation with the theme toggle below it:
 *
 * row 1: brand  | brand
 * row 2: nav    | theme
 *
 * The nav column may scroll horizontally on very narrow phones, while
 * the theme button remains visible and fixed at the far right.
 */
@media (max-width: 980px) {

    .x4a-product-topbar {
        grid-template-columns:
            minmax(0, 1fr)
            auto;

        grid-template-areas:
            "brand brand"
            "nav theme";

        align-items: center;
        gap: 9px 8px;
    }

    .x4a-product-brand {
        grid-area: brand;
        min-width: 0;
    }

    .x4a-product-nav {
        grid-area: nav;
        grid-column: auto;
        grid-row: auto;

        min-width: 0;
        width: 100%;

        align-items: center;
        justify-content: flex-start;

        overflow-x: auto;
        overflow-y: hidden;

        padding-bottom: 0;

        scrollbar-width: none;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .x4a-product-nav::-webkit-scrollbar {
        display: none;
    }

    .x4a-product-theme-toggle {
        grid-area: theme;
        grid-column: auto;
        grid-row: auto;

        align-self: center;
        justify-self: end;

        margin: 0;
    }
}


/*
 * On the smallest phones keep the right-side theme control in the same
 * row while allowing the navigation area to consume every remaining
 * horizontal pixel.
 */
@media (max-width: 430px) {

    .x4a-product-topbar {
        column-gap: 6px;
    }

    .x4a-product-nav {
        min-width: 0;
    }

    .x4a-product-theme-toggle {
        flex: 0 0 auto;
    }
}



/* X4A 72A5E-R1 SMARTPHONE PRODUCT TOPBAR SAFE LAYOUT */
/*
 * At <=700px the theme toggle no longer competes with navigation.
 * Row 1: brand | theme
 * Row 2: full-width horizontally scrollable nav
 */
@media (max-width: 700px) {
    .x4a-product-topbar {
        grid-template-columns:
            minmax(0, 1fr)
            auto;
        grid-template-areas:
            "brand theme"
            "nav nav";
        column-gap: 8px;
        row-gap: 9px;
    }

    .x4a-product-brand {
        grid-area: brand;
        min-width: 0;
    }

    .x4a-product-theme-toggle {
        grid-area: theme;
        grid-column: auto;
        grid-row: auto;
        align-self: center;
        justify-self: end;
        margin: 0;
    }

    .x4a-product-nav {
        grid-area: nav;
        grid-column: 1 / -1;
        grid-row: 2;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .x4a-product-nav > a,
    .x4a-product-nav > .x4a-product-back {
        flex: 0 0 auto;
        min-width: max-content;
    }

    .x4a-product-nav::-webkit-scrollbar {
        display: none;
    }
}


/* X4A 72A5E-R2 SMARTPHONE NAV WRAP GRID */
/*
 * Phone navigation must never hide the final destination off-screen.
 * Auto-fit creates as many >=105px columns as fit; the remainder wraps.
 * Around 390-500px this is normally three columns, so six controls form
 * two balanced rows. Future destinations add rows rather than disappear.
 */
@media (max-width: 700px) {
    .x4a-product-nav {
        display: grid;
        grid-template-columns:
            repeat(
                auto-fit,
                minmax(105px, 1fr)
            );
        gap: 4px;
        overflow: visible;
        width: 100%;
        max-width: 100%;
    }

    .x4a-product-nav > a,
    .x4a-product-nav > .x4a-product-back {
        width: 100%;
        min-width: 0;
        max-width: none;
        justify-content: center;
        box-sizing: border-box;
        white-space: normal;
        text-align: center;
        line-height: 1.15;
    }
}
