/**
 * @file blog.css
 * @description ブログ一覧・記事詳細ページのスタイル定義
 * @summary
 *   - ブログ一覧（フィルター、カード）
 *   - 記事詳細ページ（ヘッダー、本文、ナビゲーション）
 *   - Markdown 本文 (.markdown-body)
 *   - 目次 (TOC)、シェアボタン、ページネーション
 * @recent_changes
 *   - ファイル先頭に説明コメントを追加
 */

/* ==========================================================================
   1. ブログ一覧（フィルター）
   ========================================================================== */
.blog-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem 1.2rem;
    align-items: center;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   Link Card (OGP)
   ========================================================================== */
.og-card {
    display: flex;
    width: 80%;
    align-items: stretch;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none !important;
    transition: background-color 0.2s ease;
    margin: 1.5rem 0;
    height: 130px;
    color: inherit;
}

.og-card:hover {
    background-color: rgba(125, 125, 125, 0.05);
    border-color: var(--color-border);
    transform: none;
    box-shadow: none;
}

/* Thumbnail (Left side of CARD) */
.og-thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 130px;
    width: 130px;
    height: 130px;
    background: var(--color-surface);
    position: relative;
    border-right: 1px solid var(--color-border);
    overflow: hidden;
}

.og-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    /* Reset markdown styles */
    max-width: none !important;
    box-sizing: border-box !important;
    background-color: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.og-thumbnail.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
}

/* Content (Right side of CARD) */
.og-content {
    flex: 1;
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.og-site {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.og-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-heading);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.og-description {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

/* Link Card (OGP) - Wide (WILDCARD) */
.og-card.wide {
    display: block;
    height: auto;
    width: 60%;
    border: none;
    background: transparent;
    border-radius: 0;
    overflow: visible;
    margin: 1.5rem 0;
}

.og-card.wide:hover {
    background: transparent;
    opacity: 0.7;
}

.og-image-wide {
    width: 100%;
    aspect-ratio: 1.91 / 1;
    background: #000;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.og-image-wide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    /* Reset markdown styles */
    max-width: none !important;
    box-sizing: border-box !important;
    background-color: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.og-title-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
    max-width: calc(100% - 24px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.og-site-footer {
    margin-top: 2px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    padding-left: 4px;
    display: flex;
    align-items: center;
}

.blog-filter {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.blog-filter__label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.2rem;
}

.blog-filter__control {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
}

.blog-filter__control::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

.blog-filter__control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--shadow-glow);
}

.blog-filter:first-child {
    min-width: 10rem;
}
.blog-filter:last-child {
    flex: 1;
    min-width: 16rem;
}

/* ==========================================================================
   2. ブログ一覧（カード本体）
   ========================================================================== */
.blog-card {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 1.25rem;
    align-items: stretch;
    background: var(--color-panel);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    transition: var(--transition-smooth);
    overflow: hidden;
}

.blog-card::before {
    cursor: pointer;
    content: "";
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    border: 1px solid transparent;
    background: linear-gradient(
            to right,
            var(--color-accent),
            var(--color-accent-dark)
        )
        border-box;
    mask:
        linear-gradient(#fff 0 0) padding-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask-composite: exclude;
    opacity: 0;
    transition: var(--transition-smooth);
}

.blog-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    background: var(--color-surface);
}

.blog-card:hover::before {
    opacity: 1;
}

.blog-card .card__thumb {
    cursor: pointer;
    flex-shrink: 0;
    width: 14rem;
    height: 7.5rem;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border-soft);
}

.blog-card .card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: var(--transition-smooth);
}
.blog-card:hover .card__thumb img {
    transform: scale(1.05);
}

.blog-card .card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.blog-card .card__meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.4rem;
}

.blog-card .card__title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-heading);
    line-height: 1.3;
    margin-bottom: 0.4rem;
}

.blog-card .card__description {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: 0.8rem;
    flex-grow: 1;
}

.blog-card .card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: auto;
}

.tag {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    background: var(--color-accent-soft);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    white-space: pre-wrap;
    transition: var(--transition-smooth);
    text-decoration: none;
}
.tag:hover {
    background: var(--color-accent);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

/* ==========================================================================
   3. 記事詳細ページ
   ========================================================================== */
.post-detail {
    background: var(--color-panel);
    border-radius: var(--radius-lg);
    padding: 3rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
}

.post-detail__header {
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--color-border-soft);
    text-align: center;
}

.post-detail__meta {
    font-size: 0.95rem;
    color: var(
        --color-accent
    ); /* 日付などをアクセントカラーに */
    font-weight: 600;
    margin-bottom: 0.8rem;
    letter-spacing: 0.05em;
}

.post-detail__title {
    font-size: 2.4rem;
    color: var(--color-heading);
    margin-bottom: 1.2rem;
    line-height: 1.25;
}

.post-detail__description {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    max-width: 90%;
    margin: 0 auto 1.5rem;
}

.post-detail__tags {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center; /* タグも中央寄せ */
    align-items: center;
}

.post-detail__tags a.tag:focus {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(0, 0, 0, 0.06),
        0 0 0 4px var(--color-accent-soft);
    border-color: var(--color-accent);
}

.post-detail__tags a.tag {
    text-decoration: none;
}

/* ==========================================================================
   4. Markdown 本文 (.markdown-body)
   ========================================================================== */
.markdown-body {
    line-height: 1.8;
    font-size: 1.05rem;
    color: var(--color-text);
}

.markdown-body > *:first-child {
    margin-top: 0;
}
.markdown-body > *:last-child {
    margin-bottom: 0;
}

/* リンク */
.markdown-body a {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    transition: var(--transition-smooth);
}
.markdown-body a:hover {
    color: var(--color-accent-dark);
    text-decoration-thickness: 2px;
}

/* 見出し */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: var(--color-heading);
    font-family: var(--font-heading);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
    position: relative;
    scroll-margin-top: 5rem;
}

.markdown-body h2 {
    font-size: 1.8rem;
    padding: 0.5rem 0 0.5rem 1rem;
    border-left: 5px solid var(--color-accent);
    background: linear-gradient(
        to right,
        rgba(var(--color-accent-rgb), 0.1),
        transparent
    );
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body h3 {
    font-size: 1.5rem;
    padding-bottom: 0.4rem;
}
.markdown-body h3::after {
    /* アクセントの下線を追加 */
    content: "";
    display: block;
    width: auto;
    height: 2px;
    background: var(--color-accent);
    margin-top: 0.4rem;
}

.markdown-body h4 {
    font-size: 1.25rem;
    margin-top: 2rem;
}

/* 段落・リスト */
.markdown-body p {
    margin: 1rem 0;
}
.markdown-body ul,
.markdown-body ol {
    padding-left: 1.5rem;
    margin: 0rem 0;
}
.markdown-body ul {
    list-style: disc;
}
.markdown-body ol {
    list-style: decimal;
}
.markdown-body li {
    margin-bottom: 0.1rem;
    padding-left: 0.2rem;
}
.markdown-body li::marker {
    color: var(
        --color-accent
    ); /* リストマーカーに色をつける */
}

/* 定義リスト（dl, dt, dd） */
.markdown-body dl {
    margin: 2rem 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.5rem;
    align-items: baseline;
}
.markdown-body dt {
    font-weight: 700;
    color: var(--color-heading);
    grid-column: 1;
    position: relative;
}
.markdown-body dt::after {
    content: ":";
    margin-left: 0.2rem;
    color: var(--color-text-muted);
}
.markdown-body dd {
    grid-column: 2;
    margin: 0;
    color: var(--color-text-muted);
}
/* スマホなどで崩れる場合は縦並びに */
@media (max-width: 968px) {
    .markdown-body dl {
        display: block;
    }
    .markdown-body dt {
        margin-top: 1rem;
        font-size: 1.1rem;
    }
    .markdown-body dd {
        margin-left: 1rem;
        margin-bottom: 1rem;
    }
}

/* 引用 */
.markdown-body blockquote {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--color-accent);
    background: var(--color-surface);
    color: var(--color-text-muted);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
}
.markdown-body blockquote > *:first-child {
    margin-top: 0;
}
.markdown-body blockquote > *:last-child {
    margin-bottom: 0;
}

/* コードブロック */
.markdown-body code {
    font-family:
        "Fira Code", "Cascadia Code", "JetBrains Mono",
        Consolas, monospace;
    font-size: 0.9em;
    background: rgba(var(--color-accent-rgb), 0.15);
    color: var(--color-heading);
    padding: 0.2em 0.5em;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
}

.markdown-body pre {
    position: relative;
    background: #0d1117;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.5;
    margin: 2rem 0;
    border: 1px solid var(--color-border);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* コードブロック上部に表示する言語ラベルと Mermaid 用コンテナ */
.code-block {
    position: relative;
    margin: 1rem 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: inherit;
    border: 1px solid var(--color-border);
}

/* 言語ラベル（右上） */
.code-block .code-header {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    padding: 0.18rem 0.5rem;
    font-size: 12px;
    line-height: 1;
    border-radius: 4px;
    z-index: 2;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: inline-flex;
    align-items: center;
}

/* 言語アイコン */
.code-header .lang-icon,
.code-block .lang-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    margin-right: 0.4rem;
    line-height: 1;
    vertical-align: middle;
}

/* ラベルテキスト */
.code-header .lang-label {
    display: inline-block;
    font-weight: 600;
    font-size: 12px;
}

/* code-block 内の pre を調整してヘッダー分の余白を確保 */
.code-block pre {
    margin: 0;
    padding-top: 2.2rem; /* space for header */
    background: transparent;
    border-radius: 0;
    overflow-x: auto;
}

/* 内部の code 要素はブロック表示にしてパディングを調整 */
.code-block pre code {
    display: block;
    padding: 0.8rem 1rem 1rem 1rem;
    background: transparent;
}

/* Mermaid コンテナラッパー（スクロールとドラッグ対応） */
.mermaid-wrapper {
    margin: 1.25rem 0;
    overflow: hidden;
    background: var(--color-panel);
    cursor: grab;
    /* JS制御のためブラウザ標準の操作を無効化 */
    touch-action: none;
    -webkit-overflow-scrolling: touch;
    /* ページ全体へのオーバースクロール伝播を抑制（UX向上） */
    overscroll-behavior: contain;
    /* 図の選択を防ぐ（ドラッグ時の余分な選択を抑制） */
    user-select: none;
    /* 図の領域が分かるように枠・背景・陰影を付与 */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
    position: relative;
}
.mermaid-wrapper:active {
    cursor: grabbing;
}
.mermaid-wrapper .mermaid {
    display: block;
    /* transform を使う場合に備え、変換の起点と最適化を指定 */
    transform-origin: 0 0;
    will-change: transform;
    transition: transform 180ms
        cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mermaid-wrapper .mermaid svg {
    max-width: none;
    width: auto;
    display: block;
    /* SVG 内のタッチアクションは個別に扱う（ピンチ操作はラッパーで処理） */
    touch-action: none;
    user-select: none;
}

/* Mermaid toolbar (右上に縦並び) */
.mermaid-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* 高いスタッキングで常にコンテンツより前面に表示 */
    z-index: 9999;
    /* 右端に寄せてボタン群がコンテンツの右上に揃うようにする */
    align-items: flex-end;
    /* ツールバー自身でポインターイベントを受け取る（親で無効化していたため有効化） */
    pointer-events: auto;
    /* レイヤーを分離してアニメーション時の描画安定化を助ける */
    transform: translateZ(0);
}
.mermaid-toolbar .btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    /* 少し濃いめの背景で見やすくする（ダーク/ライト両対応の調整はここで可能） */
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition:
        transform 120ms ease,
        background 120ms ease;
    font-size: 14px;
    /* ボタンを前面にしてクリックを確実化 */
    position: relative;
    z-index: 10000;
}
.mermaid-toolbar .btn:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.75);
}
.mermaid-toolbar .btn:active {
    transform: translateY(0);
}

/* Scale badge */
.mermaid-toolbar .scale-badge {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 28px;
    padding: 0 8px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

/* Mermaid 内タイトルの見やすさ改善 */
.mermaid-wrapper .mermaid svg text.title,
.mermaid-wrapper .mermaid svg .title,
.mermaid-wrapper .mermaid svg .label {
    fill: var(--color-heading);
    font-weight: 700;
    font-size: 1.05em;
    paint-order: stroke fill;
    stroke: rgba(0, 0, 0, 0.02);
    stroke-width: 0.4px;
}

/* mermaid SVG 最大高さの制限（縦長すぎるのを防ぐ） */
.mermaid-wrapper {
    max-height: 60vh;
    overflow: auto;
}

/* SVG 本体にも制限をかけて縦長表示を防ぐ（アスペクトを維持） */
.mermaid-wrapper .mermaid svg {
    max-height: 120vh;
    height: auto;
    max-width: 100%;
    display: block;
    box-sizing: content-box;
}

/* small responsive tweaks */
@media (max-width: 680px) {
    .mermaid-toolbar {
        top: 6px;
        right: 6px;
        gap: 6px;
    }
    .mermaid-toolbar .btn {
        width: 32px;
        height: 32px;
        border-radius: 6px;
        font-size: 13px;
    }
    .mermaid-toolbar .scale-badge {
        min-width: 40px;
        height: 24px;
        font-size: 11px;
    }
}

/* モバイルでヘッダーが重ならないように調整 */
@media (max-width: 680px) {
    .code-block .code-header {
        top: 6px;
        right: 6px;
        font-size: 11px;
        padding: 0.12rem 0.4rem;
    }
    .code-block pre {
        padding-top: 2rem;
    }
}

/* 画像 */
.markdown-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border-soft);
}

/* 水平線 */
.markdown-body hr {
    height: 0;
    border: 0;
    border-top: 2px dashed var(--color-border);
    margin: 3rem 0;
}

/* テーブル */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}
.markdown-body th,
.markdown-body td {
    padding: 0.75rem;
    border: 1px solid var(--color-border);
}
.markdown-body th {
    background: var(--color-surface);
    font-weight: 700;
    color: var(--color-heading);
    text-align: left;
}
.markdown-body tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* ==========================================================================
   5. レスポンシブデザイン
   ========================================================================== */
@media (max-width: 680px) {
    .blog-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
    }
    .blog-card {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    .blog-card .card__thumb {
        width: 100%;
        height: auto;
    }
    .post-detail {
        padding: 1.5rem; /* スマホでは余白を詰める */
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        background: var(--color-panel);
    }
    .post-detail__title {
        font-size: 1.8rem;
    }
    .post-detail__tags {
        justify-content: flex-start; /* スマホでは左寄せに戻す */
    }
    .post-detail__header {
        text-align: left;
    }
    .markdown-body h2 {
        font-size: 1.5rem;
    }
}

/* ==========================================================================
   6. ページネーション
   ========================================================================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
}

.pagination__item {
    --size: 2.5rem;
    cursor: pointer;
    width: var(--size);
    height: var(--size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.pagination__item:hover:not(:disabled):not(.is-active) {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: var(--color-heading);
    transform: translateY(-2px);
}

.pagination__item:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.pagination__item.is-active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
    font-weight: 700;
    box-shadow: var(--shadow-glow);
}

/* ==========================================================================
   7. 記事詳細のナビゲーション
   ========================================================================== */
.post-detail__nav--bottom {
    margin-top: 2rem;
    margin-bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    /* 横幅に余裕があれば折り返さず等幅にする */
    flex-wrap: nowrap;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* 共通ボタンスタイル（back / prev / next） - デスクトップは等幅 */
.post-detail__nav--bottom .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: var(--transition-smooth);
    border: 1px solid var(--color-border);
    /* 等幅にするための flex 指定（親が横並び） */
    flex: 1 1 0;
    min-width: 0; /* overflow 対策 */
    /* 長いタイトルは省略表示 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.post-detail__nav--bottom .btn--prev {
    justify-content: flex-start;
    text-align: left;
}
.post-detail__nav--bottom .btn--back {
    justify-content: center;
    text-align: center;
}
.post-detail__nav--bottom .btn--next {
    justify-content: flex-end;
    text-align: right;
}

.btn--back:hover {
    background: var(--color-accent-soft);
    color: var(--color-text);
    border-color: var(--color-accent);
    transform: translateY(-2px);
}

/* 前の記事（左） */
.btn--prev {
    padding-left: 0.8rem;
}
.btn--prev:hover {
    background: var(--color-accent-soft);
    color: var(--color-text);
    border-color: var(--color-accent);
    transform: translateX(-4px);
}

/* 次の記事（右） */
.btn--next {
    padding-right: 0.8rem;
}
.btn--next:hover {
    background: var(--color-accent-soft);
    color: var(--color-text);
    border-color: var(--color-accent);
    transform: translateX(4px);
}

/* モバイル: ボタンを縦積み（タップしやすく、順序が明確） */
@media (max-width: 968px) {
    .post-detail__nav--bottom {
        flex-direction: column;
        gap: 0.6rem;
        align-items: stretch;
    }
    .post-detail__nav--bottom .btn {
        flex: none;
        width: 100%;
        max-width: none;
        justify-content: center;
        padding: 0.7rem 1rem;
        white-space: normal;
    }

    /* Mobile: maintain left/center/right alignment within full-width buttons */
    .post-detail__nav--bottom .btn--prev {
        justify-content: center;
        text-align: center;
    }
    .post-detail__nav--bottom .btn--back {
        justify-content: center;
        text-align: center;
    }
    .post-detail__nav--bottom .btn--next {
        justify-content: center;
        text-align: center;
    }
}

/* ==========================================================================
   8. パンくずリスト
   ========================================================================== */
.breadcrumb {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    white-space: nowrap; /* Prevent wrapping */
    overflow-x: auto; /* Allow horizontal scrolling if needed */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on touch devices */
    scrollbar-width: none; /* Hide scrollbar for Firefox */
}
.breadcrumb::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari */
}

.breadcrumb__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
}

.breadcrumb__item:not(:last-child)::after {
    content: ">";
    margin: 0 0.75rem;
    color: var(--color-text-muted);
    opacity: 0.5;
}

.breadcrumb a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.breadcrumb a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.breadcrumb__item[aria-current="page"] {
    font-weight: 600;
    color: var(--color-text);
}

/* ==========================================================================
   9. 記事詳細レイアウト（2カラム）
   ========================================================================== */
.post-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.post-content {
    min-width: 0;
}

.post-sidebar {
    display: none;
}

@media (min-width: 1000px) {
    .post-layout {
        grid-template-columns: minmax(0, 1fr) 250px;
        gap: 1rem;
    }
    .post-sidebar {
        display: block;
    }

    body[data-page="blog"] .main-container {
        max-width: 1500px;
    }
}

/* ==========================================================================
   10. 目次 (TOC)
   ========================================================================== */
.toc-sticky-container {
    position: sticky;
    top: 6rem;
}

.toc {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    max-width: 250px;
}

.toc__title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-heading);
    margin-top: 0;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--color-border-soft);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: calc(100vh - 12rem);
    overflow-y: auto;
    overflow-x: hidden;
}

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-item a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.5;
    transition: var(--transition-smooth);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-item a:hover {
    color: var(--color-accent);
    transform: translateX(4px);
}

.toc-item--level-3 {
    padding-left: 1.2rem;
}

.toc-item--level-3 a {
    font-size: 0.85rem;
    position: relative;
}

.toc-item--level-3 a::before {
    content: "";
    position: absolute;
    left: -1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--color-border);
}

.toc-item a.is-active {
    color: var(--color-accent);
    font-weight: 600;
}

/* ==========================================================================
   レスポンシブ対応のTOCメニュー
   ========================================================================== */
.toc-toggle {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    z-index: 100;
    width: 56px;
    height: 56px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: var(--shadow-lg);
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.toc-toggle span {
    display: none;
}

.toc-toggle:hover {
    background: var(--color-accent-dark);
    transform: translateY(-3px);
}

.toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.3s ease,
        visibility 0s 0.3s;
}

@media (max-width: 1000px) {
    .toc-toggle {
        display: flex;
    }

    .post-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        max-width: 320px;
        height: 100vh;
        height: 100dvh;
        background: var(--color-surface);
        z-index: 102;
        transform: translateX(100%);
        transition: transform 0.3s
            cubic-bezier(0.16, 1, 0.3, 1);
        display: block;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
    }

    .post-sidebar.is-open {
        transform: translateX(0);
    }

    .toc-overlay.is-open {
        opacity: 1;
        visibility: visible;
        transition-delay: 0s;
    }

    .toc-sticky-container {
        position: static;
        padding: 2rem 1.5rem;
    }

    .toc {
        border: none;
        padding: 0;
    }

    .toc-list {
        max-height: none;
    }
}

/* ==========================================================================
   Share Buttons
   ========================================================================== */
.share-buttons {
    margin: 1rem 0;
    text-align: center;
}

.share-buttons__title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.1em;
    margin: 0.3rem 0;
}

.share-buttons__list {
    display: inline-flex;
    gap: 1rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.share-buttons__link {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--color-surface);
    color: var(--color-text);
    transition: var(--transition-smooth);
    border: 1px solid var(--color-border);
}

.share-buttons__link:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    color: #fff;
}

.share-buttons__link--twitter:hover {
    background-color: #1da1f2;
    border-color: #1da1f2;
}

.share-buttons__link--facebook:hover {
    background-color: #1877f2;
    border-color: #1877f2;
}

.share-buttons__link--line:hover {
    background-color: #00c300;
    border-color: #00c300;
}

/* ==========================================================================
   Post header: align share buttons center and place Like/Bookmark at the right end
   - On wide screens: share buttons centered, like/bookmark pinned to right edge of the same line
   - On small screens: left-aligned and stacked (share buttons first, actions below)
   ========================================================================== */
.post-header-actions {
    position: relative;
    width: 100%;
    margin: 0.6rem 0 1rem 0;
    box-sizing: border-box;
}

/* Left area contains the existing share-buttons markup and remains centered by default */
.post-header-actions__left {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Right area holds the .post-actions (いいね / ブックマーク) and is pinned to the right */
.post-header-actions__right {
    position: absolute;
    right: 0;
    top: 65%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Keep internal .post-actions spacing consistent with post-interactions.css */
.post-header-actions .post-actions {
    margin: 0;
}

/* Responsive behavior: on narrow viewports switch to left alignment and flow stacking */
@media (max-width: 968px) {
    .post-header-actions__left {
        justify-content: flex-start;
    }

    /* Ensure share buttons in this header follow the same left alignment tweak */
    .post-header-actions .share-buttons {
        text-align: left;
        margin: 0.5rem 0;
    }
}

.section--related {
    margin-top: 4rem;
}

/* ==========================================================================
    Comments Section (with Giscus lazy-load)
   ========================================================================== */
/* コメントセクション全体 */
.section--comments {
    margin-top: 3rem;
    margin-bottom: 2rem;
}

/* コンテナ（コメント領域全体）- カード風デザイン */
.post-comments {
    max-width: 100%;
    margin: 1.5rem 0;
    padding: 1.5rem;
    box-sizing: border-box;
    border-radius: var(--radius-lg);
    background: var(--color-panel);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.post-comments:hover {
    box-shadow: var(--shadow-lg);
}

/* プレースホルダー（lazy-load 中） */
.giscus-placeholder {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.giscus-loading {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    text-align: center;
    padding: 2rem;
}

/* giscus が生成するラッパー要素（外側） */
.post-comments .giscus {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* iframe 要素本体のスタイル（giscus が作る iframe に .giscus-frame が付く） */
.post-comments .giscus-frame {
    width: 100%;
    min-height: 240px;
    height: auto;
    border: 0;
    background: transparent;
    border-radius: var(--radius-md);
    box-shadow: none;
}

/* 小さい画面での調整 */
@media (max-width: 968px) {
    .section--comments {
        margin-top: 2rem;
    }

    .post-comments {
        margin: 1rem 0;
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .giscus-placeholder {
        min-height: 150px;
    }

    .share-buttons {
        margin: 1rem 0;
        text-align: left;
    }

    .share-buttons__title {
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--color-text-muted);
        letter-spacing: 0.1em;
        margin: 0.3rem 0;
    }

    .share-buttons__list {
        display: inline-flex;
        gap: 1rem;
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .share-buttons__link {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background-color: var(--color-surface);
        color: var(--color-text);
        transition: var(--transition-smooth);
        border: 1px solid var(--color-border);
    }
}

/* ダークモード対応（CSS変数を使用しているため基本的には自動対応） */
/* 追加の調整が必要な場合 */
@media (prefers-color-scheme: dark) {
    .post-comments {
        background: var(--color-panel);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .post-comments .giscus-frame {
        background: transparent;
    }
}
