/* Tactile micro-interactions, staggered entrances & live broadcast motion */

@keyframes fade-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes bar-grow {
    from {
        transform: scaleY(0);
    }
    to {
        transform: scaleY(1);
    }
}

@keyframes accent-sweep {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes live-ping {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(220, 38, 38, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

@keyframes sync-ping {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes gold-glow {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(234, 179, 8, 0.16), var(--shadow);
    }
    50% {
        box-shadow: 0 8px 26px rgba(234, 179, 8, 0.28), var(--shadow);
    }
}

/* 1. Animated Emerald-Gold Top Accent Sweep */
.topbar::before,
.public-top::before {
    background: linear-gradient(90deg, #0d5c4d 0%, #189980 35%, #d49b38 65%, #0d5c4d 100%);
    background-size: 220% 100%;
    animation: accent-sweep 12s ease-in-out infinite;
}

/* 2. Hero Banner Ambient Glow & Smooth Entrance */
.event-heading {
    position: relative;
    overflow: hidden;
    animation: fade-rise 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.event-heading::after {
    content: "";
    position: absolute;
    inset-block-start: -55px;
    inset-inline-end: -45px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 155, 56, 0.14) 0%, rgba(13, 92, 77, 0.06) 45%, transparent 72%);
    pointer-events: none;
}

.event-heading > * {
    position: relative;
    z-index: 1;
}

/* 3. Staggered Stat & Highlight Cards */
.stats .stat,
.public-highlights .highlight-card {
    animation: fade-rise 340ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stats .stat:nth-child(1),
.public-highlights .highlight-card:nth-child(1) { animation-delay: 30ms; }
.stats .stat:nth-child(2),
.public-highlights .highlight-card:nth-child(2) { animation-delay: 75ms; }
.stats .stat:nth-child(3),
.public-highlights .highlight-card:nth-child(3) { animation-delay: 120ms; }
.stats .stat:nth-child(4),
.public-highlights .highlight-card:nth-child(4) { animation-delay: 165ms; }

.workspace .stat {
    transition:
        transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 200ms ease,
        border-color 180ms ease;
}

.workspace .stat:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(15, 36, 33, 0.09);
}

.workspace .stat .tile-icon,
.highlight-card .tile-icon {
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.workspace .stat:hover .tile-icon,
.highlight-action:hover .tile-icon {
    transform: scale(1.1) rotate(-4deg);
}

/* 4. Panels & Backstage Cards Smooth Entrance */
.panel {
    animation: fade-rise 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.backstage-card {
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.backstage-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 36, 33, 0.07);
}

/* 5. Live Radar Pulse Dots */
.nav-live-dot {
    animation: live-ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.live-pill:not(.wait):not(.sync-paused) .dot {
    animation: sync-ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* 6. Tactile Buttons, Chips & Sidebar Hover Nudge */
.btn,
.quick-chip,
.preset-chip,
.icon-btn {
    transition:
        transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
        background-color 150ms ease,
        border-color 150ms ease,
        box-shadow 180ms ease,
        color 140ms ease;
}

.btn:not(:disabled):active,
.quick-chip:active,
.preset-chip:active,
.icon-btn:active {
    transform: scale(0.97);
}

.btn:not(.secondary):not(.ghost):not(.danger) {
    position: relative;
    overflow: hidden;
}

.btn:not(.secondary):not(.ghost):not(.danger)::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.22) 50%, transparent 80%);
    transform: translateX(-120%);
    transition: transform 520ms ease;
    pointer-events: none;
}

.btn:not(.secondary):not(.ghost):not(.danger):hover:not(:disabled)::after {
    transform: translateX(120%);
}

.sidebar .nav-item {
    transition:
        transform 160ms ease,
        background-color 150ms ease,
        color 150ms ease,
        box-shadow 160ms ease;
}

.sidebar .nav-item:hover:not(.active) {
    transform: translateX(2px);
}

html[dir="rtl"] .sidebar .nav-item:hover:not(.active) {
    transform: translateX(-2px);
}

/* 7. Animated Bar Charts */
.chart-bar {
    transform-origin: bottom center;
    animation: bar-grow 480ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* 8. Celebratory Top-3 Podium Motion */
.podium-card {
    animation: fade-rise 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.podium-card.rank-3 { animation-delay: 40ms; }
.podium-card.rank-2 { animation-delay: 110ms; }
.podium-card.rank-1 {
    animation:
        fade-rise 420ms cubic-bezier(0.22, 1, 0.36, 1) 180ms both,
        gold-glow 3.4s ease-in-out 600ms infinite;
}

.podium-card:hover {
    transform: translateY(-4px);
}

/* 9. Modal Pop-in & Toast Slide-in */
dialog:not(.drawer)[open] {
    animation: modal-pop 200ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

#toast:not(:empty) {
    animation: toast-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* 10. Respect Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
