/* overlay/reactions/reactions.css - Animated Bar-Racing & Reaction Fountain Styles */

:root {
    --bg-overlay: transparent;
    --bar-bg: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --gold: #f59e0b;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.overlay-body {
    background-color: #0b0f19;
    font-family: var(--font-family);
    color: var(--text-primary);
    min-height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden !important;
    user-select: none;
    -webkit-user-select: none;
}

body.overlay-body.is-obs,
body.overlay-body.transparent-bg {
    background-color: transparent !important;
}

/* Overlay Container */
.reaction-overlay-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden !important;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    pointer-events: none;
    box-sizing: border-box;
}

/* In-App Preview / Embedded Viewport Container */
.preview-stage .reaction-overlay-container {
    min-height: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden !important;
}

/* Vertical Alignment */
.reaction-overlay-container.valign-top {
    justify-content: flex-start;
}

.reaction-overlay-container.valign-center,
.reaction-overlay-container.valign-middle {
    justify-content: center;
}

.reaction-overlay-container.valign-bottom {
    justify-content: flex-end;
}

/* Horizontal Alignment */
.reaction-overlay-container.halign-left {
    align-items: flex-start;
}

.reaction-overlay-container.halign-center {
    align-items: center;
}

.reaction-overlay-container.halign-right {
    align-items: flex-end;
}

/* Glassmorphism theme */
.theme-glass .race-card {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

/* Cyber Neon theme */
.theme-neon .race-card {
    background: rgba(10, 10, 18, 0.94);
    border: 1px solid rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.3);
}

/* Transparent OBS Theme */
.theme-transparent .race-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
}

/* Dark Solid Theme */
.theme-dark .race-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Main Race Card */
.race-card {
    border-radius: 16px;
    padding: 14px 18px;
    max-width: 580px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
    pointer-events: auto;
    transform: scale(var(--overlay-scale, 1));
    transform-origin: var(--scale-origin, center bottom);
    box-sizing: border-box;
}

/* Horizontal positioning */
.halign-left .race-card {
    margin-left: 0;
    margin-right: auto;
}

.halign-center .race-card {
    margin-left: auto;
    margin-right: auto;
}

.halign-right .race-card {
    margin-left: auto;
    margin-right: 0;
}

/* Header */
.race-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.race-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.race-badge {
    background: linear-gradient(135deg, #ef4444, #f43f5e);
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 7px;
    border-radius: 20px;
    animation: pulseGlow 2s infinite;
}

.race-timeframe-badge {
    background: rgba(59, 130, 246, 0.22);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.race-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text-primary);
}

.stream-tab-pills {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.25);
    padding: 2px;
    border-radius: 8px;
}

.stream-tab-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stream-tab-pill.active {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

/* Leaderboard Bar Track Container */
.bars-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual Bar Track Row */
.bar-row {
    position: relative;
    display: flex;
    align-items: center;
    height: 34px;
    background: var(--bar-bg);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bar-row.is-leader {
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
    border: 1px solid rgba(245, 158, 11, 0.5);
}

/* The Animated Racing Fill */
.bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: width;
    z-index: 1;
}

/* Leader Shimmer Animation */
.bar-row.is-leader .bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
    animation: shimmer 2.2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(200%);
    }
}

/* Content on top of the bar */
.bar-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
}

.bar-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bar-emoji {
    font-size: 17px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.bar-label {
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.leader-crown {
    display: none;
    font-size: 12px;
    margin-left: 2px;
}

.bar-row.is-leader .leader-crown {
    display: inline-block;
    animation: bounceCrown 1.5s infinite;
}

.bar-count-group {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.bar-count {
    font-size: 14px;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    font-variant-numeric: tabular-nums;
}

.bar-percent {
    font-size: 11px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Floating Emoji Fountain */
.emoji-fountain {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 99;
}

.floating-particle {
    position: absolute;
    bottom: -30px;
    font-size: 26px;
    opacity: 0.95;
    pointer-events: none;
    will-change: transform, opacity;
    animation: floatUp 2.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(0.6) rotate(0deg);
        opacity: 0;
    }

    15% {
        opacity: 1;
        transform: translateY(-50px) scale(1.1) rotate(var(--rot-mid, -10deg));
    }

    80% {
        opacity: 0.85;
    }

    100% {
        transform: translateY(-420px) scale(0.9) rotate(var(--rot-end, 15deg));
        opacity: 0;
    }
}

@keyframes bounceCrown {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px) scale(1.15);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.85;
        transform: scale(0.96);
    }
}

/* Compact Ticker Layout Mode */
.layout-compact .race-card {
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 6px 10px;
}

/* Hide header by default on compact ticker for a sleek horizontal bar */
.layout-compact .race-header {
    display: none;
}

.layout-compact.show-header .race-header {
    display: flex;
    margin-bottom: 6px;
    padding-bottom: 4px;
}

.layout-compact .bars-container {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
}

.layout-compact .bar-row {
    flex: 1;
    min-width: 65px;
    height: 32px;
    border-radius: 8px;
}

/* Hide labels in compact ticker so they do NOT wrap into two lines */
.layout-compact .bar-label {
    display: none !important;
}

.layout-compact .bar-content {
    padding: 0 8px;
    white-space: nowrap;
}

.layout-compact .bar-meta {
    gap: 4px;
    white-space: nowrap;
}

.layout-compact .bar-emoji {
    font-size: 18px;
}

.layout-compact .bar-count {
    font-size: 13px;
    font-weight: 700;
}

.layout-compact .bar-percent {
    font-size: 10px;
    opacity: 0.85;
}

/* Banner Mode */
.layout-banner .race-card {
    max-width: 900px;
}

.layout-banner .bars-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

/* Beta Warning Banner */
.beta-restriction-box {
    background: rgba(220, 38, 38, 0.9);
    border: 1px solid #ef4444;
    border-radius: 12px;
    padding: 18px 24px;
    max-width: 520px;
    margin: auto;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.beta-restriction-box h3 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #ffffff;
}

.beta-restriction-box p {
    font-size: 13px;
    line-height: 1.5;
    color: #fee2e2;
}

/* Waiting for Stream Notice */
.waiting-notice-box {
    background: rgba(15, 23, 42, 0.88);
    border: 1px dashed rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 12px 18px;
    margin: 0 auto 12px auto;
    max-width: 540px;
    text-align: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.3s ease;
}

.waiting-notice-box h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 3px;
    color: #60a5fa;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.waiting-notice-box p {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.4;
}

.waiting-notice-box code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 4px;
    color: #e2e8f0;
    font-family: monospace;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* On-Screen Diagnostic Debug HUD (Toggled with 'D' or ?debug=1) */
.reaction-debug-hud {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    border-radius: 9999px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
    font-size: 11px;
    color: #cbd5e1;
    backdrop-filter: blur(8px);
    pointer-events: none;
    user-select: none;
    max-width: 95vw;
}

.reaction-debug-hud .hud-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.reaction-debug-hud strong {
    color: #94a3b8;
}

.reaction-debug-hud code {
    color: #38bdf8;
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 10px;
}

.reaction-debug-hud .hud-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    display: inline-block;
}

.reaction-debug-hud .hud-dot.active {
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
    animation: pulseDot 1.5s infinite;
}

.reaction-debug-hud .hud-hint {
    color: #64748b;
    font-size: 10px;
    margin-left: 4px;
}

@keyframes pulseDot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}