/* BusyBlocks custom styles */

/* Loading indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Card hover effects */
.card-hover {
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.card-hover:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Toast notifications */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 50;
    animation: toast-in 300ms ease-out;
}

.toast-exit {
    animation: toast-out 200ms ease-in forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Toggle switch: knob + track animation on HTMX swap */
button[data-state] {
    transition: background-color 200ms ease;
}
button[data-state] span {
    transition: transform 200ms ease;
}

/* Enabled toggle inserted — animate from disabled position */
@starting-style {
    button[data-state="on"] {
        background-color: #d1d5db; /* gray-300 */
    }
    button[data-state="on"] span {
        transform: translateX(0.25rem); /* translate-x-1 */
    }
}

/* Disabled toggle inserted — animate from enabled position */
@starting-style {
    button[data-state="off"] {
        background-color: #4f46e5; /* brand-600 */
    }
    button[data-state="off"] span {
        transform: translateX(1.5rem); /* translate-x-6 */
    }
}

/* Prose dark mode for legal pages */
.dark .prose {
    --tw-prose-body: #d1d5db;
    --tw-prose-headings: #f3f4f6;
    --tw-prose-links: #60a5fa;
}

/* Button press feedback */
button:active:not(:disabled),
a[class*="bg-brand"]:active {
    transform: scale(0.97);
    transition: transform 75ms ease;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Scroll-triggered entrance animations */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(1.5rem);
    transition: opacity 600ms ease, transform 600ms ease;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}


/* Day now-banner: slide-in entrance */
@keyframes banner-slide-in {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
}

.banner-active {
    animation: banner-slide-in 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Now-dot: expanding ring pulse */
@keyframes dot-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45); }
    50% { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0); }
}

.now-dot {
    animation: dot-glow 2s ease-in-out infinite;
}

/* Past events: subtle dim */
.event-past {
    opacity: 0.5;
}

/* Reduced motion: disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .card-hover {
        transition: none;
    }

    .toast {
        animation: none;
    }

    .toast-exit {
        animation: none;
    }

    .skeleton {
        animation: none;
    }

    .animate-pulse {
        animation: none;
    }

    .banner-active {
        animation: none;
    }

    .now-dot {
        animation: none;
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
        transition: none;
    }

    button:active:not(:disabled),
    a[class*="bg-brand"]:active {
        transform: none;
        transition: none;
    }


    #nav-progress::before {
        animation: none;
        width: 100%;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Global navigation progress bar */
#nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease;
}

#nav-progress.htmx-request {
    opacity: 1;
}

#nav-progress::before {
    content: '';
    display: block;
    height: 100%;
    background: #4f46e5;
    animation: nav-progress 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes nav-progress {
    0%   { width: 0; margin-left: 0; }
    50%  { width: 60%; margin-left: 20%; }
    100% { width: 0; margin-left: 100%; }
}

/* Conflict event pulse animation */
@keyframes conflict-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.3); }
}
