/* 单词本 31 - 页面样式 */
body {
    background-color: #FFF9F0;
}

.words-container {
    max-width: var(--site-max-width);
    margin: 0 auto;
    padding: 80px var(--site-gutter) 40px;
}

.unit-block {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(96, 64, 24, 0.06);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.unit-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #262626;
    margin: 0;
    padding: 0.9rem 1.1rem;
    border-bottom: 2px solid var(--coral);
    background: var(--coral-softer);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.unit-title::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 1.2em;
    background: #FF6B6B;
    border-radius: 2px;
}

.lesson-block {
    /* 容器 */
}

.lesson-title {
    font-size: 1.05rem;
    font-weight: bold;
    color: #262626;
    background: var(--line-soft);
    padding: 0.55rem 1.1rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.lesson-block:first-of-type .lesson-title {
    border-top: none;
}

.word-row {
    display: grid;
    grid-template-columns: minmax(90px, 1.2fr) minmax(110px, 1.2fr) 2.6fr;
    column-gap: 1.25rem;
    align-items: baseline;
    padding: 0.7rem 1.1rem;
    border-bottom: 1px solid #f1f3f5;
    font-size: 1.25rem;
    line-height: 1.55;
    color: #262626;
}

.word-row:last-child {
    border-bottom: none;
}

/* 子项缩进：Order 为其他单词前缀的（如 31 是 3 的子项）
   只缩进英文单词列，中文释义、例句保持与其它词条对齐 */
.word-row-child .word-en-col {
    padding-left: 2.4rem;
}

@media (max-width: 576px) {
    .word-row-child .word-en-col {
        padding-left: 1.8rem;
    }
}

@media (hover: hover) {
    .word-row:hover {
        background-color: #f2f7fc;
    }
}

/* 英文列容器：单词 + 音标同一行展示 */
.word-row .word-en-col {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

/* 音标：小号灰色，紧跟在单词后 */
.word-row .word-phonetic {
    font-size: 0.9rem;
    color: #7c8798;
    word-break: break-word;
}

.word-en {
    color: #262626;
    font-weight: 500;
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* 重点单词（Important: true）：单词文字加粗
   .word-text 需覆盖 .word-en 默认的 500 与移动端设置的 600 */
.word-row .word-en.important,
.word-row .word-en.important .word-text {
    font-weight: bold;
}

/* 陌生单词标注按钮：位于单词前，点击切换陌生标记 */
.word-en .unfamiliar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: none;
    color: #E0D2BC;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.2s ease, transform 0.15s ease;
}
@media (hover: hover) {
    .word-en .unfamiliar-btn:hover {
        color: #f5a623;
    }
}
.word-en .unfamiliar-btn:active {
    transform: scale(0.85);
}
.word-en .unfamiliar-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
}
.word-en .unfamiliar-btn.marked {
    color: #f5a623;
}
.word-en .unfamiliar-btn.marked svg {
    fill: currentColor;
}

.word-en .word-text {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 0 2px;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
    position: relative;
}

@media (hover: hover) {
    .word-en .word-text:hover {
        color: #D93E3E;
        background-color: #FFE5E5;
    }
}

.word-en .word-text.playing {
    color: #e74c3c;
    background-color: #fff5f5;
}

/* 点击"听"按钮朗读单词 3 遍时，整行单词容器加 playing，让单词文字变红 */
.word-en.playing .word-text {
    color: #e74c3c;
    background-color: #fff5f5;
}

/* 点击单词拼读完成后：单词文字标红（持久保留） */
.word-en .word-text.spell-done {
    color: #e74c3c;
    font-weight: 600;
}

/* "听"按钮：喇叭图标，点击朗读单词 3 遍 */
.spell-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    color: #4D4A46;
    background: #FFF3E4;
    border: 1px solid #9C948A;
    user-select: none;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}
@media (hover: hover) {
    .spell-btn:hover {
        background: #d7e9fa;
    }
}
/* 点击瞬间：浅红背景 + 红边框，松开后恢复原状 */
.spell-btn:active {
    background: #fee2e2;
    border-color: #e74c3c;
}

/* 字母高亮（拼读时） */
.word-en .letter-span {
    display: inline-block;
    padding: 0 1px;
    transition: transform 0.1s;
}
.word-en .letter-span.letter-active {
    color: #e74c3c !important;
    transform: scale(1.5) !important;
    font-weight: bold;
}

/* 中文高亮（拼读时） */
.word-zh.word-chinese-active {
    color: #e74c3c !important;
    font-weight: bold;
}

/* 行高亮（拼读时） */
.word-row.spell-playing {
    outline: 2px solid #FF6B6B;
    outline-offset: -2px;
    border-radius: 6px;
}

.word-zh {
    color: #4D4A46;
    font-size: 1.05rem;
    text-align: left;
    white-space: pre-line;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
}
@media (hover: hover) {
    .word-zh:hover {
        color: #e74c3c;
        font-weight: bold;
        background-color: #FFE5E5;
    }
}

.word-sentence {
    color: #262626;
    word-break: break-word;
}

.word-sentence .sent-cn {
    display: block;
    color: #6E6A64;
    font-size: 0.95rem;
    margin-top: 0.15rem;
}

/* 句子区域：工具按钮 + 可点击单词 + 中文（参考 video/play.html） */
.sentence-row {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.sentence-tools {
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    flex-shrink: 0;
    padding-top: 0.1em;
}

.zh-toggle {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    color: #4D4A46;
    background: #FFF3E4;
    border: 1px solid #E0D2BC;
    user-select: none;
    transition: all 0.2s;
    line-height: 1;
    flex-shrink: 0;
}
@media (hover: hover) {
    .zh-toggle:hover {
        background: #EFE6D9;
        border-color: #9C948A;
    }
}
.zh-toggle.active {
    background: #fee2e2;
    color: #e74c3c;
    border-color: #e74c3c;
}

.sentence-speaker {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    background: #FFF3E4;
    border: 1px solid #9C948A;
    user-select: none;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}
@media (hover: hover) {
    .sentence-speaker:hover {
        background: #d7e9fa;
    }
}
/* 点击瞬间：浅红背景 + 红边框，松开后恢复原状 */
.sentence-speaker:active {
    background: #fee2e2;
    border-color: #e74c3c;
}

.sentence-content {
    flex: 1;
    min-width: 0;
}

.sentence-en {
    line-height: 1.7;
    transition: color 0.2s ease, background-color 0.2s ease;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
}

/* 整句朗读时：整句变红 + 浅红底，朗读结束后还原 */
.sentence-en.reading {
    color: #e74c3c;
    background-color: #fff5f5;
    font-weight: 500;
}

.sentence-en .w {
    display: inline;
    cursor: pointer;
    padding: 1px 2px;
    border-radius: 3px;
    transition: all 0.15s ease;
    position: relative;
}
@media (hover: hover) {
    .sentence-en .w:hover {
        background: #e7f1ff;
    }
}
.sentence-en .w.active {
    color: #e74c3c;
    transform: scale(1.05);
    text-shadow: 0 0 6px rgba(231, 76, 60, 0.3);
}

.sentence-zh {
    margin-top: 0.4rem;
    color: #6E6A64;
    font-size: 1.05rem;
    line-height: 1.5;
    display: none;
}
.sentence-zh.show {
    display: block;
}

/* 移动端 */
@media (max-width: 576px) {
    .words-container {
        padding: 72px var(--site-gutter) 30px;
    }

    .unit-title {
        font-size: 1.25rem;
        padding: 0.7rem 0.85rem;
    }

    .lesson-title {
        font-size: 1rem;
        padding: 0.45rem 0.85rem;
    }

    .word-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
        padding: 0.6rem 0.85rem;
        border-bottom: 1px solid #eef0f3;
        /* font-size: 1.20rem; */
    }

    .word-zh {
        text-align: left;
        color: #6E6A64;
        font-size: 1.20rem;
    }

    .word-sentence {
        padding-left: 0;
        color: #4b5563;
        font-size: 1.25rem;
    }

    .navbar-text {
        font-size: 0.8rem !important;
    }
}

/* 例句单词释义气泡（Bootstrap Popover）样式微调 */
.word-popover .popover-header { display: none; }
.word-popover .popover-body { font-size: 0.92rem; }
.word-popover .wp-phonetic { color: #6E6A64; }
.word-popover .wp-tag {
    display: inline-block;
    background: #f1f3f5;
    border: 1px solid #EFE6D9;
    border-radius: 4px;
    padding: 0 6px;
    margin-right: 4px;
    font-size: 0.78rem;
}
.word-popover .wp-example { margin-top: 6px; }
.word-popover .wp-example .en { font-weight: 500; }
.word-popover .wp-example .zh { color: #6E6A64; font-size: 0.82rem; }
.word-popover hr { margin: 6px 0; opacity: .25; }

/* ============================================================
   竖屏「双行紧凑卡片」布局（方案 B）
   ------------------------------------------------------------
   横屏沿用上方三列布局；手机竖屏改为两行紧凑卡片：
     第一行： [喇叭] [单词]        [中文释义·小字]
     第二行： [中] [例句文字……]    [喇叭]
   竖屏时例句喇叭移到例句文字后面；横屏保持原样（喇叭在例句前）。
   ============================================================ */

/* 所有屏幕尺寸下：三个按钮统一放大到 32px，方便点击 */
.word-row .spell-btn,
.word-row .zh-toggle,
.word-row .sentence-speaker {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

@media (max-width: 576px) {
    /* 每个单词一行改为两行紧凑卡片 */
    .word-row {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "en   zh"
            "sen  sen";
        gap: 0.45rem 1rem;
        align-items: center;
        padding: 0.6rem 0.85rem;
        font-size: 1rem;
        line-height: 1.4;
    }

    /* 第一行左：喇叭 + 单词 + 音标（保持横排，不换行） */
    .word-row .word-en-col {
        grid-area: en;
        display: flex;
        align-items: center;
        gap: 0.4rem;
        white-space: nowrap;
        min-width: 0;
    }
    .word-row .word-en-col .word-en {
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }
    .word-row .word-en-col .word-phonetic {
        font-size: 0.82rem;
    }
    .word-row .word-en .word-text {
        font-size: 1.12rem;
        font-weight: 600;
    }

    /* 第一行右：中文释义（小字、左对齐、贴近单词）
       点击区域贴合文字本身，不占满整列，避免与相邻的英文/「中」按钮误触 */
    .word-row .word-zh {
        grid-area: zh;
        text-align: left;
        font-size: 0.88rem;
        color: #6E6A64;
        line-height: 1.4;
        width: fit-content;
        max-width: 100%;
    }

    /* 第二行：例句 */
    .word-row .word-sentence {
        grid-area: sen;
        font-size: 0.88rem;
        color: #4b5563;
    }

    /* —— 竖屏：把例句行的「中」与「喇叭」拆到句子两侧（喇叭移到句尾） ——
       用 display:contents 拆掉 .sentence-tools 容器，
       再以 flex + order 重排：中(1) → 例句文字(2) → 喇叭(3)。
       仅竖屏生效，横屏 .sentence-tools 仍是正常盒子、喇叭在句前。 */
    .word-row .sentence-row {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }
    .word-row .sentence-tools {
        display: contents;
    }
    .word-row .zh-toggle {
        order: 1;
        /* 恢复圆形外框，并放大到 32px */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: #FFF3E4;
        border: 1px solid #E0D2BC;
        color: #4D4A46;
        font-size: 14px;
        font-weight: bold;
        line-height: 1;
        padding: 0;
    }
    @media (hover: hover) {
        .word-row .zh-toggle:hover {
            background: #EFE6D9;
            border-color: #9C948A;
        }
    }
    .word-row .zh-toggle.active {
        background: #fee2e2;
        color: #e74c3c;
        border-color: #e74c3c;
    }
    .word-row .sentence-content {
        order: 2;
        /* 宽度由例句内容决定（不撑满整行），让喇叭能紧跟例句末尾 */
        flex: 0 1 auto;
        min-width: 0;
    }
    .word-row .sentence-speaker {
        order: 3;
        font-size: 16px;
    }

    /* 子项（如 31 是 3 的子项）：英文单词与例句都缩进，中文释义保持对齐 */
    .word-row-child .word-en-col,
    .word-row-child .word-sentence {
        padding-left: 1.8rem;
    }
}
