/**
 * KEY TERMINAL OS - Effects Stylesheet
 * Animations, overlays, stage colors, celebrations
 */

/* ==========================================
   EFFECT CANVASES
   ========================================== */

.effect-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9000;
    display: none;
}

#matrix-canvas {
    z-index: 9001;
}

#particle-canvas {
    z-index: 9002;
}

/* ==========================================
   SCREEN FLASH
   ========================================== */

.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 9500;
    transition: opacity 0.15s ease-out;
}

/* ==========================================
   EFFECT OVERLAYS
   ========================================== */

.effect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 8999;
    transition: opacity 0.3s ease-in-out;
}

.effect-overlay.active {
    opacity: 1;
}

.effect-overlay-success {
    background: radial-gradient(ellipse at center, 
        rgba(40, 254, 20, 0.1) 0%, 
        rgba(0, 0, 0, 0.9) 70%,
        rgba(0, 0, 0, 0.95) 100%
    );
}

.effect-overlay-failure {
    background: radial-gradient(ellipse at center, 
        rgba(255, 0, 0, 0.15) 0%, 
        rgba(0, 0, 0, 0.9) 70%,
        rgba(0, 0, 0, 0.95) 100%
    );
}

/* ==========================================
   CELEBRATION CONTAINER
   ========================================== */

.celebration-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9100;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.celebration-container.active {
    opacity: 1;
    transform: scale(1);
}

.celebration-container.fade-out {
    opacity: 0;
    transform: scale(1.1);
}

.celebration-content {
    text-align: center;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

/* ==========================================
   SUCCESS CELEBRATION
   ========================================== */

.celebration-success .key-icon-container {
    position: relative;
    margin-bottom: 30px;
}

.celebration-success .key-icon {
    font-size: 120px;
    color: #ffd700;
    text-shadow: 
        0 0 20px #ffd700,
        0 0 40px #ffd700,
        0 0 60px #ffa500,
        0 0 80px #ffa500;
    animation: keyPulse 1s ease-in-out infinite;
}

@keyframes keyPulse {
    0%, 100% { 
        transform: scale(1);
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.1);
        filter: brightness(1.3);
    }
}

.celebration-success .key-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    animation: glowPulse 1.5s ease-in-out infinite;
}

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

.celebration-title {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 8px;
    margin-bottom: 10px;
    text-shadow: 0 0 30px currentColor;
}

.celebration-success .celebration-title {
    color: #28fe14;
}

.celebration-stage {
    font-size: 24px;
    color: #00ffff;
    letter-spacing: 4px;
    margin-bottom: 20px;
}

.celebration-divider {
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #ffd700, transparent);
    margin: 20px auto;
}

.celebration-prize {
    margin-bottom: 10px;
}

.prize-amount {
    font-size: 64px;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700;
    animation: prizeGlow 0.5s ease-out;
}

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

.prize-unit {
    font-size: 24px;
    color: #ffa500;
    margin-left: 10px;
    letter-spacing: 4px;
}

.celebration-subtitle {
    font-size: 18px;
    color: #888;
    letter-spacing: 3px;
}

/* Key Slots */
.key-slots {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 40px;
}

.key-slot {
    width: 50px;
    height: 50px;
    border: 2px solid #333;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-out;
}

.key-slot.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.key-slot-recovered {
    border-color: #28fe14;
    background: rgba(40, 254, 20, 0.1);
}

.key-slot-recovered .key-slot-icon {
    color: #28fe14;
}

.key-slot-current {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.key-slot-current .key-slot-icon {
    color: #ffd700;
}

.key-slot-current.pulse {
    animation: slotPulse 0.5s ease-out;
}

@keyframes slotPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.key-slot-locked {
    border-color: #333;
    opacity: 0.3;
}

.key-slot-icon {
    font-size: 20px;
    color: #666;
}

.key-slot-number {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
}

/* ==========================================
   PRIZE TIERS & PODIUM
   ========================================== */

.tier-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
}

.tier-badge.tier-gold { background: linear-gradient(135deg, #FFD700, #FFA500); color: #000; }
.tier-badge.tier-silver { background: linear-gradient(135deg, #C0C0C0, #A0A0A0); color: #000; }
.tier-badge.tier-bronze { background: linear-gradient(135deg, #CD7F32, #8B4513); color: #fff; }

.celebration-prize.tier-gold .prize-amount { color: #FFD700; text-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
.celebration-prize.tier-silver .prize-amount { color: #C0C0C0; text-shadow: 0 0 20px rgba(192, 192, 192, 0.8); }
.celebration-prize.tier-bronze .prize-amount { color: #CD7F32; text-shadow: 0 0 20px rgba(205, 127, 50, 0.8); }

.tier-glow-gold { filter: drop-shadow(0 0 20px #FFD700); }
.tier-glow-silver { filter: drop-shadow(0 0 20px #C0C0C0); }
.tier-glow-bronze { filter: drop-shadow(0 0 20px #CD7F32); }

.celebration-no-prize {
    margin: 20px 0;
}

.no-prize-text {
    color: #666;
    font-size: 18px;
    font-style: italic;
}

.podium-container {
    margin: 30px 0 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.podium-title {
    font-size: 16px;
    color: #FFD700;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
}

.podium-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    min-width: 100px;
    transition: all 0.3s ease;
}

.podium-entry.current {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.podium-entry.unclaimed {
    opacity: 0.5;
}

.podium-stand {
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 24px;
    border-radius: 4px 4px 0 0;
}

.stand-1 { height: 80px; background: linear-gradient(180deg, #FFD700, #CC9900); color: #000; }
.stand-2 { height: 60px; background: linear-gradient(180deg, #C0C0C0, #909090); color: #000; }
.stand-3 { height: 40px; background: linear-gradient(180deg, #CD7F32, #8B4513); color: #fff; }

.podium-medal {
    font-size: 32px;
    margin: 8px 0;
}

.podium-winner {
    font-size: 12px;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-entry.unclaimed .podium-winner {
    color: #666;
}

.podium-sats {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

.podium-entry.gold .podium-winner { color: #FFD700; }
.podium-entry.silver .podium-winner { color: #C0C0C0; }
.podium-entry.bronze .podium-winner { color: #CD7F32; }

/* ==========================================
   FAILURE CELEBRATION
   ========================================== */

.celebration-failure .failure-icon-container {
    position: relative;
    margin-bottom: 30px;
}

.celebration-failure .failure-icon {
    font-size: 100px;
    color: #ff0000;
    text-shadow: 
        0 0 20px #ff0000,
        0 0 40px #ff0000,
        0 0 60px #990000;
    animation: failureShake 0.1s ease-in-out 5;
}

@keyframes failureShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.celebration-failure .failure-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 150px;
    border: 3px solid #ff0000;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: failurePulseRing 1s ease-out infinite;
}

@keyframes failurePulseRing {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

.celebration-failure .celebration-title {
    color: #ff0000;
}

.failure-subtitle {
    color: #ff6666 !important;
    font-size: 20px !important;
    margin-bottom: 15px;
}

.failure-hint {
    color: #666;
    font-size: 14px;
    font-style: italic;
}

.failure-bars {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
}

.failure-bar {
    width: 60px;
    height: 4px;
    background: #ff0000;
    animation: failureBarFlash 0.3s ease-in-out infinite alternate;
}

.failure-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.failure-bar:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes failureBarFlash {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* ==========================================
   GLITCH TEXT EFFECT
   ========================================== */

.glitch-text {
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-text::before {
    color: #ff0000;
    animation: glitchText 0.3s ease-in-out infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translateX(-2px);
}

.glitch-text::after {
    color: #00ffff;
    animation: glitchText 0.3s ease-in-out infinite reverse;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    transform: translateX(2px);
}

@keyframes glitchText {
    0%, 100% { transform: translateX(-2px); }
    50% { transform: translateX(2px); }
}

/* ==========================================
   ENHANCED GLITCH EFFECTS
   ========================================== */

.glitch-light {
    animation: glitchLight 0.3s ease-in-out;
}

.glitch-medium {
    animation: glitchMedium 0.4s ease-in-out;
}

.glitch-heavy {
    animation: glitchHeavy 0.5s ease-in-out;
}

@keyframes glitchLight {
    0%, 100% { transform: translate(0); filter: none; }
    20% { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
    40% { transform: translate(2px, -1px); }
    60% { transform: translate(-1px, 2px); filter: hue-rotate(-90deg); }
    80% { transform: translate(1px, -2px); }
}

@keyframes glitchMedium {
    0%, 100% { transform: translate(0) skewX(0); filter: none; }
    10% { transform: translate(-3px, 2px) skewX(1deg); filter: hue-rotate(90deg); }
    20% { transform: translate(3px, -2px) skewX(-1deg); }
    30% { transform: translate(-2px, 3px) skewX(0.5deg); filter: hue-rotate(-90deg); }
    40% { transform: translate(2px, -3px) skewX(-0.5deg); }
    50% { transform: translate(-3px, 1px); filter: saturate(2); }
    60% { transform: translate(3px, -1px); }
    70% { transform: translate(-1px, 3px); filter: hue-rotate(180deg); }
    80% { transform: translate(1px, -3px); }
    90% { transform: translate(-2px, 2px); filter: none; }
}

@keyframes glitchHeavy {
    0%, 100% { transform: translate(0) skewX(0) scale(1); filter: none; }
    5% { transform: translate(-5px, 3px) skewX(2deg) scale(1.01); filter: hue-rotate(90deg) saturate(2); }
    10% { transform: translate(5px, -3px) skewX(-2deg) scale(0.99); }
    15% { transform: translate(-3px, 5px) skewX(1deg); filter: hue-rotate(-90deg) brightness(1.2); }
    20% { transform: translate(3px, -5px) skewX(-1deg); }
    25% { transform: translate(-5px, 2px) scale(1.02); filter: saturate(3); }
    30% { transform: translate(5px, -2px) scale(0.98); }
    35% { transform: translate(-2px, 5px); filter: hue-rotate(180deg); }
    40% { transform: translate(2px, -5px); }
    45% { transform: translate(-4px, 4px) skewX(3deg); filter: invert(0.1); }
    50% { transform: translate(4px, -4px) skewX(-3deg); }
    55% { transform: translate(-3px, 3px); filter: hue-rotate(-180deg); }
    60% { transform: translate(3px, -3px); }
    65% { transform: translate(-5px, 1px) scale(1.01); filter: saturate(2) brightness(0.9); }
    70% { transform: translate(5px, -1px) scale(0.99); }
    75% { transform: translate(-1px, 5px); filter: hue-rotate(90deg); }
    80% { transform: translate(1px, -5px); }
    85% { transform: translate(-4px, 2px) skewX(1deg); filter: none; }
    90% { transform: translate(4px, -2px) skewX(-1deg); }
    95% { transform: translate(-2px, 4px); }
}

/* Glitch slices */
.glitch-slices {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9200;
    overflow: hidden;
}

.glitch-slice {
    position: absolute;
    left: 0;
    right: 0;
    background: rgba(255, 0, 0, 0.1);
    animation: sliceGlitch 0.1s ease-in-out infinite;
}

@keyframes sliceGlitch {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); background: rgba(0, 255, 255, 0.1); }
    50% { transform: translateX(10px); background: rgba(255, 0, 255, 0.1); }
    75% { transform: translateX(-5px); background: rgba(255, 255, 0, 0.1); }
}

/* ==========================================
   SCANLINES INTENSE
   ========================================== */

.scanlines-intense::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.3),
        rgba(0, 0, 0, 0.3) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9998;
    animation: scanlineFlicker 0.1s infinite;
}

@keyframes scanlineFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* ==========================================
   QUICK TOASTS
   ========================================== */

.quick-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    padding: 20px 40px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    opacity: 0;
    z-index: 9300;
    transition: all 0.3s ease-out;
}

.quick-toast.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.quick-toast.fade-out {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
}

.quick-toast-success {
    background: rgba(40, 254, 20, 0.2);
    border: 2px solid #28fe14;
    color: #28fe14;
    box-shadow: 0 0 30px rgba(40, 254, 20, 0.3);
}

.quick-toast-failure {
    background: rgba(255, 0, 0, 0.2);
    border: 2px solid #ff0000;
    color: #ff0000;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.3);
}

/* ==========================================
   CONTINUE PROMPT (Gamer Style)
   ========================================== */

.celebration-continue {
    margin-top: 50px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.celebration-continue.active {
    opacity: 1;
    transform: translateY(0);
}

.continue-text {
    font-size: 16px;
    color: #888;
    letter-spacing: 3px;
    margin-bottom: 8px;
    animation: continuePulse 1.5s ease-in-out infinite;
}

.continue-key {
    font-size: 14px;
    color: #ffd700;
    letter-spacing: 2px;
    animation: continuePulse 1.5s ease-in-out infinite;
    animation-delay: 0.2s;
}

@keyframes continuePulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@media (max-width: 600px) {
    .celebration-continue {
        margin-top: 30px;
    }
    
    .continue-text {
        font-size: 12px;
        letter-spacing: 2px;
    }
    
    .continue-key {
        font-size: 11px;
    }
}

/* ==========================================
   STAGE BACKGROUND COLORS (CSS Variables)
   ========================================== */

:root {
    --stage-0-bg: #0a0a0a;
    --stage-1-bg: #0d0d12;
    --stage-2-bg: #0a0d14;
    --stage-3-bg: #0d0a14;
    --stage-4-bg: #110a16;
    --stage-5-bg: #130a18;
    --stage-6-bg: #150a1a;
    --stage-7-bg: #1a0a1f;
}

/* Stage-specific body backgrounds */
body.stage-0 { background-color: var(--stage-0-bg); }
body.stage-1 { background-color: var(--stage-1-bg); }
body.stage-2 { background-color: var(--stage-2-bg); }
body.stage-3 { background-color: var(--stage-3-bg); }
body.stage-4 { background-color: var(--stage-4-bg); }
body.stage-5 { background-color: var(--stage-5-bg); }
body.stage-6 { background-color: var(--stage-6-bg); }
body.stage-7 { background-color: var(--stage-7-bg); }

body {
    transition: background-color 1s ease-in-out;
}

/* ==========================================
   RESPONSIVE ADJUSTMENTS
   ========================================== */

@media (max-width: 600px) {
    .celebration-title {
        font-size: 28px;
        letter-spacing: 4px;
    }
    
    .celebration-success .key-icon {
        font-size: 80px;
    }
    
    .prize-amount {
        font-size: 40px;
    }
    
    .celebration-stage {
        font-size: 16px;
    }
    
    .key-slots {
        gap: 8px;
    }
    
    .key-slot {
        width: 35px;
        height: 35px;
    }
    
    .key-slot-icon {
        font-size: 16px;
    }
    
    .celebration-failure .failure-icon {
        font-size: 60px;
    }
}
