/* =========================================
   1. 基本設定 & フォント
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Roboto:wght@500;700&display=swap');

:root {
    --primary: #FF385C;       /* ブランドカラー */
    --primary-dark: #D90B3E;
    --accent-bg: #E3FDF3;     /* ステータス背景 */
    --accent-text: #00875A;   /* ステータス文字 */
    --bg-color: #F7F9FC;      /* 背景色 */
    --card-bg: #FFFFFF;
    --text-main: #222222;     /* メイン文字色 */
    --text-sub: #717171;      /* サブ文字色 */
    --shadow-card: 0 6px 16px rgba(0,0,0,0.06);
    --shadow-hover: 0 12px 24px rgba(0,0,0,0.1);
}

body {
    font-family: 'Roboto', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* =========================================
   2. ヘッダーエリア (Liveバッジ・スマホ対応)
   ========================================= */
header {
    background: linear-gradient(150deg, #FF5E62 0%, #FF385C 100%);
    padding: 40px 20px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 30px; 
    box-shadow: 0 4px 20px rgba(255, 56, 92, 0.25);
}

header::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: radial-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.6;
    pointer-events: none;
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    line-height: 1.3;
}

header p {
    margin-top: 8px;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.95;
    position: relative;
}

/* --- Live更新バッジ --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 14px;
    border-radius: 50px;
    margin-top: 15px;
    font-size: 0.85rem;
    font-weight: 700;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: #00FFCA;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 8px #00FFCA;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 202, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 255, 202, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 202, 0); }
}

/* --- スマホ表示最適化 --- */
@media screen and (max-width: 768px) {
    header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    header h1 {
        font-size: 1.4rem;
    }
    header p {
        font-size: 0.75rem;
        margin-top: 4px;
    }
    .status-badge {
        margin-top: 10px;
        padding: 4px 12px;
        font-size: 0.75rem;
    }
}

/* =========================================
   3. 検索・タグフィルターエリア
   ========================================= */
#search-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* グループコンテナ（通常版＆アコーディオン版兼用） */
.tag-group, 
.tag-group-accordion {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    border: 1px solid #eee;
    overflow: hidden;
    transition: all 0.3s ease;
    text-align: left;
}

/* タイトル部分 */
.tag-group-title,
.tag-group-summary {
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    background-color: #fff;
    border-bottom: 1px solid #f0f0f0;
}

/* アコーディオン特有の動作 */
.tag-group-summary {
    cursor: pointer;
    justify-content: space-between;
    border-bottom: none; /* 閉じている時は線なし */
}
.tag-group-accordion[open] .tag-group-summary {
    border-bottom: 1px solid #f0f0f0;
    background-color: #fafafa;
}
.tag-group-summary::-webkit-details-marker { display: none; }
.tag-group-summary::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 300;
    transition: transform 0.2s;
}
.tag-group-accordion[open] .tag-group-summary::after {
    transform: rotate(45deg);
}

/* ボタンエリア */
.tag-buttons-wrapper {
    padding: 15px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #fff;
}

/* フィルターボタン（重複を統合済み） */
.filter-tag {
    border: 1px solid #EAEAEA;
    padding: 6px 16px; /* 少し余裕を持たせたサイズを採用 */
    border-radius: 50px;
    background: white;
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.filter-tag:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
    color: var(--primary);
    background: #FFF5F6;
}

.filter-tag.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 3px 8px rgba(255, 56, 92, 0.25);
}

/* =========================================
   4. カードレイアウト & デザイン
   ========================================= */
#result-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 32px;
    padding-bottom: 80px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.03);
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

.card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background-color: #f0f0f0;
}

.card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card h3 {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0 0 12px 0;
    line-height: 1.5;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tags {
    margin-bottom: 15px;
}

.card-tags span {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--text-sub);
    background: #F3F4F6;
    padding: 4px 8px;
    border-radius: 6px;
    margin-right: 5px;
    margin-bottom: 5px;
    font-weight: 700;
    transition: 0.2s;
}

.card:hover .card-tags span {
    background: #FFE4E6;
    color: var(--primary);
}

/* =========================================
   5. フッターエリア (在庫・VODボタン)
   ========================================= */
.card-meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f0f0f0;
    padding-top: 15px;
}

/* 在庫ステータス */
.stock-status {
    font-size: 0.8rem;
    font-weight: 800;
    background-color: var(--accent-bg);
    color: var(--accent-text);
    padding: 6px 12px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    letter-spacing: 0.05em;
}

.stock-status::before {
    content: '●';
    font-size: 0.6rem;
    margin-right: 6px;
    color: var(--accent-text);
}

/* アフィリエイトボタン（単一） */
.affiliate-link {
    text-decoration: none;
    background: #222;
    color: white;
    padding: 8px 18px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    transition: transform 0.2s, opacity 0.2s;
}
.affiliate-link:hover {
    background: black;
    transform: scale(1.05);
}

/* マルチVODボタンリスト */
.service-list {
    margin-top: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    border-top: 1px solid #f0f0f0;
    padding-top: 15px;
}

.service-link {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 10px 10px;
    text-decoration: none;
    background: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-bottom: 2px solid #d0d0d0;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: inherit;
    min-height: 56px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    overflow: hidden;
}

.service-link:hover {
    transform: translateY(-2px);
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 8px 16px rgba(255, 56, 92, 0.12);
    z-index: 1;
}

.service-link:hover .service-name::after {
    color: var(--primary);
    transform: translate(2px, -2px);
}

.service-link:active {
    transform: translateY(1px);
    border-bottom-width: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* サービス名レイアウト */
.service-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
    gap: 4px;
}

.service-name {
    font-weight: 800;
    color: var(--text-main);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    flex-shrink: 0; 
}

/* サービス別アイコン */
.btn-amazon .service-name::before { content: '🛒 '; font-size: 0.9em; margin-right: 2px; }
.btn-hulu .service-name::before { content: '🟢 '; font-size: 0.9em; margin-right: 2px; }

/* リンクアイコン（↗） */
.service-name::after {
    content: ' ↗';
    font-family: sans-serif;
    font-weight: bold;
    font-size: 0.85em;
    margin-left: 4px;
    color: #bbb;
    transition: all 0.2s ease;
}

/* バッジ類 */
.service-status {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 1; 
    text-align: center;
}

.service-sub {
    font-size: 0.65rem;
    color: #888;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.trial-highlight { color: var(--primary); font-weight: 800; }
.badge-free { background: var(--accent-bg); color: var(--accent-text); border: 1px solid rgba(0, 135, 90, 0.1); }
.badge-paid { background: #F8F9FA; color: #ADB5BD; border: 1px solid #eee; }

/* --- 12サービス対応：カード内ボタンレイアウト --- */
.service-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* PC/タブレットは2列 */
    gap: 8px;
    margin-top: auto;
    border-top: 1px solid #f0f0f0;
    padding-top: 15px;
}

/* アフィリエイトあり：ブランドカラーで目立たせる */
.btn-affiliate {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-bottom: 2px solid var(--primary); /* 下線にブランド色 */
}
.btn-affiliate:hover {
    border-color: var(--primary);
    background: #FFF5F6;
}

/* アフィリエイトなし：グレー系で控えめに */
.btn-secondary {
    background: #f9f9f9;
    border: 1px solid #eee;
    opacity: 0.8;
}
.btn-secondary .service-name {
    color: #888;
}

/* スマホ対応：ボタンが小さくなりすぎるのを防ぐ */
@media screen and (max-width: 480px) {
    .service-list {
        grid-template-columns: 1fr; /* スマホは1列にして押しやすく */
    }
}

/* バッジの色分け */
.badge-free { background: var(--accent-bg); color: var(--accent-text); }
.badge-paid { background: #eee; color: #666; }

/* =========================================
   🎁 無料トライアル強調のための修正案
   ========================================= */

/* 1. トライアル情報の強調（PHP側の trial-highlight に対応） */
.trial-highlight {
    color: var(--primary) !important; /* ブランドカラーを強制適用 */
    font-weight: 800;
    font-size: 0.7rem; /* 他のサブテキストより少しだけ大きく */
}

/* 2. サービス名とバッジのバランス調整 */
.service-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 2px; /* 少し詰めて情報を凝縮 */
    gap: 4px;
}

/* 3. レンタルバッジの視認性向上（グレーだと「無効」に見えるのを避ける） */
.badge-paid { 
    background: #FFF9E6 !important; /* 薄い黄色 */
    color: #D97706 !important;     /* 濃いオレンジ */
    border: 1px solid rgba(217, 119, 6, 0.1) !important; 
}

/* 【追加】12サービス並んだ時の「高さ」を安定させる */
.service-link {
    min-height: 60px; /* 無料期間の1行分を考慮して少し確保 */
    padding: 8px 10px;
}

/* アフィリエイト案件を少しだけ浮かせて「選ばれやすく」する */
.btn-affiliate {
    border: 1px solid var(--primary) !important;
    background: #fff !important;
    box-shadow: 0 4px 12px rgba(255, 56, 92, 0.1);
}

/* U-NEXTなどの非アフィ案件は少しトーンを落とす */
.btn-secondary {
    border: 1px solid #eee !important;
    background: #fcfcfc !important;
    opacity: 0.9;
}

/* 料金と無料期間の並記スタイル */
.service-sub {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    gap: 4px;
}

.trial-tag {
    color: var(--primary);
    font-weight: 700;
}

.price-tag {
    color: #888;
}