/* リンクカードが必ず独立したブロックとして表示されるように */
.ilc-link-card {
    contain: layout style;
}

/* 記事内の他の要素との干渉を防ぐ */
.entry-content .ilc-link-card,
.post-content .ilc-link-card,
article .ilc-link-card,
.content .ilc-link-card,
main .ilc-link-card {
    clear: both !important;
    float: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    position: relative !important;
    isolation: isolate; /* スタッキングコンテキストを分離 */
}

/* リンクカードのスタイル - アイキャッチデザイン */
.ilc-link-card {
    margin: 40px 0;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: none;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    position: relative;
    transform: translateY(0);
    clear: both; /* 他の要素の回り込みを防ぐ */
    display: block; /* ブロック要素として確実に表示 */
    width: 100%; /* 幅を100%に設定 */
}

/* サイズバリエーション: 小 */
.ilc-link-card.ilc-size-small {
    margin: 15px 0;  /* 20pxから15pxに減らす */
}

.ilc-link-card.ilc-size-small .ilc-link-card-inner {
    min-height: 100px;  /* 120pxから100pxに減らす */
}

.ilc-link-card.ilc-size-small .ilc-thumbnail {
    flex: 0 0 140px;  /* 180pxから140pxに減らす */
}

.ilc-link-card.ilc-size-small .ilc-content {
    padding: 12px 18px;  /* 15px 20pxから12px 18pxに減らす */
}

.ilc-link-card.ilc-size-small .ilc-title {
    font-size: 16px;
    margin: 0 0 6px;  /* 8pxから6pxに減らす */
    line-height: 1.3;  /* タイトルの高さも調整 */
}

.ilc-link-card.ilc-size-small .ilc-excerpt {
    font-size: 13px;
    line-height: 1.6;  /* 小サイズ用に調整 */
    margin: 0 0 8px;  /* 10pxから8pxに減らす */
    -webkit-line-clamp: 2;  /* 1から2に変更 */
    max-height: 3.2em;  /* line-height 1.6 * 2行 = 3.2em */
}

.ilc-link-card.ilc-size-small .ilc-read-more {
    font-size: 12px;
}

/* サイズバリエーション: 中（デフォルト） */
.ilc-link-card.ilc-size-medium {
    /* デフォルトスタイルをそのまま使用 */
}

/* サイズバリエーション: 大 */
.ilc-link-card.ilc-size-large {
    margin: 50px 0;
}

.ilc-link-card.ilc-size-large .ilc-link-card-inner {
    min-height: 240px;
}

.ilc-link-card.ilc-size-large .ilc-thumbnail {
    flex: 0 0 360px;
}

.ilc-link-card.ilc-size-large .ilc-content {
    padding: 35px 40px;
}

.ilc-link-card.ilc-size-large .ilc-title {
    font-size: 26px;
    margin: 0 0 16px;
}

.ilc-link-card.ilc-size-large .ilc-excerpt {
    font-size: 17px;
    line-height: 1.8;  /* 余裕を持たせる */
    margin: 0 0 20px;
    -webkit-line-clamp: 3;
    max-height: 5.4em;  /* line-height 1.8 * 3行 = 5.4em */
}

.ilc-link-card.ilc-size-large .ilc-read-more {
    font-size: 16px;
    padding-right: 30px;
}

.ilc-link-card.ilc-size-large .ilc-badge-new {
    top: 20px;
    left: 20px;
    padding: 7px 20px;
    font-size: 14px;
}

/* ホバー時の浮き上がりエフェクト */
.ilc-link-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

/* グラデーションボーダーのアニメーション */
.ilc-link-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    padding: 2px;
    background: linear-gradient(45deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 300% 300%;
    animation: gradient-border 3s ease infinite;
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* クリックを透過 */
}

.ilc-link-card:hover::before {
    opacity: 1;
}

@keyframes gradient-border {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* リンクカード内部 */
.ilc-link-card-inner {
    display: flex;
    text-decoration: none;
    color: inherit;
    min-height: 180px;
    position: relative;
    z-index: 1;
}

/* サムネイル部分 */
.ilc-thumbnail {
    flex: 0 0 280px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ilc-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.320, 1);
    opacity: 0.95;
}

/* スマホ版でのアスペクト比保持設定 */
@media (max-width: 768px) {
    .ilc-thumbnail {
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #f8f9fa;
        padding: 10px; /* 画像の周りに余白を追加 */
    }
    
    .ilc-thumbnail img {
        max-width: 100%;
        max-height: 100%;
        width: auto !important; /* 幅を自動調整 */
        height: auto !important; /* 高さを自動調整 */
        object-fit: contain !important; /* 重要度を上げて確実に適用 */
        object-position: center center !important; /* 中央配置を強制 */
        position: relative;
        display: block;
        margin: 0 auto; /* 左右中央揃え */
    }
}

.ilc-link-card:hover .ilc-thumbnail img {
    transform: scale(1.1) rotate(2deg);
    opacity: 1;
}

/* NEWバッジ（オプション） */
.ilc-badge-new {
    position: absolute;
    top: 15px;
    left: 15px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 5px 15px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* コンテンツ部分 */
.ilc-content {
    padding: 25px 30px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

/* 装飾的な背景パターン */
.ilc-content::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* タイトル（divをh3のようにスタイリング） */
.ilc-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 12px;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: all 0.3s ease;
    /* h3と同じような見た目にする */
    display: block;
}

.ilc-link-card:hover .ilc-title {
    background: linear-gradient(135deg, #3498db 0%, #667eea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 概要文 */
.ilc-excerpt {
    font-size: 15px;
    color: #4a5568;
    line-height: 1.8;  /* 1.7から1.8に増やして余裕を持たせる */
    margin: 0 0 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;  /* 2行表示 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
    /* 2行表示を確実にするための追加設定 */
    max-height: 3.6em;  /* line-height 1.8 * 2行 = 3.6em */
    text-overflow: ellipsis;
}

.ilc-link-card:hover .ilc-excerpt {
    color: #2d3748;
}

/* 続きを読むボタン風の要素 */
.ilc-read-more {
    display: inline-flex;
    align-items: center;
    color: #667eea;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    position: relative;
    padding-right: 25px;
}

.ilc-read-more::after {
    content: '→';
    position: absolute;
    right: 0;
    transition: transform 0.3s ease;
}

.ilc-link-card:hover .ilc-read-more {
    color: #764ba2;
}

.ilc-link-card:hover .ilc-read-more::after {
    transform: translateX(5px);
}

/* カテゴリータグ（オプション） */
.ilc-category-tag {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #667eea;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* スタイルバリエーション: カード型 */
.ilc-style-card .ilc-link-card {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.ilc-style-card .ilc-link-card-inner {
    flex-direction: column;
}

.ilc-style-card .ilc-thumbnail {
    flex: none;
    height: 200px;
    border-radius: 16px 16px 0 0;
    background-color: #f5f5f5; /* 画像がない部分の背景色 */
}

/* カード型でも画像全体を表示（モバイル用） */
@media (max-width: 768px) {
    .ilc-style-card .ilc-thumbnail img {
        object-fit: contain;
        width: 100%;
        height: 100%;
        object-position: center;
    }
}

/* カード型 + サイズ調整 */
.ilc-style-card.ilc-size-small .ilc-thumbnail {
    height: 120px;  /* 150pxから120pxに減らす */
}

.ilc-style-card.ilc-size-large .ilc-thumbnail {
    height: 280px;
}

/* スタイルバリエーション: ミニマル */
.ilc-style-minimal .ilc-link-card {
    background: transparent;
    border: 2px solid #e2e8f0;
    box-shadow: none;
}

.ilc-style-minimal .ilc-link-card:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

/* スタイルバリエーション: グラデーション */
.ilc-style-gradient .ilc-link-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ilc-style-gradient .ilc-title {
    -webkit-text-fill-color: white;
}

.ilc-style-gradient .ilc-excerpt {
    color: rgba(255, 255, 255, 0.9);
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .ilc-link-card {
        background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    }
    
    .ilc-title {
        background: linear-gradient(135deg, #63b3ed 0%, #9f7aea 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
    
    .ilc-excerpt {
        color: #cbd5e0;
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .ilc-link-card {
        margin: 30px auto; /* 左右中央揃えに変更 */
        border-radius: 8px; /* 角丸を維持 */
        max-width: 100%; /* 最大幅を設定 */
        clear: both !important; /* floatを確実にクリア */
        float: none !important; /* floatを無効化 */
        position: relative;
        z-index: 1; /* 他の要素より前面に */
    }
    
    .ilc-link-card-inner {
        flex-direction: column;
    }
    
    .ilc-thumbnail {
        flex: none;
        height: 200px;
        background-color: #f5f5f5; /* 画像がない部分の背景色 */
    }
    
    /* スマホ版で画像全体を表示 */
    .ilc-thumbnail img {
        object-fit: contain !important; /* coverからcontainに変更して画像全体を表示 */
        width: 100% !important;
        height: 100% !important;
        object-position: center center !important; /* 画像を中央に配置 */
    }
    
    .ilc-content {
        padding: 20px;
    }
    
    .ilc-title {
        font-size: 18px;
    }
    
    .ilc-excerpt {
        font-size: 14px;
    }
    
    /* モバイルでのサイズ調整 */
    .ilc-link-card.ilc-size-small .ilc-thumbnail {
        height: 120px;  /* 150pxから120pxに減らす */
    }
    
    .ilc-link-card.ilc-size-small .ilc-content {
        padding: 12px 15px;  /* さらにコンパクトに */
    }
    
    .ilc-link-card.ilc-size-large {
        margin: 30px -15px;
    }
    
    .ilc-link-card.ilc-size-large .ilc-thumbnail {
        height: 250px;
    }
    
    .ilc-link-card.ilc-size-large .ilc-content {
        padding: 25px 20px;
    }
    
    .ilc-link-card.ilc-size-large .ilc-title {
        font-size: 22px;
    }
    
    .ilc-link-card.ilc-size-large .ilc-excerpt {
        font-size: 15px;
    }
    
    /* ホバー時のエフェクトを無効化（スマホでは不要） */
    .ilc-link-card:hover {
        transform: none;
    }
    
    .ilc-link-card:hover .ilc-thumbnail img {
        transform: none;
    }
}

/* アニメーション: フェードイン */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ilc-link-card {
    animation: fadeInUp 0.6s ease-out;
}

/* モバイル向けの追加対策 */
@media (max-width: 768px) {
    /* NEWLINEテキストを非表示にする緊急対策 */
    .ilc-excerpt:contains("NEWLINE"),
    .ilc-excerpt:contains("newline") {
        display: none !important;
    }
    
    /* 代替テキストを表示 */
    .ilc-excerpt:empty::after {
        content: "記事の内容を読み込んでいます...";
    }
    
    /* リンクカード前後の余白を調整 */
    .ilc-link-card {
        margin: 30px 10px !important; /* 左右に10pxの余白 */
        width: calc(100% - 20px) !important; /* 余白を引いた幅 */
    }
    
    /* 記事内の画像との干渉を防ぐ追加設定 */
    .entry-content img + .ilc-link-card,
    .post-content img + .ilc-link-card,
    article img + .ilc-link-card {
        margin-top: 40px !important; /* 画像の後の余白を増やす */
    }
    
    /* リンクカード内のサムネイルを最適化 */
    .ilc-thumbnail {
        position: relative;
        overflow: hidden;
    }
    
    /* 画像の縦横比を維持しながら中央配置 */
    .ilc-thumbnail img {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        object-position: center center !important;
        background-color: transparent;
    }
}

/* 記事内画像との干渉を完全に防ぐ */
.entry-content .alignleft + .ilc-link-card,
.entry-content .alignright + .ilc-link-card,
.post-content .alignleft + .ilc-link-card,
.post-content .alignright + .ilc-link-card {
    clear: both !important;
    margin-top: 50px !important;
}

/* WordPressの標準ギャラリーとの干渉を防ぐ */
.gallery + .ilc-link-card,
.wp-block-gallery + .ilc-link-card {
    clear: both !important;
    margin-top: 40px !important;
}

/* リンクカードの上下にクリアフィックス空間を追加 */
.ilc-link-card::before,
.ilc-link-card::after {
    content: "";
    display: table;
    clear: both;
    width: 100%;
    height: 0;
}

/* パフォーマンス最適化 */
@media (prefers-reduced-motion: reduce) {
    .ilc-link-card,
    .ilc-link-card * {
        animation: none !important;
        transition: none !important;
    }
}

/* 特別なスタイル: 人気記事 */
.ilc-link-card.ilc-popular {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.ilc-link-card.ilc-popular .ilc-title {
    -webkit-text-fill-color: white;
}

.ilc-link-card.ilc-popular .ilc-excerpt {
    color: rgba(255, 255, 255, 0.95);
}

.ilc-link-card.ilc-popular::after {
    content: '🔥 人気記事';
    position: absolute;
    top: 15px;
    right: 15px;
    background: white;
    color: #f5576c;
    padding: 5px 15px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 人気記事バッジのサイズ調整 */
.ilc-link-card.ilc-size-small.ilc-popular::after {
    font-size: 10px;
    padding: 3px 10px;
    top: 10px;
    right: 10px;
}

.ilc-link-card.ilc-size-large.ilc-popular::after {
    font-size: 14px;
    padding: 7px 20px;
    top: 20px;
    right: 20px;
}

/* 遅延読み込み用のスタイル */
.ilc-lazy img[data-src] {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.ilc-lazy img.ilc-loaded {
    opacity: 1;
}

/* プレースホルダーアニメーション */
.ilc-lazy .ilc-thumbnail::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
}

.ilc-lazy.ilc-card-loaded .ilc-thumbnail::before {
    display: none;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* WebPサポート */
.ilc-thumbnail picture {
    display: block;
    width: 100%;
    height: 100%;
}

.ilc-thumbnail source,
.ilc-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}