/**
 * CRT Chaos - Glitch Effects & Chaos Styling
 */

/* CRT Monitor Effects */
.crt-scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9998;
    animation: scanlines 8s linear infinite;
}

@keyframes scanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(10px); }
}

.crt-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    z-index: 9997;
}

/* Screen Effects */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.03) 2px,
            rgba(255, 255, 255, 0.03) 4px
        );
    pointer-events: none;
    z-index: 9996;
}

/* Glitch Effects */
@keyframes glitch-skew {
    0% { transform: skew(0deg); }
    10% { transform: skew(-2deg); }
    20% { transform: skew(1deg); }
    30% { transform: skew(3deg); }
    40% { transform: skew(-1deg); }
    50% { transform: skew(2deg); }
    60% { transform: skew(0deg); }
    100% { transform: skew(0deg); }
}

@keyframes glitch-1 {
    0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
    20% { clip-path: inset(100% 0 0 0); transform: translate(-2px, 2px); }
    40% { clip-path: inset(0 0 100% 0); transform: translate(2px, -2px); }
    60% { clip-path: inset(0 100% 0 0); transform: translate(-2px, 0); }
    80% { clip-path: inset(0 0 0 100%); transform: translate(2px, 0); }
}

@keyframes glitch-2 {
    0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
    20% { clip-path: inset(0 100% 0 0); transform: translate(2px, 0); }
    40% { clip-path: inset(0 0 0 100%); transform: translate(-2px, 0); }
    60% { clip-path: inset(100% 0 0 0); transform: translate(0, -2px); }
    80% { clip-path: inset(0 0 100% 0); transform: translate(0, 2px); }
}

/* Screen Tear Effect */
.screen-tear {
    animation: screen-tear 0.2s ease-out;
}

@keyframes screen-tear {
    0% { transform: translateX(0); }
    20% { transform: translateX(-5px); filter: blur(1px); }
    40% { transform: translateX(5px); filter: blur(2px); }
    60% { transform: translateX(-3px); filter: blur(1px); }
    80% { transform: translateX(2px); filter: blur(0); }
    100% { transform: translateX(0); filter: blur(0); }
}

/* Element Shake */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Theme Variations */
.theme-inverted {
    filter: invert(1) hue-rotate(180deg);
}

.theme-monochrome {
    filter: grayscale(1) contrast(1.2);
}

.theme-glitch {
    animation: glitch-filter 0.3s infinite;
}

@keyframes glitch-filter {
    0% { filter: hue-rotate(0deg) saturate(1); }
    20% { filter: hue-rotate(90deg) saturate(3); }
    40% { filter: hue-rotate(-90deg) saturate(0.5); }
    60% { filter: hue-rotate(45deg) saturate(2); }
    80% { filter: hue-rotate(-45deg) saturate(1.5); }
    100% { filter: hue-rotate(0deg) saturate(1); }
}

.theme-matrix {
    filter: hue-rotate(90deg) contrast(1.5) brightness(0.8);
}

/* Chaos Notifications */
.chaos-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #000;
    border: 2px solid var(--neon-green);
    color: var(--neon-green);
    padding: 15px 30px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 20px var(--neon-green);
    z-index: 10000;
    transition: transform 0.3s ease-out;
}

.chaos-notification.show {
    transform: translateX(-50%) translateY(0);
}

.chaos-notification.error {
    border-color: #ff0000;
    color: #ff0000;
    box-shadow: 0 0 20px #ff0000;
}

.chaos-notification.victory {
    border-color: #ffff00;
    color: #ffff00;
    box-shadow: 0 0 20px #ffff00;
    animation: victory-pulse 1s infinite;
}

@keyframes victory-pulse {
    0%, 100% { box-shadow: 0 0 20px #ffff00; }
    50% { box-shadow: 0 0 40px #ffff00; }
}

/* Terminal Container Base */
.terminal-container {
    background: #0a0a0a;
    border: 2px solid var(--neon-green);
    border-radius: 0;
    padding: 20px;
    font-family: 'Courier New', monospace;
    color: var(--neon-green);
    box-shadow: 
        0 0 20px rgba(0, 255, 0, 0.5),
        inset 0 0 20px rgba(0, 255, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.terminal-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 0, 0.03) 2px,
        rgba(0, 255, 0, 0.03) 4px
    );
    pointer-events: none;
}

.terminal-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--neon-green);
}

.terminal-title {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.terminal-controls {
    display: flex;
    gap: 8px;
}

.terminal-control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--neon-green);
}

.terminal-control.close {
    background: #ff3b30;
}

.terminal-control.minimize {
    background: #ffcc00;
}

.terminal-control.maximize {
    background: #28cd41;
}

/* Cursor Blink */
.cursor {
    display: inline-block;
    width: 10px;
    height: 20px;
    background: var(--neon-green);
    animation: cursor-blink 1s infinite;
    vertical-align: text-bottom;
}

@keyframes cursor-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Glitch Text Effect */
.glitch-text {
    position: relative;
    display: inline-block;
}

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

.glitch-text::before {
    animation: glitch-1 0.3s infinite;
    color: #ff00ff;
    z-index: -1;
}

.glitch-text::after {
    animation: glitch-2 0.3s infinite;
    color: #00ffff;
    z-index: -2;
}

/* Puzzle Status Indicators */
.puzzle-status {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 10px;
}

.puzzle-status.unsolved {
    background: #ff0000;
    box-shadow: 0 0 10px #ff0000;
    animation: status-pulse 2s infinite;
}

.puzzle-status.solved {
    background: #00ff00;
    box-shadow: 0 0 10px #00ff00;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Victory State */
.victory-state {
    animation: victory-animation 2s ease-out;
}

@keyframes victory-animation {
    0% { filter: hue-rotate(0deg) brightness(1); }
    50% { filter: hue-rotate(360deg) brightness(1.5); }
    100% { filter: hue-rotate(0deg) brightness(1); }
}

/* Chaos Level Indicator */
.chaos-meter {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: #000;
    border: 2px solid var(--neon-green);
    padding: 10px 20px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--neon-green);
    text-transform: uppercase;
    z-index: 9999;
}

.chaos-meter-bar {
    width: 100px;
    height: 10px;
    background: #0a0a0a;
    border: 1px solid var(--neon-green);
    margin-top: 5px;
    position: relative;
    overflow: hidden;
}

.chaos-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #ffff00, #ff0000);
    transition: width 0.3s ease;
}

/* Puzzle Modal Styles */
.puzzle-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    /* display controlled by JavaScript */
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.puzzle-modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: auto;
}

/* Mobile Warning */
.mobile-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: var(--neon-green);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    z-index: 10001;
}

.mobile-warning h2 {
    color: #ff0000;
    margin-bottom: 20px;
    animation: glitch-skew 0.5s infinite;
}

.mobile-warning button {
    background: transparent;
    border: 2px solid var(--neon-green);
    color: var(--neon-green);
    padding: 10px 30px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
}

.mobile-warning button:hover {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 20px var(--neon-green);
}

/* Panic Menu Styles */
.panic-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    backdrop-filter: blur(5px);
}

.panic-content {
    background: #0a0a0a;
    border: 3px solid #ffff00;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    box-shadow: 
        0 0 30px #ffff00,
        inset 0 0 20px rgba(255, 255, 0, 0.1);
    animation: panic-glow 2s ease-in-out infinite;
}

@keyframes panic-glow {
    0%, 100% { box-shadow: 0 0 30px #ffff00, inset 0 0 20px rgba(255, 255, 0, 0.1); }
    50% { box-shadow: 0 0 50px #ffff00, inset 0 0 30px rgba(255, 255, 0, 0.2); }
}

.panic-content h2 {
    color: #ffff00;
    text-align: center;
    margin-bottom: 20px;
    font-size: 28px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.panic-content > p {
    color: #fff;
    text-align: center;
    margin-bottom: 30px;
    font-size: 16px;
}

.panic-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.panic-options button {
    background: transparent;
    border: 2px solid var(--neon-green);
    color: var(--neon-green);
    padding: 15px 20px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.panic-options button:hover {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 20px var(--neon-green);
    transform: translateX(5px);
}

.panic-options button:last-child {
    border-color: #ff0000;
    color: #ff0000;
    margin-top: 10px;
}

.panic-options button:last-child:hover {
    background: #ff0000;
    box-shadow: 0 0 20px #ff0000;
}

.panic-shortcuts {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #666;
    padding: 20px;
    margin-bottom: 20px;
}

.panic-shortcuts h3 {
    color: #ffff00;
    margin-bottom: 15px;
    font-size: 18px;
}

.panic-shortcuts p {
    color: #ccc;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.panic-shortcuts kbd {
    background: #333;
    border: 1px solid #666;
    border-radius: 3px;
    padding: 3px 6px;
    font-size: 12px;
    color: #fff;
    box-shadow: 0 2px 0 #222;
}

.panic-close {
    background: transparent;
    border: 2px solid #666;
    color: #999;
    padding: 10px 30px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    display: block;
    margin: 0 auto;
}

.panic-close:hover {
    border-color: #fff;
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}