/**
 * 公開用ブログページ スタイルシート
 * 
 * 暖色系テーマ、メンテナンス性重視のCSS設計
 * BEM記法によるクラス命名、セクション分割構成
 * 
 * セクション構成:
 * 1. CSS Variables（変数定義）
 * 2. Reset & Base（リセット・基本設定）
 * 3. Layout（レイアウト）
 * 4. Components（コンポーネント）
 * 5. Utilities（ユーティリティ）
 * 
 * @author  Your Name
 * @version 1.0.0
 * @since   2025-01-30
 */

/* =====================================
   1. CSS Variables（変数定義）
   ===================================== */
:root {
    /* カラーパレット（暖色系） */
    --primary-color: #8b4513;        /* サドルブラウン */
    --secondary-color: #d2691e;      /* チョコレート */
    --accent-color: #ff6347;         /* トマト */
    --text-color: #3c2414;           /* ダークブラウン */
    --text-light: #8b7355;           /* 薄茶 */
    --bg-color: #ffffff;             /* 白 */
    --bg-light: #fdf6f0;             /* 薄いクリーム */
    --border-color: #f0e6dc;         /* ベージュ */
    --header-gradient-start: #a0522d; /* シエナ */
    --header-gradient-end: #cd853f;   /* ペルー */
    --link-color: #d2691e;           /* チョコレート */
    --link-hover: #a0522d;           /* シエナ */
    --sidebar-bg: #faf5f0;           /* オフホワイト */
    
    /* サイズ・レイアウト */
    --sidebar-width: 280px;
    --container-max-width: 1200px;
    --content-max-width: 800px;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    
    /* ドロップシャドウ（4段階） */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.15);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.2);
    
    /* フォント */
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    
    /* トランジション */
    --transition: all 0.3s ease;
}

/* =====================================
   2. Reset & Base（リセット・基本設定）
   ===================================== */

/* リセット */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基本設定 */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-color);
    background: linear-gradient(180deg, var(--bg-light) 0%, var(--bg-color) 100%);
    min-height: 100vh;
}

/* リンク */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* リスト */
ul, ol {
    list-style: none;
}

/* 画像 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* =====================================
   3. Layout（レイアウト）
   ===================================== */

/* メインコンテナ（CSS Grid） */
.site-container {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar content";
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: auto 1fr;
    max-width: var(--container-max-width);
    margin: 20px auto;
    background-color: var(--bg-color);
    box-shadow: var(--shadow-xl);
    border-radius: 12px;
    overflow: hidden;
}

/* メインコンテンツエリア */
.main-content {
    grid-area: content;
    padding: 2.5rem;
    background: linear-gradient(180deg, var(--bg-color) 0%, var(--bg-light) 50%);
    min-height: calc(100vh - 200px);
}

.content-wrapper {
    max-width: var(--content-max-width);
}

/* =====================================
   4. Components（コンポーネント）
   ===================================== */

/* --------------------------------------
   4.1 ヘッダー
   -------------------------------------- */
.site-header {
    grid-area: header;
    height: 200px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;  /* はみ出し防止 */
}

/* バナー画像のリンク */
.site-header__link {
    display: block;
    width: 100%;
    height: 100%;
}

/* バナー画像 */
.site-header__banner {
    width: 100%;
    height: 100%;
    object-fit: contain;  /* 画像全体を表示 */
    object-position: center;  /* 中央配置 */
}

/* ヘッダー下部の光るエフェクト */
.site-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255,255,255,0.5), 
        transparent);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* --------------------------------------
   4.2 サイドバー
   -------------------------------------- */
.sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--bg-color) 100%);
    padding: 2rem 1.5rem;
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
}

.sidebar__section {
    margin-bottom: 2rem;
}

.sidebar__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--secondary-color);
    position: relative;
}

/* サイドバータイトル下部のアニメーションバー */
.sidebar__title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.sidebar__section:hover .sidebar__title::after {
    width: 100%;
}

.sidebar__list {
    list-style: none;
}

.sidebar__item {
    margin-bottom: 0.75rem;
    position: relative;
}

.sidebar__date {
    font-size: 0.75rem;
    color: var(--text-light);
    display: block;
    margin-bottom: 0.25rem;
}

.sidebar__link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    font-size: 0.9rem;
}

/* サイドバーリンクの左側バー */
.sidebar__link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 0;
    background: var(--secondary-color);
    transition: height 0.3s ease;
}

.sidebar__link:hover {
    background: linear-gradient(90deg, var(--bg-light) 0%, transparent 100%);
    color: var(--link-hover);
    transform: translateX(6px);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.sidebar__link:hover::before {
    height: 100%;
}

.sidebar__empty {
    color: var(--text-light);
    font-size: 0.9rem;
    padding: 1rem;
    text-align: center;
}

/* --------------------------------------
   4.3 記事（Article）
   -------------------------------------- */
.article {
    background: linear-gradient(145deg, var(--bg-color), var(--bg-light));
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 2.5rem;
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

/* 記事上部のカラーバー */
.article::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.article:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.article:hover::before {
    transform: scaleX(1);
}

.article__header {
    padding: 1.75rem 2rem 1rem;
}

.article__title {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    color: var(--primary-color);
}

.article__title-link {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.article__title-link:hover {
    color: var(--secondary-color);
    text-decoration: none;
}

.article__meta {
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.article__date::before {
    content: '📅 ';
    font-size: 1rem;
}

.article__body {
    padding: 0 2rem 1.75rem;
}

.article__content {
    color: var(--text-color);
    line-height: 1.8;
}

/* TinyMCEで生成されたコンテンツのスタイル調整 */
.article__content h2 {
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--primary-color);
}

.article__content h3 {
    font-size: 1.2rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--primary-color);
}

.article__content p {
    margin-bottom: 1rem;
}

.article__content ul,
.article__content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.article__content ul {
    list-style-type: disc;
}

.article__content ol {
    list-style-type: decimal;
}

.article__content li {
    margin-bottom: 0.5rem;
}

.article__content blockquote {
    border-left: 3px solid var(--secondary-color);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--text-light);
    font-style: italic;
}

.article__content code {
    background-color: var(--bg-light);
    padding: 0.2rem 0.4rem;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.article__content pre {
    background-color: var(--bg-light);
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 1rem 0;
}

.article__content pre code {
    background: none;
    padding: 0;
}

.article__content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

.article__content a {
    color: var(--link-color);
    text-decoration: underline;
}

.article__content a:hover {
    color: var(--link-hover);
}

/* --------------------------------------
   4.4 ページネーション
   -------------------------------------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.pagination__link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(145deg, var(--bg-color), var(--bg-light));
    color: var(--link-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.pagination__link:hover {
    background: linear-gradient(145deg, var(--secondary-color), var(--primary-color));
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    text-decoration: none;
}

.pagination__info {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* --------------------------------------
   4.5 エラーメッセージ
   -------------------------------------- */
.error-message {
    background: linear-gradient(145deg, var(--bg-color), var(--bg-light));
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 3rem;
    text-align: center;
    margin: 2rem 0;
}

.error-message__text {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 2rem;
}

.error-message__link a {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: linear-gradient(145deg, var(--secondary-color), var(--primary-color));
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
}

.error-message__link a:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* =====================================
   5. Utilities（ユーティリティ）
   ===================================== */

/* --------------------------------------
   5.1 レスポンシブ対応
   -------------------------------------- */
@media (max-width: 768px) {
    /* グリッドレイアウトの変更 */
    .site-container {
        grid-template-areas: 
            "header"
            "content"
            "sidebar";
        grid-template-columns: 1fr;
        margin: 0;
        border-radius: 0;
    }
    
    /* ヘッダー調整 */
    .site-header {
        height: 200px;  /* スマホでは高さを調整 */
    }
    
    /* バナー画像の調整はobject-fitが自動で行う */
    
    /* サイドバー調整 */
    .sidebar {
        border-right: none;
        border-top: 2px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        padding: 1.5rem;
    }
    
    /* メインコンテンツ調整 */
    .main-content {
        padding: 1.5rem;
        min-height: auto;
    }
    
    /* 記事調整 */
    .article {
        margin-bottom: 1.5rem;
    }
    
    .article__header {
        padding: 1.25rem 1.5rem 0.75rem;
    }
    
    .article__title {
        font-size: 1.3rem;
    }
    
    .article__body {
        padding: 0 1.5rem 1.25rem;
    }
    
    /* ページネーション調整 */
    .pagination {
        flex-direction: column;
        gap: 1rem;
    }
    
    .pagination__link {
        width: 100%;
        justify-content: center;
    }
}

/* 印刷用スタイル */
@media print {
    .site-header,
    .sidebar,
    .pagination {
        display: none;
    }
    
    .site-container {
        display: block;
        max-width: 100%;
        margin: 0;
        box-shadow: none;
    }
    
    .main-content {
        padding: 0;
    }
    
    .article {
        box-shadow: none;
        page-break-inside: avoid;
    }
}