/* =====================================================
   縦書き小説プラグイン - tategaki.css
   ===================================================== */

/* ── ラッパー ── */
.tategaki-wrapper {
    position: relative;
    width: 100%;
    margin: 1.5em 0;
}

/* ── ツールバー ── */
.tategaki-toolbar {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.tategaki-toolbar button {
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    color: inherit;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    line-height: 1;
    padding: 5px 10px;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.tategaki-toolbar button:hover {
    opacity: 1;
}

.tategaki-toggle-btn .tategaki-icon-v,
.tategaki-toggle-btn .tategaki-icon-h {
    font-size: 12px;
}

/* アクティブ表示（JS で付与） */
.tategaki-wrapper.is-vertical .tategaki-icon-v,
.tategaki-wrapper.is-horizontal .tategaki-icon-h {
    font-weight: bold;
    color: #7b4e2d;
    text-decoration: underline;
}

/* ── 縦書きコンテンツ ── */
.tategaki-content {
    overflow: auto;
    padding: 1.5em;
    /* 背景・文字色はサイトから継承（テーマの色設定に自動追従） */
    background: inherit;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 4px;
    box-sizing: border-box;
    opacity: 0.95;
    font-family: "游明朝", "Yu Mincho", "YuMincho", "ヒラギノ明朝 Pro W3",
                 "Hiragino Mincho Pro", "HG明朝E", "ＭＳ Ｐ明朝",
                 "MS PMincho", serif;
}

/* 縦書きモード */
.tategaki-content.tategaki-vertical {
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    -ms-writing-mode: tb-rl;
    text-orientation: upright;
    max-height: 80vh;
    overflow-x: auto;
    overflow-y: hidden;
    /* スムーズスクロール */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* 横書きモード */
.tategaki-content.tategaki-horizontal {
    writing-mode: horizontal-tb;
    -webkit-writing-mode: horizontal-tb;
    -ms-writing-mode: lr-tb;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ── ページ全体縦書きの場合、コンテンツ幅を広くする ── */
.tategaki-page-active .entry-content,
.tategaki-page-active .post-content,
.tategaki-page-active article {
    max-width: 100%;
}

/* ── 段落 ── */
.tategaki-content p {
    margin: 0 1em;
    text-indent: 1em;
}
.tategaki-content.tategaki-horizontal p {
    margin: 0 0 1em;
    text-indent: 1em;
}

/* ── ルビ ── */
.tategaki-content ruby {
    ruby-align: center;
}
.tategaki-content ruby rt {
    font-size: 0.5em;
    line-height: 1;
}
.tategaki-content ruby rp {
    display: none;
}

/* ── 縦中横（数字など）── */
.tategaki-content.tategaki-vertical .tate-chu-yoko,
.tategaki-content.tategaki-vertical .tcv {
    text-combine-upright: all;
    -webkit-text-combine: horizontal;
    -ms-text-combine-horizontal: all;
}

/* ── 傍点 ── */
.tategaki-content em {
    font-style: normal;
    text-emphasis: sesame;
    -webkit-text-emphasis: sesame;
}

/* ── スクロールバー（Webkit） ── */
.tategaki-content::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
.tategaki-content::-webkit-scrollbar-track {
    background: transparent;
}
.tategaki-content::-webkit-scrollbar-thumb {
    background: currentColor;
    opacity: 0.4;
    border-radius: 4px;
}

/* ── レスポンシブ ── */
@media (max-width: 600px) {
    .tategaki-content.tategaki-vertical {
        max-height: 70vh;
        font-size: 16px !important;
        padding: 1em;
    }
    .tategaki-toolbar button {
        font-size: 12px;
        padding: 4px 8px;
    }
}
