/*
Theme Name: iKeRyo Top Page Theme
Description: iKeRyo Blog用のカスタムトップページテーマ
Version: 1.4
*/

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ---------------- Code Block Styling ---------------- */
.code-block-wrapper {
    margin: 1.5rem 0;
    background: #1e1e1e;
    border-radius: 8px;
    overflow: auto;
    position: relative;
}

.code-block-wrapper pre {
    margin: 0;
    padding: 1rem;
    overflow: auto;
}

.code-language-label {
    position: absolute;
    top: 0;
    right: 0;
    padding: 2px 8px;
    font-size: 0.75rem;
    color: #ffffff;
    background: #4b5563;
    border-bottom-left-radius: 8px;
    text-transform: uppercase;
}

.code-line {
    display: block;
    white-space: pre;
}

.line-number {
    display: inline-block;
    width: 2em;
    user-select: none;
    opacity: 0.6;
}

.line-add {
    background: rgba(40, 167, 69, 0.1);
    border-left: 3px solid #28a745;
}

.line-error {
    background: rgba(220, 53, 69, 0.1);
    border-left: 3px solid #dc3545;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
}

/* 基本コンテナ */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダー */
.header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 24px 0 0;
    position: relative;
    z-index: 100;
    margin-bottom: 60px;
}

.site-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1f2937;
    text-decoration: none;
}

.site-title:hover {
    color: #3b82f6;
}

/* フッター */
.footer {
    text-align: center;
    padding: 40px 0;
    border-top: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 0.875rem;
    background: white;
    margin-top: 60px;
}

.back-to-home {
    display: inline-block;
    margin-bottom: 20px;
    padding: 12px 24px;
    background: #3b82f6;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.back-to-home:hover {
    background: #2563eb;
}

/* 基本テキストスタイル */
h1, h2, h3, h4, h5, h6 {
    color: #1f2937;
    font-weight: 700;
    line-height: 1.4;
}

p {
    margin-bottom: 1rem;
}

a {
    color: #3b82f6;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .site-title {
        font-size: 1.5rem;
    }
    
    .header {
        margin-bottom: 40px;
    }
}

/* URLカードの直前・直後の単独リンク段落を非表示 */
.post-body p:has(> a:only-child) + .url-card,
.url-card + p:has(> a:only-child) {
    display: none;
}

/* URLカードが段落に囲まれている場合の処理 */
.post-body p:has(> .url-card) {
    margin: 0;
    padding: 0;
}

/* URLカードのスタイルを確実に適用 */
.post-body .url-card {
    display: flex !important;
    margin: 1.5rem 0 !important;
}

/* 連続するURLカードの間隔を狭める */
.post-body .url-card + .url-card {
    margin-top: 0.75rem !important;
}

/* 空の段落を非表示 */
.post-body p:empty {
    display: none;
}

/* URLカード前後の空段落を除去 */
.post-body p:has(+ .url-card):empty,
.post-body .url-card + p:empty {
    display: none;
}

/* 3つ以上連続する場合も同じ間隔を維持 */
.post-body .url-card + .url-card + .url-card {
    margin-top: 0.75rem !important;
}

/* URLカードグループの最初と最後の間隔を保持 */
.post-body p:not(:empty) + .url-card {
    margin-top: 1.5rem !important;
}

.post-body .url-card + p:not(:empty) {
    margin-top: 1.5rem !important;
}

/* 重複したURLカードを防ぐ */
.post-body .url-card .url-card {
    display: none;
}