/* ============================================================
   toc.css — 追従目次（ガイドページ共通）
   template-guide-flow.php / template-guide-howto.php
   template-guide-choose-company.php
============================================================ */


/* ============================================================
   見出しスクロールマージン（固定ヘッダー分を吸収）
============================================================ */
.js-toc-content h2,
.js-toc-content h3 {
  scroll-margin-top: 12rem;
}


/* ============================================================
   レイアウト（本文 + 追従目次を横並び）
   モバイルは縦積み、1024px 以上で 2 カラム
============================================================ */
.p-guide-layout {
  display: block;
}

@media (min-width: 1024px) {
  .p-guide-layout {
    align-items: flex-start;
    display: flex;
  }

  .p-guide-layout__main {
    flex: 1;
    min-width: 0;
  }
}


/* ============================================================
   追従目次本体
   モバイルは非表示、1024px 以上で表示
============================================================ */
.c-sticky-toc {
  display: none;
}

.c-toc-mobile-button {
  align-items: center;
  background: var(--color-blue, #2980b9);
  border: 0;
  border-radius: 999px;
  bottom: 1.6rem;
  box-shadow: 0 0.8rem 2.4rem rgba(0, 0, 0, 0.18);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-size: 1.3rem;
  font-weight: 700;
  gap: 0.6rem;
  line-height: 1;
  padding: 1.2rem 1.6rem;
  position: fixed;
  z-index: 1000;
}

.c-toc-mobile-button__icon {
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(currentColor, currentColor),
    linear-gradient(currentColor, currentColor);
  background-position: 0 0, 0 50%, 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 0.2rem;
  display: block;
  height: 1.1rem;
  width: 1.4rem;
}

.c-toc-modal {
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.2s ease;
  z-index: 1001;
}

.c-toc-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.c-toc-modal__backdrop {
  background: rgba(0, 0, 0, 0.45);
  inset: 0;
  position: absolute;
}

.c-toc-modal__dialog {
  background: #fff;
  border-radius: 1.6rem 1.6rem 0 0;
  bottom: 0;
  box-shadow: 0 -0.8rem 3.2rem rgba(0, 0, 0, 0.16);
  left: 0;
  max-height: min(72vh, 54rem);
  overflow: hidden;
  padding: 2rem 1.6rem 1.8rem;
  position: absolute;
  right: 0;
  transform: translateY(100%);
  transition: transform 0.24s ease;
}

.c-toc-modal.is-open .c-toc-modal__dialog {
  transform: translateY(0);
}

.c-toc-modal__header {
  align-items: flex-start;
  border-bottom: 0.1rem solid var(--color-border, #ddd);
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
}

.c-toc-modal__label {
  color: var(--color-blue, #2980b9);
  font-size: 1.0rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.c-toc-modal__title {
  font-size: 1.6rem;
  font-weight: 700;
}

.c-toc-modal__close {
  background: transparent;
  border: 0;
  cursor: pointer;
  height: 3.2rem;
  position: relative;
  width: 3.2rem;
}

.c-toc-modal__close::before,
.c-toc-modal__close::after {
  background: var(--color-text, #333);
  content: "";
  height: 0.2rem;
  left: 0.7rem;
  position: absolute;
  top: 1.5rem;
  width: 1.8rem;
}

.c-toc-modal__close::before {
  transform: rotate(45deg);
}

.c-toc-modal__close::after {
  transform: rotate(-45deg);
}

.c-toc-modal__nav {
  max-height: calc(min(72vh, 54rem) - 9.6rem);
  overflow-y: auto;
}

.c-toc-modal__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.c-toc-modal .c-sticky-toc__item {
  margin: 0;
}

.c-toc-modal .c-sticky-toc__link {
  border-left: 0.2rem solid transparent;
  color: var(--color-text-sub, #777);
  display: block;
  font-size: 1.3rem;
  line-height: 1.5;
  padding: 0.7rem 0.8rem;
  text-decoration: none;
}

.c-toc-modal .c-sticky-toc__link.is-active {
  border-left-color: var(--color-blue, #2980b9);
  color: var(--color-blue, #2980b9);
  font-weight: 700;
}

.c-toc-modal .c-sticky-toc__item.is-level-3 > .c-sticky-toc__link {
  font-size: 1.2rem;
  padding-left: 1.8rem;
}

.is-toc-modal-open {
  overflow: hidden;
}

@media (min-width: 1024px) {
  .c-toc-mobile-button,
  .c-toc-modal {
    display: none;
  }

  .c-sticky-toc {
    background: #fff;
    border: 0.1rem solid var(--color-border, #ddd);
    border-radius: 0.8rem;
    box-shadow: 0 0.2rem 0.8rem rgba(0, 0, 0, 0.05);
    display: block;
    flex-shrink: 0;
    margin-left: 3.2rem;
    max-height: calc(100vh - 14rem);
    overflow-y: auto;
    padding: 2rem 1.6rem;
    position: sticky;
    /* top はヘッダー高さ + 余白。SWELL 固定ヘッダーに合わせて調整してください */
    top: 10rem;
    width: 24rem;
  }

  /* スクロールバーを細く上品に */
  .c-sticky-toc::-webkit-scrollbar {
    width: 0.4rem;
  }

  .c-sticky-toc::-webkit-scrollbar-track {
    background: transparent;
  }

  .c-sticky-toc::-webkit-scrollbar-thumb {
    background: var(--color-border, #ddd);
    border-radius: 0.2rem;
  }
}


/* ============================================================
   目次ラベル・タイトル
============================================================ */
@media (min-width: 1024px) {
  .c-sticky-toc__label {
    color: var(--color-blue, #2980b9);
    font-size: 1.0rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
  }

  .c-sticky-toc__title {
    border-bottom: 0.1rem solid var(--color-border, #ddd);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
  }
}


/* ============================================================
   目次リスト
============================================================ */
@media (min-width: 1024px) {
  .c-sticky-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .c-sticky-toc__item {
    margin: 0;
  }


  /* ----------------------------------------------------------
     目次リンク（共通）
  ---------------------------------------------------------- */
  .c-sticky-toc__link {
    border-left: 0.2rem solid transparent;
    color: var(--color-text-sub, #777);
    display: block;
    font-size: 1.3rem;
    line-height: 1.5;
    padding: 0.5rem 0.8rem;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
  }

  .c-sticky-toc__link:hover {
    color: var(--color-text, #333);
  }

  /* アクティブ状態（色 + 左ボーダー + 太字で多角的に表現） */
  .c-sticky-toc__link.is-active {
    border-left-color: var(--color-blue, #2980b9);
    color: var(--color-blue, #2980b9);
    font-weight: 600;
  }


  /* ----------------------------------------------------------
     h2 アイテム
  ---------------------------------------------------------- */
  .c-sticky-toc__item.is-level-2 + .c-sticky-toc__item.is-level-2 {
    margin-top: 0.2rem;
  }


  /* ----------------------------------------------------------
     h3 アイテム（インデントで階層を表現）
  ---------------------------------------------------------- */
  .c-sticky-toc__item.is-level-3 > .c-sticky-toc__link {
    font-size: 1.2rem;
    padding-left: 1.8rem;
  }
}
