/* ============================================================
 * 記事ページ・記事一覧(お役立ち情報)専用CSS
 * 追加: 2026-07-14
 * 準拠: docs/design/DESIGN_SYSTEM.md v1.0
 *       docs/article-lp/ARTICLE_LP_SPEC.md v1.0
 * ルール:
 * - 色・主要余白・角丸・フォントサイズはトークン変数を参照
 * - 既存CSSの上書きは .single-post 等のスコープ内のみ
 * - ブレークポイント: 960px(記事2カラム解除) / 767px(SP)
 * ============================================================ */

/* ------------------------------
  Design Tokens
  ※ 現状サイト唯一の変数定義。将来 tokens.css へ移設(TODO)
------------------------------ */
:root {
  /* color */
  --color-primary: #ffe400;
  --color-line: #06c755;
  --color-link: #0066cc;
  --color-border: #d9d9d9;
  --color-black: #222;
  --color-black-pure: #000;
  --color-text-sub: #555;
  --color-white: #fff;
  --color-bg-gray: #f5f5f5;
  --color-marker: #ffd6e6;

  /* article */
  --article-main-width: 680px;
  --article-sidebar-width: 320px;
  --article-gap: 40px;
  --article-radius: 8px;
  --article-sticky-top: 88px;
}

/* ------------------------------
  Layout(記事詳細: 2カラム)
------------------------------ */
.article__inner {
  padding-block: 20px 72px;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--article-main-width)) var(--article-sidebar-width);
  gap: var(--article-gap);
}

.article-main {
  min-width: 0;
}

/* ------------------------------
  Sidebar(PC・sticky)
------------------------------ */
.article-sidebar__sticky {
  position: sticky;
  top: var(--article-sticky-top);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-bar .article-sidebar__sticky {
  top: 120px;
}

.sidebar__widget {
  border: 1px solid var(--color-border);
  border-radius: var(--article-radius);
  background: var(--color-white);
  overflow: hidden;
}

.sidebar__title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-bg-gray);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
}

.sidebar__title::before {
  content: "";
  width: 5px;
  height: 20px;
  flex-shrink: 0;
  background: var(--color-primary);
}

/* 目次 */
.sidebar-toc__list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: toc;
}

.sidebar-toc__item a {
  display: block;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-black);
  text-decoration: none;
}

.sidebar-toc__item--h2 a::before {
  counter-increment: toc;
  content: counter(toc) ". ";
  font-weight: 700;
}

.sidebar-toc__item--h3 {
  padding-left: 1.4em;
}

.sidebar-toc__item--h3 a {
  font-size: 13px;
  color: var(--color-text-sub);
}

.sidebar-toc__item a:hover {
  text-decoration: underline;
  text-underline-offset: .2em;
}

.sidebar-toc__item a.is-current {
  color: var(--color-black);
  background: none;
  font-weight: 700;
  border-left: 3px solid var(--color-primary);
  padding-left: 8px;
  margin-left: -11px;
}

/* カテゴリー */
.sidebar-category__list {
  padding: 8px 16px 16px;
}

.sidebar-category__list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-category__list li:last-child {
  border-bottom: none;
}

.sidebar-category__list a {
  flex: 1;
  padding: 10px 2px;
  font-size: 14px;
  color: var(--color-black);
  text-decoration: none;
}

.sidebar-category__list a:hover {
  opacity: .7;
}

/* 最新の記事 */
.sidebar-latest__list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-latest__item a {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-decoration: none;
  color: var(--color-black);
}

.sidebar-latest__item a:hover {
  opacity: .7;
}

.sidebar-latest__thumb {
  width: 80px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
}

.sidebar-latest__thumb img {
  width: 80px;
  height: 60px;
  object-fit: cover;
}

.sidebar-latest__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
}

/* ------------------------------
  Article Header
------------------------------ */
.article-breadcrumb {
  font-size: 12px;
  margin-bottom: 24px;
}

.article-breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 13px;
  color: var(--color-text-sub);
}

.article-breadcrumb__list li:not(:last-child)::after {
  content: ">";
  margin-left: 4px;
}

.article-breadcrumb__list a {
  color: var(--color-text-sub);
  text-decoration: underline;
  text-underline-offset: .2em;
}

.article-breadcrumb__list li[aria-current] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 24em;
}

.article-category {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 4px;
  background: var(--color-primary);
  color: var(--color-black);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.article-title {
  margin-top: 16px;
  font-size: 42px;
  font-weight: 700;
  line-height: 1.25;
}

.article-meta {
  margin-top: 14px;
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--color-text-sub);
}

.article-lead {
  margin-top: 20px;
  font-size: 18px;
  line-height: 1.8;
  color: var(--color-text-sub);
}

.article-eyecatch {
  margin-top: 24px;
  border-radius: var(--article-radius);
  overflow: hidden;
}

.article-eyecatch img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ------------------------------
  目次(SPインライン・details)
  PCではサイドバー版を使うため非表示
------------------------------ */
.article-toc {
  display: none;
}

/* ------------------------------
  Article Body(WP本文要素)
------------------------------ */
.article-body {
  margin-top: 40px;
  font-size: 16px;
  line-height: 1.9;
  overflow-wrap: break-word;
}

.article-body > * + * {
  margin-top: 1.5em;
}

/* 見出し(クラス付与なし・要素セレクタ) */
.article-body h2 {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 64px;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.4;
  scroll-margin-top: var(--article-sticky-top);
}

.article-body h2::before {
  content: "";
  width: 6px;
  align-self: stretch;
  flex-shrink: 0;
  background: var(--color-primary);
}

.article-body h3 {
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.45;
  scroll-margin-top: var(--article-sticky-top);
}

.article-body h4 {
  margin-top: 32px;
  margin-bottom: 12px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
}

.article-body h5 {
  margin-top: 24px;
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
}

/* テキスト */
.article-body a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: .2em;
}

.article-body strong {
  font-weight: 700;
}

.article-body mark {
  background: linear-gradient(transparent 55%, var(--color-marker) 55%);
  color: inherit;
}

/* マーカー誤用ガード: パレット色を文字色として選んでもマーカー表示に矯正 */
.article-body .has-marker-color {
  color: inherit;
  background: linear-gradient(transparent 55%, var(--color-marker) 55%);
}

/* リスト */
.article-body ul,
.article-body ol {
  padding-left: 1.5em;
}

.article-body ul li {
  list-style: disc;
}

.article-body ol li {
  list-style: decimal;
}

.article-body li {
  margin-top: .45em;
}

.article-body li::marker {
  color: var(--color-black);
}

/* 引用 */
.article-body blockquote {
  padding: 16px 20px;
  border-left: 4px solid var(--color-border);
  background: var(--color-bg-gray);
  border-radius: 0 var(--article-radius) var(--article-radius) 0;
}

.article-body blockquote cite {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-style: normal;
  color: var(--color-text-sub);
}

/* 表 */
.article-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.article-body table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.6;
}

.article-body th,
.article-body td {
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.article-body th {
  background: var(--color-bg-gray);
  font-weight: 700;
}

/* 画像・figure */
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--article-radius);
}

.article-body figure {
  margin-block: 24px;
}

.article-body figcaption {
  margin-top: 8px;
  font-size: 13px;
  text-align: center;
  color: var(--color-text-sub);
}

/* WP配置クラス */
.article-body .aligncenter {
  margin-inline: auto;
  display: block;
}

.article-body .alignleft {
  float: left;
  margin: 0 24px 16px 0;
}

.article-body .alignright {
  float: right;
  margin: 0 0 16px 24px;
}

.article-body .alignwide {
  width: 100%;
}

/* 埋め込み */
.article-body .wp-block-embed iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: var(--article-radius);
}

/* コード */
.article-body code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-bg-gray);
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 14px;
}

.article-body pre {
  padding: 20px;
  border-radius: var(--article-radius);
  background: var(--color-black);
  color: var(--color-white);
  overflow-x: auto;
}

.article-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

/* 区切り線 */
.article-body hr {
  margin-block: 48px;
  border: none;
  border-top: 1px solid var(--color-border);
}

/* ------------------------------
  結論・注意ボックス(ブロックパターン)
------------------------------ */
.article-point,
.article-warning {
  padding: 24px;
  border-radius: var(--article-radius);
}

.article-point {
  background: var(--color-white);
  border: 2px solid var(--color-primary);
}

.article-warning {
  background: var(--color-bg-gray);
  border: 2px solid var(--color-black);
}

.article-point__label,
.article-warning__label {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.article-point__label {
  background: var(--color-primary);
  color: var(--color-black);
}

.article-warning__label {
  background: var(--color-black);
  color: var(--color-white);
}

.article-point > * + *,
.article-warning > * + * {
  margin-top: 12px;
}

/* ------------------------------
  記事CTA
------------------------------ */
.article-cta {
  margin-top: 56px;
  padding: 38px 40px;
  border-radius: 10px;
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.article-body .article-cta {
  margin-top: 40px;
}

.article-cta__copy {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-black);
}

.article-cta .btn {
  width: min(100%, 488px);
}

/* ------------------------------
  著者情報
------------------------------ */
.article-author {
  margin-top: 56px;
  padding: 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--article-radius);
}

.article-author__heading {
  font-size: 18px;
  font-weight: 700;
}

.article-author__inner {
  margin-top: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.article-author__avatar {
  flex-shrink: 0;
}

.article-author__avatar img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
}

.article-author__name {
  font-size: 16px;
  font-weight: 700;
}

.article-author__bio {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--color-text-sub);
}

/* ------------------------------
  関連記事・記事カード
------------------------------ */
.article-related {
  margin-top: 56px;
}

.article-related__heading {
  font-size: 24px;
  font-weight: 700;
}

.article-related__list {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.article-card {
  border: 1px solid var(--color-border);
  border-radius: var(--article-radius);
  background: var(--color-white);
  overflow: hidden;
}

.article-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--color-black);
  text-decoration: none;
  transition: opacity .3s ease;
}

.article-card__link:hover {
  opacity: .8;
}

.article-card__image img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 0;
}

.article-card__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
}

.article-card__category {
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--color-bg-gray);
  font-size: 12px;
  color: var(--color-text-sub);
}

.article-card__title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
}

.article-card__date {
  font-size: 13px;
  color: var(--color-text-sub);
}

/* ------------------------------
  前後記事ナビ・ページネーション
------------------------------ */
.article-nav {
  margin-top: 56px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.article-nav .pagination__item a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--article-radius);
  color: var(--color-black);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .3s ease;
}

.article-nav .pagination__item a:hover {
  opacity: .7;
}

/* 一覧ページネーション(the_posts_pagination出力) */
.archive-page .pagination {
  margin-top: 48px;
}

.archive-page .pagination .nav-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.archive-page .pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--color-border);
  border-radius: var(--article-radius);
  background: var(--color-white);
  color: var(--color-black);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .3s ease;
}

.archive-page .pagination .page-numbers:hover {
  opacity: .7;
}

.archive-page .pagination .page-numbers.current {
  background: var(--color-primary);
  border-color: var(--color-primary);
  font-weight: 700;
}

.archive-page .pagination .page-numbers.dots {
  border: none;
  width: auto;
  color: var(--color-text-sub);
}

/* ------------------------------
  記事一覧(home / category)
------------------------------ */
.archive-page__inner {
  padding-block: 20px 72px;
}

.archive-page__heading {
  margin-top: 24px;
}

.archive-grid {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 40px 24px;
}

.archive-empty {
  margin-top: 40px;
  text-align: center;
  color: var(--color-text-sub);
}

/* ============================================================
  Responsive: 960px以下(記事2カラム解除・グリッド2列)
  ※ 記事ページ限定の例外ブレークポイント
============================================================ */
@media screen and (max-width: 960px) {

  .article-layout {
    grid-template-columns: 1fr;
  }

  /* サイドバーは記事末尾へ(DOM順のまま下に落ちる) */
  .article-sidebar__sticky {
    position: static;
    margin-top: 56px;
  }

  /* サイドバー目次はPC専用 → 非表示、SPインライン目次を表示 */
  .sidebar-toc {
    display: none;
  }

  /* SPではカテゴリーウィジェットを非表示(読了後はCTA・関連記事を優先) */
  .sidebar-category {
    display: none;
  }

  .article-toc {
    display: block;
    margin-top: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--article-radius);
    overflow: hidden;
  }

  .article-toc__title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--color-bg-gray);
    font-size: 18px;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
  }

  .article-toc__title::-webkit-details-marker {
    display: none;
  }

  .article-toc__title::before {
    content: "";
    width: 5px;
    height: 20px;
    background: var(--color-primary);
  }

  .article-toc__title::after {
    content: "+";
    margin-left: auto;
    font-size: 22px;
    font-weight: 700;
  }

  .article-toc[open] .article-toc__title::after {
    content: "−";
  }

  .article-toc__list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    counter-reset: toc;
  }

  .article-toc__item a {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-black);
    text-decoration: none;
  }

  .article-toc__item--h2 a::before {
    counter-increment: toc;
    content: counter(toc) ". ";
    font-weight: 700;
  }

  .article-toc__item--h3 {
    padding-left: 1.4em;
  }

  .archive-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ============================================================
  Responsive: 767px以下(SP)
============================================================ */
@media screen and (max-width: 767px) {

  .article__inner,
  .archive-page__inner {
    padding-block: 32px 48px;
  }

  .article-sidebar__sticky {
    margin-top: 32px;
  }

  .article-title {
    font-size: 32px;
  }

  .article-meta {
    font-size: 12px;
  }

  .article-lead {
    font-size: 15px;
  }

  .article-body {
    margin-top: 32px;
    font-size: 15px;
  }

  .article-body h2 {
    margin-top: 48px;
    margin-bottom: 20px;
    font-size: 22px;
    gap: 12px;
  }

  .article-body h3 {
    margin-top: 32px;
    font-size: 18px;
  }

  .article-body h4 {
    font-size: 17px;
  }

  .article-body h5 {
    font-size: 16px;
  }

  .article-body table {
    font-size: 14px;
  }

  .article-body th,
  .article-body td {
    padding: 10px 12px;
  }

  /* SPではfloat解除 */
  .article-body .alignleft,
  .article-body .alignright {
    float: none;
    margin: 24px auto;
    display: block;
  }

  .article-point,
  .article-warning {
    padding: 18px 16px;
  }

  .article-cta {
    margin-top: 40px;
    padding: 28px 16px;
    gap: 16px;
  }

  .article-cta .btn {
    width: 100%;
  }

  .article-author__avatar img {
    width: 56px;
    height: 56px;
  }

  .article-related__list {
    grid-template-columns: 1fr;
  }

  .article-nav {
    flex-direction: column;
  }

  .article-nav .pagination__item a {
    width: 100%;
    justify-content: center;
  }

  .archive-grid {
    margin-top: 32px;
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .archive-page .pagination .page-numbers {
    width: 44px;
    height: 44px;
    font-size: 15px;
  }
}