/*
 * NTS Blog List - Frontend Stylesheet (Improved Responsive Version)
 * カードサイズ統一化とレスポンシブ対応強化版
 */

/* ==========================================================================
   コンテナとリセット
   ========================================================================== */
.easel-blog-list-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    color: #333;
    margin: 2em 0;
    box-sizing: border-box;
    container-type: inline-size;
}

/* コンテナ内の全要素で、ボックスサイズの計算方法を統一 */
.easel-blog-list-container *,
.easel-blog-list-container *::before,
.easel-blog-list-container *::after {
    border: 0;
    margin: 0;
    padding: 0;
    font: inherit;
    vertical-align: baseline;
    text-decoration: none;
    box-sizing: border-box;
}

/* ==========================================================================
   グリッドレイアウト（カラム数を保持）
   ========================================================================== */
.easel-blog-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

/* 2カラム設定 */
.easel-blog-grid[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

/* 3カラム設定（デフォルト） */
.easel-blog-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

/* 4カラム設定 */
.easel-blog-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

/* レスポンシブ対応：画面幅に応じて最小カード幅を調整 */
@media (max-width: 1200px) {
    .easel-blog-grid[data-columns="4"] {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .easel-blog-grid[data-columns="3"],
    .easel-blog-grid[data-columns="4"] {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 600px) {
    .easel-blog-grid {
        gap: 12px;
    }
}

@media (max-width: 400px) {
    .easel-blog-grid[data-columns="2"],
    .easel-blog-grid[data-columns="3"],
    .easel-blog-grid[data-columns="4"] {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ==========================================================================
   カードデザイン（高さ統一）
   ========================================================================== */
.easel-blog-card {
    display: flex;
    position: relative;
    flex-direction: column;
    height: 100%; /* グリッド内で高さを揃える */
    background: #ffffff;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px;
    overflow: hidden;
    transition: 0.3s ease;
}

.easel-blog-card:hover {
    background: #e9ecec;
}

/* カード画像エリア（縦横比固定） */
.easel-blog-card-image {
    width: 100%;
    aspect-ratio: 12 / 6; /* 16:9の縦横比に固定 */
    background-color: #f3f4f6;
    overflow: hidden;
    flex-shrink: 0; /* 画像エリアのサイズを固定 */
}

.easel-blog-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover; /* すべての画像でcoverを使用 */
    object-position: center; /* 中央部分を表示 */
    transition: transform 0.3s ease;
}

.easel-blog-thumbnail.easel-no-image {
    object-fit: cover; /* no-imageもcoverに変更して余白をなくす */
    object-position: center;
    background-color: #f9fafb;
}

/* カードコンテンツエリア（固定レイアウト） */
.easel-blog-card-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 8px 12px;
    min-height: 0; /* flexboxでの高さ調整を有効化 */

    /* 幅に関わらず縦のレイアウトを統一 */
    height: auto;
    min-height: 160px; /* 最小高さを設定 */
}

/* タイトル（1行制限、省略記号付き） */
.easel-blog-title {
    font-size: 17px !important;
    font-weight: 600;
    line-height: 1.4;
    margin: 5px 0 0 0 !important;
    padding: 0 !important;
    color: #111827 !important;
    text-decoration: none !important;
    border: none !important;
    transition: color 0.3s ease;

    /* 1行制限 */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    height: calc(17px * 1.4); /* フォントサイズ×行高×1行 */
    white-space: nowrap; /* 念のため追加 */
    text-overflow: ellipsis;
}

.easel-blog-title:hover {
    color: #4f46e5 !important;
}

/* メタ情報（日付） */
.easel-blog-meta {
    font-size: 10px;
    color: #6b7280 !important;
    flex-shrink: 0;
}

.easel-blog-meta a {
    color: inherit !important;
    text-decoration: none !important;
    border: none !important;
}

/* 抜粋（2行制限） */
.easel-blog-excerpt {
    color: #4b5563;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 12px;

    /* 2行制限 */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    height: calc(13px * 1.6 * 2); /* フォントサイズ×行高×2行 */
}

/* カテゴリ・タグ（下部固定） */
.easel-blog-terms {
    position: relative;
    z-index: 2;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.easel-blog-term {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 9999px;
    color: #ffffff !important;
    text-decoration: none !important;
    border: none !important;
    transition: opacity 0.2s ease;

    /* テキストが長い場合の省略 */
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.easel-blog-term:hover {
    opacity: 0.8;
}

.easel-blog-category {
    background-color: #7cb4b6;
}

.easel-blog-tag {
    background-color: #8093c5;
}

/* カード全体を覆うリンク */
.easel-blog-card-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ==========================================================================
   小画面での微調整（縦長対策強化）
   ========================================================================== */
@media (max-width: 768px) {
    .easel-blog-card-content {
        padding: 6px 10px;
        min-height: 140px;
    }

    .easel-blog-title {
        font-size: 15px !important;
        height: calc(15px * 1.3); /* 1行のみ */
        line-height: 1.3;
        margin: 4px 0 0 0 !important; /* margin完全に0 */
        -webkit-line-clamp: 1; /* 1行制限 */
    }

    .easel-blog-excerpt {
        font-size: 12px;
        height: calc(12px * 1.5 * 2); /* 2行 */
        line-height: 1.5;
        -webkit-line-clamp: 2;
        margin-bottom: 8px;
    }

    .easel-blog-meta {
        font-size: 8px;
    }

    .easel-blog-terms {
        padding-top: 5px;
        gap: 5px;
    }

    .easel-blog-term {
        font-size: 10px;
        padding: 2px 6px;
        max-width: 60px;
    }
}

@media (max-width: 600px) {
    .easel-blog-card-image {
        aspect-ratio: 2 / 1; /* より横長にして縦スペース削減 */
    }

    .easel-blog-card-content {
        padding: 6px 8px;
        min-height: 120px;
    }

    .easel-blog-title {
        font-size: 14px !important;
        height: calc(14px * 1.3); /* 1行のみ */
        margin: 3px 0 0 0 !important;
        -webkit-line-clamp: 1;
    }

    .easel-blog-excerpt {
        font-size: 11px;
        height: calc(11px * 1.4 * 2);
        line-height: 1.4;
        margin-bottom: 6px;
        -webkit-line-clamp: 2;
    }

    .easel-blog-meta {
        font-size: 7px;
    }

    .easel-blog-terms {
        padding-top: 3px;
        gap: 4px;
    }

    .easel-blog-term {
        font-size: 9px;
        padding: 1px 5px;
        max-width: 50px;
    }
}

@media (max-width: 480px) {
    .easel-blog-card-image {
        aspect-ratio: 2.2 / 1; /* さらに横長に */
    }

    .easel-blog-card-content {
        padding: 4px 6px;
        min-height: 100px;
    }

    .easel-blog-title {
        font-size: 13px !important;
        height: calc(13px * 1.2); /* 1行のみ */
        line-height: 1.2;
        margin: 2px 0 0 0 !important;
        -webkit-line-clamp: 1;
    }

    .easel-blog-excerpt {
        font-size: 10px;
        height: calc(10px * 1.4 * 2);
        line-height: 1.4;
        margin-bottom: 4px;
        -webkit-line-clamp: 2;
    }

    .easel-blog-meta {
        font-size: 6px;
    }

    .easel-blog-terms {
        padding-top: 2px;
        gap: 3px;
    }

    .easel-blog-term {
        font-size: 8px;
        padding: 1px 4px;
        max-width: 40px;
    }
}

@media (max-width: 400px) {
    .easel-blog-grid {
        gap: 8px;
    }

    .easel-blog-card-image {
        aspect-ratio: 2.5 / 1; /* 最も横長に */
    }

    .easel-blog-card-content {
        padding: 2px 4px;
        min-height: 90px;
    }

    .easel-blog-title {
        font-size: 12px !important;
        height: calc(12px * 1.2); /* 1行のみ */
        margin: 1px 0 0 0 !important;
        -webkit-line-clamp: 1;
    }

    .easel-blog-excerpt {
        font-size: 10px;
        height: calc(10px * 1.3 * 2);
        line-height: 1.3;
        margin-bottom: 3px;
        -webkit-line-clamp: 2;
    }

    .easel-blog-meta {
        font-size: 6px;
        margin: 0;
    }

    .easel-blog-terms {
        padding-top: 2px;
        gap: 2px;
    }

    .easel-blog-term {
        font-size: 7px;
        padding: 1px 3px;
        max-width: 40px;
    }
}

/* ==========================================================================
   ページネーション
   ========================================================================== */
.easel-blog-pagination {
    text-align: center;
    margin-top: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.easel-blog-pagination a,
.easel-blog-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid #d1d5db !important;
    border-radius: 6px;
    background-color: #ffffff;
    color: #374151 !important;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.2s ease;
}

.easel-blog-pagination a:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
    color: #111827 !important;
}

.easel-blog-pagination .current {
    background-color: #65768b;
    border-color: #65768b;
    color: #ffffff !important;
    cursor: default;
}

.easel-blog-pagination .dots {
    border: none;
    background: none;
}

@media (max-width: 480px) {
    .easel-blog-pagination {
        gap: 4px;
    }

    .easel-blog-pagination a,
    .easel-blog-pagination span {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }
}
