/* effects.css */

:root {
    --static-intensity: 1.0;
    --color-bleed: 0.8;
}

.stream-container {
    background: #000;
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}

/* ============================================
   Fullscreen Noise Background
   ============================================ */

.noise-fullscreen {
    position: absolute;
    inset: 0;
    background: #0a0a0a;
    overflow: hidden;
}

.noise-fullscreen .static-overlay {
    position: absolute;
    inset: 0;
    background: url('noise.gif');
    background-size: cover;
    opacity: 0.9;
    mix-blend-mode: normal;
    animation: static-flicker 0.1s infinite;
}

.noise-fullscreen .rolling-bar {
    position: absolute;
    width: 100%;
    height: 40px;
    background: rgba(255,255,255,0.08);
    animation: roll 4s linear infinite;
}

/* ============================================
   Webcam Overlay (Bottom-Right)
   ============================================ */

.webcam-overlay {
    position: absolute;
    bottom: 60px;
    right: 16px;
    width: 300px;
    height: 225px;
    z-index: 10;
}

.webcam-frame {
    position: relative;
    width: 100%;
    height: 100%;
    border: 2px solid #333;
    box-shadow:
        0 0 0 1px #000,
        0 4px 20px rgba(0, 0, 0, 0.8),
        inset 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    background: #000;
}

.webcam-frame .test-pattern {
    height: 100%;
}

.webcam-static {
    opacity: 0.3;
}

.webcam-label {
    position: absolute;
    top: 6px;
    left: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.65rem;
    color: #ff3333;
    text-shadow: 0 0 4px #ff0000;
    letter-spacing: 0.1em;
    animation: rec-blink 1.5s infinite;
}

.webcam-label::before {
    content: '●';
    margin-right: 4px;
    animation: rec-blink 1s infinite;
}

@keyframes rec-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* ============================================
   Stream Chat Overlay (Above Webcam)
   ============================================ */

.stream-chat-overlay {
    position: absolute;
    top: 60px;
    bottom: 300px;
    right: 16px;
    width: 280px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
    overflow: hidden;
}

.stream-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    padding: 8px;
}

.stream-chat-msg {
    background: rgba(0, 0, 0, 0.7);
    border-left: 2px solid var(--phosphor-dim, #33aa55);
    padding: 6px 10px;
    font-size: 0.8rem;
    backdrop-filter: blur(4px);
    animation: stream-msg-appear 0.3s ease-out;
}

.stream-chat-msg.user-msg {
    border-left-color: var(--phosphor-green, #00ff41);
}

.stream-chat-msg.null-response {
    border-left-color: #ff4444;
    background: rgba(40, 0, 0, 0.8);
}

.stream-chat-msg .msg-user {
    display: block;
    font-size: 0.7rem;
    color: var(--phosphor-dim, #33aa55);
    margin-bottom: 2px;
    font-family: 'Courier New', monospace;
}

.stream-chat-msg.null-response .msg-user {
    color: #ff4444;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.5);
}

.stream-chat-msg .msg-text {
    color: var(--phosphor-green, #00ff41);
    word-break: break-word;
}

.stream-chat-msg.null-response .msg-text {
    color: #ff6666;
    font-style: italic;
}

@keyframes stream-msg-appear {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Mobile responsive webcam and stream chat */
@media (max-width: 900px) {
    .webcam-overlay {
        width: 210px;
        height: 158px;
        bottom: 50px;
        right: 10px;
    }

    .webcam-label {
        font-size: 0.55rem;
        top: 4px;
        left: 6px;
    }

    .stream-chat-overlay {
        width: 200px;
        right: 10px;
        top: 50px;
        bottom: 220px;
    }

    .stream-chat-msg {
        font-size: 0.75rem;
        padding: 4px 8px;
    }

    .stream-chat-msg .msg-user {
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .webcam-overlay {
        width: 150px;
        height: 113px;
        bottom: 45px;
        right: 8px;
    }

    .webcam-label {
        font-size: 0.5rem;
    }

    .stream-chat-overlay {
        width: 160px;
        right: 8px;
        top: 45px;
        bottom: 170px;
    }

    .stream-chat-msg {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    .stream-chat-msg .msg-user {
        font-size: 0.6rem;
    }
}

/* Heavy static */
.static-overlay {
    position: absolute;
    inset: 0;
    background: url('noise.gif');  /* Or CSS noise pattern */
    opacity: var(--static-intensity);
    mix-blend-mode: overlay;
    animation: static-flicker 0.1s infinite;
}

/* Scan lines */
.scanlines::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.3) 2px,
        rgba(0, 0, 0, 0.3) 4px
    );
    pointer-events: none;
}

/* Color bars (test pattern) */
.test-pattern {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    height: 100%;
}
.test-pattern > div:nth-child(1) { background: #fff; }
.test-pattern > div:nth-child(2) { background: #ff0; }
.test-pattern > div:nth-child(3) { background: #0ff; }
.test-pattern > div:nth-child(4) { background: #0f0; }
.test-pattern > div:nth-child(5) { background: #f0f; }
.test-pattern > div:nth-child(6) { background: #f00; }
.test-pattern > div:nth-child(7) { background: #00f; }
.test-pattern > div:nth-child(8) { background: #000; }

/* Fullscreen test pattern */
.test-pattern.fullscreen-pattern {
    position: absolute;
    inset: 0;
    height: 100%;
    width: 100%;
}

/* Rolling distortion */
@keyframes roll {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

.rolling-bar {
    position: absolute;
    width: 100%;
    height: 20px;
    background: rgba(255,255,255,0.1);
    animation: roll 3s linear infinite;
}
