/* =========================================================================
   Live Now Mini-Player — bottom-left dock, sibling to the Radio Player.
   Same compact-bar / expanding-panel pattern, themed in red/pink for LIVE.

   Visibility rules (handled in live-now-toast.js):
     • Only shows after the user has scrolled PAST the home Hero "Live Now"
       panel (intersection observer). Outside the home, shows whenever
       streams exist.
     • Hides immediately if there are no watchable streams (peerId valid).
     • Hides if the user explicitly closes it; comes back when a brand-new
       stream id appears later in the same session.
   ========================================================================= */

/* Hide the legacy left-edge toggle button — replaced by this widget */
body.modern-ui-theme .live-streams-toggle,
.live-streams-toggle {
    display: none !important;
}

/* Reusable theme colors */
:root {
    --lnt-red:    #ff2d55;
    --lnt-pink:   #ff4d7a;
    --lnt-orange: #ff6a00;
}

/* ---------- Container / docking ---------- */
#liveNowToast {
    position: fixed;
    /* Sit on the bottom-right edge, just to the LEFT of the chat
       toggle button (which is 65px + 20px right). When the chat panel
       opens (it covers right:20 / bottom:90 / width:420), the JS hides
       us so we never overlap. */
    bottom: 20px;
    right: 100px;
    z-index: 99980;
    font-family: 'Courier New', monospace;
    user-select: none;
    transition: opacity 0.32s ease, transform 0.32s ease, visibility 0.32s;
    pointer-events: auto;
}
#liveNowToast.lnt-hidden {
    opacity: 0 !important;
    transform: translateY(16px) !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* On narrow screens drop above the bottom-nav */
@media (max-width: 640px) {
    #liveNowToast { right: 90px; bottom: 76px; }
}
@media (max-width: 480px) {
    /* Tiny phones: not enough room beside chat → above it */
    #liveNowToast { right: 10px; left: auto; bottom: 96px; }
}

/* ---------- Compact bar (always visible while widget is open) ---------- */
.lnt-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 8px 0 10px;
    background: linear-gradient(90deg, rgba(8,8,20,0.98) 0%, rgba(28,8,18,0.98) 100%);
    border: 1px solid rgba(255, 45, 85, 0.45);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(255, 45, 85, 0.18), inset 0 1px 0 rgba(255,255,255,0.05);
    transition: border-color 0.3s, box-shadow 0.3s;
    min-width: 240px;
    max-width: 320px;
    position: relative;
    overflow: hidden;
}
.lnt-bar::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        0deg, transparent, transparent 2px,
        rgba(0,0,0,0.1) 2px, rgba(0,0,0,0.1) 4px
    );
    pointer-events: none;
    border-radius: inherit;
    z-index: 1;
}
.lnt-bar:hover {
    border-color: rgba(255, 77, 122, 0.95);
    box-shadow: 0 0 28px rgba(255, 45, 85, 0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* Persistent glow ring */
.lnt-glow-ring {
    position: absolute;
    inset: -1px;
    border-radius: 9px;
    box-shadow:
        0 0 0 1px rgba(255, 45, 85, 0.55),
        0 0 18px rgba(255, 45, 85, 0.35),
        0 0 32px rgba(255, 106, 0, 0.15);
    pointer-events: none;
    opacity: 0.85;
    z-index: 0;
    will-change: opacity;
    animation: lntGlowPulse 2.2s ease-in-out infinite;
}
@keyframes lntGlowPulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* Equalizer (left side of the bar) */
.lnt-bar-left { flex-shrink: 0; position: relative; z-index: 3; }
.lnt-equalizer {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 20px;
}
.lnt-equalizer span {
    width: 3px;
    border-radius: 2px 2px 0 0;
    background: linear-gradient(to top, var(--lnt-red) 0%, var(--lnt-pink) 60%, rgba(255, 106, 0, 0.6) 100%);
    transform-origin: bottom;
    animation: lntEqBar 0.7s ease-in-out infinite alternate;
    will-change: transform;
    opacity: 1;
}
.lnt-equalizer span:nth-child(1) { height:  9px; animation-duration: 0.55s; animation-delay: 0s; }
.lnt-equalizer span:nth-child(2) { height: 16px; animation-duration: 0.72s; animation-delay: 0.08s; }
.lnt-equalizer span:nth-child(3) { height: 20px; animation-duration: 0.48s; animation-delay: 0.16s; }
.lnt-equalizer span:nth-child(4) { height: 12px; animation-duration: 0.80s; animation-delay: 0.05s; }
.lnt-equalizer span:nth-child(5) { height: 15px; animation-duration: 0.62s; animation-delay: 0.22s; }
@keyframes lntEqBar { from { transform: scaleY(0.4); } to { transform: scaleY(1); } }

/* Center: LIVE badge + ticker */
.lnt-bar-center {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 3;
}
.lnt-live-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 45, 85, 0.14);
    border: 1px solid rgba(255, 45, 85, 0.5);
    border-radius: 3px;
    padding: 2px 6px;
    flex-shrink: 0;
}
.lnt-live-badge span:last-child {
    font-size: 8px;
    font-weight: 700;
    color: var(--lnt-pink);
    letter-spacing: 1px;
}
.lnt-live-dot {
    width: 6px;
    height: 6px;
    background: var(--lnt-red);
    border-radius: 50%;
    animation: lntLivePulse 1.2s ease-in-out infinite;
    will-change: opacity;
}
@keyframes lntLivePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(0.85); }
}

/* Marquee ticker showing streamer + game */
.lnt-marquee-wrap {
    overflow: hidden;
    flex: 1;
    min-width: 0;
}
.lnt-marquee {
    font-size: 10px;
    color: rgba(255,255,255,0.85);
    letter-spacing: 0.3px;
    white-space: nowrap;
    display: inline-block;
    /* Pause animation if the message fits inside the wrap (avoids a
       single short title scrolling out of view). */
    animation: lntMarquee 22s linear infinite;
    will-change: transform;
}
@keyframes lntMarquee {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* Right side: chevron + close button */
.lnt-bar-right {
    flex-shrink: 0;
    margin-left: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 3;
}
.lnt-chevron {
    color: rgba(255, 77, 122, 0.6);
    transition: transform 0.3s, color 0.2s;
}
#liveNowToast.lnt-open .lnt-chevron { transform: rotate(180deg); color: var(--lnt-pink); }

.lnt-close-x {
    width: 22px; height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.55);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.lnt-close-x:hover {
    background: rgba(255, 45, 85, 0.18);
    color: #fff;
    border-color: rgba(255, 45, 85, 0.5);
}

/* ---------- Expanded panel (sits above the bar) ---------- */
.lnt-panel {
    position: absolute;
    bottom: 50px;
    /* Anchor to the right edge so the panel grows leftward and stays
       on-screen when the bar is docked at the right. */
    right: 0;
    width: 296px;
    background: linear-gradient(160deg, rgba(14,4,12,0.99) 0%, rgba(28,6,18,0.99) 100%);
    border: 1px solid rgba(255, 45, 85, 0.45);
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
        0 -4px 40px rgba(255, 45, 85, 0.22),
        0 8px 40px rgba(0,0,0,0.7);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.26s cubic-bezier(0.4,0,0.2,1),
                transform 0.26s cubic-bezier(0.4,0,0.2,1),
                visibility 0.26s;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.1) 2px, rgba(0,0,0,0.1) 4px),
        linear-gradient(160deg, rgba(14,4,12,0.99) 0%, rgba(28,6,18,0.99) 100%);
}
#liveNowToast.lnt-open .lnt-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}
.lnt-panel::before {
    content: '';
    display: block;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--lnt-red), var(--lnt-pink), var(--lnt-orange), var(--lnt-pink), var(--lnt-red), transparent);
    background-size: 200% 100%;
    animation: lntAccent 3s linear infinite;
    will-change: background-position;
}
@keyframes lntAccent {
    0%   { background-position: 0% 0; }
    100% { background-position: -200% 0; }
}

.lnt-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(255, 45, 85, 0.12);
}
.lnt-panel-logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.55);
    letter-spacing: 1.5px;
}
.lnt-panel-logo svg { color: var(--lnt-pink); }
.lnt-panel-status {
    font-size: 9px;
    font-weight: 700;
    color: var(--lnt-red);
    letter-spacing: 1px;
    animation: lntLivePulse 1.2s ease-in-out infinite;
    will-change: opacity;
}

/* Stream preview thumbnail (with optional P2P video) */
.lnt-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #000 center / cover no-repeat;
    overflow: hidden;
}
.lnt-thumb video {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    background: #000;
    display: none;
}
.lnt-thumb video.lnt-active { display: block; }
.lnt-thumb-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.55));
    pointer-events: none;
}
.lnt-thumb-loading::before {
    content: '';
    width: 14px; height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--lnt-red);
    border-radius: 50%;
    margin-right: 6px;
    animation: lntSpin 0.9s linear infinite;
}
@keyframes lntSpin { to { transform: rotate(360deg); } }
.lnt-thumb.lnt-has-video .lnt-thumb-loading { display: none; }

/* Streamer info row */
.lnt-info {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
}
.lnt-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--lnt-red), var(--lnt-orange));
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.08);
}
.lnt-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lnt-meta { min-width: 0; flex: 1; }
.lnt-streamer {
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Space Grotesk', sans-serif;
}
.lnt-game-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    min-width: 0;
}
.lnt-cover-mini {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #0a0a14;
}
.lnt-game {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Space Grotesk', sans-serif;
    flex: 1;
    min-width: 0;
}

/* Action row */
.lnt-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px 14px;
    border-top: 1px solid rgba(255, 45, 85, 0.1);
}
.lnt-watch-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    background: linear-gradient(135deg, var(--lnt-red), var(--lnt-orange));
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(255, 45, 85, 0.28);
    transition: transform 0.15s, box-shadow 0.15s;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.lnt-watch-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(255, 45, 85, 0.45); }
.lnt-watch-btn:active { transform: scale(0.97); }

.lnt-nav-arrows {
    display: flex;
    gap: 4px;
}
.lnt-nav {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}
.lnt-nav:hover {
    background: rgba(255, 45, 85, 0.18);
    border-color: rgba(255, 45, 85, 0.5);
    color: #fff;
}
.lnt-nav:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Counter (X of Y) shown when there are 2+ streams */
.lnt-counter {
    margin: 0 10px 8px;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.5px;
    text-align: center;
}

@media (max-width: 600px) {
    .lnt-panel { width: calc(100vw - 32px); max-width: 320px; }
    .lnt-bar  { min-width: 0; max-width: calc(100vw - 32px); }
}
