/* 祭祀场景样式 — 由 ?scene=memorial 激活 */

html[data-scene="memorial"] body {
    --memorial-accent: #c8a45c;
    --memorial-accent-soft: rgba(200, 164, 92, 0.18);
}

html[data-scene="memorial"] .background-overlay {
    background: linear-gradient(
        180deg,
        rgba(26, 20, 16, 0.55) 0%,
        rgba(26, 20, 16, 0.75) 100%
    ) !important;
}

html[data-scene="memorial"] .memorial-scene-banner {
    display: flex;
}

.memorial-scene-banner {
    display: none;
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: rgba(26, 20, 16, 0.88);
    border: 1px solid rgba(200, 164, 92, 0.35);
    border-radius: 24px;
    color: #e8d5a3;
    font-size: 13px;
    font-family: "Noto Serif SC", "PingFang SC", serif;
    backdrop-filter: blur(8px);
    pointer-events: none;
    white-space: nowrap;
}

html[data-scene="memorial"] #cameraContainer {
    display: none !important;
}

html[data-scene="memorial"] .dial-btn,
html[data-scene="memorial"] .connect-btn {
    border-color: rgba(200, 164, 92, 0.5) !important;
}

html[data-scene="memorial"] .status.connected {
    color: #c8a45c !important;
}

/* iframe 嵌入模式：用 100% 替代 100vh，避免只显示一条 */
html[data-embedded="true"],
html[data-embedded="true"] body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

html[data-embedded="true"] body {
    min-height: 100%;
}

html[data-embedded="true"] .background-container {
    width: 100%;
    height: 100%;
}

html[data-embedded="true"] .container {
    width: 100%;
    height: 100%;
}

html[data-embedded="true"] #live2d-stage {
    width: 100%;
    height: 100%;
}

html[data-embedded="true"] .modal {
    width: 100%;
    height: 100%;
}

html[data-embedded="true"] .memorial-scene-banner {
    top: 10px;
    font-size: 13px;
    padding: 7px 16px;
}

/* 祭祀场景：照片形象更大 */
html[data-scene="memorial"] .photo-avatar {
    top: 42%;
    transform: translate(-50%, -50%);
}

html[data-scene="memorial"] .photo-avatar-frame {
    width: min(380px, 78vw);
    height: min(480px, 62vh);
}

html[data-scene="memorial"] .photo-avatar-portrait {
    font-size: clamp(72px, 16vw, 140px);
}

html[data-scene="memorial"] .photo-avatar-name {
    font-size: 22px;
}

html[data-scene="memorial"] .photo-avatar-dates {
    font-size: 14px;
}

/* ===== 嵌入祭祀模式：沉浸全幅布局 ===== */
html[data-embedded="true"][data-scene="memorial"] body.photo-avatar-active {
    background: #1a1410;
}

html[data-embedded="true"][data-scene="memorial"] .photo-avatar {
    position: fixed;
    top: 36%;
    left: 54%;
    transform: translate(-50%, -50%);
    width: min(440px, 52%);
    max-width: 480px;
    z-index: 110;
}

html[data-embedded="true"][data-scene="memorial"] .photo-avatar-frame {
    width: 100%;
    height: min(540px, 56vh);
    min-height: 380px;
    max-width: none;
    padding: 8px;
    border-radius: 16px;
}

html[data-embedded="true"][data-scene="memorial"] .photo-avatar-portrait {
    font-size: clamp(96px, 14vw, 168px);
    border-radius: 10px;
}

html[data-embedded="true"][data-scene="memorial"] .photo-avatar-caption {
    margin-top: 18px;
}

html[data-embedded="true"][data-scene="memorial"] .photo-avatar-name {
    font-size: 26px;
}

html[data-embedded="true"][data-scene="memorial"] .photo-avatar-dates {
    font-size: 15px;
    margin-top: 6px;
}

/* 聊天区移至左侧，避免与肖像重叠 */
html[data-embedded="true"][data-scene="memorial"] .chat-container {
    position: fixed;
    left: 20px;
    right: auto;
    bottom: 96px;
    width: min(380px, 40%);
    min-width: 260px;
    z-index: 150;
}

html[data-embedded="true"][data-scene="memorial"] .chat-stream {
    width: 100%;
    max-height: min(360px, 42vh);
    margin-bottom: 12px;
}

html[data-embedded="true"][data-scene="memorial"] .message-bubble {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.55;
    padding: 10px 14px;
    border-radius: 14px;
}

html[data-embedded="true"][data-scene="memorial"] .chat-message.user .message-bubble {
    background: rgba(200, 164, 92, 0.32);
    border: 1px solid rgba(200, 164, 92, 0.35);
    color: #f5efe6;
}

html[data-embedded="true"][data-scene="memorial"] .chat-message.ai .message-bubble {
    color: #e8d5a3;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

html[data-embedded="true"][data-scene="memorial"] .chat-ipt input {
    background: rgba(26, 20, 16, 0.9);
    border: 1px solid rgba(200, 164, 92, 0.28);
    color: #e8d5a3;
    font-size: 14px;
    padding: 13px 18px;
}

html[data-embedded="true"][data-scene="memorial"] .chat-ipt input::placeholder {
    color: rgba(184, 169, 144, 0.6);
}

html[data-embedded="true"][data-scene="memorial"] .chat-ipt input:focus {
    border-color: rgba(200, 164, 92, 0.55);
    box-shadow: 0 4px 16px rgba(200, 164, 92, 0.15);
}

/* 底部控制栏 */
html[data-embedded="true"][data-scene="memorial"] .control-bar {
    bottom: 16px;
    padding: 11px 24px;
    gap: 14px;
    background: rgba(26, 20, 16, 0.94);
    border: 1px solid rgba(200, 164, 92, 0.22);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

html[data-embedded="true"][data-scene="memorial"] .control-btn {
    width: 56px;
    height: 56px;
}

html[data-embedded="true"][data-scene="memorial"] .status-indicator {
    display: none;
}

/* 窄屏：肖像居中上移，聊天移到底部 */
@media (max-width: 720px) {
    html[data-embedded="true"][data-scene="memorial"] .photo-avatar {
        left: 50%;
        top: 32%;
        width: min(340px, 88vw);
    }

    html[data-embedded="true"][data-scene="memorial"] .photo-avatar-frame {
        height: min(420px, 48vh);
        min-height: 300px;
    }

    html[data-embedded="true"][data-scene="memorial"] .chat-container {
        left: 12px;
        right: 12px;
        width: auto;
        bottom: 88px;
    }

    html[data-embedded="true"][data-scene="memorial"] .chat-stream {
        max-height: min(200px, 28vh);
    }

    html[data-embedded="true"][data-scene="memorial"] .control-btn {
        width: 50px;
        height: 50px;
    }
}

/* ===== 照片形象模式（替代 Live2D 卡通） ===== */
body.photo-avatar-active .background-container {
    background-image: none !important;
    background: linear-gradient(165deg, #1a1410 0%, #2c2416 40%, #1a1410 100%) !important;
}

body.photo-avatar-active .background-overlay {
    background: radial-gradient(ellipse at center 30%, rgba(200,164,92,0.12) 0%, transparent 60%) !important;
}

.photo-avatar {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    z-index: 120;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.photo-avatar-frame {
    position: relative;
    width: min(280px, 70vw);
    height: min(360px, 85vw);
    border-radius: 12px;
    padding: 6px;
    background: linear-gradient(145deg, rgba(200,164,92,0.6), rgba(160,128,64,0.3));
    box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}

.photo-avatar-portrait {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background-size: cover;
    background-position: center top;
    background-color: #3d3428;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 96px;
    font-family: "Noto Serif SC", serif;
    color: rgba(232,213,163,0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.photo-avatar-portrait.placeholder {
    background: linear-gradient(160deg, #4a4035, #2c2416);
}

.photo-avatar-glow {
    position: absolute;
    inset: -4px;
    border-radius: 14px;
    opacity: 0;
    background: radial-gradient(ellipse at center, rgba(200,164,92,0.35), transparent 70%);
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.photo-avatar.speaking .photo-avatar-glow {
    opacity: 1;
    animation: photoSpeakPulse 1.2s ease-in-out infinite;
}

.photo-avatar.speaking .photo-avatar-portrait {
    transform: scale(1.02);
    box-shadow: 0 0 24px rgba(200,164,92,0.25);
}

@keyframes photoSpeakPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.03); }
}

.photo-avatar-caption {
    margin-top: 16px;
    text-align: center;
}

.photo-avatar-name {
    font-size: 20px;
    font-weight: 600;
    color: #e8d5a3;
    font-family: "Noto Serif SC", serif;
}

.photo-avatar-dates {
    font-size: 13px;
    color: rgba(184,169,144,0.85);
    margin-top: 4px;
}

html[data-avatar-mode="photo"] #live2d-stage {
    display: none !important;
}
