/* --- viewer_style.css --- */
:root {
    --theatre-bg: #141414;
    --chat-bg: #1a1d21;
    --input-bg: #2a2d31;
    --text-light: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-blue: #39C3FF;
    --border-color: #333;
    --font-family: 'Segoe UI', 'Inter', sans-serif;
    --header-height: 50px; /* Approx height for info/controls */
    --input-height: 50px; /* Approx height for comment input */
    --emoji-bar-height: 40px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden; /* Prevent body scroll */
    background-color: var(--theatre-bg);
    color: var(--text-light);
    font-family: var(--font-family);
    font-size: 15px; /* Base font size for mobile */
}

#theatre-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: var(--theatre-bg);
}

/* Status Overlay (Countdown/Replay) */
#status-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    display: none; /* Hidden by default */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 50;
    padding: 20px;
}
#status-overlay.visible {
    display: flex;
}
#countdown-timer {
    font-size: 1.8em;
    font-weight: bold;
    margin-bottom: 20px;
}
#watch-replay-button {
    background-color: var(--accent-blue);
    color: #111;
    border: none;
    padding: 12px 25px;
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
#watch-replay-button:hover {
    background-color: #6acfff;
}


/* Video Player Area */
#video-player-area {
    position: relative; /* For emoji overlay */
    width: 100%;
    background-color: black; /* Fallback */
    flex-shrink: 0;
    aspect-ratio: 16 / 9; /* Default aspect ratio */
}

#youtube-player {
    width: 100%;
    height: 100%;
    border: none; /* Remove iframe border */
}

/* Floating Emoji Overlay */
#emoji-overlay {
    position: absolute;
    bottom: 10px; /* Start emojis near bottom */
    left: 0;
    right: 0;
    height: 150px; /* Area where emojis float */
    overflow: hidden;
    pointer-events: none; /* Allow clicks through to video */
    z-index: 10;
    display: flex;
    justify-content: center; /* Center starting point horizontally */
    align-items: flex-end; /* Start emojis from bottom */
}

.floating-emoji {
    position: absolute;
    font-size: 2rem; /* Emoji size */
    opacity: 1;
    animation: floatUpFadeOut 4s ease-out forwards;
    /* Random horizontal start position adjusted by JS */
}

@keyframes floatUpFadeOut {
    0% {
        transform: translateY(0) scale(0.8);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(-140px) scale(1.2); /* Float up */
        opacity: 0; /* Fade out */
    }
}

/* Info and Controls Bar */
#info-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background-color: #1f1f1f; /* Slightly different shade */
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    height: var(--header-height);
    font-size: 0.9em;
}

#viewer-info {
    color: var(--text-secondary);
}
#viewer-info i {
    margin-right: 5px;
}
#viewer-count {
    font-weight: 600;
    color: var(--text-light);
}

#user-controls button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3em;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease;
}
#user-controls button:hover {
    color: var(--text-light);
}
#user-controls button.muted i {
    color: var(--accent-blue); /* Indicate muted state */
}

/* Chat Area */
#chat-area {
    flex-grow: 1; /* Takes remaining space */
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
    overflow: hidden; /* Important: prevent chat overflow */
}

/* Comment List */
#comment-list {
    flex-grow: 1;
    overflow-y: auto; /* Scrollable comment list */
    padding: 10px 15px;
    display: flex;
    flex-direction: column-reverse; /* Newest messages at the bottom */
}
/* Add padding to bottom to avoid overlap with input */
#comment-list::after {
    content: '';
    display: block;
    height: calc(var(--input-height) + var(--emoji-bar-height) + 10px); /* Space for input+emojis */
}

.comment-item {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 5px;
    line-height: 1.4;
    max-width: 95%; /* Prevent full width comments */
    word-wrap: break-word;
    display: inline-block; /* Allow fitting content */
    background-color: rgba(255, 255, 255, 0.05); /* Subtle background */
}
.comment-item.reaction-only {
    background-color: transparent; /* No background for just emojis */
    padding: 2px 0; /* Less padding */
    font-size: 1.3em; /* Larger emoji */
}

.comment-sender {
    font-weight: 600;
    color: var(--accent-blue); /* Highlight sender */
    margin-right: 6px;
    font-size: 0.9em;
}
.comment-text {
    /* color: var(--text-light); Inherited */
    font-size: 0.95em;
    white-space: pre-wrap; /* Respect line breaks */
}
.reaction-only .comment-text {
    display: inline; /* Keep emoji inline */
}

/* Comment Input Form */
#comment-form {
    flex-shrink: 0;
    background-color: var(--input-bg);
    border-top: 1px solid var(--border-color);
}

/* Emoji Reaction Bar */
#emoji-reactions {
    display: flex;
    justify-content: space-around;
    padding: 5px 10px;
    height: var(--emoji-bar-height);
    border-bottom: 1px solid var(--border-color);
}
#emoji-reactions button {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    transition: transform 0.1s ease;
    padding: 2px 5px;
}
#emoji-reactions button:hover {
    transform: scale(1.2);
}
#emoji-reactions button:active {
    transform: scale(1.1);
}

/* Text Input Row */
.input-row {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    height: var(--input-height);
    gap: 8px;
}

#comment-input {
    flex-grow: 1;
    background-color: var(--chat-bg);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 0.95em;
    outline: none;
}
#comment-input:focus {
    border-color: var(--accent-blue);
}

.input-row button {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4em;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease;
}
.input-row button:hover {
    color: var(--accent-blue);
}
#dictate-button.listening i {
     color: var(--accent-blue); /* Indicate listening state */
     animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}


/* Responsiveness */
@media (min-width: 768px) {
    body {
        font-size: 16px; /* Slightly larger base font on desktop */
    }

    #theatre-container {
        flex-direction: row; /* Side-by-side layout */
        max-width: 1200px; /* Limit max width */
        margin: auto; /* Center */
        height: 95vh; /* Limit height */
        max-height: 800px;
        border-radius: 8px;
        overflow: hidden; /* Clip corners */
        box-shadow: 0 5px 25px rgba(0,0,0,0.3);
    }

    #video-player-area {
        flex-grow: 1; /* Video takes available horizontal space */
        height: 100%; /* Full container height */
        aspect-ratio: unset; /* Let height determine width */
    }

    #info-controls {
        /* Position over video */
        position: absolute;
        bottom: 0;
        left: 0;
        right: calc(300px + 1px); /* Adjust width based on chat area */
        background-color: rgba(0, 0, 0, 0.6);
        border-top: 1px solid var(--border-color);
        border-bottom: none;
        z-index: 20;
        height: auto; /* Auto height */
        padding: 5px 15px;
    }

    #chat-area {
        width: 300px; /* Fixed width chat sidebar */
        flex-shrink: 0;
        border-left: 1px solid var(--border-color);
        height: 100%; /* Full container height */
    }

     /* Ensure comment list scrolls correctly in fixed height */
     #comment-list {
         height: calc(100% - var(--input-height) - var(--emoji-bar-height));
         padding-bottom: 10px; /* Less padding needed now */
     }
     #comment-list::after {
         display: none; /* Remove extra padding */
     }

     #emoji-overlay {
        /* Adjust position if needed */
        right: calc(300px + 1px);
     }
}