/**
 * Top Banner Styles
 * V1.0 by BLAR
 */

#topbanner {
    width: 100%;
    padding: 1px 5px;
    position: relative;
    overflow: hidden;
    z-index: 2;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    box-sizing: border-box;
    /* Driven by the template via the --banner-min-height custom property so
       that media queries below can override it predictably (an inline
       min-height would always win over stylesheet rules). */
    min-height: var(--banner-min-height, 10px);
}

/* Text alignment classes */
#topbanner[style*="text-align: left"] {
    justify-content: flex-start;
}

#topbanner[style*="text-align: center"] {
    justify-content: center;
}

#topbanner[style*="text-align: right"] {
    justify-content: flex-end;
}

.topbanner-container {
    max-width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.topbanner-content {
    display: inline-block;
    white-space: nowrap;
    padding: 0;
}

.topbanner-content a {
    color: inherit;
    text-decoration: underline;
}

.topbanner-content a:hover {
    opacity: 0.8;
}

/* Static Animation (No Animation) */
.topbanner-static .topbanner-content {
    white-space: normal;
    display: block;
}

/* Slide Animation (Scrolling Text) */
.topbanner-slide .topbanner-slider {
    display: flex;
    animation: slide-animation var(--slide-speed, 30s) linear infinite;
}

.topbanner-slide .topbanner-content {
    padding-right: var(--scroll-spacing, 100px);
    flex-shrink: 0;
}

@keyframes slide-animation {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Fade Animation */
.topbanner-fade .topbanner-content {
    animation: fade-animation var(--fade-speed, 3s) ease-in-out infinite;
    white-space: normal;
    display: block;
}

@keyframes fade-animation {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #topbanner {
        font-size: 12px;
        padding: 1px 15px;
        min-height: var(--banner-min-height, 10px);
    }

    /* Keep slide animation working on mobile */
    .topbanner-slide .topbanner-content {
        padding-right: 50px;
    }

    /* Allow text wrapping for static and fade animations only */
    .topbanner-static .topbanner-content,
    .topbanner-fade .topbanner-content {
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Ensure static and fade banners can grow in height if needed */
    .topbanner-static,
    .topbanner-fade {
        min-height: 40px;
        height: auto;
    }
}

@media (max-width: 480px) {
    #topbanner {
        font-size: 11px;
        padding: 1px 10px;
        min-height: var(--banner-min-height, 10px);
    }

    /* Reduce spacing for slide animation on very small screens */
    .topbanner-slide .topbanner-content {
        padding-right: 30px;
    }

    /* Allow text wrapping for static and fade animations */
    .topbanner-static .topbanner-content,
    .topbanner-fade .topbanner-content {
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        display: block;
    }

    /* Ensure static and fade banners can grow in height on mobile */
    .topbanner-static,
    .topbanner-fade {
        min-height: 40px;
        height: auto;
    }
}

/* Additional styling for better appearance */
#topbanner strong {
    font-weight: 700;
}

#topbanner em {
    font-style: italic;
}

#topbanner u {
    text-decoration: underline;
}

/* Respect users who prefer reduced motion: stop scrolling/fading animations
   (WCAG 2.2.2 - Pause, Stop, Hide). */
@media (prefers-reduced-motion: reduce) {
    .topbanner-slide .topbanner-slider,
    .topbanner-fade .topbanner-content {
        animation: none !important;
    }

    .topbanner-slide .topbanner-content {
        white-space: normal;
    }
}
