/* ==========================================================================
   1. 全局定义与重置
   ========================================================================== */
:root {
    --base-width: 402;
    --base-height: 721;
    --u: calc(1024px / var(--base-width));
}

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

body {
    background-color: #e8f4fd; /* 修改背景色以测试CSS更新 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    overflow-y: auto;
    overflow-x: hidden;
}

/* ==========================================================================
   2. 布局容器
   ========================================================================== */
.app-container {
    display: grid;
    width: 100vw;
    min-height: 100vh;
    overflow: auto;
    position: relative; /* 作为 tooltip 的定位参照容器 */
}

.img-container {
    position: relative;
    width: calc(var(--base-width) * var(--u));
    height: calc(var(--base-height) * var(--u));
    background-color: white;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    margin: calc(60 * var(--u)) auto 0 auto; 
    flex-shrink: 0;
    overflow: hidden;
}

.background-video {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* ==========================================================================
   3. 组件样式
   ========================================================================== */

/* 页面导航栏 */
.page-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(60 * var(--u));
    background: #f0f2f5;
    backdrop-filter: blur(calc(10 * var(--u)));
    -webkit-backdrop-filter: blur(calc(10 * var(--u)));
    border-bottom: calc(1 * var(--u)) solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 0 calc(16 * var(--u));
}

.back-button {
    position: absolute;
    left: calc(16 * var(--u));
    top: 50%;
    transform: translateY(-50%);
    width: calc(32 * var(--u));
    height: calc(32 * var(--u));
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: calc(8 * var(--u));
    transition: background-color 0.2s ease;
}

.back-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.back-button:active {
    background-color: rgba(0, 0, 0, 0.1);
    transform: translateY(-50%) scale(0.95);
}

.back-button .icon {
    width: calc(20 * var(--u));
    height: calc(20 * var(--u));
    color: #333;
}

.search-icon-topics {
    width: calc(20 * var(--u));
    height: calc(20 * var(--u));
    color: #333;
}

/* 路由切换动画（淡入淡出），与 Router.transitionClass 协同 */
.route-fade {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.route-enter {
    opacity: 0.01;
    transform: translateY(4px);
}
.route-fade.route-enter {
    opacity: 1;
    transform: translateY(0);
}
.route-leave {
    opacity: 1;
}
.route-fade.route-leave {
    opacity: 0.01;
}

.page-title {
    text-align: center;
    flex: 1;
}

.page-title-text {
    font-size: calc(16 * var(--u));
    font-weight: 600;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.tag-button {
    appearance: none;
    border: none;
    background: none;
    font: inherit;
    cursor: pointer;
    text-align: center;
    position: absolute; 
    display: flex;
    align-items: center;
    justify-content: center;
    height: calc(25 * var(--u));
    padding: calc(8 * var(--u)) calc(9 * var(--u));
    gap: calc(8 * var(--u));
    border-radius: calc(12 * var(--u));
    box-shadow: 0px calc(8 * var(--u)) calc(16 * var(--u)) 0px rgba(0, 0, 0, 0.25);
    font-size: calc(16 * var(--u));
    background-color: white;
    font-family: 'Alibaba Sans:Medium', sans-serif;
    color: #121212;
    white-space: pre;
    line-height: normal;
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out, opacity 0.3s ease-in-out;
}

.tag-button:active {
    transform: scale(0.98); 
    box-shadow: 0px calc(4 * var(--u)) calc(12 * var(--u)) 0px rgba(0, 0, 0, 0.2),
                0 0 0 calc(4 * var(--u)) rgba(59, 130, 246, 0.4);
}

.line-container {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    /* width和height将由JavaScript动态设置 */
    transition: opacity 0.3s ease-in-out;
}

.line-rotator { 
    flex-shrink: 0; 
    /* transform将由JavaScript动态设置 */
}
.line-svg-wrapper { 
    position: relative; 
    /* width将由JavaScript动态设置 */
    height: 0; 
}
.line-svg-positioner { position: absolute; top: calc(-1 * var(--u)); left: 0; right: 0; bottom: 0; }
.line-svg { display: block; width: 100%; height: 100%; }

/* ==========================================================================
   4. 模态框 (Modal) 样式
   ========================================================================== */

.modal-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    will-change: opacity;
}

.modal-content {
    position: absolute;
    width: calc(320 * var(--u));
    padding: calc(20 * var(--u));
    border-radius: calc(24 * var(--u));
    background: rgba(255, 255, 255, 0.7); 
    backdrop-filter: blur(calc(20 * var(--u)));
    -webkit-backdrop-filter: blur(calc(20 * var(--u)));
    border: calc(1 * var(--u)) solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 calc(15 * var(--u)) calc(35 * var(--u)) rgba(0, 0, 0, 0.2);
    transform: translateY(calc(15 * var(--u))) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateY(calc(15 * var(--u))) scale(0.95);
}

.modal-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(12 * var(--u));
    margin-bottom: calc(16 * var(--u));
}

.modal-title-row {
    display: flex;
    align-items: center;
    width: 100%;
    gap: calc(16 * var(--u));
}

.modal-title {
    font-size: calc(24 * var(--u));
    font-weight: 700;
    color: #1d1d1f;
    text-transform: capitalize;
    text-shadow: 0 calc(2 * var(--u)) calc(5 * var(--u)) rgba(0, 0, 0, 0.25);
    margin: 0;
}

.modal-translation {
    font-size: calc(18 * var(--u));
    font-weight: 500;
    color: #555;
    margin: calc(4 * var(--u)) 0 0 0;
    text-shadow: 0 calc(1 * var(--u)) calc(4 * var(--u)) rgba(0, 0, 0, 0.2);
    line-height: 1.4;
    flex: 1;
}

.modal-translation-favorite-container {
    display: flex;
    align-items: center;
    gap: calc(12 * var(--u));
    margin-top: calc(4 * var(--u));
}

.modal-phonetics {
    display: flex;
    gap: calc(20 * var(--u));
    margin-top: calc(8 * var(--u));
    flex-wrap: nowrap;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.phonetic-item {
    display: flex;
    align-items: center;
    gap: calc(6 * var(--u));
}

.phonetic-label {
    font-size: calc(12 * var(--u));
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: calc(0.5 * var(--u));
}

.phonetic-symbol {
    font-size: calc(16 * var(--u));
    font-weight: 400;
    color: #333;
    font-family: 'Times New Roman', serif;
    background: rgba(255, 255, 255, 0.6);
    padding: calc(4 * var(--u)) calc(8 * var(--u));
    border-radius: calc(6 * var(--u));
    border: calc(1 * var(--u)) solid rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.modal-pronunciation-controls {
    display: flex;
    gap: calc(6 * var(--u));
    flex-shrink: 0;
}


.modal-favorite-controls {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.favorite-button {
    background: rgba(255, 255, 255, 0.6);
    border: calc(1 * var(--u)) solid rgba(0, 0, 0, 0.1);
    border-radius: calc(6 * var(--u));
    padding: calc(6 * var(--u));
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(32 * var(--u));
    height: calc(32 * var(--u));
}

.favorite-button img {
    width: calc(20 * var(--u));
    height: calc(20 * var(--u));
    transition: opacity 0.2s ease;
}

@media (hover: hover) {
    .favorite-button:hover {
        background: rgba(0, 0, 0, 0.05);
        transform: scale(1.1);
    }
}

.favorite-button:active {
    transform: scale(0.95);
}

.pronunciation-button {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: calc(4 * var(--u));
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: calc(6 * var(--u)) calc(10 * var(--u));
    border-radius: calc(6 * var(--u));
    border: calc(1 * var(--u)) solid rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, background-color 0.2s ease;
    position: relative;
}

.pronunciation-button .icon {
    width: calc(16 * var(--u));
    height: calc(16 * var(--u));
    color: #333;
}

.pronunciation-button .label {
    font-size: calc(12 * var(--u));
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: calc(0.5 * var(--u));
}

@media (hover: hover) {
    .pronunciation-button:not(:disabled):hover {
        background: rgba(0, 0, 0, 0.05);
        transform: scale(1.1);
    }
}
.pronunciation-button:not(:disabled):active {
    transform: scale(0.95);
}
.pronunciation-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* MODIFIED: Static background for playing state, no animation */
.pronunciation-button.is-playing {
    background: rgba(0, 122, 255, 0.15);
}

.modal-body {
    border-top: calc(1 * var(--u)) solid rgba(0, 0, 0, 0.1);
    padding-top: calc(16 * var(--u));
}

.modal-english, .modal-chinese {
    text-shadow: 0 calc(1 * var(--u)) calc(4 * var(--u)) rgba(0, 0, 0, 0.2);
}
.modal-english {
    font-size: calc(18 * var(--u));
    font-weight: 500;
    color: #1d1d1f;
    line-height: 1.5;
    margin-bottom: calc(12 * var(--u));
}
.modal-chinese {
    font-size: calc(18 * var(--u));
    color: #333;
    line-height: 1.6;
}

.close-button-wrapper {
     position: absolute;
     top: calc(6 * var(--u));
     right: calc(9 * var(--u));
}
.modal-close-button {
    width: calc(21 * var(--u));
    height: calc(21 * var(--u));
    font-size: calc(20 * var(--u));
    line-height: 1;
    color: #555;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}
.modal-close-button:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.1);
}

.img-container.modal-active .tag-button,
.img-container.modal-active .line-container {
    opacity: 0;
    pointer-events: none;
}

.img-container.modal-active .modal-overlay {
    opacity: 1;
    pointer-events: auto;
}

.img-container.modal-active .modal-content {
    transform: translate(-50%, -50%) translateY(0) scale(1);
}

/* ==========================================================================
   5. 响应式逻辑
   ========================================================================== */
@media (max-width: 1024px) {
    :root { --u: calc(100vw / var(--base-width)); }
}

@media (max-width: 360px) {
    :root { --u: calc(360px / var(--base-width)); }
}

/* ==========================================================================
   6. 背景音乐控制
   ========================================================================== */
.mute-button {
    position: absolute;
    top: calc(15 * var(--u));
    right: calc(15 * var(--u));
    width: calc(40 * var(--u));
    height: calc(40 * var(--u));
    background: rgba(255, 255, 255, 0.7);
    border: calc(1 * var(--u)) solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(calc(20 * var(--u)));
    -webkit-backdrop-filter: blur(calc(20 * var(--u)));
    box-shadow: 0 calc(8 * var(--u)) calc(20 * var(--u)) rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.mute-button:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.05);
    box-shadow: 0 calc(12 * var(--u)) calc(25 * var(--u)) rgba(0, 0, 0, 0.2);
}

.mute-button .icon {
    width: calc(20 * var(--u));
    height: calc(20 * var(--u));
    color: #333;
    transition: color 0.3s ease;
}

.mute-button.muted .icon {
    color: #999;
}

.mute-button:active {
    transform: scale(0.95);
}

/* 当modal打开时，静音按钮稍微降低透明度 */
.img-container.modal-active .mute-button {
    opacity: 0.7;
}

/* 播放按钮进入页面时的醒目动效 */
.mute-button.entry-animation {
    animation: muteButtonEntryAnimation 3s ease-out;
}

@keyframes muteButtonEntryAnimation {
    0% {
        transform: scale(1);
        box-shadow: 0 calc(8 * var(--u)) calc(20 * var(--u)) rgba(0, 0, 0, 0.15);
    }
    15% {
        transform: scale(1.2);
        box-shadow: 0 calc(15 * var(--u)) calc(30 * var(--u)) rgba(255, 215, 0, 0.4);
        background: rgba(255, 215, 0, 0.8);
        border-color: rgba(255, 215, 0, 0.6);
    }
    30% {
        transform: scale(1);
        box-shadow: 0 calc(8 * var(--u)) calc(20 * var(--u)) rgba(0, 0, 0, 0.15);
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(255, 255, 255, 0.2);
    }
    45% {
        transform: scale(1.15);
        box-shadow: 0 calc(12 * var(--u)) calc(25 * var(--u)) rgba(255, 215, 0, 0.3);
        background: rgba(255, 215, 0, 0.7);
        border-color: rgba(255, 215, 0, 0.5);
    }
    60% {
        transform: scale(1);
        box-shadow: 0 calc(8 * var(--u)) calc(20 * var(--u)) rgba(0, 0, 0, 0.15);
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(255, 255, 255, 0.2);
    }
    75% {
        transform: scale(1.1);
        box-shadow: 0 calc(10 * var(--u)) calc(22 * var(--u)) rgba(255, 215, 0, 0.2);
        background: rgba(255, 215, 0, 0.6);
        border-color: rgba(255, 215, 0, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 calc(8 * var(--u)) calc(20 * var(--u)) rgba(0, 0, 0, 0.15);
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(255, 255, 255, 0.2);
    }
}

/* ==========================================================================
   版本更新进度条样式
   ========================================================================== */
.update-progress-container {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    display: grid;
    place-content: center;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.update-progress-header {
    text-align: center;
    margin-bottom: calc(30 * var(--u, 1px));
}

.update-progress-header h3 {
    font-size: calc(20 * var(--u, 1px));
    font-weight: 600;
    margin-bottom: calc(10 * var(--u, 1px));
    color: #ffffff;
}

.update-progress-description {
    font-size: calc(14 * var(--u, 1px));
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.update-progress-bar-container {
    display: flex;
    align-items: center;
    gap: calc(15 * var(--u, 1px));
    margin-bottom: calc(20 * var(--u, 1px));
    padding: 0 calc(20 * var(--u, 1px));
    justify-content: center;
}

.update-progress-bar {
    width: calc(300 * var(--u, 1px));
    max-width: 80vw;
    height: calc(6 * var(--u, 1px));
    background: rgba(255, 255, 255, 0.2);
    border-radius: calc(3 * var(--u, 1px));
    overflow: hidden;
    position: relative;
}

.update-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: calc(3 * var(--u, 1px));
    transition: width 0.3s ease;
    position: relative;
}

.update-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progress-shine 2s infinite;
}

.update-progress-text {
    font-size: calc(16 * var(--u, 1px));
    font-weight: 600;
    color: #ffffff;
    min-width: calc(50 * var(--u, 1px));
    text-align: right;
}

.update-progress-details {
    text-align: center;
    font-size: calc(12 * var(--u, 1px));
    color: rgba(255, 255, 255, 0.7);
}

.update-progress-current-file {
    margin-bottom: calc(5 * var(--u, 1px));
    max-width: calc(350 * var(--u, 1px));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.update-progress-stats {
    font-weight: 500;
}

@keyframes progress-shine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}
