/**
 * =========================================
 * TEXT MARQUEE COMPONENT
 * =========================================
 * 
 * Reusable scrolling text animation for long usernames
 * or any text that exceeds container width.
 * 
 * Usage:
 *   <div class="text-marquee">
 *     <div class="marquee">
 *       <p>Your long text here...</p>
 *     </div>
 *   </div>
 * 
 * Or use with TextMarquee.init() JavaScript utility
 */

/* ============================================
 * BASE MARQUEE STRUCTURE
 * ============================================ */

.text-marquee,
.marquee {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.text-marquee {
    width: 100%;
    max-width: 100%;
}

.marquee {
    margin: 0.1em;
    z-index: 1;
}

.marquee p {
    display: inline-block;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    /* Duration set by JavaScript or inline style */
    animation: marquee-scroll var(--scroll-duration, 9s) linear infinite;
    will-change: transform;
}

/* ============================================
 * MARQUEE ANIMATION
 * ============================================ */

@keyframes marquee-scroll {
    0% {
        transform: translateX(100%);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* ============================================
 * MARQUEE MODIFIERS
 * ============================================ */

/* Pause on hover */
.text-marquee--pause-hover:hover .marquee p,
.marquee--pause-hover:hover p {
    animation-play-state: paused;
}

/* Slower speed */
.text-marquee--slow .marquee p,
.marquee--slow p {
    animation-duration: var(--scroll-duration-slow, 15s);
}

/* Faster speed */
.text-marquee--fast .marquee p,
.marquee--fast p {
    animation-duration: var(--scroll-duration-fast, 5s);
}

/* ============================================
 * FADE TRANSITIONS
 * ============================================ */

@keyframes marquee-fade-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes marquee-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Apply fade when updating content */
.text-marquee--fading-out .marquee,
.marquee--fading-out {
    animation: marquee-fade-out 0.3s ease-out forwards;
}

.text-marquee--fading-in .marquee,
.marquee--fading-in {
    animation: marquee-fade-in 0.3s ease-in forwards;
}

/* ============================================
 * COMMON STYLING VARIANTS
 * ============================================ */

/* Username variant (gold with glow) */
.text-marquee--username .marquee p,
.marquee--username p {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #ffd700;
    font-weight: 600;
    text-shadow:
        0 0 5px rgba(255, 215, 0, 0.6),
        0 0 10px rgba(255, 215, 0, 0.3);
    letter-spacing: 0.5px;
}

/* Monospace variant */
.text-marquee--mono .marquee p,
.marquee--mono p {
    font-family: 'Courier New', 'Courier', monospace;
    letter-spacing: 1px;
}

/* Compact variant (smaller text) */
.text-marquee--compact .marquee p,
.marquee--compact p {
    font-size: 0.85em;
}

/* Large variant */
.text-marquee--large .marquee p,
.marquee--large p {
    font-size: 1.2em;
}

/* ============================================
 * AVATAR OVERLAY VARIANT
 * ============================================ */

/* Used specifically for avatar username overlays */
.text-marquee--avatar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg,
            rgba(250, 250, 250, 0) 0%,
            rgba(78, 80, 83, 0.9) 50%,
            rgba(0, 0, 0, 0.86) 100%);
    overflow: hidden;
    border-radius: 0 0 var(--radius-lg, 12px) var(--radius-lg, 12px);
    box-shadow: inset 0 0 20px rgba(255, 200, 0, 0.1);
    padding: 2px 0;
}

.text-marquee--avatar .marquee p {
    font-size: 0.7rem;
    letter-spacing: 1px;
    color: #ffd700;
    font-weight: 500;
}

/* ============================================
 * RESPONSIVE ADJUSTMENTS
 * ============================================ */

@media (max-width: 768px) {
    .text-marquee--avatar .marquee p {
        font-size: 0.65rem;
    }
}

/* ============================================
 * ACCESSIBILITY
 * ============================================ */

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .marquee p {
        animation: none;
        transform: translateX(0);
        /* Show text statically if animation is disabled */
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        max-width: 100%;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {

    .text-marquee--username .marquee p,
    .marquee--username p {
        text-shadow: none;
        font-weight: 700;
    }
}