/* ==========================================
   PERFORMANCE OPTIMIZATIONS
   ========================================== */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Hardware acceleration for animations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* CSS Containment for better performance */
.animate-dice-roll,
.animate-coin-flip,
.animate-spinner-cycle,
.animate-reveal-winner {
    contain: layout style paint;
}

/* Optimize animated elements */
[class*="animate-"] {
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: auto;
}

/* ==========================================
   MODERN NAME PICKER / SCROLLER
   ========================================== */

/* Overlay */
.picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.97) 0%, 
        rgba(30, 41, 59, 0.98) 50%,
        rgba(15, 23, 42, 0.97) 100%);
    backdrop-filter: blur(10px);
}

.picker-overlay-content {
    text-align: center;
    padding: 2rem;
    width: 100%;
    max-width: 500px;
}

/* Main container */
.picker-container {
    position: relative;
    margin: 0 auto 2rem;
}

/* Ambient glow */
.picker-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, 
        rgba(16, 185, 129, 0.25) 0%, 
        rgba(20, 184, 166, 0.15) 30%,
        transparent 70%);
    filter: blur(40px);
    animation: picker-pulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes picker-pulse {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

/* Scroller window */
.picker-window {
    position: relative;
    width: 340px;
    height: 400px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 24px;
    background: linear-gradient(180deg,
        rgba(30, 41, 59, 0.9) 0%,
        rgba(15, 23, 42, 0.95) 50%,
        rgba(30, 41, 59, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Fade gradients */
.picker-fade-top,
.picker-fade-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: 120px;
    pointer-events: none;
    z-index: 10;
}

.picker-fade-top {
    top: 0;
    background: linear-gradient(to bottom, 
        rgba(15, 23, 42, 1) 0%,
        rgba(15, 23, 42, 0.8) 40%,
        transparent 100%);
}

.picker-fade-bottom {
    bottom: 0;
    background: linear-gradient(to top, 
        rgba(15, 23, 42, 1) 0%,
        rgba(15, 23, 42, 0.8) 40%,
        transparent 100%);
}

/* Scrolling track */
.picker-track {
    will-change: transform;
    padding: 160px 0;
}

.scroller-fast {
    transition: transform 0.08s linear;
}

.scroller-decelerate {
    transition: transform 3.5s cubic-bezier(0.15, 0.8, 0.2, 1);
}

.scroller-stopped {
    transition: none;
}

/* Individual item */
.picker-item {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
}

.picker-item-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.02em;
    transition: all 0.15s ease;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 280px;
}

/* Selection highlight zone */
.picker-selection {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 24px);
    height: 84px;
    border-radius: 16px;
    border: 2px solid rgba(16, 185, 129, 0.6);
    background: linear-gradient(90deg,
        rgba(16, 185, 129, 0.1) 0%,
        rgba(20, 184, 166, 0.15) 50%,
        rgba(16, 185, 129, 0.1) 100%);
    pointer-events: none;
    z-index: 5;
}

.picker-selection-glow {
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    background: linear-gradient(90deg,
        rgba(16, 185, 129, 0.3) 0%,
        rgba(20, 184, 166, 0.4) 50%,
        rgba(16, 185, 129, 0.3) 100%);
    filter: blur(15px);
    opacity: 0.7;
    animation: selection-glow 2s ease-in-out infinite;
}

@keyframes selection-glow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.9; }
}

/* Side indicators */
.picker-indicator-left,
.picker-indicator-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60px;
    border-radius: 2px;
    background: linear-gradient(180deg, 
        transparent 0%,
        rgba(16, 185, 129, 0.8) 50%,
        transparent 100%);
    z-index: 15;
}

.picker-indicator-left { left: 8px; }
.picker-indicator-right { right: 8px; }

/* Floating particles */
.picker-particle {
    position: absolute;
    background: rgba(16, 185, 129, 0.6);
    border-radius: 50%;
    animation: particle-float 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes particle-float {
    0%, 100% { 
        opacity: 0;
        transform: translateY(100px) scale(0);
    }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { 
        opacity: 0;
        transform: translateY(-100px) scale(1);
    }
}

/* Status indicator */
.picker-status {
    margin-top: 2rem;
}

.picker-status-inner {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    font-size: 1rem;
}

.picker-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: status-pulse 1s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Mobile responsive */
@media (max-width: 480px) {
    .picker-window {
        width: 300px;
        height: 350px;
    }
    
    .picker-item {
        height: 70px;
    }
    
    .picker-item-text {
        font-size: 1.25rem;
    }
    
    .picker-selection {
        height: 74px;
    }
    
    .picker-track {
        padding: 140px 0;
    }
}

/* ==========================================
   BLOB ANIMATIONS (BACKGROUND)
   ========================================== */

@keyframes blob {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

.animate-blob {
    animation: blob 7s ease-in-out infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

.animation-delay-4000 {
    animation-delay: 4s;
}

/* ==========================================
   PULSE & LOADING ANIMATIONS
   ========================================== */

@keyframes pulse-slow {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.animate-pulse-slow {
    animation: pulse-slow 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.animate-pulse-ring {
    animation: pulse-ring 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* ==========================================
   FADE ANIMATIONS
   ========================================== */

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

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

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
    opacity: 0;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out forwards;
    opacity: 0;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-fade-in-scale {
    animation: fadeInScale 0.5s ease-out forwards;
    opacity: 0;
}

/* ==========================================
   WINNER REVEAL ANIMATIONS
   ========================================== */

@keyframes revealWinner {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(-50px);
        filter: blur(10px) brightness(2);
    }

    50% {
        transform: scale(1.15) translateY(0);
        filter: blur(0px) brightness(1.5);
    }

    70% {
        transform: scale(0.95);
    }

    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px) brightness(1);
    }
}

.animate-reveal-winner {
    animation: revealWinner 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
}

@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);
    }
}

.animate-bounce-in {
    animation: bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes winner-glow {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 25px rgba(251, 191, 36, 0.9));
    }
}

.animate-winner-glow {
    animation: winner-glow 1.5s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* ==========================================
   EXCITEMENT ANIMATIONS
   ========================================== */

@keyframes containerShake {
    0%, 100% {
        transform: translateX(0);
    }

    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-2px);
    }

    20%, 40%, 60%, 80% {
        transform: translateX(2px);
    }
}

.animate-shake {
    animation: containerShake 0.5s ease-in-out;
}

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

    50% {
        transform: translateY(-10px);
    }
}

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

/* ==========================================
   CONFETTI & CELEBRATION
   ========================================== */

@keyframes confetti {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti 3s ease-out forwards;
    pointer-events: none;
}

/* ==========================================
   WINNER CARD ANIMATION
   ========================================== */

@keyframes winner-card-enter {
    0% {
        opacity: 0;
        transform: translateX(-50px) scale(0.8);
    }

    60% {
        transform: translateX(10px) scale(1.05);
    }

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

.winner-card {
    animation: winner-card-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

/* ==========================================
   DICE & COIN ANIMATIONS
   ========================================== */

@keyframes diceRoll3D {
    0% {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    }

    25% {
        transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg);
    }

    50% {
        transform: rotateX(360deg) rotateY(270deg) rotateZ(180deg);
    }

    75% {
        transform: rotateX(540deg) rotateY(450deg) rotateZ(315deg);
    }

    100% {
        transform: rotateX(720deg) rotateY(720deg) rotateZ(360deg);
    }
}

.animate-dice-roll {
    animation: diceRoll3D 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateZ(0);
    backface-visibility: hidden;
}

@keyframes coinFlip3D {
    0% {
        transform: rotateY(0deg) translateY(0) translateZ(0);
    }

    25% {
        transform: rotateY(360deg) translateY(-30px) translateZ(0);
    }

    50% {
        transform: rotateY(720deg) translateY(0) translateZ(0);
    }

    75% {
        transform: rotateY(1080deg) translateY(-20px) translateZ(0);
    }

    100% {
        transform: rotateY(1440deg) translateY(0) translateZ(0);
    }
}

.animate-coin-flip {
    animation: coinFlip3D 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ==========================================
   GRADIENT ANIMATIONS
   ========================================== */

@keyframes gradient-shift {
    0%, 100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.animate-gradient {
    background-size: 200% 200%;
    animation: gradient-shift 3s ease infinite;
}

/* ==========================================
   HOVER EFFECTS
   ========================================== */

.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.hover-scale {
    transition: transform 0.2s ease;
}

    .hover-scale:hover {
        transform: scale(1.05);
    }

.hover-glow {
    transition: box-shadow 0.3s ease;
}

    .hover-glow:hover {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    }

/* ==========================================
   LOADING STATES
   ========================================== */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

/* ==========================================
   ACCESSIBILITY
   ========================================== */

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 100;
    transition: top 0.3s;
    border-radius: 0 0 0.375rem 0;
}

    .skip-to-content:focus {
        top: 0;
    }

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

/* ==========================================
   MOBILE OPTIMIZATIONS
   ========================================== */

@media (max-width: 768px) {
    .wheel-container {
        width: 300px;
        height: 300px;
    }

    .wheel-outer-ring {
        inset: -10px;
    }

    .wheel-segment-text {
        font-size: 0.7rem;
        max-width: 65px;
        padding: 2px 6px;
    }

    .wheel-segment-inner {
        top: 10px;
    }

    .wheel-center {
        width: 55px;
        height: 55px;
    }

    .wheel-center-inner {
        width: 35px;
        height: 35px;
    }

    .wheel-pointer {
        top: -6px;
        border-left: 14px solid transparent;
        border-right: 14px solid transparent;
        border-top: 26px solid #dc2626;
    }

    .wheel-pointer::before {
        top: -26px;
        left: -14px;
        width: 28px;
        height: 26px;
    }

    .wheel-peg {
        width: 6px;
        height: 6px;
    }
}

@media (max-width: 480px) {
    .wheel-container {
        width: 260px;
        height: 260px;
    }

    .wheel-segment-text {
        font-size: 0.65rem;
        max-width: 55px;
    }

    .wheel-center {
        width: 45px;
        height: 45px;
    }

    .wheel-center-inner {
        width: 30px;
        height: 30px;
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    nav,
    footer,
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }
}
