/* General Styles - 总体样式 (Mobile First) */
body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f8f8f8;
    color: #333;
    display: flex;
    min-height: 100vh;
    font-size: 16px;
    padding-bottom: 60px;
}

.container {
    display: flex;
    width: 100%;
}



/* Bottom Navigation Styles - 底部导航样式 (默认显示) */
#bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: #ffffff;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    z-index: 950; /* 低于 tooltip，但高于 sidebar */
    border-top: 1px solid #e0e0e0;
}

#bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    color: #757575;
    font-size: 0.75em;
    padding: 5px 0;
    transition: color 0.2s ease;
}

#bottom-nav .nav-item i {
    font-size: 1.5em;
    margin-bottom: 4px;
}

#bottom-nav .nav-item.active {
    color: #72a5f8eb;
}

/* Content Area - 内容区域 */
#content {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
    margin-left: 0;
    transition: margin-left 0.3s;
    z-index: 800; /* 最低层，确保 tooltip 在其上方 */
}

/* Card - 卡片 */
.card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    cursor: pointer;
    letter-spacing: 10px;
    -webkit-tap-highlight-color: transparent;
    font-size: 32px;
    line-height: 1.8; /* 确保行高足够 */
}

/* Hanzi Character - 汉字字符 */
.hanzi-char {
    cursor: pointer;
    padding: 2px 4px;
    font-size: 1em;
    line-height: 1.5;
}

/* Hanzi Character - 汉字字符 */
.hanzi-char, .non-hanzi {
    cursor: pointer;
    padding: 2px 4px;
    font-size: 1em;
    line-height: 1.5;
}

/* TTS Highlight - 播放时逐字高亮 */
.hanzi-char.tts-highlight, .non-hanzi.tts-highlight {
    background-color: #ff000080;
    color: #333;
    border-radius: 3px;
    padding: 2px 4px;
    display: inline-block;
    letter-spacing: 0;
}

/* Buttons - 按钮样式 */
#playButton, #articleButton, #nextSentenceButton, #nextArticleButton, .tts-button {
    position: relative;
    background-color: #4285f4;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    margin: 10px;
    z-index: 1000; /* 同级于 bottom-nav，低于 tooltip */
    border: 1px solid transparent;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#playButton:hover, #articleButton:hover, #nextSentenceButton:hover, #nextArticleButton:hover, .tts-button:hover {
    background-color: #3267d6;
    border-color: #fff;
}

#playButton:active, #articleButton:active, #nextSentenceButton:active, #nextArticleButton:active, .tts-button:active {
    background-color: #2a56c6;
}

/* Button Container - 按钮容器 */
.button-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
    gap: 10px;
}

/* Pinyin Component Styles (用于 tooltip) */
.pinyin-component {
    padding: 8px 12px;
    min-width: 40px;
    display: inline-block;
    text-align: center;
    transition: background-color 0.2s ease;
}
.plus { 
    color: rgb(9, 9, 9); 
    margin: 0 2px; 
}
.pinyin-component.initial { 
    color: blue; 
}
.pinyin-component.medial { 
    color: green; 
}
.pinyin-component.final { 
    color: red; 
    text-align: right; /* 确保最后一个音节右对齐 */
}
.pinyin-component.whole-syllable { 
    color: rgb(154, 46, 152); 
    text-align: right; /* 右对齐 */
}
.pinyin-component.whole-pinyin { 
    color: black; 
    text-align: right; /* 右对齐 */
}

/* Pinyin Tooltip */
.pinyin-tooltip {
    background-color: #eae9e9fa;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 8px 10px;
    z-index: 3000; /* 最高层，确保不被遮挡 */
    font-size: clamp(1.2rem, 2.5vw, 1.4rem);
    opacity: 0;
    /*transition: opacity 0.2s ease, top 0.2s ease, left 0.2s ease;
    max-width: 75vw; /* 紧凑 */
    overflow: hidden;
    word-break: break-word;
}

.pinyin-tooltip.show {
    opacity: 1;
}

.pinyin-tooltip .tooltip-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start; /* 从左到右 */
    align-items: center;
    gap: 6px;
    color: #333;
}

.pinyin-tooltip .pinyin-component {
    padding: 5px 8px;
    min-width: 30px;
    border-radius: 3px;
    font-size: 1.2em;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.pinyin-tooltip .pinyin-component:hover {
    transform: scale(1.05);
}

.pinyin-tooltip .pinyin-component.pinyin-highlight {
    background-color: #e6f3ff;
}

.pinyin-tooltip .plus {
    margin: 0 4px;
    font-size: 0.9em;
}

/* Highlight Styles */
.hanzi-char.highlight {
    background-color: #c9d5d2;
    color: #333;
    border-radius: 3px;
    padding: 2px 4px;
    display: inline-block;
    letter-spacing: 0;
}

/* Loading Styles */
.loading { 
    text-align: center; 
    color: #666; 
    margin: 20px; 
}

/* Article Styles */
.article {
    line-height: 1.8;
    margin: 10px 0;
    text-align: left;
    letter-spacing: normal;
}
.article h3 {
    font-size: 1.5em;
    margin-bottom: 15px;
    text-align: center;
}

/* 统一 h3 样式 */
.card h3 {
    font-size: 1.5em;
    margin-bottom: 15px;
    text-align: center;
}

.article p {
    margin: 0 0 1em 0;
    text-indent: 0;
    line-height: 1.8;
}
.article p:last-child {
    margin-bottom: 0;
}

/* Card Container Styles */
#card-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Media Queries for Responsiveness --- */

/* 超小屏幕适配 (max-width: 360px) */
@media (max-width: 360px) {
    #playButton, #articleButton, #nextSentenceButton, #nextArticleButton, .tts-button {
        font-size: clamp(0.6rem, 2vw, 0.7rem);
        padding: 5px 10px;
    }
    .card {
        font-size: 20px;
        letter-spacing: 2px;
        padding: 8px;
    }
    .button-container {
        gap: 6px;
    }
    .pinyin-tooltip {
        font-size: clamp(1rem, 2vw, 1.1rem);
        max-width: 70vw;
        padding: 6px 8px;
    }
    .pinyin-tooltip .pinyin-component {
        padding: 3px 6px;
        min-width: 25px;
    }
}

/* 移动端样式调整 (max-width: 800px) */
@media (max-width: 800px) {
    body {
        padding-bottom: 60px;
    }
    .card {
        font-size: 28px;
        letter-spacing: 5px;
        padding: 15px;
    }
    #playButton, #articleButton, #nextSentenceButton, #nextArticleButton, .tts-button {
        font-size: clamp(0.8rem, 2.5vw, 0.9rem);
        padding: 8px 16px;
    }
    .article {
        font-size: 2.5em;
    }
    .pinyin-tooltip {
        padding: 6px 8px;
        font-size: clamp(1.1rem, 2.5vw, 1.2rem);
        max-width: 75vw;
    }
    .pinyin-tooltip .tooltip-content {
        gap: 4px;
    }
    .pinyin-tooltip .pinyin-component {
        padding: 4px 6px;
        min-width: 25px;
        font-size: 1.4em;
    }
    .pinyin-tooltip .plus {
        margin: 0 3px;
    }

    #bottom-nav {
        display: flex;
    }
    #content {
        margin-left: 0;
    }
}

/* 手机横屏模式 */
@media (max-width: 900px) and (orientation: landscape) {
    body {
        padding-bottom: 60px;
    }

    #bottom-nav {
        display: flex;
    }
    #content {
        margin-left: 0;
    }
    .card {
        font-size: 24px;
        letter-spacing: 3px;
    }
    .pinyin-tooltip {
        font-size: clamp(1.1rem, 2vw, 1.2rem);
        max-width: 75vw;
    }
}

/* 平板及桌面端样式调整 (min-width: 801px) */
@media (min-width: 801px) {
    body {
        padding-bottom: 60px;
        font-size: 17px;
        
    }

    #bottom-nav {
        display: flex;
    }
    #content {
        margin-left: 0;
    }
    .article, .article p {
        text-indent: 2em;
        font-size: clamp(3.6rem, 6vw, 3.9rem);
        
    }
    #playButton, #articleButton, #nextSentenceButton, #nextArticleButton, .tts-button {
        font-size: clamp(0.9rem, 2.5vw, 1rem);
    }
    .pinyin-tooltip {
        font-size: clamp(2.4rem, 4vw, 2.6rem);
        max-width: 50vw;
        padding: 8px 12px;
    }
    .pinyin-tooltip .pinyin-component {
        padding: 6px 10px;
        min-width: 35px;
        font-size: 1.4em;
    }
}