/**
 * 黑板组件样式
 * 完整复刻自 ai-tutor-v3.1-阿里 项目，适配当前 LiveKit 版本
 */

/* ===== 手写字体 ===== */
@font-face {
    font-family: 'shouxie';
    src: url('../../assets/fonts/shouxie.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ===== 黑板容器 ===== */
.blackboard {
    flex: 1;
    background: linear-gradient(145deg, #2d5a3d 0%, #1e3d2f 50%, #0f2920 100%);
    border-radius: var(--radius-lg);
    border: 8px solid #8b7355;
    position: relative;
    overflow: hidden;
    padding: var(--spacing-3xl);
}

/* 黑板纹理效果 */
.blackboard::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.02) 2px,
        rgba(255, 255, 255, 0.02) 4px
    );
    pointer-events: none;
}

/* 黑板标题栏 */
.blackboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xl);
    padding: 10px 35px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

.blackboard-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.blackboard-status {
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
}

/* 题目展示区域 */
.question-area {
    min-height: 200px;
    padding: var(--spacing-2xl);
    border-radius: var(--radius-sm);
    font-family: var(--font-family-english);
}

.question-label {
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* 题干容器（包含小喇叭和题干文字） */
.question-content-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* 小喇叭图标 */
.speaker-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    color: var(--text-chalk);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.speaker-icon svg {
    width: 120%;
    height: 120%;
    margin-top: 10px;
    color: #ffff66;
}

/* 小喇叭声波动画（默认隐藏） */
.speaker-icon .sound-wave {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* AI说话时，小喇叭发出声波 */
.speaker-icon.speaking .sound-wave {
    opacity: 1;
}

.speaker-icon.speaking .wave-1 {
    animation: soundWavePulse 1s ease-in-out infinite;
}

.speaker-icon.speaking .wave-2 {
    animation: soundWavePulse 1s ease-in-out infinite 0.2s;
}

@keyframes soundWavePulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.question-content {
    font-size: 28px;
    color: var(--text-chalk);
    font-family: 'times new roman';
    word-break: break-word;
    width: fit-content;
    color: #fff;
}

/* 单词标记（默认无样式） */
.word-marker {
    position: relative;
    text-decoration: none;
    border-bottom: none;
}

/* 提示词标记（默认无样式） */
.clue-marker {
    position: relative;
    text-decoration: none;
    border-bottom: none;
}

/* 手写绘制动画 */
@keyframes handwriteDraw {
    0% { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}

/* 高亮下划线（改为手写动画渲染） */
.word-marker.highlight::after,
.clue-marker.highlight::after {
    content: none;
}

/* 填空占位 */
.blank-slot {
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    min-width: 6ch;
    margin: 0 4px;
    position: relative;
    padding: 0 4px;
}

/* 填空答案文字 */
.blank-answer {
    color: #ff3666;
    font-family: 'times new roman';
    opacity: 0;
    animation: handwriteFadeIn 0.5s ease-out forwards;
    font-size: 28px;
}

@keyframes handwriteFadeIn {
    0% { opacity: 0; transform: translateY(2px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ===== 板书区域样式 ===== */
/* 板书容器 */
.note-area {
    margin-top: 30px;
    padding-top: 20px;
    min-height: 50px;
    margin-left: 55px;
    max-width: 100%;
    position: relative;

    /* 板书更多就往右排列，因此改为横向布局 */
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 28px;
    flex-wrap: nowrap;
}

/* 单组板书（一组标题+多行要点），用于横向排列 */
.note-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: fit-content;
}

/* 板书整行遮罩书写文字 */
.note-line {
    white-space: nowrap;
    clip-path: inset(0 100% 0 0);    /* 默认整行隐藏 */
    will-change: clip-path;
    width: fit-content;
    max-width: 100%;
}

/* 板书下划线笔迹 */
.hand-underline {
    position: absolute;
    left: 0;
    bottom: -6px;
    height: 6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 6' preserveAspectRatio='none'%3E%3Cpath d='M0 3 Q 2.5 0, 5 3 T 10 3 T 15 3 T 20 3' stroke='%23ff0000' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: 20px 6px;
    background-repeat: repeat-x;
    transform-origin: left center;
    width: 0;
}

/* 板书笔迹层（用于画圈等扩展动作） */
.ink-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
}

/* ===== 题目闪烁动画 ===== */
.question-content.flashing {
    animation: textFlash 1.5s ease-in-out infinite;
}

@keyframes textFlash {
    0%, 100% {
        color: #fff;
    }
    25% {
        color: #fff;
    }
    50% {
        color: #ff3666;
    }
    75% {
        color: #fff;
    }
}

/* 板书标题行 */
.note-title {
    font-size: 22px;
    color: #ff3666;
    font-weight: 600;
    margin-bottom: 12px;
    font-family: 'shouxie', 'KaiTi', 'STKaiti', serif;
}

/* 板书内容行 */
.note-item {
    font-size: 20px;
    color: #09efbadb;
    margin-left: 20px;
    margin-bottom: 8px;
    font-family: 'shouxie', 'KaiTi', 'STKaiti', serif;
    line-height: 1.3;
}

/* 逐字出现动画 */
.note-char {
    opacity: 0;
    display: inline-block;
    animation: charFadeIn 0.15s ease-out forwards;
}

@keyframes charFadeIn {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 左边栏 */
.left-panel {
    height: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #00cc99;
    overflow: hidden;
    margin: 10px;
}

/* ===== 讲解手拿笔样式（PNG抠图） ===== */
/* 手臂容器 */
.teaching-arm {
    position: absolute;
    width: 280px;
    height: auto;
    pointer-events: none;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.5s ease, left 0.6s cubic-bezier(0.4, 0, 0.2, 1), top 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left top;
}

.teaching-arm.visible {
    opacity: 1;
}

/* 手部PNG图片 */
.teaching-hand-img {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(3px 5px 8px rgba(0, 0, 0, 0.35));
    transform-origin: left top;
}

/* 指点动画（轻微上下点击，模拟手腕动作） */
.teaching-arm.pointing .teaching-hand-img {
    animation: pointGesture 1.5s ease-in-out infinite;
}

@keyframes pointGesture {
    0%, 100% {
        transform: translate(0, 0);
    }
    50% {
        transform: translate(-3px, -3px);
    }
}

/* 写字动画（手腕自然摆动书写） */
.teaching-arm.writing .teaching-hand-img {
    animation: writingMotion 2s ease-in-out infinite;
}

@keyframes writingMotion {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(3px, 1px) rotate(0.5deg);
    }
    50% {
        transform: translate(-2px, 2px) rotate(-0.5deg);
    }
    75% {
        transform: translate(2px, 0px) rotate(0.3deg);
    }
}

/* 移动动画（保持平滑过渡） */
.teaching-arm.moving {
    transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1), top 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== AI字幕条样式 ===== */
/* 字幕条容器 */
.subtitle-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 70%;
    min-height: 50px;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    overflow: hidden;
}

.subtitle-bar.active {
    opacity: 1;
}

/* 字幕文字 */
.subtitle-text {
    color: #fff666;
    font-size: 18px;
    line-height: 1.6;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    word-break: break-word;
    max-width: 100%;
    padding: 3px 10px;
    border-radius: 5px;
    background: #00cc99;
    height: 35px;
    overflow: hidden;
}

/* ===== 题目区域闪烁动画 ===== */
.question-area.flashing {
    animation: questionFlash 0.8s ease-in-out;
}

@keyframes questionFlash {
    0%, 100% {
        background-color: transparent;
    }
    25% {
        background-color: rgba(255, 215, 0, 0.15);
    }
    50% {
        background-color: rgba(255, 215, 0, 0.25);
    }
    75% {
        background-color: rgba(255, 215, 0, 0.15);
    }
}
