/* Enhanced Animations and Visual Feedback */

/* Resource Change Animations */
@keyframes resourceIncrease {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.3);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

@keyframes resourceDecrease {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(0.95);
        filter: brightness(0.7);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

.resource-bar.increasing {
    animation: resourceIncrease 0.6s ease-out;
}

.resource-bar.decreasing {
    animation: resourceDecrease 0.6s ease-out;
}

/* Resource Change Particles */
@keyframes particleFloat {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) translateX(var(--particle-x, 0)) scale(0);
        opacity: 0;
    }
}

.resource-particle {
    position: absolute;
    font-size: 18px;
    font-weight: bold;
    pointer-events: none;
    animation: particleFloat 1.2s ease-out forwards;
    --particle-x: calc((random() - 0.5) * 40px);
}

.resource-particle.positive {
    color: var(--color-green);
}

.resource-particle.negative {
    color: var(--color-red);
}

/* Card Hover Interactions */
.card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Decision Preview Effects */
@keyframes decisionPreview {
    0% {
        opacity: 0;
        transform: translateX(var(--preview-direction, 0));
    }
    100% {
        opacity: 0.8;
        transform: translateX(0);
    }
}

.decision-preview {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    padding: var(--spacing-md);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: var(--radius-md);
    font-size: 14px;
    animation: decisionPreview 0.2s ease-out;
    pointer-events: none;
}

.decision-preview.left {
    left: -150px;
    --preview-direction: 20px;
}

.decision-preview.right {
    right: -150px;
    --preview-direction: -20px;
}

/* Phase Transition Screen */
@keyframes phaseTransitionIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.phase-transition-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: modalFadeIn 0.5s ease-out;
}

.phase-transition-screen.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.phase-transition-content {
    text-align: center;
    animation: phaseTransitionIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.phase-number {
    font-size: 120px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--spacing-md);
}

/* Game Over Effects */
@keyframes gameOverReveal {
    0% {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.game-over-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}

.game-over-content {
    text-align: center;
    max-width: 600px;
    padding: var(--spacing-xl);
    animation: gameOverReveal 1s ease-out;
}

/* Typewriter Effect for Story Text */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 3s steps(40) 1s forwards;
    position: relative;
}

.typewriter::after {
    content: '|';
    position: absolute;
    right: 0;
    animation: blink 1s infinite;
}

/* Competitor Progress Warning */
@keyframes competitorWarning {
    0%, 100% {
        transform: translateX(0);
        opacity: 0.8;
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.competitor-warning {
    position: fixed;
    top: 100px;
    right: 20px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    animation: competitorWarning 2s ease-in-out;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.3);
}

/* Resource Critical State */
@keyframes criticalFlash {
    0%, 100% {
        background-color: var(--color-red);
    }
    50% {
        background-color: white;
    }
}

.resource-bar-container.critical .resource-bar {
    animation: criticalFlash 0.8s ease-in-out 2;
}

/* Success Confetti */
@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(300px) rotate(720deg);
        opacity: 0;
    }
}

.confetti-particle {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--confetti-color);
    animation: confetti 3s ease-out forwards;
    z-index: 5000;
}

/* Card Stack Effect */
@keyframes stackBehind {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(20px) scale(0.95);
        opacity: 0.5;
    }
}

/* Card stack effects removed to eliminate grey rectangles */

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

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Newspaper Entrance */
@keyframes newspaperUnfold {
    0% {
        transform: perspective(1000px) rotateX(90deg) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: perspective(1000px) rotateX(45deg) scale(0.8);
        opacity: 0.7;
    }
    100% {
        transform: perspective(1000px) rotateX(0deg) scale(1);
        opacity: 1;
    }
}

.newspaper-modal.active .newspaper {
    animation: newspaperUnfold 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Special Effects for Different Endings */
/* Removed flashing animations for endings */

.ending-aligned {
    /* No animation - removed distracting flashing lights */
}

.ending-rogue {
    /* No animation - removed distracting flashing lights */
}

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