/* =====================================================
   QuizMaster AI - Custom Styles
   ===================================================== */

/* Alpine.js - Hide elements before initialization */
[x-cloak] {
    display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #0ea5e9, #d946ef);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #0284c7, #c026d3);
}

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

/* Loading Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin-slow {
    animation: spin 3s linear infinite;
}

/* Pulse Animation for Timer */
@keyframes pulse-warning {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.timer-warning {
    animation: pulse-warning 1s ease-in-out infinite;
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(to right, #0ea5e9, #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Card Hover Effects */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Button Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Progress Bar Animation */
@keyframes progress {
    from {
        width: 0%;
    }
}

.progress-bar {
    animation: progress 1s ease-out;
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.fade-in-delay-1 {
    animation: fadeIn 0.5s ease-out 0.1s both;
}

.fade-in-delay-2 {
    animation: fadeIn 0.5s ease-out 0.2s both;
}

.fade-in-delay-3 {
    animation: fadeIn 0.5s ease-out 0.3s both;
}

/* Slide In Animation */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

/* Bounce Animation */
@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

.bounce-in {
    animation: bounce-in 0.6s ease-out;
}

/* Shake Animation for Wrong Answers */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.5s;
}

/* Correct Answer Celebration */
@keyframes celebrate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.celebrate {
    animation: celebrate 0.5s ease-out;
}

/* Glow Effect */
.glow {
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.5);
}

.glow-primary {
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.5);
}

.glow-secondary {
    box-shadow: 0 0 20px rgba(217, 70, 239, 0.5);
}

.glow-success {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

.glow-error {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

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

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 300px;
    max-width: 500px;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
}

.toast.toast-success {
    background-color: #10b981;
    color: white;
}

.toast.toast-error {
    background-color: #ef4444;
    color: white;
}

.toast.toast-info {
    background-color: #0ea5e9;
    color: white;
}

/* Countdown Timer Styles */
.timer-circle {
    transition: stroke-dashoffset 1s linear;
}

/* Quiz Answer Button States */
.answer-btn {
    transition: all 0.3s ease;
    position: relative;
}

.answer-btn:hover:not(:disabled) {
    transform: translateX(5px);
}

.answer-btn.selected {
    border: 3px solid #0ea5e9;
}

.answer-btn.correct {
    background: linear-gradient(to right, #10b981, #059669);
    animation: celebrate 0.5s ease-out;
}

.answer-btn.incorrect {
    background: linear-gradient(to right, #ef4444, #dc2626);
    animation: shake 0.5s;
}

/* Leaderboard Entry Animation */
.leaderboard-entry {
    animation: slideInRight 0.3s ease-out;
}

.leaderboard-entry:nth-child(1) {
    animation-delay: 0.1s;
}

.leaderboard-entry:nth-child(2) {
    animation-delay: 0.2s;
}

.leaderboard-entry:nth-child(3) {
    animation-delay: 0.3s;
}

/* Podium Styles */
.podium-first {
    animation: bounce-in 0.8s ease-out;
}

.podium-second {
    animation: bounce-in 0.8s ease-out 0.2s both;
}

.podium-third {
    animation: bounce-in 0.8s ease-out 0.4s both;
}

/* Confetti Effect Container */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Loading Dots */
.loading-dots span {
    animation: loading-dots 1.4s infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-dots {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* Custom Focus Styles */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.5);
}

/* Disabled State */
.disabled-state {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .toast {
        bottom: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
    }
    
    .answer-btn:hover:not(:disabled) {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
}

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

/* Dark Mode Support (Future Enhancement) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here */
}

@keyframes achievementPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.25);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

@keyframes achievementPulse {
    0%, 100% {
        transform: scale(1);
        text-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
    }
    50% {
        transform: scale(1.1);
        text-shadow: 0 0 14px rgba(255, 215, 0, 1);
    }
}

.animate-achievement-pop {
    animation: achievementPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.animate-achievement-pulse {
    animation: achievementPulse 1.6s ease-in-out infinite;
}

.achievement-counter::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 9999px;
    border: 2px solid rgba(255, 215, 0, 0.6);
    animation: ringGlow 2s infinite;
}

@keyframes ringGlow {
    0% { opacity: 0; transform: scale(0.9); }
    50% { opacity: 1; }
    100% { opacity: 0; transform: scale(1.2); }
}
