/**
 * Affiliate Density Fold (13.5.0).
 *
 * 鬱陶しさを最小化しつつ affiliate 候補を保持する `<details>` 折り畳み UI.
 * AffiliateDensityGuard が maxPerArticle 超過分を wrap した要素のスタイル.
 *
 * デザイン方針:
 *   - 既存の mg-pcard / LegacyProduct box と並んだ時の視覚的優劣を尊重
 *   - 折り畳まれた状態では「ノイズに感じない」程度に subtle
 *   - 展開時は通常 affiliate element と同等
 */

.mg-affiliate-fold {
    margin: 24px 0;
    border: 1px solid #e8e8eb;
    border-radius: 8px;
    background: #fafafa;
    overflow: hidden;
    transition: box-shadow 0.18s ease;
}

.mg-affiliate-fold[open] {
    border-color: #d2d3d6;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.mg-affiliate-fold__summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 16px;
    color: #595a5e;
    font-size: 0.92em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    line-height: 1.4;
}

.mg-affiliate-fold__summary::-webkit-details-marker {
    display: none;
}

.mg-affiliate-fold__summary::after {
    content: '';
    margin-left: auto;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    transition: transform 0.18s ease;
    opacity: 0.6;
}

.mg-affiliate-fold[open] .mg-affiliate-fold__summary::after {
    transform: rotate(180deg);
}

.mg-affiliate-fold__summary:hover {
    background: #f3f3f5;
    color: #1d1d1f;
}

.mg-affiliate-fold__summary:focus-visible {
    outline: 2px solid var(--mg-wp-blue, #2271b1);
    outline-offset: -2px;
}

.mg-affiliate-fold__summary span[aria-hidden] {
    color: #909195;
    font-size: 0.8em;
}

.mg-affiliate-fold__content {
    padding: 4px 16px 16px;
    border-top: 1px solid #ececef;
}

/* 折り畳まれた状態で内部要素の上余白を消す (重複 margin 防止) */
.mg-affiliate-fold__content > :first-child {
    margin-top: 12px;
}
.mg-affiliate-fold__content > :last-child {
    margin-bottom: 0;
}

/* type 別の subtle differentiation */
.mg-affiliate-fold--mg-pcard .mg-affiliate-fold__summary::before {
    content: '';
    font-size: 0.95em;
}
/* Read-only selector for fold wrappers already persisted in older content. */
.mg-affiliate-fold--mg-news-button .mg-affiliate-fold__summary::before,
.mg-affiliate-fold--swell-button .mg-affiliate-fold__summary::before,
.mg-affiliate-fold--legacy_theme-button .mg-affiliate-fold__summary::before,
.mg-affiliate-fold--legacy-theme-button .mg-affiliate-fold__summary::before {
    content: '';
    font-size: 0.95em;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mg-affiliate-fold,
    .mg-affiliate-fold__summary::after {
        transition: none;
    }
}

/* 既定 light 固定（OSダークに勝手に追従しない＝運用者方針「背景デフォルト明るく」）。
   旧実装は @media(prefers-color-scheme:dark) でこの折り畳み box を無条件に黒(#1d1d1f)化していた
   （light 既定の記事内でここだけ黒くなる＝mga-box/mg-pcard と同じバグクラス）。ダーク対応が要るなら
   data-theme でゲートする opt-in 方式で再導入する。 */
