/* ==============================================================
 * tw_zhuyin.css
 * 台日辞書 TANゴ（tw.cntango.org）の注音ルビ表示専用 CSS
 * 既存の style.css に追加 or 別ファイルとして読み込む
 * ============================================================== */

/* 注音用フォント（繁體字対応） */
.tw-cn-text,
body[data-lang="tw"] .cn-text {
    font-family: 'Noto Sans TC', 'Source Han Sans TW', 
                 'Microsoft JhengHei', 'PingFang TC',
                 'Hiragino Sans GB', sans-serif;
}

/* ==== 注音ルビ表示 ==== */
ruby.zhuyin {
    ruby-position: over;
    ruby-align: center;
    line-height: 2.4;
}

ruby.zhuyin > rt {
    font-size: 0.5em;
    font-family: 'Noto Sans TC', sans-serif;
    color: #666;
    font-weight: normal;
    line-height: 1.0;
    
    /* 注音を縦に並べる */
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    text-orientation: upright;
    -webkit-text-orientation: upright;
    
    /* ルビと漢字の間隔 */
    margin-left: 2px;
}

/* ルビが大きいヘッダーで表示される時 */
.headword ruby.zhuyin {
    line-height: 1.6;
}

.headword ruby.zhuyin > rt {
    font-size: 0.4em;
    color: #888;
}

/* 例文のルビ */
.example-text ruby.zhuyin > rt {
    font-size: 0.55em;
}

/* ルビ表示OFF状態 */
body.zhuyin-off ruby.zhuyin > rt {
    display: none;
}

/* ==== ルビトグルボタン ==== */
.zhuyin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #d4c8b8;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6a5b3a;
}

.zhuyin-toggle:hover {
    background: #fdf6e3;
    border-color: #ff9800;
}

.zhuyin-toggle .toggle-label {
    font-weight: 600;
}

.zhuyin-toggle .toggle-state {
    background: #00897b;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    transition: all 0.2s;
}

body.zhuyin-off .zhuyin-toggle .toggle-state {
    background: #999;
}

body.zhuyin-off .zhuyin-toggle .toggle-state::before {
    content: 'OFF';
}

body:not(.zhuyin-off) .zhuyin-toggle .toggle-state::before {
    content: 'ON';
}

/* ==== ピンインと注音の併記 ==== */
.headword-pron {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.headword-pron .pinyin {
    color: #555;
    font-size: 18px;
    font-style: italic;
}

.headword-pron .bopomofo {
    color: #777;
    font-size: 16px;
    font-family: 'Noto Sans TC', sans-serif;
}

/* OFF時は注音文字列も非表示 */
body.zhuyin-off .headword-pron .bopomofo {
    display: none;
}

/* ==== モバイル対応 ==== */
@media (max-width: 600px) {
    ruby.zhuyin > rt {
        font-size: 0.45em;
    }
    .headword-pron {
        font-size: 14px;
    }
}
