/* css/style.css - 修正版 (line-clamp対応) */

:root {
    --primary-color: #3b82f6; /* ブルー */
    --primary-hover: #2563eb;
    --bg-color: #f8fafc;
    --text-color: #334155;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --price-color: #e11d48; /* レッド */
    --transition: all 0.3s ease;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* =========================================
   ヘッダー & ナビゲーション
   ========================================= */
.page-header {
    text-align: center;
    padding: 3rem 1rem 2rem;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.page-eyebrow {
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    opacity: 0.8;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    letter-spacing: -0.025em;
}

.page-title-em {
    color: var(--primary-color);
}

.page-subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* =========================================
   ツールバー (検索・フィルタ)
   ========================================= */
.toolbar {
    background: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
}

.select-wrapper {
    position: relative;
    min-width: 180px;
}

.custom-select {
    width: 100%;
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.custom-select:hover {
    border-color: var(--primary-color);
}

.search-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
    min-width: 250px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: var(--transition);
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* =========================================
   商品グリッドレイアウト
   ========================================= */
.product-grid {
    display: grid;
    /* 画面幅に合わせて自動調整 (最小180px) */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    padding: 2rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* =========================================
   商品カードスタイル
   ========================================= */
.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%; /* 高さ揃え */
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.1);
}

/* 画像エリア設定 */
.product-media {
    position: relative; /* バッジの基準点 */
    width: 100%;
    aspect-ratio: 2 / 3; /* 縦横比固定 */
    background-color: #f1f5f9;
    overflow: hidden;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.product-card:hover .product-img {
    transform: scale(1.05);
}

/* ランキングバッジ */
.badge-rank {
    position: absolute; /* 画像の上に重ねる */
    top: 0;
    left: 0;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    border-bottom-right-radius: 10px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    z-index: 10;
}

/* 1位〜3位の特別色設定 */
.product-card:nth-child(1) .badge-rank { background: linear-gradient(135deg, #fbbf24, #d97706); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.product-card:nth-child(2) .badge-rank { background: linear-gradient(135deg, #94a3b8, #64748b); }
.product-card:nth-child(3) .badge-rank { background: linear-gradient(135deg, #b45309, #78350f); }

/* メーカーバッジ */
.badge-maker {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-top-left-radius: 8px;
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    backdrop-filter: blur(2px);
}

/* =========================================
   カード本文エリア
   ========================================= */
.product-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* 高さを埋める */
}

.product-title {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.5;
    margin: 0 0 0.5rem 0;
    
    /* 3点リーダー省略設定 */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Chrome, Safari, etc. */
    line-clamp: 2;         /* Standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
    
    height: 3em; /* 2行分の高さ確保 */
}

.product-title a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s;
}

.product-title a:hover {
    color: var(--primary-color);
}

/* 価格・DL数・日付 */
.product-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.meta-price {
    color: var(--price-color);
    font-weight: 700;
    font-size: 1rem;
}

.meta-count {
    color: #64748b;
    font-size: 0.8rem;
}

.meta-date {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: right;
    margin-bottom: 0.75rem;
}

/* =========================================
   説明文（アコーディオン）スタイル
   ========================================= */
.product-description-container {
    margin-top: auto; /* 下部に押し付け */
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}

.product-description-text {
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.6;
    max-height: 0; /* 閉じた状態 */
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease-out, opacity 0.3s ease;
}

/* 開いた状態（JS用） */
.product-description-container.open .product-description-text {
    max-height: 200px;
    opacity: 1;
    margin-bottom: 0.5rem;
    overflow-y: auto; /* 長すぎる場合はスクロール */
}

.desc-toggle-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.75rem;
    cursor: pointer;
    width: 100%;
    text-align: center;
    padding: 4px 0;
}

.desc-toggle-btn:hover {
    text-decoration: underline;
}

/* =========================================
   フッターボタン
   ========================================= */
.product-footer {
    padding: 1rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color);
}

.cta-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0.6rem;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 6px;
    transition: background-color 0.2s;
    box-sizing: border-box; /* 必須 */
}

.cta-btn:hover {
    background-color: var(--primary-hover);
}

/* =========================================
   メニュー（ハンバーガー）
   ========================================= */
.menu-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.menu-btn:hover {
    transform: scale(1.1);
}

.menu-btn-line {
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
}

/* オーバーレイメニュー */
.menu-overlay {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    z-index: 999;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -5px 0 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.menu-open .menu-overlay {
    right: 0;
}

.menu-content {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

.menu-title {
    font-size: 1.5rem;
    font-weight: 700;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    color: #1e293b;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-list li {
    margin-bottom: 1rem;
}

.menu-link {
    text-decoration: none;
    color: #334155;
    font-weight: 500;
    display: block;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.menu-link:hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
}

.menu-footer {
    padding: 2rem;
    text-align: center;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

.menu-close-btn {
    margin-top: 1rem;
    padding: 0.5rem 2rem;
    background: #94a3b8;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}

/* =========================================
   レスポンシブ / ユーティリティ
   ========================================= */
.loading, .no-results-message {
    text-align: center;
    padding: 3rem;
    grid-column: 1 / -1; /* 全カラム幅を使う */
    color: #64748b;
    font-weight: 500;
}

@media (max-width: 768px) {
    .page-title {
        font-size: 1.5rem;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .select-wrapper, .search-wrapper {
        width: 100%;
        max-width: none;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr); /* スマホは2列 */
        gap: 0.75rem;
        padding: 1rem 0.5rem;
    }

    .product-body {
        padding: 0.75rem;
    }
}