/* 導入事例一覧のスタイル */
.case-study-container {
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 1280px;
    overflow-x: hidden; /* 横スクロールを防ぐ */
    box-sizing: border-box; /* パディングを含めた幅計算 */
}

/* フィルターボタン */
/* デスクトップ・タブレット用の調整 */
.case-study-filter {
    text-align: center;
    margin-bottom: 40px;
    display: grid; /* flexからgridに変更 */
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    justify-content: center;
    gap: 10px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.filter-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    color: #666;
    text-align: center; /* 中央寄せを確実に */
    white-space: nowrap; /* テキストの改行を防ぐ */
}

/* タブレット用（768px以上） */
@media (min-width: 768px) and (max-width: 1024px) {
    .case-study-filter {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .filter-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* スマホ用（767px以下）- ここが最重要 */
@media (max-width: 767px) {
    .case-study-filter {
        grid-template-columns: repeat(2, 1fr); /* 横2列固定 */
        gap: 6px;
        margin-bottom: 20px;
        padding: 0 10px; /* 左右に余白を追加 */
    }
    
    .filter-btn {
        padding: 8px 10px; /* パディングを小さく */
        font-size: 12px; /* フォントサイズを小さく */
        border-radius: 20px; /* 角丸を小さく */
        min-height: 36px; /* 最小高さを設定 */
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* 非常に小さなスマホ用（400px以下） */
@media (max-width: 400px) {
    .case-study-filter {
        gap: 4px;
        padding: 0 5px;
    }
    
    .filter-btn {
        padding: 6px 8px;
        font-size: 11px;
        min-height: 32px;
    }
}

.filter-btn:hover,
.filter-btn.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

/* リストのベーススタイル */
.case-study-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.case-study-item {
    background: #fff;
    border-radius: 8px;
    border: 2px solid #e0e0e0; /* 枠線を追加 */
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: auto;
}

.case-study-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    border-color: #007cba; /* ホバー時の枠線色 */
}

.case-study-item.hidden {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

.case-study-item a {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
    color: inherit;
    padding: 20px; /* リンク全体にパディングを追加 */
}

/* 画像エリア - 1080×1080px対応 */
.case-image {
    margin-bottom: 16px;
    overflow: hidden;
    border-radius: 4px;
    flex-shrink: 0;
    background: #f9f9f9;
    width: 100%;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
}

.case-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.3s ease;
}

.case-study-item:hover .case-image img {
    transform: scale(1.05);
}

/* コンテンツエリア - 新しい構造に対応 */
.case-content {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between; /* ディスクリプションとカテゴリの間にスペースを作る */
}

/* ディスクリプション */
.case-description {
    font-size: 19px;
    line-height: 1.5;
    color: #333;
    margin: 0 0 16px 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 3行で切り取り */
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    word-break: break-word;
    font-weight: bold;
    flex-grow: 1; /* 残りのスペースを埋める */
}

/* カテゴリタグ - 下部に固定 */
.case-categories {
    margin-top: auto; /* 上の余白を自動調整して下詰め */
    margin-bottom: 0; /* 下の余白をリセット */
    padding-bottom: 0; /* パディングもリセット */
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-tag {
    background: #e8f4fd;
    color: #007cba;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.2;
    display: inline-block;
}

/* デスクトップ専用（1025px以上）の設定 */
@media only screen and (min-width: 1025px) {
    .case-study-item .case-description {
        font-size: 19px !important;
        line-height: 1.5 !important;
        font-weight: bold !important;
    }
    
    .case-study-item a {
        padding: 24px !important;
    }
}

/* iPad Mini専用設定（768px×1024px） */
@media only screen and (min-width: 768px) and (max-width: 768px) and (min-height: 1024px) and (max-height: 1024px) {
    .case-study-container {
        padding: 0 30px;
    }
    
    .case-study-list {
        grid-template-columns: repeat(2, 1fr); /* 2列固定 */
        gap: 20px;
    }
    
    .case-study-item {
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }
    
    .case-study-item a {
        padding: 16px !important;
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    .case-image {
        width: 100%;
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0;
        margin-bottom: 12px;
        box-sizing: border-box;
    }
    
    .case-description {
        font-size: 16px !important;
        line-height: 1.5 !important;
        font-weight: bold !important;
        margin-bottom: 12px !important;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        text-overflow: ellipsis;
        word-break: break-word;
        flex-grow: 1;
    }
    
    .case-categories {
        margin-top: auto;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .category-tag {
        font-size: 13px;
        padding: 5px 10px;
    }
}

/* 一般的なタブレット表示（769px以上1024px以下、iPad Mini以外） */
@media only screen and (min-width: 769px) and (max-width: 1024px) {
    .case-study-container {
        padding: 0 40px;
    }
    
    .case-study-list {
        grid-template-columns: repeat(2, 1fr); /* 2列固定に変更 */
        gap: 25px;
    }
    
    .case-study-item {
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }
    
    .case-study-item a {
        padding: 20px !important;
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    .case-image {
        aspect-ratio: 1 / 1;
        flex-shrink: 0;
        margin-bottom: 16px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .case-description {
        font-size: 18px !important;
        line-height: 1.5 !important;
        font-weight: bold !important;
        margin-bottom: 16px !important;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        text-overflow: ellipsis;
        word-break: break-word;
        flex-grow: 1;
    }
    
    .case-categories {
        margin-top: auto;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .category-tag {
        font-size: 14px;
        padding: 6px 12px;
    }
}

/* スマホ表示（768px以下） */
@media only screen and (max-width: 768px) {
    .case-study-container {
        padding: 0 15px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .case-study-item {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }
    
    .case-study-item a {
        padding: 16px !important;
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }
    
    .case-study-list {
        grid-template-columns: 1fr; /* 1列表示 */
        gap: 20px;
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
    }
    
    .case-study-filter {
        margin-bottom: 30px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .filter-btn {
        padding: 8px 16px;
        font-size: 12px;
        box-sizing: border-box;
    }
    
    .case-image {
        margin-bottom: 12px;
        width: 100%;
        aspect-ratio: 1 / 1;
        flex-shrink: 0;
        box-sizing: border-box;
    }
    
    .case-image img {
        width: 100% !important;
        height: 100% !important;
        max-width: 100%;
        object-fit: cover;
        object-position: center;
        box-sizing: border-box;
        display: block;
    }
    
    .case-content {
        width: 100%;
        box-sizing: border-box;
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .case-description {
        font-size: 16px !important;
        line-height: 1.4 !important;
        font-weight: bold !important;
        margin-bottom: 12px !important;
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        text-overflow: ellipsis;
        word-break: break-word;
        flex-grow: 1;
    }

    .case-categories {
        margin-top: auto;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 0;
        padding-bottom: 0;
    }
    
    .category-tag {
        font-size: 12px;
        padding: 6px 10px;
        box-sizing: border-box;
    }
}

/* 小さなスマホ用の追加調整 */
@media only screen and (max-width: 480px) {
    .case-study-container {
        padding: 0 10px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .case-study-filter {
        width: 100%;
        max-width: 100%;
    }
    
    .filter-btn {
        width: 100%;
        max-width: 200px;
        box-sizing: border-box;
    }
    
    .case-study-item a {
        padding: 12px !important;
    }
    
    .case-description {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    .category-tag {
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* アニメーション */
.case-study-item {
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* フィルタリング時のアニメーション */
.case-study-item.filtering {
    transition: all 0.4s ease;
}

.case-study-item.hidden {
    display: none !important;
}

/* 見出しのスタイル */
.case-study-heading {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    margin: 2rem 0;
    color: #333;
}

/* スマホ対応（画面幅が768px以下のとき） */
@media screen and (max-width: 768px) {
    .case-study-heading {
        font-size: 1.2rem;
        margin: 1.5rem 0;
    }
}