/* ========================================
   倉頡模式樣式
   ======================================== */

/* 基礎容器 */
.cangjie {
    line-height: 1.8;
    padding: 20px;
}

/* 字組容器 */
.cangjie .word {
    background-color: transparent;
    border: none;
    border-radius: 6px;
    margin: 2px;
    min-width: 45px;
    padding: 3px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* 字組文字顯示 */
.cangjie .word .display {
    font-size: 36px;
    font-weight: 500;
    color: #aaa;
    line-height: 1.2;
}

/* 字組文字容器 */
.cangjie .word-char-text-container {
    padding: 5px 10px;
}

.cangjie .word.current .word-char-text-container {
    background: #FFF;
    border-radius: 4px;
}

/* 字符編碼顯示 */
.cangjie .chars {
    position: relative;
    margin-bottom: 24px;
    gap: 3px;
}

.cangjie .char .text {
    margin-top: -4px;
    padding: 0 3px;
    font-size: 14px;
    font-weight: 400;
    font-family: 'Roboto Mono', 'Consolas', monospace;
    color: #999;
    opacity: 0.9;
}

.cangjie .char .code {
    padding: 0 3px;
    font-size: 14px;
    font-weight: 400;
    font-family: 'Roboto Mono', 'Consolas', monospace;
    color: #aaa;
}

/* 當前字符高亮 */
.cangjie .current.display {
    color: #000;
}

.cangjie .char.current {
    font-weight: 600;
}

.cangjie .char.current .code,
.cangjie .char.current .text {
    color: #FFF !important;
}

.cangjie .word .display.current,
.cangjie .char.current {
    border-bottom: none;
}

.cangjie .word .display {
    border-bottom: 4px solid transparent;
}

.cangjie .word .display.current {
    border-bottom: 4px solid #6974ff;
}

/* 圖片容器 (預設隱藏) */
.cangjie .word-img-container {
    display: none;
}

/* 當前字符的圖片提示框 */
.cangjie .word.current .word-img-container {
    display: none;
    position: absolute;
    top: -106px;
    width: 86px;
    height: 86px;
    padding: 6px;
    background: #f6f6f6;
    border: 1px solid #b7b7b7;
    border-radius: 5px;
}

.cangjie .word-img-container {
    display: none;
}

.word-tooltips-active .cangjie .current .word-img-container {
    display: block;
}

.cangjie .word.current .word-img-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 提示框三角形箭頭 - 邊框層 */
.cangjie .word.current .word-img-container::before {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-top: 10px solid #b7b7b7;
    z-index: 1;
}

/* 提示框三角形箭頭 - 填充層 */
.cangjie .word.current .word-img-container::after {
    content: "";
    position: absolute;
    top: calc(100% - 0.5px);
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 9px solid #f6f6f6;
    z-index: 2;
}

/* 正確輸入樣式 */
.cangjie .char.correct:not(.wrong):not(.once-wronged) {
    background: #ebfde7 !important;
}

.cangjie .word .display.typed.correct,
.char.typed.correct {
    background: transparent !important;
    color: #39c716;
}

.cangjie .correct .code,
.cangjie .correct .text {
    color: #39c716;
}

.cangjie .display.correct {
    color: #39c716;
    background: transparent;
}

.cangjie .display.correct.once-wronged {
    background: transparent !important;
    color: #f29910;
}

.cangjie .char.current {
    background: #000;
}

/* Once Wronged */
.cangjie .word .char.typed.correct.once-wronged,
.cangjie .char.typed.correct.once-wronged {
    background: #fff4d4 !important;
}

/* 錯誤輸入樣式 */
.cangjie .word .char.typed.wrong {
    color: #fd6680;
    background: #ffebee;
}

.cangjie .word .char.once-wronged {
    background: #fff4d4;
}

.cangjie .word .char.once-wronged .code,
.cangjie .word .char.once-wronged .text {
    color: #f29910;
}

.cangjie .word .char.typed.wrong .code,
.cangjie .word .char.typed.wrong .text {
    color: #fd6680;
}

.cangjie .word .display.typed.wrong {
    color: #ec8092;
}

.cangjie .char.typed.wrong {
    color: #f44336;
}

/* 曾經輸入錯誤的樣式 */
.cangjie .word .display.typed.correct.once-wronged {
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    color: #f57f17;
}

/* 空格字符特殊處理 */
.cangjie .word .display.space::after {
    content: "⎵";
    color: #95a5a6;
    font-size: 20px;
}

/* 移除邊框底線 */
.cangjie .char {
    border-bottom: none;
    border-radius: 2px;
}

.cangjie .char.current {
    background: #000 !important;
}

.cangjie .char.code-space {
    display: block;
    position: absolute;
    bottom: -24px;
    width: 100%;
    text-align: center;
}

.cangjie .char.code-space .text::after {
    content: "\2423";
}
