/* =========================================================================
 *  Lantern Ruby - Standard Ruby Alignment Sync Patch (右上ズレ完全制圧版)
 * ========================================================================= */

/* 1. 親要素：一括拡大時も領域を崩さない標準インラインルビを再定義 */
.editor-styles-wrapper ruby,
.editor-styles-wrapper .c-lp-ruby-node,
.wp-block-paragraph ruby,
.block-editor-rich-text__editable ruby,
ruby,
.c-lp-ruby-node {
    /* 🛠️ absoluteを廃止し、ブラウザ本来のルビ表示モードで外枠を固定 */
    display: inline-ruby !important;
    
    /* 通常の文字の流れ（ベースライン）に100%一致させ、床落ち・へこみを完全防止 */
    vertical-align: baseline !important;
    
    /* ルビの位置を絶対に「親文字の真上」にロック */
    ruby-position: over !important;
    -webkit-ruby-position: over !important;
    
    /* 💡文字サイズ変更時にSWELL側で肥大化する隙間・レタースペースを極限までゼロ化 */
    margin: 0 !important;
    padding: 0 !important;
    text-indent: 0 !important;
    letter-spacing: normal !important;
    white-space: nowrap !important;
    
    /* 周囲の文字サイズ一括変更に美しく同調させます */
    font-size: inherit !important;
    line-height: inherit !important;
}

/* 2. 子要素：右上へ逃げる原因（余白・文字間）をクレンジングして真上センターに吸着 */
.editor-styles-wrapper rt,
.editor-styles-wrapper .c-lp-rt-node,
.wp-block-paragraph rt,
.block-editor-rich-text__editable rt,
rt,
.c-lp-rt-node {
    /* ブラウザ標準のルビテキスト配置を強制 */
    display: ruby-text !important;
    
    /* 🛠️ 右上に流れていく最大の元凶である、SWELL固有の文字間隔（letter-spacing）を完全消滅 */
    letter-spacing: normal !important;
    
    /* 親文字に対して常に自動でジャストセンター（中央揃え）にする設定 */
    ruby-align: center !important;
    text-align: center !important;
    
    /* 💡ズレを引き起こす絶対配置(absolute)やfloatの設定を上書きリセット */
    position: relative !important;
    float: none !important;
    top: 0 !important;
    left: 0 !important;
    
    /* 💡一括でフォントサイズを大きくされても、親文字に対して「常に0.45倍（理想のサイズ）」へ自動縮小 */
    font-size: 0.45em !important;
    line-height: 1.1 !important;
    
    /* SWELLが文字の後ろに押し出して右上に突き抜けさせる原因となる余白を物理ゼロ化 */
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 0 1px 0 !important;
    white-space: nowrap !important;
    user-select: none !important;
}

/* 3. セーフティ：ルビ付きの行全体が、上の行の文章と被らないように適切な天井高を確保 */
.editor-styles-wrapper .c-lp-ruby-node,
.c-lp-ruby-node {
    margin-top: 0.3em !important;
}
