/* 自觉一点 - 单词动画 H5 样式 */

/* 加载项目内楷体字体（与原视频保持一致） */
@font-face {
    font-family: 'STKAITI';
    src: url('../font/STKAITI.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: #1a1a1a;
    color: #fff;
    user-select: none;
}

#app {
    display: flex;
    height: 100vh;
}

/* ==================== 侧栏 ==================== */
#sidebar {
    width: 300px;
    background: #222;
    padding: 16px;
    overflow-y: auto;
    border-right: 1px solid #333;
    flex-shrink: 0;
}

#sidebar h1 {
    color: pink;
    font-size: 24px;
    margin-bottom: 12px;
    text-align: center;
    text-shadow: 0 0 4px red;
}

/* ==================== 添加单词区 ==================== */
#add-words-section {
    margin-bottom: 12px;
    background: #2a2a2a;
    border-radius: 6px;
    padding: 8px;
}

#add-words-section summary {
    cursor: pointer;
    font-size: 14px;
    color: #8a8acc;
    padding: 4px;
    user-select: none;
}

#add-words-section summary:hover {
    color: #aaaadd;
}

#add-words-section .hint {
    font-size: 11px;
    color: #888;
    margin: 8px 4px 4px;
}

.audio-select {
    display: flex;
    gap: 16px;
    margin: 8px 4px;
    font-size: 12px;
    color: #aaa;
}

.audio-select label {
    cursor: pointer;
}

.audio-select input[type="radio"] {
    margin-right: 4px;
}

#add-words-input {
    width: 100%;
    height: 100px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
    padding: 8px;
    font-size: 13px;
    font-family: monospace;
    resize: vertical;
}

#add-words-input:focus {
    outline: none;
    border-color: #666;
}

.btn-fetch {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    background: #4a7a4a;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.btn-fetch:hover {
    background: #3a3a7a;
}

.btn-fetch:disabled {
    background: #555;
    cursor: not-allowed;
}

#fetch-status {
    font-size: 12px;
    margin-top: 6px;
    padding: 4px;
    min-height: 16px;
}

#fetch-status.ok {
    color: #6a6;
}

#fetch-status.err {
    color: #a66;
}

#fetch-status .word-result {
    display: inline-block;
    margin: 2px 4px;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 11px;
}

#fetch-status .word-result.ok {
    background: #2a4a2a;
    color: #8c8;
}

#fetch-status .word-result.fail {
    background: #4a2a2a;
    color: #c88;
}

/* 采集进度条 */
.fetch-progress-wrap {
    width: 100%;
    height: 22px;
    background: #2a2a2a;
    border-radius: 11px;
    overflow: hidden;
    margin-bottom: 6px;
    border: 1px solid #444;
}

.fetch-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #4a8a6a 0%, #5a9a7a 50%, #4a8a6a 100%);
    background-size: 200% 100%;
    border-radius: 11px;
    transition: width 0.3s ease;
    animation: fetch-progress-shimmer 1.5s linear infinite;
}

@keyframes fetch-progress-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.fetch-progress-text {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 6px;
}

.fetch-results {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

/* ==================== 设置面板 ==================== */
#settings-section {
    margin-bottom: 12px;
    background: #2a2a2a;
    border-radius: 6px;
    padding: 8px;
}

#settings-section summary {
    cursor: pointer;
    font-size: 14px;
    color: #9a9acc;
    padding: 8px 12px;
    user-select: none;
    background: rgba(100, 100, 160, 0.2);
    border-radius: 4px;
    margin: -4px;
    transition: all 0.2s ease;
}

#settings-section summary:hover {
    color: #bbbedd;
    background: rgba(100, 100, 160, 0.3);
}

#settings-section[open] summary {
    background: rgba(100, 100, 160, 0.4);
    border-radius: 4px 4px 0 0;
}

/* 设置预览 */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 8px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-group label {
    font-size: 11px;
    color: #888;
}

.setting-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #3a3a5a 0%, #444 100%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    appearance: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #8a8acc 0%, #6a6a9a 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.setting-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.setting-group input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #3a3a5a 0%, #444 100%);
    border-radius: 3px;
    border: none;
}

.setting-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #8a8acc 0%, #6a6a9a 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.setting-group input[type="color"] {
    width: 100%;
    height: 34px;
    background: transparent;
    border: 2px solid #444;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.setting-group input[type="color"]:hover {
    border-color: #666;
}

.setting-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 4px;
}

.setting-group input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.setting-group input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    background: #1a1a1a;
    border: 2px solid #444;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s ease;
}

.setting-group input[type="text"]:focus {
    outline: none;
    border-color: #8a8acc;
}

.setting-value {
    font-size: 11px;
    color: #aaa;
    text-align: right;
}

.setting-tip {
    font-size: 10px;
    color: #666;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    cursor: pointer;
    margin-bottom: 4px;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.setting-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #444;
    display: flex;
    gap: 10px;
}

.setting-actions button {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#btn-save-settings {
    background: linear-gradient(135deg, #2a8a4a 0%, #1a7a3a 100%);
    color: #fff;
}

#btn-save-settings:hover {
    background: linear-gradient(135deg, #3a9a5a 0%, #2a8a4a 100%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

#btn-save-settings.saved {
    background: linear-gradient(135deg, #4aaa6a 0%, #3a9a5a 100%);
}

#btn-reset-settings {
    background: linear-gradient(135deg, #6b6b9b 0%, #5a5a8a 100%);
    color: #fff;
}

#btn-reset-settings:hover {
    background: linear-gradient(135deg, #7b7baa 0%, #6a6a9a 100%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.setting-actions button:active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transform: translateY(0);
}

.setting-actions button:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* 背景图片上传按钮 */
.bg-upload-row {
    display: flex;
    gap: 6px;
}

.btn-bg {
    flex: 1;
    padding: 6px 10px;
    background: #3a3a3a;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}

.btn-bg:hover {
    background: #4a4a4a;
}

.btn-bg:disabled {
    opacity: 0.5;
    cursor: wait;
}

.btn-bg-clear {
    background: #3a2a2a;
    color: #ff8888;
    border-color: #6a3a3a;
    flex: 0 0 auto;
}

.btn-bg-clear:hover {
    background: #4a2a2a;
}

/* ==================== 搜索 ==================== */
#word-list-header {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

#word-list-header #search {
    flex: 1;
    margin-bottom: 0;
}

#word-list-header .btn-clear {
    width: auto;
    padding: 8px 12px;
    margin-top: 0;
    background: #3a3a3a;
    color: #ff6666;
    font-size: 16px;
    line-height: 1;
}

#word-list-header .btn-clear:hover {
    background: #5a3a3a;
}

#search {
    width: 100%;
    padding: 8px 12px;
    background: #333;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 14px;
}

#search:focus {
    outline: none;
    border-color: #666;
}

#word-list {
    list-style: none;
}

#word-list li {
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: baseline;
}

#word-list li:hover {
    background: #333;
}

#word-list li.active {
    background: #4a4a8a;
}

#word-list li .num {
    color: #888;
    font-size: 13px;
    margin-right: 8px;
    font-family: monospace;
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

#word-list li .en {
    color: white;
    font-size: 15px;
    font-weight: 500;
}

#word-list li .cn {
    color: #aaa;
    font-size: 12px;
    margin-left: 8px;
}

.btn-delete-word {
    background: none;
    border: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

#word-list li:hover .btn-delete-word {
    opacity: 1;
}

.btn-delete-word:hover {
    color: #ff6666;
}

#word-list .empty {
    color: #666;
    text-align: center;
    padding: 20px;
}

/* ==================== 播放区 ==================== */
#player {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-width: 0;
}

#canvas-wrap {
    position: relative;
    height: calc(100vh - 120px);
    aspect-ratio: 1080 / 1440;
    background: black;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 循环计数徽章 */
#loop-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 12px;
    pointer-events: none;
    font-family: -apple-system, "Segoe UI", sans-serif;
    backdrop-filter: blur(4px);
}

#loop-badge #loop-count {
    color: yellow;
    font-weight: 600;
    margin-left: 2px;
}

#controls {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
}

button {
    padding: 10px 16px;
    background: #4a4a8a;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s;
}

button:hover {
    background: #5a5a9a;
}

button:active {
    background: #3a3a7a;
}

#btn-play {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 18px;
}

#current-word {
    color: #aaa;
    font-size: 14px;
    margin-left: 12px;
    font-family: 'STKAITI', serif;
}

#current-word .word-num {
    color: #888;
    font-size: 12px;
    font-family: monospace;
    margin-right: 4px;
}

#current-word .ipa {
    color: yellow;
    font-family: Arial, sans-serif;
    margin: 0 6px;
}

/* ==================== 移动端适配 ==================== */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }
    #sidebar {
        width: 100%;
        height: 35vh;
        border-right: none;
        border-bottom: 1px solid #333;
    }
    #canvas-wrap {
        height: calc(65vh - 80px);
    }
}

/* ==================== 导出按钮 ==================== */
.btn-export {
    padding: 6px 12px;
    background: #4a6a4a;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
    margin-left: 4px;
}

.btn-export:hover {
    background: #5a7a5a;
}

.btn-export:disabled {
    background: #555;
    cursor: not-allowed;
}

.btn-export.recording {
    background: #a44;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 导出进度提示 */
#export-status {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    display: none;
}

#export-status.show {
    display: block;
}

#export-status .progress-bar {
    width: 200px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

#export-status .progress-fill {
    height: 100%;
    background: #6a6;
    width: 0%;
    transition: width 0.1s;
}
