/* ==========================================================================
   Manual Craft Front Styles - High Specificity Version (With Lang Switcher)
   ========================================================================== */

/* * 基本戦略: すべてのセレクタの頭に .manual-craft-container を付けることで
 * 詳細度を上げ、テーマのCSSによる干渉を防ぐ。
 */

/* --- 親コンテナ --- */
.manual-craft-container {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 40px !important;
    width: 100% !important;
    margin: 40px 0 !important;
    position: relative !important;
    overflow: visible !important;
    transition: gap 0.3s ease;
}

/* --- 目次エリア --- */
.manual-craft-container .manual-toc-wrapper {
    width: 260px;
    min-width: 260px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.manual-craft-container .manual-toc {
    width: 260px;
    padding: 0;
    background: transparent;
    border-right: 1px solid #eee;
    box-sizing: border-box;
    max-height: calc(100vh - 50px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    top: auto;
    z-index: 10;
}

.manual-craft-container .manual-toc-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
    scrollbar-width: thin;
}

/* --- 目次リンク --- */
.manual-craft-container .toc-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: #666;
    text-decoration: none !important;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    line-height: 1.5;
    overflow: hidden;
}

.manual-craft-container .toc-num {
    font-weight: bold;
    margin-right: 8px;
    min-width: 20px;
    flex-shrink: 0;
    font-family: monospace;
}

.manual-craft-container .toc-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.manual-craft-container .toc-h3 .toc-num {
    margin-left: 10px;
}
.manual-craft-container .toc-h4 .toc-num {
    margin-left: 20px;
}

.manual-craft-container .toc-link:hover,
.manual-craft-container .toc-link.is-active {
    color: #0073aa !important;
    background-color: #f0f7ff;
    border-left-color: #0073aa !important;
}

/* --- 本文エリア --- */
.manual-craft-container .manual-body {
    flex-grow: 1 !important;
    min-width: 0 !important;
    width: 100%;
    transition: width 0.3s ease;
}

.manual-craft-container .mc-number {
    color: #0073aa;
    margin-right: 0.5em;
}

/* 画像 */
.manual-craft-container .manual-body img {
    display: block !important;
    margin: 30px auto !important;
    max-width: 100% !important;
    height: auto !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
@media (min-width: 800px) {
    .manual-craft-container .manual-body img {
        max-width: 800px !important;
    }
}

/* テーブルレスポンシブ */
.manual-craft-container .wp-table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    margin-bottom: 20px;
}
.manual-craft-container .wp-table-responsive table {
    width: 100%;
    border-collapse: collapse;
}

/* ==========================================================================
   ★ スマホ・タブレット対応 (1023px以下)
   ========================================================================== */
@media (max-width: 1023px) {
    .manual-craft-container {
        gap: 15px !important;
    }

    .manual-craft-container .manual-toc-wrapper {
        width: 40px !important;
        min-width: 40px !important;
        overflow: hidden;
    }

    .manual-craft-container .manual-toc {
        width: 40px !important;
        border-right: none;
        background: #fcfcfc;
        position: relative;
        top: auto;
    }

    .manual-craft-container .toc-text {
        display: none !important;
    }

    .manual-craft-container .toc-link {
        padding: 10px 0;
        justify-content: center;
        border-left-width: 0;
        border-right: 3px solid transparent;
    }

    .manual-craft-container .toc-link.is-active {
        border-left-color: transparent !important;
        border-right-color: #0073aa !important;
        background-color: rgba(0, 115, 170, 0.1);
    }

    .manual-craft-container .toc-num {
        margin: 0 !important;
        font-size: 12px;
        text-align: center;
        width: 100%;
    }
    .manual-craft-container .toc-h4 .toc-num {
        font-size: 10px;
        letter-spacing: -1px;
    }

    /* --- 開閉機能（トグル） --- */

    /* ボタン自体 */
    .manual-craft-container .mc-mobile-toggle {
        display: block;
        position: fixed; /* 常に画面固定 */
        left: 0;
        /* topはJSで制御 */
        width: 40px;
        height: 40px;
        background: rgba(0, 115, 170, 0.8);
        color: #fff;
        border: none;
        cursor: pointer;
        text-align: center;
        line-height: 40px;
        z-index: 9999;
        border-radius: 0 4px 4px 0;
    }

    /* アイコン */
    .manual-craft-container .mc-mobile-toggle::before {
        content: '';
        display: inline-block;
        width: 8px;
        height: 8px;
        border-top: 2px solid #fff;
        border-right: 2px solid #fff;
        transform: rotate(-135deg); /* 左向き（閉じる） */
        vertical-align: middle;
        margin-left: 4px;
        margin-top: -2px;
    }

    /* ===================================
       閉じた状態 (Closed State)
       =================================== */

    .manual-craft-container.is-closed {
        gap: 0 !important;
    }

    /* 閉じた時はラッパーとメニューを隠す */
    .manual-craft-container.is-closed .manual-toc-wrapper,
    .manual-craft-container.is-closed .manual-toc {
        width: 0 !important;
        min-width: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
    }

    /* 閉じた時のボタン（右向きに変化） */
    .manual-craft-container.is-closed .mc-mobile-toggle {
        background: rgba(50, 50, 50, 0.5);
    }

    .manual-craft-container.is-closed .mc-mobile-toggle::before {
        transform: rotate(45deg); /* 右向き（開く） */
        margin-left: -4px;
    }
}

/* PCではトグルボタンを表示しない */
@media (min-width: 1024px) {
    .manual-craft-container .mc-mobile-toggle {
        display: none !important;
    }
}

/* ==========================================================================
   独自の装飾スタイル (H1-H4, List)
   すべて .manual-craft-container 配下に限定
   ========================================================================== */

/* H1 */
.manual-craft-container .manual-body h1 {
    margin: 0 0 30px 0;
    padding: 12px 8px;
    background-color: #182640;
    color: #fff;
    opacity: 0.9;
    font-size: 24px;
}

/* H2 */
.manual-craft-container .manual-body h2 {
    position: relative;
    padding-bottom: 10px;
    font-size: 26px !important; /* 強制適用 */
    background-image: none !important;
}
.manual-craft-container .manual-body h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background-image: repeating-linear-gradient(45deg, #0073aa 0px, #b4a983 1px, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 50%);
    background-size: 8px 8px;
}

/* H3 */
.manual-craft-container .manual-body h3 {
    font-size: 20px !important;
}

/* H4 */
.manual-craft-container .manual-body h4 {
    font-size: 17px !important;
    margin: 20px 0 10px;
}


/* スマホ用フォントサイズ微調整 */
@media (max-width: 600px) {
    .manual-craft-container .manual-body h1 {
        font-size: 20px;
    }
    .manual-craft-container .manual-body h2 {
        font-size: 18px !important;
    }
    .manual-craft-container .manual-body h3 {
        font-size: 16.5px !important;
    }
    .manual-craft-container .manual-body h4 {
        font-size: 15.5px !important;
    }
}

/* ==========================================================================
   言語切り替えボタン (Lang Switcher)
   ========================================================================== */
.manual-craft-container .manual-craft-lang-switcher {
    margin-bottom: 20px;
    text-align: right; /* 右寄せ */
}

.manual-craft-container .mc-lang-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    text-decoration: none !important;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* 英語へ切り替えるボタン (Read in English) */
/* 背景: 白、文字: 紺 */
.manual-craft-container .mc-lang-en {
    background-color: #fff !important;
    color: #182640 !important;
    border: 1px solid #182640 !important;
}
.manual-craft-container .mc-lang-en:hover {
    background-color: #f0f0f0 !important;
}

/* 日本語へ切り替えるボタン (Read in Japanese) */
/* ★修正: 背景: 紺、文字: 白 (強制適用) */
.manual-craft-container .mc-lang-ja {
    background-color: #182640 !important;
    color: #fff !important;
    border: 1px solid #182640 !important;
}
.manual-craft-container .mc-lang-ja:hover {
    background-color: #2c3e5a !important;
}

/* =========================================
   1) 親の ol（1階層目）を「丸の中に数字だけ」に統一（ドット無し）
   2) ol > li > ul（ol-li → ul-li）だけ丸ポチを付ける
   すべて !important
   ========================================= */

/* 親 ol の基本リセット */
#content .entry-content ol{
  counter-reset: edel_ol_1 !important;
  list-style: none !important;
  margin: 1em 0 !important;
  padding: 0 !important;
}

/* 親 ol の各 li */
#content .entry-content ol > li{
  counter-increment: edel_ol_1 !important;
  list-style: none !important;
  position: relative !important;
  margin: 0.5em 0 !important;
  padding-left: 2.4em !important; /* 丸番号ぶんの余白 */
  line-height: 1.75 !important;
}

/* テーマ側の ::marker を無効化（ドット含む表記を消す） */
#content .entry-content ol > li::marker{
  content: "" !important;
}

/* 親 ol の丸番号（数字だけ・ドット無し） */
#content .entry-content ol > li::before{
  content: counter(edel_ol_1) !important; /* ←ドット無し */
  position: absolute !important;
  left: 3.00em !important;
  top: 1.45em !important;

  width: 1.5em !important;
  height: 1.5em !important;
  line-height: 1.5em !important;

  background: #182640 !important;
  color: #fff !important;
  border-radius: 999px !important;

  text-align: center !important;
  font-size: 0.8em !important;
  font-weight: 700 !important;

  transform: translateY(-50%) !important;
  display: inline-block !important;
}

/* =========================================
   ol-li → ul-li（この組み合わせだけ）を装飾
   ========================================= */

/* ネスト ul の余白 */
#content .entry-content ol > li > ul{
  list-style: none !important;
  margin: 0.7em 0 0.7em 0 !important;
  padding: 0 !important;
}

/* ネスト ul の各 li */
#content .entry-content ol > li > ul > li{
  list-style: none !important;
  position: relative !important;
  margin: 0.35em 0 !important;
  padding-left: 1.8em !important;
  line-height: 1.75 !important;
}

/* ネスト ul の丸ポチ（#182640） */
#content .entry-content ol > li > ul > li::before{
  content: "" !important;
  position: absolute !important;
  left: 2.65em !important;
  top: 1.50em !important;
  width: 0.5em !important;
  height: 0.5em !important;
  background: #182640 !important;
  border-radius: 999px !important;
  transform: translateY(-50%) !important;
}
