/* BAM Marquee Bar — Frontend Styles */

#bam-marquee-bar {
    background: var(--bam-bg, #1a3a5c);
    color: var(--bam-color, #ffffff);
    font-size: var(--bam-size, 14px);
    height: var(--bam-height, 34px);
    line-height: var(--bam-height, 34px);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    /* Use the theme's font — no font-family override */
}

/* When NOT sticky, just sits in normal flow at top */
#bam-marquee-bar:not([style*="fixed"]) {
    position: relative;
}

/* Link wrap — makes entire bar clickable */
#bam-marquee-bar .bam-link-wrap {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

#bam-marquee-bar .bam-link-wrap:hover {
    opacity: 0.9;
}

#bam-marquee-bar .bam-link-wrap:focus {
    outline: 2px solid rgba(255,255,255,0.6);
    outline-offset: -2px;
}

/* The scrolling track */
.bam-track {
    display: flex;
    width: max-content;
    animation: bamScroll var(--bam-speed, 30s) linear infinite;
    will-change: transform;
}

.bam-inner {
    display: flex;
    align-items: center;
    white-space: nowrap;
    padding: 0;
}

.bam-item {
    padding: 0 8px;
    font-weight: 500;
}

.bam-item a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bam-sep {
    opacity: 0.6;
}

/* Scroll animation */
@keyframes bamScroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ─── Static / centered single-item mode ─────────────────────
   Used when:
   - PHP renders bar-mode-static (admin chose "Always center"), OR
   - JS adds bam-is-static at runtime in 'auto' mode because the
     single item fits the viewport without overflowing.
*/
#bam-marquee-bar.bam-mode-static .bam-static-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    text-align: center;
}

#bam-marquee-bar.bam-is-static .bam-track {
    animation: none;
    justify-content: center;
    width: 100%;
}

/* In runtime-static mode, hide the duplicate copy so the single
   item stays cleanly centered. */
#bam-marquee-bar.bam-is-static .bam-inner:nth-child(2) {
    display: none;
}

#bam-marquee-bar.bam-is-static .bam-inner {
    flex: 0 1 auto;
}

/* Hide the trailing separator after the final item when static
   (it's only meaningful between items in a scroll loop). */
#bam-marquee-bar.bam-is-static .bam-inner > .bam-sep:last-child {
    display: none;
}

/* Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .bam-track {
        animation: none;
        justify-content: center;
        overflow: hidden;
    }
}
