/* CSS สำหรับหน้าจอ Subtitle OBS Overlay */

:root {
    --bg-glass: rgba(15, 15, 20, 0.45);
    --border-glass: rgba(46, 204, 113, 0.25);
    --neon-shadow: rgba(46, 204, 113, 0.35);
    --text-primary: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
    --glow-color: #2ecc71;
}

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background: transparent; /* โปร่งใสเพื่อให้ OBS ซ้อนภาพทับลงเกมได้ */
    font-family: 'Outfit', 'Sarabun', sans-serif;
    overflow: hidden;
}

#overlay-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-end; /* วางซับไว้ด้านล่างหน้าจอ */
    padding-bottom: 50px;
    box-sizing: border-box;
}

/* กล่องคำพูดแบบกระจกแก้วสะท้อนแสง (Glassmorphic Speech Bubble) */
#speech-bubble {
    width: 80%;
    max-width: 900px;
    min-height: 110px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 2px solid var(--border-glass);
    border-radius: 20px;
    padding: 20px 25px;
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 
                0 0 20px var(--neon-shadow),
                inset 0 1px 1px rgba(255, 255, 255, 0.1);
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: translateY(20px);
}

/* แสดงการ์ดลอยขึ้น */
#speech-bubble.active {
    opacity: 1;
    transform: translateY(0);
}

/* ส่วนหัวของการ์ด */
#bubble-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

/* จุดไฟบอกอารมณ์บอท */
#avatar-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
    transition: all 0.3s ease;
}

#speaker-name {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* ป้ายอารมณ์แสดงผลน่ารัก */
#emotion-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

/* ส่วนเนื้อหาซับไตเติ้ล */
#subtitle-body {
    position: relative;
}

#subtitle-text {
    font-size: 20px;
    line-height: 1.6;
    font-weight: 400;
    color: var(--text-primary);
    margin: 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85); /* เงากล่องรอบคำเพื่อให้อ่านบนคลิปสตรีมสว่างๆ ได้ชัด */
    word-wrap: break-word;
}

/* แถบแสงไฟตกแต่งด้านล่าง */
#mood-glow-bar {
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 3px;
    background: var(--glow-color);
    box-shadow: 0 0 10px var(--glow-color);
    border-radius: 10px;
    transition: all 0.4s ease;
}

/* ==========================================
   ธีมสีอิงตามอารมณ์เด่น (Emotion Color Mappings)
   ========================================== */

/* 1. มีความสุข / ปกติ (Green Theme) */
#speech-bubble.happy {
    --border-glass: rgba(46, 204, 113, 0.35);
    --neon-shadow: rgba(46, 204, 113, 0.2);
    --glow-color: #2ecc71;
}
.dot-happy { color: #2ecc71; background-color: #2ecc71; }
.badge-happy { background-color: rgba(46, 204, 113, 0.65); }

/* 2. เศร้า / ร้องไห้ (Blue Theme) */
#speech-bubble.cry {
    --border-glass: rgba(52, 152, 219, 0.35);
    --neon-shadow: rgba(52, 152, 219, 0.2);
    --glow-color: #3498db;
}
.dot-cry { color: #3498db; background-color: #3498db; }
.badge-cry { background-color: rgba(52, 152, 219, 0.65); }

/* 3. โกรธ (Red Theme) */
#speech-bubble.angry {
    --border-glass: rgba(231, 76, 60, 0.35);
    --neon-shadow: rgba(231, 76, 60, 0.25);
    --glow-color: #e74c3c;
}
.dot-angry { color: #e74c3c; background-color: #e74c3c; }
.badge-angry { background-color: rgba(231, 76, 60, 0.65); }

/* 4. กลัว / ตื่นตระหนก (Purple Theme) */
#speech-bubble.scared {
    --border-glass: rgba(155, 89, 182, 0.35);
    --neon-shadow: rgba(155, 89, 182, 0.2);
    --glow-color: #9b59b6;
}
.dot-scared { color: #9b59b6; background-color: #9b59b6; }
.badge-scared { background-color: rgba(155, 89, 182, 0.65); }

/* 5. ตื่นเต้น / ประหลาดใจ (Gold Theme) */
#speech-bubble.surprised {
    --border-glass: rgba(241, 196, 15, 0.35);
    --neon-shadow: rgba(241, 196, 15, 0.2);
    --glow-color: #f1c40f;
}
.dot-surprised { color: #f1c40f; background-color: #f1c40f; }
.badge-surprised { background-color: rgba(241, 196, 15, 0.65); }

/* ==========================================
   อนิเมชันพิเศษ: การขัดจังหวะแซงคิว (Interrupted State)
   ========================================== */

#speech-bubble.interrupted {
    --border-glass: rgba(231, 76, 60, 0.85) !important;
    --neon-shadow: rgba(231, 76, 60, 0.7) !important;
    --glow-color: #e74c3c !important;
    animation: shake 0.3s ease-in-out, flash-red 0.4s infinite alternate;
}

@keyframes shake {
    0% { transform: translateX(0); }
    15% { transform: translateX(-15px) rotate(-1.5deg); }
    30% { transform: translateX(12px) rotate(1.2deg); }
    45% { transform: translateX(-10px) rotate(-0.8deg); }
    60% { transform: translateX(8px) rotate(0.5deg); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

@keyframes flash-red {
    from { box-shadow: 0 0 10px rgba(231, 76, 60, 0.3); }
    to { box-shadow: 0 0 25px rgba(231, 76, 60, 0.8); }
}

/* ==========================================
   อนิเมชัน Bouncing Typing Dots
   ========================================== */

#typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    margin-top: 5px;
}

#typing-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-primary);
    border-radius: 50%;
    opacity: 0.6;
    animation: bounce 1.2s infinite ease-in-out;
}

#typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
#typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); opacity: 1; }
}

.hidden {
    display: none !important;
}
