/**
 * Affiliate Density Fold (13.5.0).
 *
 * 鬱陶しさを最小化しつつ affiliate 候補を保持する `<details>` 折り畳み UI.
 * AffiliateDensityGuard が maxPerArticle 超過分を wrap した要素のスタイル.
 *
 * デザイン方針:
 *   - 既存の mg-pcard / Pochipp 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;
}
.mg-affiliate-fold--swell-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;
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .mg-affiliate-fold {
        background: #1d1d1f;
        border-color: #3a3a3e;
    }
    .mg-affiliate-fold[open] {
        background: #232326;
        border-color: #4a4b4f;
    }
    .mg-affiliate-fold__summary {
        color: #c4c5c8;
    }
    .mg-affiliate-fold__summary:hover {
        background: #2a2b2e;
        color: #fff;
    }
    .mg-affiliate-fold__content {
        border-top-color: #3a3a3e;
    }
}
