﻿/* 全局重置与基础样式 - 适配1080×1920竖屏 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "微软雅黑", sans-serif;
    touch-action: manipulation; /* 优化触控体验 */
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* 禁止页面滚动 */
    background-color: #f5f7fa;
}

body {
    padding: 15px;
    display: flex;
    flex-direction: column; /* 竖屏垂直布局 */
    align-items: center;
    justify-content: center; /* 整体居中 */
}

/* 人物容器 - 核心：唯一的人物展示区域，竖屏居中 */
.character-wrapper {
    position: relative;
    /*width: 240px;
    height: 340px;*/
    width: 80%;
    height: 80%;
    margin: 0 auto 30px;
}

/* 身体图层（静态） */
.character-body {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('../images/body.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 1;
    background-position: center;
}

/* 眼睛图层 */
.character-eyes {
    position: absolute;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 2;
    animation: blink 4s infinite;
    background-position: center;
}

/* 嘴巴图层 */
.character-mouth {
    position: absolute;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 3;
    background-position: center;
}

/* 眼睛眨眼动画 */
@keyframes blink {
    0% {
        background-image: url('../images/eye-1.png');
    }
    /* 初始睁眼 */
    40% {
        background-image: url('../images/eye-1.png');
    }
    /* 保持睁眼 */
    50% {
        background-image: url('../images/eye-3.png');
    }
    /* 完全闭眼（峰值） */
    60% {
        background-image: url('../images/eye-5.png');
    }
    /* 快速睁眼 */
    100% {
        background-image: url('../images/eye-1.png');
    }
}

/* 嘴巴说话动画 */
@keyframes talk {
    0% {
        background-image: url('../images/剧本杀女检察官-2.png');
    }

    11.11% {
        background-image: url('../images/剧本杀女检察官-10.png');
    }

    22.22% {
        background-image: url('../images/剧本杀女检察官-3.png');
    }

    33.33% {
        background-image: url('../images/剧本杀女检察官-4.png');
    }

    44.44% {
        background-image: url('../images/剧本杀女检察官-5.png');
    }

    55.55% {
        background-image: url('../images/剧本杀女检察官-6.png');
    }

    66.66% {
        background-image: url('../images/剧本杀女检察官-7.png');
    }

    77.77% {
        background-image: url('../images/剧本杀女检察官-8.png');
    }

    88.88% {
        background-image: url('../images/剧本杀女检察官-9.png');
    }

    100% {
                background-image: url('../images/剧本杀女检察官-2.png');
    }
}

.speaking {
    animation: talk 0.8s steps(9) infinite;
}

/* 加载动画 */
.loading-animation {
    display: none;
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 45px;
    height: 45px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #624aff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }

    100% {
        transform: translateX(-50%) rotate(360deg);
    }
}

/* 开始按钮 */
.start-btn {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 35px;
    background: #624aff;
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 10;
    min-width: 180px;
}

    .start-btn:hover {
        background: #5038e0;
    }

    .start-btn:disabled {
        background: #999;
        cursor: not-allowed;
    }

/* 控制按钮容器（结束/隐藏记录） */
.control-buttons {
    display: none; /* 初始隐藏 */
    margin-top: 20px;
    text-align: center;
}

/* 结束/切换按钮样式 */
.end-btn, .toggle-dialog-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
    margin: 0 5px 10px;
    min-width: 120px;
}

.end-btn {
    background: #ff4d4f;
    color: #fff;
}

    .end-btn:hover {
        background: #d9363e;
    }

.toggle-dialog-btn {
    background: #40a9ff;
    color: #fff;
}

    .toggle-dialog-btn:hover {
        background: #1890ff;
    }

/* 对话记录区域 */
.dialog-history {
    display: none; /* 初始隐藏 */
    width: 100%;
    max-width: 90vw;
    height: 200px;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    font-size: 16px;
    margin-top: 20px;
}

.dialog-item {
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 8px;
    max-width: 95%;
}

    .dialog-item.user {
        background: #e8f4ff;
        margin-left: auto;
    }

    .dialog-item.bot {
        background: #f0f0f0;
        margin-right: auto;
    }

    .dialog-item .content {
        font-size: 16px;
        line-height: 1.6;
    }

    .dialog-item .time {
        font-size: 14px;
        color: #999;
        margin-top: 5px;
        text-align: right;
    }

/* 对话状态提示 */
.dialog-status {
    display: none; /* 初始隐藏 */
    font-size: 18px;
    color: #624aff;
    margin: 10px 0;
    text-align: center;
}

/* 音频播放器和错误提示 */
.audio-player {
    display: none;
    width: 100%;
    max-width: 90vw;
    margin-top: 10px;
}

.audio-worklet-error {
    display: none;
    color: #ff4d4f;
    padding: 10px;
    margin: 10px 0;
    background: #fff2f0;
    border-radius: 4px;
    font-size: 16px;
    max-width: 90vw;
}

/* 适配1080×1920竖屏 */
@media screen and (width: 1080px) and (height: 1920px) {
    .character-wrapper {
        width: 260px;
        height: 360px;
    }

    .dialog-history {
        height: 450px;
    }

    .start-btn {
        font-size: 20px;
        padding: 18px 40px;
    }

    .dialog-status {
        font-size: 20px;
    }
}
