/**
 * 事業内容・当店のこだわり：ページ内ジャンプ（ご利用ガイドの目次に近い左カラム＋本文）
 */

#tbt-anchor-jigyounaiyou,
#tbt-anchor-keiei-rinen,
#tbt-anchor-engaku,
#jigyou-1,
#jigyou-2,
#jigyou-3,
#kodawari-1,
#kodawari-2,
#kodawari-3,
h2[id^="tbt-kodawari-"],
#tbt-faq-products,
#tbt-faq-delivery,
#tbt-faq-packaging,
#tbt-faq-payment,
#tbt-faq-returns,
#tbt-faq-other,
#faq-section-1,
#faq-section-2,
#faq-section-3,
#faq-section-4,
#faq-section-5,
#faq-section-6,
#guide-section-1,
#guide-section-2,
#guide-section-3,
#guide-section-4,
#privacy-section-1,
#privacy-section-2,
#privacy-section-3,
#privacy-section-4,
#privacy-section-5,
#privacy-section-6,
#tokusho-section-1,
#tokusho-section-2,
#tokusho-section-3,
#tokusho-section-4,
#tokusho-section-5,
#tokusho-section-6,
#tokusho-section-7 {
    scroll-margin-top: clamp(5rem, 14vw, 7rem);
}

/* ラッパー：目次 | 本文の2カラム（モバイルは縦積み） */
.tbt-page-section-nav__wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(1.15rem, 2.8vw, 1.85rem);
    align-items: start;
    max-width: 1120px;
    margin-left: auto;
    margin-right: auto;
    /* スライダー／ページ見出し直下で目次が詰まりすぎないよう少し下げる */
    margin-top: clamp(1rem, 2.6vw, 1.65rem);
}

@media (min-width: 900px) {
    .tbt-page-section-nav__wrap {
        grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
        gap: clamp(1.35rem, 3vw, 2.25rem);
    }
}

.tbt-page-section-nav__main {
    min-width: 0;
}

/* 目次：body 直下に fixed 配置（本文 DOM とは独立。left / top は JS で算出） */
body > .tbt-toc-sidebar {
    position: fixed;
    top: 120px;
    left: 0;
    width: max-content;
    min-width: 180px;
    max-width: 280px;
    height: auto;
    min-height: 0;
    margin-top: 0;
    background: #fdfaf5;
    border: 1px solid #c8a97a;
    border-radius: 6px;
    padding: 16px 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: flex-start;
    will-change: left, top;
}

/* 本文内に残った旧目次を非表示 */
.entry-content .tbt-toc-sidebar,
.site-main .tbt-toc-sidebar {
    display: none !important;
}

.tbt-toc-sidebar .tbt-page-section-nav {
    display: block;
    position: static;
    top: auto;
    width: max-content;
    min-width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    align-self: flex-start;
}

/* body 直下 fixed 目次：グリッド用 offset / sticky を無効化し中身を上詰め */
body > .tbt-toc-sidebar .tbt-page-section-nav {
    position: static !important;
    top: auto !important;
    margin-top: 0 !important;
    height: auto !important;
    min-height: 0 !important;
}

.tbt-toc-sidebar .toc-title,
.tbt-toc-sidebar .tbt-page-section-nav__title {
    font-size: 0.95rem;
    font-weight: bold;
    color: #2c1a0e;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #c8a97a;
    padding-bottom: 8px;
    margin: 0 0 10px;
}

.tbt-toc-sidebar ul,
.tbt-toc-sidebar .tbt-page-section-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: block;
    gap: 0;
}

.tbt-toc-sidebar li,
.tbt-toc-sidebar .tbt-page-section-nav ul li {
    padding: 5px 0;
    margin: 0;
    border-bottom: 1px dotted #e0d0bc;
}

.tbt-toc-sidebar li:last-child,
.tbt-toc-sidebar .tbt-page-section-nav ul li:last-child {
    border-bottom: none;
}

.tbt-toc-sidebar a,
.tbt-toc-sidebar .tbt-page-section-nav a {
    color: #5c1a1a;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 5px;
    line-height: 1.5;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
}

.tbt-toc-sidebar a::before,
.tbt-toc-sidebar .tbt-page-section-nav a::before {
    content: "▶";
    font-size: 0.5rem;
    color: #c8a97a;
    flex-shrink: 0;
    border: none;
    width: auto;
    height: auto;
    margin: 0;
}

.tbt-toc-sidebar a:hover,
.tbt-toc-sidebar .tbt-page-section-nav a:hover {
    color: #8b1a1a;
    text-decoration: underline;
    background: transparent;
}

.tbt-toc-sidebar .tbt-page-section-nav__link-text {
    flex: 0 1 auto;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
}

/* こだわり：top は JS がアンカー位置から算出（CSS はフォールバック） */
body.tbt-page-kodawari > .tbt-toc-sidebar {
    top: 120px;
}

body.tbt-page-kodawari > .tbt-toc-sidebar .tbt-page-section-nav {
    margin-top: 0 !important;
}

/* よくある質問：本文列を中央寄せ（目次 left は #primary 左端から JS 算出） */
@media (min-width: 1200px) {
    body.tbt-page-faq #primary.content-area,
    body.tbt-page-faq #primary {
        max-width: 860px;
        margin-left: auto;
        margin-right: auto;
    }
}

body.tbt-page-faq > .tbt-toc-sidebar {
    top: 200px;
}

/* よくある質問：目次ボックス内の上余白を削除 */
body.tbt-page-faq .tbt-toc-sidebar,
body.tbt-page-faq aside.tbt-toc-sidebar {
    padding-top: 14px !important;
    margin-top: 0 !important;
}

body.tbt-page-faq .tbt-toc-sidebar > *:first-child,
body.tbt-page-faq aside.tbt-toc-sidebar > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body.tbt-page-faq > .tbt-toc-sidebar .tbt-page-section-nav,
body.tbt-page-faq > .tbt-toc-sidebar .tbt-page-section-nav--faq {
    margin-top: 0 !important;
}

@media (max-width: 1199px) {
    body > .tbt-toc-sidebar {
        display: none !important;
    }
}

/* 本文内に残った旧インライン目次を非表示 */
body:is(.tbt-page-faq, .tbt-page-guide, .tbt-page-user-guide) .entry-content > .tbt-page-section-nav,
body:is(.tbt-page-faq, .tbt-page-guide, .tbt-page-user-guide) .tbt-page-section-nav__wrap > .tbt-page-section-nav,
body:is(.tbt-page-guide, .tbt-page-user-guide) .tcf-user-guide__toc {
    display: none !important;
}

@media (min-width: 1200px) {
    body:is(.tbt-page-guide, .tbt-page-user-guide) .entry-content .tcf-user-guide {
        display: block;
        max-width: none;
        margin-left: 0;
        margin-right: 0;
        padding: 0;
    }
}

/* 事業内容・当店のこだわり：中央寄せレイアウト用（本文列の最大幅。900px 以上で 1fr | auto | 1fr グリッドと組み合わせる） */
body.tbt-page-jigyounaiyou .tbt-page-section-nav__wrap {
    /* 経営理念・事業内容：本文列を約30%広く（124rem×1.3、ラッパーは1120px×1.3） */
    --tbt-section-main-max: min(99vw, calc(124rem * 1.3));
    max-width: min(100%, calc(1120px * 1.3));
}

body.tbt-page-kodawari .tbt-page-section-nav__wrap {
    /* 白カード・本文列の上限（読みやすさ重視で従来より広く） */
    --tbt-section-main-max: 108rem;
}

/* 目次カード（ご利用ガイドの .tcf-user-guide__toc に寄せたトーン） */
.tbt-page-section-nav {
    box-sizing: border-box;
    margin: 0;
    padding: 1.2rem 1.1rem 1.25rem;
    border-radius: 14px;
    border: 1px solid rgba(184, 139, 70, 0.22);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.97) 0%, rgba(252, 247, 240, 0.94) 100%);
    box-shadow:
        0 4px 14px rgba(26, 19, 13, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

@media (min-width: 900px) {
    .tbt-page-section-nav {
        position: sticky;
        /* 固定ヘッダーとの距離を広げ、スクロール時の貼り付き位置をやや下げる */
        top: calc(var(--wp-admin--admin-bar--height, 0px) + 6.35rem);
        z-index: 2;
    }
}

.tbt-page-section-nav__title {
    margin: 0 0 0.85rem;
    padding-bottom: 0.65rem;
    border-bottom: 2px solid rgba(184, 139, 70, 0.45);
    font-family: var(--tbt-font-serif, 'Noto Serif JP', 'Yu Mincho', 'Hiragino Mincho ProN', serif);
    font-size: 1.02rem;
    font-weight: 700;
    color: #1e2745;
    line-height: 1.45;
    letter-spacing: 0.04em;
}

.tbt-page-section-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tbt-page-section-nav a {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.48rem 0.5rem;
    margin: 0 -0.3rem;
    border-radius: 10px;
    font-family: var(--tbt-font-sans, 'Noto Sans JP', 'Hiragino Sans', Meiryo, sans-serif);
    font-size: 0.92rem;
    font-weight: 700;
    color: #2f261d !important;
    text-decoration: none !important;
    line-height: 1.55;
    transition: background 0.15s ease, color 0.15s ease;
}

.tbt-page-section-nav a::before {
    content: '';
    flex: 0 0 0.42rem;
    width: 0;
    height: 0;
    margin-top: 0.4rem;
    border-style: solid;
    border-width: 0.24rem 0 0.24rem 0.4rem;
    border-color: transparent transparent transparent #b88b46;
}

.tbt-page-section-nav a:hover,
.tbt-page-section-nav a:focus-visible {
    background: rgba(184, 139, 70, 0.12);
    color: #3a3028 !important;
    outline: none;
}

.tbt-page-section-nav a:focus-visible {
    outline: 2px solid rgba(184, 139, 70, 0.45);
    outline-offset: 2px;
}

.tbt-page-section-nav__link-text {
    flex: 1;
    min-width: 0;
}

/* 事業内容：モバイルの見出しタイポ（本文 p / li は layout.css の公式サイト共通ルールに統一） */
@media (max-width: 781px) {
    body.tbt-page-jigyounaiyou .tbt-page-section-nav__main :where(h2, h3).wp-block-heading,
    body.tbt-page-jigyounaiyou .tbt-page-section-nav__main :where(h2, h3):not(.wp-block-heading) {
        font-size: clamp(1.18rem, 4.6vw, 1.5rem) !important;
        line-height: 1.28 !important;
        letter-spacing: 0.02em;
    }
}

/* 事業内容：沿革（年表）を本文列よりやや横広く（PCのみ。モバイルは100%で右はみ出し防止） */
@media (min-width: 782px) {
    body.tbt-page-jigyounaiyou .tbt-page-section-nav__main .tcf-history-timeline {
        margin-left: calc(-0.5 * clamp(0.65rem, 3vw, 2rem));
        margin-right: calc(-0.5 * clamp(0.65rem, 3vw, 2rem));
        width: calc(100% + clamp(1.3rem, 6vw, 4rem));
        max-width: none;
        box-sizing: border-box;
    }
}

@media (max-width: 781px) {
    body.tbt-page-jigyounaiyou .tbt-page-section-nav__main .tcf-history-timeline {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        min-width: 0;
    }
}

/* FAQ：リンクが多いのでややコンパクトに */
.tbt-page-section-nav--faq ul {
    gap: 0.38rem;
}

.tbt-page-section-nav--faq a {
    font-size: 0.86rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

@media (max-width: 781px) {
    body.tbt-page-faq .tbt-page-section-nav {
        display: none !important;
    }

    body.tbt-page-faq .tbt-page-section-nav__wrap {
        grid-template-columns: minmax(0, 1fr) !important;
        column-gap: 0 !important;
    }

    /* URL配下違いでも確実にFAQナビだけ非表示 */
    .tbt-page-section-nav--faq {
        display: none !important;
    }

    .tbt-page-section-nav__wrap:has(> .tbt-page-section-nav--faq) {
        grid-template-columns: minmax(0, 1fr) !important;
        column-gap: 0 !important;
    }

    /* FAQメイン見出し（-よくある質問-）を1行固定 */
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main .tbt-heading-with-eyebrow > :is(h1, h2, h3, h4, h5, h6),
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main > :is(h1, h2, h3).wp-block-heading {
        display: block;
        width: 100%;
        max-width: 100%;
        white-space: nowrap !important;
        font-size: min(0.9rem, 3.1vw) !important;
        letter-spacing: -0.03em !important;
        line-height: 1.14 !important;
        overflow-wrap: normal !important;
        word-break: keep-all !important;
        text-align: center !important;
    }

    .tbt-page-section-nav--faq + .tbt-page-section-nav__main .tbt-heading-with-eyebrow > :is(h1, h2, h3, h4, h5, h6) br,
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main > :is(h1, h2, h3).wp-block-heading br {
        display: none !important;
    }

    .tbt-page-section-nav--faq + .tbt-page-section-nav__main .tbt-heading-with-eyebrow > :is(h1, h2, h3, h4, h5, h6) *,
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main > :is(h1, h2, h3).wp-block-heading * {
        display: inline !important;
        white-space: inherit !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }

    /* FAQカード（モバイル）：間隔を均一化 */
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main :is(
        details,
        .wp-block-details,
        .wp-block-accordion-item,
        .kt-accordion-item,
        .wp-block-uagb-accordion .uagb-accordion-item
    ) {
        margin: 0 !important;
        border-radius: 10px;
    }

    .tbt-page-section-nav--faq + .tbt-page-section-nav__main :is(
        details,
        .wp-block-details,
        .wp-block-accordion-item,
        .kt-accordion-item,
        .wp-block-uagb-accordion .uagb-accordion-item
    ) + :is(
        details,
        .wp-block-details,
        .wp-block-accordion-item,
        .kt-accordion-item,
        .wp-block-uagb-accordion .uagb-accordion-item
    ) {
        margin-top: 0.38rem !important;
    }

    .tbt-page-section-nav--faq + .tbt-page-section-nav__main :is(
        p,
        .wp-block-spacer,
        .wp-block-group,
        .wp-block-columns,
        .wp-block-column
    ) {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    .tbt-page-section-nav--faq + .tbt-page-section-nav__main details > summary {
        gap: 0.5rem;
        padding: 0.58rem 0.65rem 0.58rem 0.72rem;
        font-size: clamp(0.84rem, 3.1vw, 0.92rem);
        line-height: 1.42;
    }

    .tbt-page-section-nav--faq + .tbt-page-section-nav__main details .wp-block-details__summary-arrow,
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main details:not(:has(.wp-block-details__summary-arrow)) > summary::after {
        width: 1.42rem;
        height: 1.42rem;
        font-size: 0.88rem;
        border-radius: 6px;
    }

    .tbt-page-section-nav--faq + .tbt-page-section-nav__main details > :not(summary),
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main .wp-block-accordion-panel,
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main .kt-accordion-panel-inner,
    .tbt-page-section-nav--faq + .tbt-page-section-nav__main .wp-block-uagb-accordion .uagb-accordion-content {
        padding: 0.65rem 0.72rem 0.72rem 0.78rem;
        font-size: 0.86rem;
        line-height: 1.68;
    }
}

/*
 * 左カラムの目次を、本文側の第一セクション（見出し〜カード枠）付近の高さまで下げる。
 * メインカラム先頭の margin だけでは左カラムが上に残るため、目次側にオフセットを足す。
 * body 直下 fixed 目次（.tbt-toc-sidebar）には適用しない。
 */
@media (min-width: 900px) {
    body.tbt-page-faq .tbt-page-section-nav__wrap > .tbt-page-section-nav {
        margin-top: clamp(4.65rem, 11.8vw, 7.65rem);
    }

    body.tbt-page-kodawari .tbt-page-section-nav__wrap > .tbt-page-section-nav {
        margin-top: clamp(6.35rem, 14.5vw, 10.25rem);
    }
}

/* 事業内容：本文カラム内の見出し（英字＋下線）をセクション中央に */
body.tbt-page-jigyounaiyou .tbt-page-section-nav__main .tbt-heading-with-eyebrow {
    align-items: center !important;
    text-align: center !important;
    width: 100%;
    max-width: 100%;
}

body.tbt-page-jigyounaiyou .tbt-page-section-nav__main .tbt-heading-with-eyebrow .tbt-heading-eyebrow {
    width: 100%;
    text-align: center;
}

body.tbt-page-jigyounaiyou .tbt-page-section-nav__main .tbt-heading-with-eyebrow > :is(h1, h2, h3, h4, h5, h6) {
    text-align: center !important;
}

body.tbt-page-jigyounaiyou .tbt-page-section-nav__main .tbt-heading-with-eyebrow > .tbt-heading-reveal-underline,
body.tbt-page-jigyounaiyou .tbt-page-section-nav__main .tbt-heading-with-eyebrow > h2.tbt-heading-reveal-underline {
    margin-left: auto !important;
    margin-right: auto !important;
    align-self: center !important;
    justify-self: center !important;
    background-position: center 100%;
}

/*
 * 事業内容：英字は中央なのに和文見出しだけ左に寄る対策。
 * 従来の「> h2」は本文がグループブロック内だと効かないため、ネスト含めて中央軸に揃える。
 */
body.tbt-page-jigyounaiyou .tbt-page-section-nav__main
    :is(h1, h2, h3, h4, h5, h6).wp-block-heading.tbt-heading-reveal-underline {
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: center !important;
    align-self: center !important;
    justify-self: center !important;
    background-position: center 100% !important;
}

body.tbt-page-jigyounaiyou .tbt-page-section-nav__main > h2.wp-block-heading,
body.tbt-page-jigyounaiyou .tbt-page-section-nav__main h2.wp-block-heading,
body.tbt-page-jigyounaiyou .tbt-page-section-nav__main h3.wp-block-heading {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* 事業内容：リストマーカーを臙脂より黄金系に（経営理念など） */
body.tbt-page-jigyounaiyou .tbt-page-section-nav__main :where(ul, ol) li::marker {
    color: rgba(184, 139, 70, 0.88);
}

/*
 * 事業内容：本文メイン列内では theme.json の contentSize / wideSize が効き、
 * 白カード・2カラムが 1080px 前後に縮む。継承で変数を上書きし、必要なら子を明示的に広げる。
 */
body.tbt-page-jigyounaiyou:not(.page-staff-only) .tbt-page-section-nav__main {
    --wp--style--global--content-size: min(100%, var(--tbt-section-main-max, calc(124rem * 1.3)));
    --wp--style--global--wide-size: min(100%, var(--tbt-section-main-max, calc(124rem * 1.3)));
}

body.tbt-page-jigyounaiyou:not(.page-staff-only)
    .tbt-page-section-nav__main
    .is-layout-constrained
    > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
    max-width: min(100%, var(--tbt-section-main-max, calc(124rem * 1.3))) !important;
}

body.tbt-page-jigyounaiyou:not(.page-staff-only) .tbt-page-section-nav__main :where(.wp-block-group, .wp-block-columns).alignwide,
body.tbt-page-jigyounaiyou:not(.page-staff-only) .tbt-page-section-nav__main .alignwide {
    max-width: min(100%, var(--tbt-section-main-max, calc(124rem * 1.3))) !important;
    width: min(100%, var(--tbt-section-main-max, calc(124rem * 1.3))) !important;
    box-sizing: border-box;
}

body.tbt-page-jigyounaiyou:not(.page-staff-only) .tbt-page-section-nav__main .wp-block-columns,
body.tbt-page-jigyounaiyou:not(.page-staff-only) .tbt-page-section-nav__main .wp-block-columns.is-layout-flex {
    max-width: min(100%, var(--tbt-section-main-max, calc(124rem * 1.3))) !important;
}

body.tbt-page-jigyounaiyou:not(.page-staff-only) .tbt-page-section-nav__main .wp-block-column {
    min-width: 0;
}

/* 当店のこだわり：セクション2・3のカード余白を詰めて密度を調整 */
body.tbt-page-kodawari .tbt-page-section-nav__main .wp-block-columns {
    align-items: flex-start;
    gap: clamp(0.7rem, 1.8vw, 1.2rem);
}

body.tbt-page-kodawari .tbt-page-section-nav__main .wp-block-columns > .wp-block-column {
    min-height: 0 !important;
}

body.tbt-page-kodawari .tbt-page-section-nav__main .wp-block-columns > .wp-block-column > .wp-block-group {
    min-height: 0 !important;
    padding-block: clamp(0.72rem, 1.4vw, 1rem) !important;
}

body.tbt-page-kodawari .tbt-page-section-nav__main .wp-block-columns > .wp-block-column :where(p, ul, ol) {
    margin-block: 0.45rem 0.72rem;
    line-height: 1.68;
}

/* 当店のこだわり：左目次リンクの改行（1200px 以上） */
@media (min-width: 1200px) {
    body.tbt-page-kodawari .tbt-toc-sidebar .tbt-page-section-nav__link-text {
        word-break: keep-all;
        overflow-wrap: normal;
    }
}
