/**
 * AFFINGER ショートコード互換レイヤー
 * テーマ移行用暫定レイヤー。Phase 2完了後に削除する。
 *
 * 対応: 会話吹き出し / メモボックス / カード / 装飾ボックス / ボタン /
 *       ステップ / カテゴリグループ / タイムライン / ランキング /
 *       コードブロック / ブログカード / ミニ吹き出し / 見出しボックス /
 *       記事グループ / テキスト装飾クラス
 */

/* ==========================================================================
   デザイントークン参照（既存 :root から継承）
   --color-primary: #2B6CB0
   --color-accent: #E8956D
   --color-heading: #2D3748
   --color-body: #4A5568
   --color-sub: #718096
   --color-bg-light: #F7F7F7
   --color-success: #059669
   --color-primary-tint: #DBEAFE
   ========================================================================== */

/* ==========================================================================
   1. 会話吹き出し (.cclt-compat-kaiwa)
   ========================================================================== */

.cclt-compat-kaiwa {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin: 1.5em 0;
}

.cclt-compat-kaiwa.cclt-compat-kaiwa--right {
  flex-direction: row-reverse;
}

/* アイコン */
.cclt-compat-kaiwa .cclt-compat-kaiwa__icon {
  flex-shrink: 0;
  width: 80px;
  text-align: center;
}

.cclt-compat-kaiwa .cclt-compat-kaiwa__icon img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.cclt-compat-kaiwa .cclt-compat-kaiwa__icon .cclt-compat-kaiwa__name {
  display: block;
  margin-top: 4px;
  font-size: 0.7em;
  color: var(--color-sub, #718096);
  line-height: 1.3;
}

/* 吹き出しバブル（テキストの外側ラッパー） */
.cclt-compat-kaiwa .cclt-compat-kaiwa__bubble {
  position: relative;
  flex: 1;
  padding: 1em 1.2em;
  border-radius: 12px;
  color: var(--color-body, #4A5568);
  line-height: 1.8;
  font-size: 0.95em;
}

/* テキスト本体 */
.cclt-compat-kaiwa .cclt-compat-kaiwa__text {
  /* バブル内のテキスト。レイアウトはバブルが担うのでここは最低限 */
}

/* 三角マーク不使用（モダンな角丸バブルのみ） */

/* ==========================================================================
   2. メモボックス (.cclt-compat-cmemo)
   ========================================================================== */

.cclt-compat-cmemo {
  padding: 1em 1.2em;
  margin: 1.5em 0;
  border-radius: 4px;
  line-height: 1.8;
  color: var(--color-body, #4A5568);
}

.cclt-compat-cmemo .cclt-compat-cmemo__icon {
  margin-right: 0.5em;
  font-size: 1.1em;
}

.cclt-compat-cmemo .cclt-compat-cmemo__text {
  /* テキスト部分。displayはデフォルトのまま */
}

.cclt-compat-cmemo p {
  margin: 0;
}

/* ==========================================================================
   3. カード (.cclt-compat-card)
   ========================================================================== */

.cclt-compat-card {
  position: relative;
  display: flex;
  align-items: stretch;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  margin: 1.5em 0;
  background: #fff;
  transition: box-shadow 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.cclt-compat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* カードリンクラッパー */
.cclt-compat-card .cclt-compat-card__link {
  display: flex;
  align-items: stretch;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.cclt-compat-card .cclt-compat-card__thumb {
  flex-shrink: 0;
  width: 150px;
  overflow: hidden;
}

.cclt-compat-card .cclt-compat-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cclt-compat-card .cclt-compat-card__body {
  flex: 1;
  padding: 1em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cclt-compat-card .cclt-compat-card__title {
  font-size: 1em;
  font-weight: bold;
  color: var(--color-heading, #2D3748);
  margin: 0 0 0.4em;
  line-height: 1.5;
}

.cclt-compat-card .cclt-compat-card__excerpt {
  font-size: 0.85em;
  color: var(--color-sub, #718096);
  line-height: 1.6;
  margin: 0;
}

/* 「続きを読む」リンク */
.cclt-compat-card .cclt-compat-card__readmore {
  display: inline-block;
  margin-top: 0.5em;
  font-size: 0.8em;
  font-weight: bold;
  color: var(--color-primary, #2B6CB0);
}

/* カードラベル（左上バッジ） */
.cclt-compat-card .cclt-compat-card__label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 10px;
  font-size: 0.75em;
  font-weight: bold;
  color: #fff;
  background: var(--color-primary, #2B6CB0);
  border-radius: 0 0 8px 0;
  line-height: 1.6;
  z-index: 1;
}

/* ==========================================================================
   4. 装飾ボックス (.cclt-compat-mybox)
   ========================================================================== */

.cclt-compat-mybox {
  margin: 1.5em 0;
  border: 2px solid var(--color-primary, #2B6CB0);
  border-radius: 4px;
  overflow: hidden;
}

.cclt-compat-mybox .cclt-compat-mybox__title {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.6em 1em;
  font-size: 0.95em;
  font-weight: bold;
  color: var(--color-heading, #2D3748);
  line-height: 1.5;
}

.cclt-compat-mybox .cclt-compat-mybox__title .fa,
.cclt-compat-mybox .cclt-compat-mybox__title .fas,
.cclt-compat-mybox .cclt-compat-mybox__title .far,
.cclt-compat-mybox .cclt-compat-mybox__title .fab {
  font-size: 1.1em;
}

.cclt-compat-mybox .cclt-compat-mybox__content {
  padding: 1em 1.2em;
  color: var(--color-body, #4A5568);
  line-height: 1.8;
}

.cclt-compat-mybox .cclt-compat-mybox__content p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   5. ボタン (.cclt-compat-mybutton, .cclt-compat-mybutton-mini)
   ========================================================================== */

.cclt-compat-mybutton {
  display: block;
  text-align: center;
  margin: 1.5em auto;
}

.cclt-compat-mybutton .cclt-compat-mybutton__link {
  display: inline-block;
  padding: 0.8em 2em;
  border-radius: 6px;
  font-size: 1em;
  font-weight: bold;
  text-decoration: none;
  color: #fff;
  background: var(--color-primary, #2B6CB0);
  transition: opacity 0.2s ease;
  line-height: 1.5;
}

.cclt-compat-mybutton .cclt-compat-mybutton__link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* シャドウ付きボタン */
.cclt-compat-mybutton.cclt-compat-mybutton--shadow .cclt-compat-mybutton__link {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
}

/* ref付きボタン（光るアニメーション等は将来対応） */
.cclt-compat-mybutton.cclt-compat-mybutton--ref .cclt-compat-mybutton__link {
  /* 将来的にアテンション演出を追加可能 */
}

/* ミニボタン */
.cclt-compat-mybutton-mini {
  display: inline-block;
  text-align: center;
  margin: 0.3em 0;
}

.cclt-compat-mybutton-mini .cclt-compat-mybutton-mini__link {
  display: inline-block;
  padding: 0.4em 1.2em;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
  text-decoration: none;
  color: #fff;
  background: var(--color-primary, #2B6CB0);
  transition: opacity 0.2s ease;
  line-height: 1.5;
}

.cclt-compat-mybutton-mini .cclt-compat-mybutton-mini__link:hover {
  opacity: 0.85;
}

/* ==========================================================================
   6. ステップ (.cclt-compat-step)
   ========================================================================== */

/* 個別ステップアイテム */
.cclt-compat-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 1.2em 0;
  border-bottom: 2px dashed #e2e8f0;
  margin: 0 0 0;
}

.cclt-compat-step:last-child {
  border-bottom: none;
}

/* ステップ番号バッジ */
.cclt-compat-step .cclt-compat-step__number {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary, #2B6CB0);
  color: #fff;
  font-size: 0.75em;
  font-weight: bold;
  line-height: 1;
  text-align: center;
}

/* ステップコンテンツ */
.cclt-compat-step .cclt-compat-step__content {
  flex: 1;
}

.cclt-compat-step .cclt-compat-step__content h4 {
  margin: 0 0 0.4em;
  font-size: 1.05em;
  font-weight: bold;
  color: var(--color-heading, #2D3748);
}

.cclt-compat-step .cclt-compat-step__content p {
  margin: 0;
  color: var(--color-body, #4A5568);
  line-height: 1.8;
}

/* ==========================================================================
   7. カテゴリグループ (.cclt-compat-catgroup)
   ========================================================================== */

.cclt-compat-catgroup {
  margin: 1.5em 0;
}

.cclt-compat-catgroup .cclt-compat-catgroup__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.cclt-compat-catgroup .cclt-compat-catgroup__item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: box-shadow 0.2s ease;
}

.cclt-compat-catgroup .cclt-compat-catgroup__item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cclt-compat-catgroup .cclt-compat-catgroup__link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.cclt-compat-catgroup .cclt-compat-catgroup__thumb img {
  width: 100%;
  height: auto;
  display: block;
}

.cclt-compat-catgroup .cclt-compat-catgroup__title {
  display: block;
  padding: 0.6em 0.8em;
  font-size: 0.9em;
  font-weight: bold;
  color: var(--color-heading, #2D3748);
  line-height: 1.5;
}

.cclt-compat-catgroup .cclt-compat-catgroup__date {
  display: block;
  padding: 0 0.8em 0.6em;
  font-size: 0.75em;
  color: var(--color-sub, #718096);
}

/* ==========================================================================
   8. タイムライン (.cclt-compat-timeline)
   ========================================================================== */

.cclt-compat-timeline {
  margin: 1.5em 0;
  padding-left: 24px;
  border-left: 3px solid var(--color-primary, #2B6CB0);
}

.cclt-compat-timeline .cclt-compat-timeline__item {
  position: relative;
  padding: 0 0 1.5em 20px;
}

.cclt-compat-timeline .cclt-compat-timeline__item:last-child {
  padding-bottom: 0;
}

/* ドット */
.cclt-compat-timeline .cclt-compat-timeline__item::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -32px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary, #2B6CB0);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--color-primary, #2B6CB0);
}

.cclt-compat-timeline .cclt-compat-timeline__label {
  margin: 0 0 0.3em;
  font-size: 1em;
  font-weight: bold;
  color: var(--color-heading, #2D3748);
  line-height: 1.5;
}

.cclt-compat-timeline .cclt-compat-timeline__content {
  color: var(--color-body, #4A5568);
  line-height: 1.8;
  font-size: 0.95em;
}

.cclt-compat-timeline .cclt-compat-timeline__content p {
  margin: 0;
}

/* ==========================================================================
   9. ランキング (.cclt-compat-rank)
   ========================================================================== */

/* 個別ランキングアイテム */
.cclt-compat-rank {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 1em;
  margin-bottom: 1em;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.cclt-compat-rank:last-child {
  margin-bottom: 0;
}

/* 順位バッジ */
.cclt-compat-rank .cclt-compat-rank__number {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: 50%;
  font-size: 0.85em;
  font-weight: bold;
  color: #fff;
  background: var(--color-sub, #718096);
}

/* 星評価 */
.cclt-compat-rank .cclt-compat-rank__stars {
  display: inline-flex;
  gap: 2px;
  margin-left: 0.5em;
  color: #d4a017;
  font-size: 0.9em;
}

.cclt-compat-rank .cclt-compat-rank__content {
  flex: 1;
}

.cclt-compat-rank .cclt-compat-rank__content p {
  margin: 0;
  font-size: 0.9em;
  color: var(--color-body, #4A5568);
  line-height: 1.7;
}

/* ==========================================================================
   10. コードブロック (.cclt-compat-pre)
   ========================================================================== */

.cclt-compat-pre {
  margin: 1.5em 0;
  padding: 1.2em 1.4em;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  line-height: 1.7;
  border-radius: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cclt-compat-pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ==========================================================================
   11. ブログカード (.cclt-compat-blogcard)
   ========================================================================== */

.cclt-compat-blogcard {
  display: flex;
  align-items: stretch;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  margin: 1.5em 0;
  background: #fff;
  transition: box-shadow 0.2s ease;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.cclt-compat-blogcard:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ブログカードリンクラッパー */
.cclt-compat-blogcard .cclt-compat-blogcard__link {
  display: flex;
  align-items: stretch;
  text-decoration: none;
  color: inherit;
  width: 100%;
}

.cclt-compat-blogcard .cclt-compat-blogcard__thumb {
  flex-shrink: 0;
  width: 150px;
  overflow: hidden;
}

.cclt-compat-blogcard .cclt-compat-blogcard__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cclt-compat-blogcard .cclt-compat-blogcard__body {
  flex: 1;
  padding: 1em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.cclt-compat-blogcard .cclt-compat-blogcard__title {
  font-size: 1em;
  font-weight: bold;
  color: var(--color-heading, #2D3748);
  margin: 0 0 0.4em;
  line-height: 1.5;
}

.cclt-compat-blogcard .cclt-compat-blogcard__excerpt {
  font-size: 0.85em;
  color: var(--color-sub, #718096);
  line-height: 1.6;
  margin: 0;
}

/* 外部リンク修飾子 */
.cclt-compat-blogcard.cclt-compat-blogcard--external {
  /* 外部リンクカードの基本スタイルは共通。追加装飾はここで */
}

/* ドメイン表示 */
.cclt-compat-blogcard .cclt-compat-blogcard__domain {
  display: block;
  margin-top: 0.3em;
  font-size: 0.75em;
  color: var(--color-sub, #718096);
}

/* ==========================================================================
   12. ミニ吹き出し (.cclt-compat-minihukidashi)
   ========================================================================== */

.cclt-compat-minihukidashi {
  display: inline-block;
  padding: 0.2em 0.8em;
  font-size: 0.8em;
  font-weight: bold;
  color: #fff;
  background: var(--color-primary, #2B6CB0);
  border-radius: 4px;
  line-height: 1.5;
  vertical-align: middle;
  margin: 0 0.2em;
}

/* ==========================================================================
   13. 見出しボックス (.cclt-compat-midasibox)
   ========================================================================== */

.cclt-compat-midasibox {
  margin: 1.5em 0;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.cclt-compat-midasibox .cclt-compat-midasibox__title {
  padding: 0.6em 1em;
  font-size: 0.95em;
  font-weight: bold;
  color: #fff;
  background: var(--color-primary, #2B6CB0);
  line-height: 1.5;
}

.cclt-compat-midasibox .cclt-compat-midasibox__content {
  padding: 1em 1.2em;
  color: var(--color-body, #4A5568);
  line-height: 1.8;
}

.cclt-compat-midasibox .cclt-compat-midasibox__content p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   14. 記事グループ (.cclt-compat-postgroup)
   ========================================================================== */

.cclt-compat-postgroup {
  margin: 1.5em 0;
}

.cclt-compat-postgroup .cclt-compat-postgroup__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cclt-compat-postgroup .cclt-compat-postgroup__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.8em 0;
  border-bottom: 1px solid #e2e8f0;
}

.cclt-compat-postgroup .cclt-compat-postgroup__item:last-child {
  border-bottom: none;
}

.cclt-compat-postgroup .cclt-compat-postgroup__rank {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary, #2B6CB0);
  color: #fff;
  font-size: 0.8em;
  font-weight: bold;
}

.cclt-compat-postgroup .cclt-compat-postgroup__link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex: 1;
}

.cclt-compat-postgroup .cclt-compat-postgroup__thumb {
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  overflow: hidden;
  border-radius: 4px;
}

.cclt-compat-postgroup .cclt-compat-postgroup__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cclt-compat-postgroup .cclt-compat-postgroup__title {
  font-size: 0.9em;
  font-weight: bold;
  color: var(--color-heading, #2D3748);
  line-height: 1.5;
}

/* ==========================================================================
   15. AFFINGER固有テキストクラス互換
   ========================================================================== */

.hutoaka {
  font-weight: bold;
  color: var(--color-accent, #E8956D);
}

.huto {
  font-weight: bold;
}

.hutoline {
  font-weight: bold;
  text-decoration: underline;
}

.st-mycolor-class {
  /* 色はinline styleで上書きされる。ここではフォールバックのみ */
  font-weight: bold;
}

/* ==========================================================================
   Font Awesome 5 互換（最低限のディスプレイ設定）
   ========================================================================== */

.cclt-compat-cmemo .fa,
.cclt-compat-cmemo .fas,
.cclt-compat-cmemo .far,
.cclt-compat-cmemo .fab,
.cclt-compat-mybox .fa,
.cclt-compat-mybox .fas,
.cclt-compat-mybox .far,
.cclt-compat-mybox .fab {
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   レスポンシブ: 768px以下
   ========================================================================== */

@media (max-width: 768px) {
  /* カード: 縦積み */
  .cclt-compat-card .cclt-compat-card__link,
  .cclt-compat-blogcard .cclt-compat-blogcard__link {
    flex-direction: column;
  }

  .cclt-compat-card .cclt-compat-card__thumb,
  .cclt-compat-blogcard .cclt-compat-blogcard__thumb {
    width: 100%;
    height: 180px;
  }

  /* カテゴリグループ: 2列 */
  .cclt-compat-catgroup .cclt-compat-catgroup__list {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ランキング: 縦積み */
  .cclt-compat-rank {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* ==========================================================================
   レスポンシブ: 480px以下
   ========================================================================== */

@media (max-width: 480px) {
  /* 会話吹き出し: アイコン60px */
  .cclt-compat-kaiwa .cclt-compat-kaiwa__icon {
    width: 60px;
  }

  .cclt-compat-kaiwa .cclt-compat-kaiwa__icon img {
    width: 60px;
    height: 60px;
  }

  /* カテゴリグループ: 1列 */
  .cclt-compat-catgroup .cclt-compat-catgroup__list {
    grid-template-columns: 1fr;
  }

  /* 会話吹き出し: フォント縮小 */
  .cclt-compat-kaiwa .cclt-compat-kaiwa__bubble {
    font-size: 0.9em;
  }

  /* ステップ: 縦積み */
  .cclt-compat-step {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}
