/* ===================================================
   article.css - 記事ページ専用スタイル
   =================================================== */

/* === スムーズスクロール === */
html {
    scroll-behavior: smooth;
}

/* === 基本テキスト === */
.article-body p {
    margin: 1.25rem 0;
    line-height: 2;
    color: #374151;
    font-size: 1rem;
}
.article-body strong {
    color: #111827;
    font-weight: 700;
}

/* === 見出し === */
.article-body h2 {
    font-size: 1.625rem;
    font-weight: 800;
    margin: 3rem 0 1.5rem;
    color: #111827;
    border-left: 3px solid #15803d;
    padding: 0.75rem 1rem;
    background: #f0fdf4;
    border-radius: 0 0.5rem 0.5rem 0;
}
.article-body h3 {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    color: #1f2937;
    padding-left: 0.75rem;
    border-left: 3px solid #22c55e;
}
.article-body h4 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 2rem 0 0.75rem;
    color: #374151;
}

/* === リスト === */
.article-body ul {
    margin: 1.25rem 0;
    padding-left: 0;
    list-style: none;
}
.article-body ul li {
    position: relative;
    padding: 0.5rem 0 0.5rem 1.75rem;
    line-height: 1.8;
    color: #374151;
}
.article-body ul li::before {
    content: '';
    position: absolute;
    left: 0.25rem;
    top: 1rem;
    width: 8px;
    height: 8px;
    background: #15803d;
    border-radius: 50%;
}
.article-body ol {
    margin: 1.25rem 0;
    padding-left: 1.5rem;
    counter-reset: ol-counter;
    list-style: none;
}
.article-body ol li {
    position: relative;
    padding: 0.5rem 0 0.5rem 0.5rem;
    line-height: 1.8;
    color: #374151;
    counter-increment: ol-counter;
}
.article-body ol li::before {
    content: counter(ol-counter);
    position: absolute;
    left: -1.5rem;
    top: 0.6rem;
    width: 1.5rem;
    height: 1.5rem;
    background: #15803d;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === リンク === */
.article-body a {
    color: #15803d;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid #22c55e;
    transition: color 0.2s, border-color 0.2s;
}
.article-body a:hover {
    color: #166534;
    border-bottom-color: #15803d;
}
.article-body a[target="_blank"]::after {
    content: ' \2197';
    font-size: 0.75em;
    vertical-align: super;
    opacity: 0;
    transition: opacity 0.2s;
}
.article-body a[target="_blank"]:hover::after {
    opacity: 1;
}
/* 画像を囲むリンクにはアロー表示しない */
.article-body a:has(> img)::after {
    content: none !important;
}
/* 画像を囲むリンクのスタイルリセット */
.article-body a:has(> img) {
    display: block;
    border-bottom: none;
    background: none !important;
    padding: 0 !important;
    color: inherit !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    font-weight: normal !important;
}

/* === テーブル === */
.article-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2.5rem 0;
    font-size: 0.9375rem;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}
.article-body thead {
    background: linear-gradient(135deg, #14532d, #166534);
}
.article-body thead th {
    padding: 1rem 1.25rem;
    text-align: left;
    font-weight: 700;
    color: #ffffff;
    font-size: 0.875rem;
    letter-spacing: 0.03em;
    text-transform: none;
    border-right: 1px solid rgba(255,255,255,0.15);
}
.article-body thead th:last-child {
    border-right: none;
}
.article-body tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.15s;
}
.article-body tbody tr:hover {
    background-color: #ecfdf5;
}
.article-body tbody tr:nth-child(even) {
    background-color: #f9fafb;
}
.article-body tbody tr:nth-child(even):hover {
    background-color: #ecfdf5;
}
.article-body tbody td {
    padding: 1rem 1.25rem;
    color: #374151;
    vertical-align: middle;
    line-height: 1.7;
    border-right: 1px solid #f3f4f6;
}
.article-body tbody td:last-child {
    border-right: none;
}
.article-body tbody td:first-child {
    font-weight: 600;
    color: #1f2937;
    background-color: rgba(34,197,94,0.04);
}
.article-body tbody tr:last-child td {
    border-bottom: none;
}

/* === 画像 === */
.article-body img {
    max-width: 100%;
    height: auto;
    margin: 1.5rem auto;
    border-radius: 0.75rem;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
/* アフィリエイト商品画像のサイズ制限 */
.article-body img[src*="rakuten.co.jp"],
.article-body img[src*="amazon.co.jp"],
.article-body img[src*="amazon.com"],
.article-body img[src*="a8.net"] {
    max-width: 60%;
    max-height: 60%;
    width: auto;
    object-fit: contain;
}

/* === セクション画像（AI生成） === */
.article-section-image {
    margin: 1.5rem 0 2rem;
    border-radius: 12px;
    overflow: hidden;
}
.article-section-image img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* === 引用 === */
.article-body blockquote {
    margin: 1.5rem 0;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid #3b82f6;
    background: #eff6ff;
    border-radius: 0 0.5rem 0.5rem 0;
    color: #374151;
    font-style: italic;
}

/* === 注意書き === */
.article-body > p:has(※),
.article-body > p:last-of-type {
    font-size: 0.875rem;
    color: #6b7280;
}

/* === 商品画像下の控えめリンク === */
.article-body .product-detail-link {
    text-align: center;
    margin: 0.25rem 0 0;
}
.article-body .product-detail-link a {
    all: unset;
    cursor: pointer;
    color: #fff !important;
    font-size: 0.75rem !important;
    font-weight: 400 !important;
    text-decoration: none !important;
    background: #666 !important;
    border: none !important;
    box-shadow: none !important;
    padding: 3px 12px !important;
    margin: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: inline-block !important;
    border-radius: 3px !important;
}
.article-body .product-detail-link a:hover {
    color: #fff !important;
    background: #555 !important;
    box-shadow: none !important;
    transform: none !important;
}
.article-body .product-detail-link a::before,
.article-body .product-detail-link a::after {
    content: none !important;
}

/* === アフィリエイトボタン (記事本文内、画像リンクは除外) === */
.article-body a[href*="rakuten.co.jp"]:not(:has(> img)),
.article-body a[href*="amazon.co.jp"]:not(:has(> img)),
.article-body a[href*="a8.net"]:not(:has(> img)) {
    display: block;
    width: fit-content;
    margin: 1rem auto;
    background: linear-gradient(135deg, #059669, #047857);
    color: #ffffff !important;
    padding: 0.875rem 2.5rem;
    border-radius: 0.625rem;
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
    text-decoration: none !important;
    border: none !important;
    border-bottom: none !important;
    min-width: 220px;
    min-height: 44px;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(5,150,105,0.35);
}
.article-body a[href*="rakuten.co.jp"]:not(:has(> img)):hover,
.article-body a[href*="amazon.co.jp"]:not(:has(> img)):hover,
.article-body a[href*="a8.net"]:not(:has(> img)):hover {
    background: linear-gradient(135deg, #047857, #065f46);
    box-shadow: 0 4px 12px rgba(5,150,105,0.4);
    transform: translateY(-2px);
}
/* --- ストア別バッジ (楽天=赤, Amazon=オレンジ) --- */
.article-body a[href*="rakuten.co.jp"]:not(:has(> img)) {
    background: linear-gradient(135deg, #bf0000, #a00000) !important;
    box-shadow: 0 2px 6px rgba(191,0,0,0.35);
}
.article-body a[href*="rakuten.co.jp"]:not(:has(> img)):hover {
    background: linear-gradient(135deg, #a00000, #800000) !important;
    box-shadow: 0 4px 12px rgba(191,0,0,0.4);
}
.article-body a[href*="rakuten.co.jp"]:not(:has(> img))::before {
    content: '\1F6D2  ';
    font-style: normal;
}
.article-body a[href*="rakuten.co.jp"]:not(:has(> img))::after {
    content: ' \2197' !important;
    margin-left: 0.375rem;
}
.article-body a[href*="amazon.co.jp"]:not(:has(> img)) {
    background: linear-gradient(135deg, #ff9900, #e68a00) !important;
    box-shadow: 0 2px 6px rgba(255,153,0,0.35);
}
.article-body a[href*="amazon.co.jp"]:not(:has(> img)):hover {
    background: linear-gradient(135deg, #e68a00, #cc7a00) !important;
    box-shadow: 0 4px 12px rgba(255,153,0,0.4);
}
.article-body a[href*="amazon.co.jp"]:not(:has(> img))::before {
    content: '\1F4E6  ';
    font-style: normal;
}
.article-body a[href*="amazon.co.jp"]:not(:has(> img))::after {
    content: ' \2197' !important;
    margin-left: 0.375rem;
}
.article-body a[href*="a8.net"]:not(:has(> img))::after {
    content: ' \2197' !important;
    margin-left: 0.375rem;
}

/* === 目次 (TOC) === */
.article-toc {
    background: linear-gradient(135deg, #f8fafc, #eff6ff);
    border: 1px solid #e2e8f0;
    border-left: 4px solid #15803d;
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.article-toc-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.article-toc ol {
    margin: 0;
    padding-left: 1.25rem;
    counter-reset: toc-counter;
    list-style: none;
}
.article-toc ol li {
    padding: 0.25rem 0;
    line-height: 1.6;
    counter-increment: toc-counter;
}
.article-toc ol li::before {
    content: counter(toc-counter) ".";
    position: static;
    width: auto;
    height: auto;
    background: none;
    color: #15803d;
    font-weight: 700;
    font-size: 0.875rem;
    display: inline;
    margin-right: 0.5rem;
    border-radius: 0;
}
.article-toc ol li a {
    color: #475569;
    text-decoration: none;
    font-size: 0.9375rem;
    border-bottom: none;
    transition: color 0.2s;
}
.article-toc ol li a:hover {
    color: #15803d;
}
.article-toc ol li a::after {
    content: none !important;
}
.article-toc ol ol {
    margin-top: 0.25rem;
    padding-left: 1.25rem;
    counter-reset: toc-sub-counter;
}
.article-toc ol ol li {
    counter-increment: toc-sub-counter;
    font-size: 0.875rem;
}
.article-toc ol ol li::before {
    content: counter(toc-counter) "-" counter(toc-sub-counter) ".";
    color: #22c55e;
}

/* === PR表記バナー === */
.pr-banner {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    color: #0369a1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === PR バッジ（記事上部）=== */
.pr-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem 0.5rem;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 0.25rem;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

/* === 商品カード個別「広告」バッジ === */
.product-ad-badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    background: #3b82f6;
    color: #ffffff;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 0.25rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

/* === ソーシャルシェアボタン === */
.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.share-buttons a {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    transition: opacity 0.2s;
}
.share-buttons a:hover {
    opacity: 0.85;
}
.share-buttons a::after {
    content: none !important;
}
.share-btn-x {
    background: #0f1419;
    color: #ffffff !important;
}
.share-btn-facebook {
    background: #1877f2;
    color: #ffffff !important;
}
.share-btn-line {
    background: #06c755;
    color: #ffffff !important;
}
.share-btn-hatena {
    background: #00a4de;
    color: #ffffff !important;
}

/* === 著者情報 === */
.author-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.author-avatar {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, #15803d, #15803d);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
}
.author-info h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.25rem;
    border-left: none;
    padding-left: 0;
}
.author-info p {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.6;
    margin: 0;
}

/* === スタイル漏れ防止（.article-body外のセクションをリセット）=== */
/* AI生成HTMLに閉じタグ漏れがあった場合の安全策 */
.article-body ~ section h2,
.article-body ~ section h3 {
    border-left: none !important;
    background: none !important;
    padding-left: 0 !important;
    border-radius: 0 !important;
}
.article-body ~ section a {
    color: inherit;
    border-bottom: none;
    font-weight: inherit;
}
.article-body ~ section a::after {
    content: none !important;
}
.article-body ~ section a.bg-emerald-600 {
    color: #ffffff !important;
}
.article-body ~ section a[href*="rakuten.co.jp"]:not(.bg-emerald-600),
.article-body ~ section a[href*="amazon.co.jp"]:not(.bg-emerald-600),
.article-body ~ section a[href*="a8.net"]:not(.bg-emerald-600) {
    background: none !important;
    color: inherit !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    display: inline !important;
    margin: 0 !important;
}

/* === レスポンシブ === */
@media (max-width: 640px) {
    .article-body p {
        font-size: 0.9375rem;
    }
    .article-body ul li,
    .article-body ol li {
        font-size: 0.9375rem;
    }
    .article-body table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.8125rem;
    }
    .article-body thead th,
    .article-body tbody td {
        padding: 0.625rem 0.75rem;
    }
    .article-body h2 {
        font-size: 1.375rem;
    }
    .article-body h3 {
        font-size: 1.25rem;
    }
    .share-buttons {
        flex-direction: column;
    }
    .share-buttons a {
        justify-content: center;
    }
    .author-box {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}
