/**
 * カスタムサイドバー用スタイルシート
 * メンテナンスしやすいよう、明確な構造と変数を使用
 * Updated: 2025-01-09
 */

/* ====================================
   CSS変数定義（簡単に調整可能）
   ==================================== */
:root {
    /* レイアウト */
    --sidebar-width-pc: 320px;
    --sidebar-gap: 30px;
    --sidebar-sticky-top: 80px;
    
    /* 色設定 */
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e5e5;
    --sidebar-shadow: rgba(0, 0, 0, 0.08);
    --sidebar-heading-color: #333333;
    --sidebar-text-color: #666666;
    --sidebar-link-color: #0066cc;
    --sidebar-link-hover: #0052a3;
    
    /* スペーシング */
    --sidebar-section-gap: 30px;
    --sidebar-padding: 20px;
    
    /* ブレークポイント */
    --breakpoint-pc: 768px;
}

/* ====================================
   メインレイアウト調整
   ==================================== */
   
/* PC表示：記事とサイドバーを横並び */
@media (min-width: 768px) {
    /* sidebar-layout-fix.cssで管理するため、ここでは定義しない */
    /* 
    .lb--singles .lb--container {
        display: flex;
        flex-direction: row-reverse;
        gap: var(--sidebar-gap);
        align-items: flex-start;
    }
    
    .lb--singles .lb--contents {
        flex: 1;
        min-width: 0;
    }
    */
    
    .custom-sidebar {
        width: var(--sidebar-width-pc);
        flex-shrink: 0;
        position: sticky;
        top: var(--sidebar-sticky-top);
        max-height: calc(100vh - var(--sidebar-sticky-top) - 20px);
        overflow-y: auto;
    }
    
    /* スクロールバーのスタイリング */
    .custom-sidebar::-webkit-scrollbar {
        width: 6px;
    }
    
    .custom-sidebar::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }
    
    .custom-sidebar::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }
    
    .custom-sidebar::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }
}

/* SP表示：サイドバーをサブフッターの上に配置 */
@media (max-width: 767px) {
    .lb--single-contents {
        display: block;
    }
    
    .custom-sidebar {
        width: 100%;
        margin: 40px auto;
        order: 2; /* 記事の後に表示 */
    }
    
    /* サブフッターの前に配置 */
    .lb--sub-footer {
        order: 3;
    }
}

/* ====================================
   サイドバー基本スタイル
   ==================================== */
.custom-sidebar {
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--sidebar-shadow);
    overflow: hidden;
}

/* 通知メッセージスタイル */
.sidebar-notice {
    padding: 20px;
    background: #f8f9fa;
    border-left: 4px solid #0066cc;
    margin: 10px 0;
}

.sidebar-notice p {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.sidebar-inner {
    padding: var(--sidebar-padding);
}

/* セクション共通スタイル */
.sidebar-section {
    margin-bottom: var(--sidebar-section-gap);
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

/* 見出しスタイル */
.sidebar-heading {
    font-size: 16px;
    font-weight: 700;
    color: var(--sidebar-heading-color);
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--sidebar-border);
}

/* ====================================
   認証バッジセクション
   ==================================== */
.sidebar-badges {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
}

.badge-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

/* SPでは1列表示 */
@media (max-width: 767px) {
    .badge-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .badge-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 5px;
    background: white;
    border-radius: 6px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.badge-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.badge-image {
    width: 100%;
    max-width: 80px;
    height: auto;
    margin-bottom: 8px;
    object-fit: contain;
}

.badge-label {
    font-size: 11px;
    color: var(--sidebar-text-color);
    line-height: 1.3;
}


/* ====================================
   再利用ブロック用スタイル
   ==================================== */
.sidebar-reusable-content {
    /* 再利用ブロック内のスタイルを調整 */
}

.sidebar-reusable-content h2,
.sidebar-reusable-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--sidebar-heading-color);
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--sidebar-border);
}

.sidebar-reusable-content p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--sidebar-text-color);
    margin-bottom: 15px;
}

.sidebar-reusable-content a {
    color: var(--sidebar-link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.sidebar-reusable-content a:hover {
    color: var(--sidebar-link-hover);
    text-decoration: underline;
}

/* ====================================
   アクセシビリティ
   ==================================== */
@media (prefers-reduced-motion: reduce) {
    .badge-item,
    .sidebar-button,
    .cta-button {
        transition: none;
    }
}

/* ====================================
   印刷時の表示
   ==================================== */
@media print {
    .custom-sidebar {
        display: none;
    }
}

/* ====================================
   ダークモード対応（オプション）
   ==================================== */
@media (prefers-color-scheme: dark) {
    .custom-sidebar {
        /* ダークモード時のスタイルをここに追加 */
    }
}