/**
 * 火桥（huoqiao）· 多功能沉浸式 WordPress 主题
 * 联系方式：12492501@qq.com
 * 支持正版，从我做起，你的支持是我们前行的动力！
 *
 * @package   huoqiao
 * @author    三木
 * @copyright Copyright (c) 2026-09-01 huoqiao.cn
 * @license   GPL-2.0-or-later
 * @link      https://huoqiao.cn
 * @tags      design-tokens, responsive, dark-mode, glassmorphism, animation
 */

/* ============================================================
   1. 消息操作条上的「朗读」按钮
   ============================================================ */
.hq-ai-spk-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px 3px 8px;
}

.hq-ai-spk-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    opacity: 0.85;
}

.hq-ai-spk-btn.is-on {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.16), rgba(34, 211, 238, 0.16));
    color: #6d51f2;
    font-weight: 600;
}

.hq-ai-spk-btn.is-on svg {
    opacity: 1;
    animation: hq-ai-spk-pop 1.4s ease-in-out infinite;
}

@keyframes hq-ai-spk-pop {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.16); }
}

/* 朗读中：操作条常显（不依赖 hover） */
.hq-ai__msg.is-speaking .hq-ai__msg-actions {
    opacity: 1;
}

/* 朗读中：气泡高亮描边 + 左侧渐变条 */
.hq-ai__msg.is-speaking .hq-ai__bubble {
    border-color: rgba(124, 92, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.1);
    position: relative;
}

.hq-ai__msg.is-speaking .hq-ai__bubble::after {
    content: "";
    position: absolute;
    left: -1px;
    top: 12px;
    bottom: 12px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, #7C5CFF, #22D3EE);
    animation: hq-ai-spk-glow 1.6s ease-in-out infinite;
}

@keyframes hq-ai-spk-glow {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 1; }
}

/* ============================================================
   2. 朗读控制条（位于输入台上方）
   ============================================================ */
.hq-ai-spk {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    max-height: 0;
    margin: 0;
    padding: 0 14px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    border-top: 1px solid transparent;
    background: rgba(124, 92, 255, 0.06);
    transition: max-height 0.24s ease, opacity 0.2s ease, padding 0.24s ease,
                border-color 0.24s ease;
}

.hq-ai-spk.is-on {
    max-height: 60px;
    padding: 9px 14px;
    opacity: 1;
    pointer-events: auto;
    border-top-color: rgba(124, 92, 255, 0.16);
}

.hq-ai-spk__spacer {
    flex: 1;
    min-width: 0;
}

/* --- 声波动画 --- */
.hq-ai-spk__wave {
    display: inline-flex;
    align-items: flex-end;
    gap: 2.5px;
    height: 16px;
    flex-shrink: 0;
}

.hq-ai-spk__wave i {
    display: block;
    width: 3px;
    height: 5px;
    border-radius: 2px;
    background: linear-gradient(180deg, #7C5CFF, #22D3EE);
    animation: hq-ai-spk-bar 0.9s ease-in-out infinite;
}

.hq-ai-spk__wave i:nth-child(1) { animation-delay: 0s; }
.hq-ai-spk__wave i:nth-child(2) { animation-delay: 0.14s; }
.hq-ai-spk__wave i:nth-child(3) { animation-delay: 0.28s; }
.hq-ai-spk__wave i:nth-child(4) { animation-delay: 0.42s; }
.hq-ai-spk__wave i:nth-child(5) { animation-delay: 0.56s; }

@keyframes hq-ai-spk-bar {
    0%, 100% { height: 5px;  opacity: 0.55; }
    50%      { height: 15px; opacity: 1; }
}

.hq-ai-spk__wave.is-paused i {
    animation-play-state: paused;
    height: 6px;
    opacity: 0.5;
}

/* --- 文案与进度 --- */
.hq-ai-spk__text {
    font-size: 12.5px;
    font-weight: 600;
    color: #6d51f2;
    white-space: nowrap;
}

.hq-ai-spk__prog {
    font-size: 11.5px;
    color: #9a8f86;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(58, 46, 40, 0.07);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* --- 语速 / 控制按钮 --- */
.hq-ai-spk__rate {
    padding: 4px 10px;
    border: 1px solid rgba(124, 92, 255, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    color: #6d51f2;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.18s ease, transform 0.18s ease;
    font-variant-numeric: tabular-nums;
}

.hq-ai-spk__rate:hover {
    background: rgba(124, 92, 255, 0.12);
}

.hq-ai-spk__rate:active { transform: scale(0.94); }

.hq-ai-spk__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #7C5CFF, #22D3EE);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.hq-ai-spk__btn svg { width: 15px; height: 15px; }

.hq-ai-spk__btn:hover {
    box-shadow: 0 4px 12px rgba(124, 92, 255, 0.34);
}

.hq-ai-spk__btn:active { transform: scale(0.9); }

.hq-ai-spk__btn--stop {
    background: rgba(58, 46, 40, 0.1);
    color: #5a4f48;
}

.hq-ai-spk__btn--stop:hover {
    background: rgba(255, 106, 61, 0.16);
    color: #e8552f;
    box-shadow: none;
}

/* ============================================================
   3. 暗色模式
   ============================================================ */
[data-theme="dark"] .hq-ai-spk {
    background: rgba(124, 92, 255, 0.1);
}

[data-theme="dark"] .hq-ai-spk.is-on {
    border-top-color: rgba(124, 92, 255, 0.22);
}

[data-theme="dark"] .hq-ai-spk__text { color: #a78bfa; }

[data-theme="dark"] .hq-ai-spk__prog {
    background: rgba(255, 255, 255, 0.08);
    color: #8d97a8;
}

[data-theme="dark"] .hq-ai-spk__rate {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(167, 139, 250, 0.32);
    color: #a78bfa;
}

[data-theme="dark"] .hq-ai-spk__rate:hover {
    background: rgba(124, 92, 255, 0.2);
}

[data-theme="dark"] .hq-ai-spk__btn--stop {
    background: rgba(255, 255, 255, 0.09);
    color: #c3cad6;
}

[data-theme="dark"] .hq-ai-spk__btn--stop:hover {
    background: rgba(255, 106, 61, 0.2);
    color: #ffb59e;
}

[data-theme="dark"] .hq-ai-spk-btn.is-on {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.26), rgba(34, 211, 238, 0.22));
    color: #c4b5fd;
}

[data-theme="dark"] .hq-ai__msg.is-speaking .hq-ai__bubble {
    border-color: rgba(167, 139, 250, 0.5);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.16);
}

/* ============================================================
   4. 移动端（≤760px）：更紧凑、触控友好
   ============================================================ */
@media (max-width: 760px) {
    .hq-ai-spk.is-on {
        max-height: 58px;
        padding: 8px 12px;
        gap: 8px;
    }

    .hq-ai-spk__text { font-size: 12px; }

    .hq-ai-spk__prog { font-size: 11px; padding: 2px 7px; }

    .hq-ai-spk__btn {
        width: 34px;
        height: 34px;
    }

    .hq-ai-spk__btn svg { width: 16px; height: 16px; }

    .hq-ai-spk__rate { padding: 5px 10px; }
}

/* 窄屏（≤380px）：隐藏进度，保住按钮区 */
@media (max-width: 380px) {
    .hq-ai-spk__prog { display: none; }
}
