/* ===========================================================
 * AIちゃんねる -アイちゃん- 子テーマカスタムスタイル
 * Phase 0 ではほぼ空。Phase 1 で AI 開示表示などを追加する。
 * =========================================================== */

/* AI 開示 (記事上部) */
.ai-disclosure-top {
    background: #fff8e1;
    border-left: 4px solid #ffb300;
    padding: 12px 16px;
    margin: 0 0 24px 0;
    font-size: 0.9em;
    color: #5d4037;
    border-radius: 4px;
}

/* AI 開示 (記事末尾) */
.ai-disclosure-bottom {
    margin: 32px 0;
    padding: 12px 0;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    font-size: 0.85em;
}

.ai-disclosure-bottom a {
    color: #666;
    text-decoration: underline;
}

/* ============================================================
 * 引用元ボックス (URL 投入記事の元ネタ表示)
 * ============================================================ */
.ai-times-source .ai-times-quote,
blockquote.ai-times-quote {
    background: #f5f7fa;
    border-left: 4px solid #0d9488;
    padding: 12px 16px;
    margin: 0 0 24px 0;
    border-radius: 4px;
}

blockquote.ai-times-quote p {
    margin: 0 0 8px 0;
    font-size: 0.95em;
    color: #334155;
}

blockquote.ai-times-quote cite {
    display: block;
    font-style: normal;
    font-size: 0.85em;
    color: #64748b;
    margin-top: 8px;
}

blockquote.ai-times-quote cite a {
    color: #0d9488;
    text-decoration: underline;
}

/* X の埋め込みは Twitter widgets.js が無いと素の blockquote になる。
 * 最低限の見栄えを確保 */
blockquote.twitter-tweet {
    background: #f8fafc;
    border-left: 4px solid #1da1f2;
    padding: 12px 16px;
    margin: 0 0 24px 0;
    border-radius: 4px;
}

/* ============================================================
 * AdSense (記事内広告のラッパー)
 * ============================================================ */
.ai-times-ad {
    margin: 28px auto;
    text-align: center;
}

/* モバイル (~767px) で h2 前広告は非表示にしてレイアウト破綻を避ける */
@media (max-width: 767px) {
    .ai-times-ad-h2 {
        display: none !important;
    }
}

/* ============================================================
 * 機能2: 5ch風カード型レイアウト (記事一覧)
 *   - 参考: https://itest.5ch.io
 *   - スマホ 1 カラム / PC 2 カラム grid
 *   - 余白縮小、情報密度高め、白基調 + アクセントカラー
 *   - Cocoon 親テーマのセレクタを上書き (テーマ更新でも消えない)
 * ============================================================ */

/* 一覧 grid (Cocoon の .list は親 wrapper) */
.list {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 0;
}

@media (min-width: 768px) {
    .list {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1200px) {
    .list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* カード本体 */
.list .a-wrap,
.list .entry-card-wrap,
.entry-card-wrap.a-wrap {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.list .a-wrap:hover,
.list .entry-card-wrap:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10);
    transform: translateY(-1px);
}

/* カード内部レイアウト */
.list .entry-card-content,
.list .e-card-content,
.list .card-content {
    padding: 12px 14px !important;
}

/* サムネ (上配置・16:9) */
.list .entry-card-thumb,
.list .card-thumb {
    margin: 0 !important;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f1f5f9;
}

.list .entry-card-thumb img,
.list .card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* タイトル */
.list .entry-card-title,
.list .card-title,
.list .e-card-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    margin: 0 0 6px !important;
    color: #0f172a !important;
    /* スマホでも最低 14px (アクセシビリティ) */
    -webkit-line-clamp: 3;
    line-clamp: 3;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 768px) {
    .list .entry-card-title,
    .list .card-title {
        font-size: 17px !important;
    }
}

/* 抜粋 (グレー、控えめ) */
.list .entry-card-snippet,
.list .card-snippet {
    font-size: 13px !important;
    line-height: 1.5 !important;
    color: #64748b !important;
    margin: 0 0 8px !important;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* メタ情報 (日付・カテゴリ) */
.list .entry-card-meta,
.list .card-meta,
.list .post-date,
.list .post-update {
    font-size: 12px !important;
    color: #94a3b8 !important;
    font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo,
                 Consolas, 'Liberation Mono', monospace !important;
}

/* カテゴリラベル (Cocoon の .cat-label) */
.list .cat-label,
.cat-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff !important;
    background: #64748b;
    margin-right: 6px;
    line-height: 1.6;
}

/* カテゴリ別配色 (機能2 仕様) */
.cat-label.cat-AI論文,
.cat-AI論文 .cat-label,
.cat-label[data-cat="AI論文"],
.cat-label.cat-ai            { background: #2196f3 !important; }
.cat-label.cat-個人開発,
.cat-label[data-cat="個人開発"]    { background: #9c27b0 !important; }
.cat-label.cat-サーバー,
.cat-label[data-cat="サーバー"]    { background: #43a047 !important; }
.cat-label.cat-ブログ運営,
.cat-label[data-cat="ブログ運営"]  { background: #fb8c00 !important; }
.cat-label.cat-ライティング,
.cat-label[data-cat="ライティング"] { background: #795548 !important; }
.cat-label.cat-生成AI,
.cat-label[data-cat="生成AI"]      { background: #e91e63 !important; }
.cat-label.cat-ゲーム,
.cat-label[data-cat="ゲーム"]      { background: #424242 !important; }
.cat-label.cat-FX,
.cat-label.cat-金融,
.cat-label[data-cat="FX"],
.cat-label[data-cat="金融"]        { background: #ffa000 !important; color: #1a1a1a !important; }

/* タップ領域確保 (44x44) — 個別記事リンク全体をタップ可能に */
.list .a-wrap {
    min-height: 44px;
}

.list .a-wrap a,
.list .entry-card-wrap a {
    text-decoration: none;
    color: inherit;
}

/* 横スクロール禁止 (スマホ) */
@media (max-width: 767px) {
    html, body {
        overflow-x: hidden;
    }

    .list .entry-card-content,
    .list .card-content {
        padding: 10px 12px !important;
    }
}

/* ============================================================
 * 機能3: A8 バナー (サイドバー / フッター / インライン)
 * ============================================================ */

/* 共通 */
.ai-times-a8-banner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(13, 148, 136, 0.25);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    line-height: 1.4;
}

.ai-times-a8-banner:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.35);
}

.ai-times-a8-banner-label {
    font-size: 14px;
    font-weight: 700;
}

.ai-times-a8-banner-cta {
    font-size: 12px;
    opacity: 0.9;
}

/* サイドバー */
.ai-times-a8-sidebar-wrap {
    margin: 0 0 16px;
}

.ai-times-a8-sidebar {
    /* PC サイドバー幅に最適化 */
    width: 100%;
}

/* 記事一覧インライン (1 カラム分を占有) */
.ai-times-a8-inline-wrap {
    grid-column: 1 / -1;
    margin: 0;
}

.ai-times-a8-inline {
    width: 100%;
}

/* フッター固定 (全デバイス) */
.ai-times-a8-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    padding: 8px 12px 8px 36px;
    background: rgba(15, 23, 42, 0.96);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.18);
    /* 中の .ai-times-a8-banner は横長 inline 表示 */
}

.ai-times-a8-footer .ai-times-a8-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    gap: 12px;
}

.ai-times-a8-footer .ai-times-a8-banner-label {
    font-size: 13px;
}

.ai-times-a8-footer .ai-times-a8-banner-cta {
    white-space: nowrap;
    font-size: 12px;
}

.ai-times-a8-footer-close {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    /* タップ領域 44px 確保 */
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-times-a8-footer-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* スマホでフッターが本文を隠さないように下部余白を確保 */
@media (max-width: 767px) {
    body {
        padding-bottom: 64px;
    }

    .ai-times-a8-footer .ai-times-a8-banner {
        padding: 6px 8px;
        gap: 6px;
    }

    .ai-times-a8-footer .ai-times-a8-banner-label {
        font-size: 12px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* ============================================================
 * スマホ表示応急パッチ (2026-05-31)
 * Cocoon 親テーマの固定幅を強制上書きして
 * カードを画面内に収める
 * ============================================================ */
@media (max-width: 767px) {
    /* メインコンテンツの幅を画面に合わせる */
    .wrap,
    .main,
    .content-in,
    .content,
    .article,
    #content {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* カード自体の幅をコンテナに収める */
    .list,
    .list .a-wrap,
    .list .entry-card-wrap,
    .entry-card-wrap.a-wrap,
    .entry-card-wrap {
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* 画像のはみ出し防止 */
    .list .entry-card-thumb img,
    .list .card-thumb img,
    .list img,
    article img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* grid 強制 1 列 */
    .list {
        grid-template-columns: 1fr !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}

/* ============================================================
 * スマホ表示応急パッチ 第2弾 (2026-05-31)
 * Cocoon 親テーマの「サムネ左+タイトル右」横並びを
 * 「サムネ上+タイトル下」縦並びに強制 (5ch風カード)
 * ※ PC 含む全幅で適用
 * ============================================================ */

/* カード内部を縦並びに (サムネ上、テキスト下) */
.list .entry-card-wrap,
.list .a-wrap,
.entry-card-wrap.a-wrap {
    display: flex !important;
    flex-direction: column !important;
}

/* サムネ領域は横幅 100% */
.list .entry-card-thumb,
.list .entry-card-thumb-content,
.list .card-thumb,
.entry-card-thumb {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    float: none !important;
}

/* テキスト領域も横幅 100% */
.list .entry-card-content,
.list .e-card-content,
.list .card-content {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 auto !important;
    margin: 0 !important;
    padding: 12px 14px !important;
    float: none !important;
}
