/* 基本設定 */
:root {
    --primary-color: #003d5b;    /* 海：Deep Sea Blue */
    --sakura-color: #f4a7b9;     /* 桜：Sakura Pink */
    --btn-color: #3498db;        /* ボタン：Original Blue */
    --bg-color: #f0f4f8;         /* 背景：Sea Mist */
    --text-color: #2c3e50;
    --white: #ffffff;
    --gray: #777;
    --header-height: 70px; /* ★JavaScriptで上書きされるまでの初期値 */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* スムーズなスクロールを有効化 */
    scroll-behavior: smooth;
    /* ヘッダーの高さ分、スクロールの「止まる位置」を自動調整 */
    scroll-padding-top: var(--header-height);
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダー */
header {
    background: var(--primary-color);
    color: var(--white);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav ul {
    display: flex;
    list-style: none;
}

nav ul li {
    margin-left: 20px;
}

nav ul li a {
    color: var(--white);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

nav ul li a:hover {
    color: var(--sakura-color);
}

/* 各セクション */
section {
    padding: 60px 0;
}

h2 {
    border-bottom: 3px solid var(--sakura-color);
    display: inline-block;
    margin-bottom: 25px;
    padding-bottom: 5px;
    color: var(--primary-color);
}

.section-desc {
    margin-bottom: 20px;
    color: var(--gray);
    font-size: 0.9rem;
}

/* グリッドレイアウト（スマホの狭い画面にも対応） */
.grid {
    display: grid;
    /* min(100%, 280px) にすることで、画面幅が280px以下の端末でもはみ出さない */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 20px;
}

/* 単体カード */
.card {
    background: var(--white);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 20px; /* 直書きのカード用 */
    text-align: left; /* ★ カード内の要素が意図せず中央揃えになるのを防ぐ */
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.card h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
    line-height: 1.4;
}

/* =========================================
   Wikiセクション用のスタイル（リンク付きカード等）
   ========================================= */

/* リンク付きカード全体の囲み */
.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-link .card {
    margin-bottom: 20px;
}

/* Wikiタグなどの配置 */
.wiki-meta {
    display: flex;
    justify-content: flex-start; /* ★ 確実に左側に寄せる */
    align-items: center; /* 縦方向のズレ防止（テキストの高さ合わせ） */
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px; /* ★ タグ全体と日付の間の余白 */
}

.tag-list {
    display: flex;
    justify-content: flex-start; /* ★ 複数のタグも確実に左寄せ */
    flex-wrap: wrap;
    gap: 4px; /* ★ 複数のタグ同士の距離をギュッと近づける（8px → 4px） */
}

.category-tag {
    background: #ffeef2;
    color: #d88a9c;
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 4px;
    font-weight: bold;
    display: inline-block;
}

.update-date {
    font-size: 0.75rem;
    color: var(--gray);
}
/* ========================================= */

/* ボタン（元の青色を維持） */
.btn {
    display: inline-block;
    background: var(--btn-color);
    color: var(--white);
    padding: 12px 30px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    margin-top: 15px;
    transition: background 0.3s, opacity 0.3s;
}

.btn:hover {
    opacity: 0.9;
    background: #2980b9;
}

/* フッター */
footer {
    text-align: center;
    padding: 60px 0;
    font-size: 0.85rem;
    color: var(--gray);
    border-top: 1px solid #ddd;
}

/* レスポンシブ（スマホ・タブレット対応） */
@media (max-width: 600px) {
    header .container {
        flex-direction: column;
        gap: 15px;
        padding: 10px 20px;
    }
    
    nav ul {
        flex-wrap: wrap; /* メニューが横幅を超えたら折り返す */
        justify-content: center; /* スマホ時のメニューのみ中央揃え */
        gap: 15px;
    }
    
    nav ul li {
        margin: 0; /* 折り返しを綺麗にするため個別のマージンをリセット */
    }
    
    section {
        padding: 40px 0;
        /* JSで自動計算されるため scroll-margin-top は指定しない */
    }
}

.md ul, .md ol {
    margin-left: 2.0rem; /* 1.5remから少し増やして余裕を持たせる */
    margin-bottom: 1rem;
    padding-left: 0;
}

/* 2階層目以降のリストのインデント幅 */
.md ul ul, 
.md ol ol, 
.md ul ol, 
.md ol ul {
    margin-left: 1.5rem; /* 子階層のインデント量 */
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

/* 箇条書きの「点」の形を階層ごとに変える（お好みで） */
.md ul li {
    list-style-type: disc; /* 1階層目：黒丸 */
}
.md ul ul li {
    list-style-type: circle; /* 2階層目：白丸 */
}

/* Markdown内のコードブロックをカード風にデザイン */
.md pre {
    background: #ffffff;         /* 背景色（白） */
    padding: 20px;               /* 内側の余白 */
    border-radius: 8px;          /* 角丸 */
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); /* 軽い影 */
    border: 1px solid #eee;      /* 薄い枠線 */
    margin: 20px 0;              /* 上下の余白 */
    overflow-x: auto;            /* 横長になった場合にスクロール */
}

/* コード内の文字スタイル */
.md code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    color: #003d5b; /* インラインコードの色（お好みで） */
}

/* --- コードブロック：ミニマル・言語タグ対応版 --- */

.md pre {
    position: relative;
    background-color: var(--bg-color); /* 背景色 (#f0f4f8) */
    color: var(--primary-color);      /* 見出しと同じ色 (#003d5b) */
    padding: 2.5rem 1.2rem 1.2rem;    /* ラベル用に上部余白を確保 */
    border-radius: 6px;
    margin: 1.5rem 0;
    overflow-x: auto;
    border: 1px solid rgba(0, 61, 91, 0.1); /* 薄い枠線 */
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

/* 言語タグのスタイル（左上） */
.lang-tag {
    position: absolute;
    top: 10px;        /* 位置を微調整 */
    left: 14px;       /* 位置を微調整 */
    font-size: 12px;  /* 10pxから12pxに拡大 */
    font-weight: bold;
    color: var(--primary-color); /* 深い紺色 (#003d5b) */
    opacity: 0.5;     /* 少しだけ濃くして読みやすく（0.4から0.5へ） */
    letter-spacing: 0.08em; /* 文字間隔を広げて読みやすく */
    text-transform: uppercase;
}

/* コピーボタン（右上） */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 10px;
    font-size: 10px;
    font-weight: bold;
    /* 文字色は白にして視認性を確保 */
    color: var(--white); 
    /* 背景を海の色（Deep Sea Blue）に設定 */
    background-color: var(--primary-color); 
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    /* 派手さを抑えるため、通常時は少し透過させて馴染ませます */
    opacity: 0.8; 
    transition: all 0.2s ease;
}

.copy-btn:hover {
    opacity: 1;
    background-color: var(--sakura-color); /* 桜色 (#f4a7b9) */
    color: var(--primary-color);           /* 文字は視認性の高い紺色 (#003d5b) */
    border-color: var(--sakura-color);
}

.copy-btn.copied {
    background: #27ae60; /* 成功時は緑 */
    color: white;
    border-color: #27ae60;
}

/* インラインコード */
.md :not(pre) > code {
    background-color: rgba(0, 61, 91, 0.04);
    color: var(--primary-color);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
}

/* Social buttons */
.contact-actions {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.btn.social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    text-decoration: none;
    color: var(--white);
    width: 44px;
    height: 44px;
    border-radius: 10px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.12);
}

.btn.social .icon {
    width: 20px;
    height: 20px;
    display: inline-block;
}

.btn.social svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}

.btn.social.github {
    background: #24292f;
}

.btn.social.x {
    background: linear-gradient(135deg, #111213 0%, #000 100%);
}

.btn.social .label {
    display: none;
}

.btn.social:hover {
    opacity: 0.95;
    transform: translateY(-2px);
}