/* One component palette for product cards, ranking tables and article references.
   OS preference changes colors only when the operator explicitly selects auto. */
:is(.mga-box, .ranking-table-maker-root, .mg-article-references) {
    color-scheme: light;
    --mg-commerce-bg: #ffffff;
    --mg-commerce-link: var(--mg-public-link, #1a5fb4);
    --mg-commerce-border: #e3e6eb;
    --mg-commerce-text: #1e1e1e;
    --mg-commerce-text-muted: #6b7280;
    --mg-commerce-price: #c0392b;
    --mg-commerce-meta: #666666;
    --mg-commerce-rank: #b12704;
    --mg-commerce-feature: #333333;
    --mg-commerce-chip-bg: #f0f0f1;
    --mg-commerce-chip-text: #6b6b6b;
    --mg-commerce-accent-bg: #f0f9ff;
    --mg-shop-amazon-fill: #fff3d6;
    --mg-shop-amazon-ink: #694100;
    --mg-shop-aliexpress-fill: #ffe4d6;
    --mg-shop-aliexpress-ink: #913317;
    --mg-shop-rakuten-fill: #f5e6f2;
    --mg-shop-rakuten-ink: #741940;
    --mg-shop-yahoo-fill: #eaf2ff;
    --mg-shop-yahoo-ink: #174b86;
    --mg-shop-mercari-fill: #e7f8f4;
    --mg-shop-mercari-ink: #00594e;
    --mg-shop-official-fill: #f3eef9;
    --mg-shop-official-ink: #45335c;
    --mg-shop-other-fill: #f1f3f6;
    --mg-shop-other-ink: #404858;
}

.mg-commerce-price-amount {
    font-size: 1.35rem;
    font-size: clamp(1.35rem, 1rem + 3cqi, 1.6rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.mg-commerce-price-status {
    color: var(--mg-commerce-price, #c0392b);
    font-size: 1.05rem;
    font-weight: 750;
    line-height: 1.4;
}
@media (prefers-color-scheme: dark) {
    :is(.mga-box, .ranking-table-maker-root, .mg-article-references)[data-theme="auto"] {
        color-scheme: dark;
        --mg-commerce-bg: #1f2430;
        --mg-commerce-link: #8ab4f8;
        --mg-commerce-border: #39414f;
        --mg-commerce-text: #e7e9ee;
        --mg-commerce-text-muted: #9aa3b2;
        --mg-commerce-price: #f87171;
        --mg-commerce-meta: #c2c8d2;
        --mg-commerce-rank: #f0a37a;
        --mg-commerce-feature: #d2d7e0;
        --mg-commerce-chip-bg: #2c3340;
        --mg-commerce-chip-text: #9aa3b2;
        --mg-commerce-accent-bg: #25304a;
    }
}
:is(.mga-box, .ranking-table-maker-root, .mg-article-references)[data-theme="dark"] {
    color-scheme: dark;
    --mg-commerce-bg: #1f2430;
    --mg-commerce-link: #8ab4f8;
    --mg-commerce-border: #39414f;
    --mg-commerce-text: #e7e9ee;
    --mg-commerce-text-muted: #9aa3b2;
    --mg-commerce-price: #f87171;
    --mg-commerce-meta: #c2c8d2;
    --mg-commerce-rank: #f0a37a;
    --mg-commerce-feature: #d2d7e0;
    --mg-commerce-chip-bg: #2c3340;
    --mg-commerce-chip-text: #9aa3b2;
    --mg-commerce-accent-bg: #25304a;
}

/* Product-box and ranking renderers own placement and density. This is the
   common purchase action, including the one used by Finder result cards. */
:is(.mga-box__btn, .cw-buy-btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-block-size: var(--mg-public-touch-size, 44px);
    border: var(--mga-shop-border, 0);
    border-radius: var(--mg-public-control-radius, 8px);
    color: var(--mga-shop-text, var(--mga-default-shop-text, #fff));
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

:is(.mga-box__btn, .cw-buy-btn):hover {
    transform: translateY(-1px);
}

:is(.mga-box__btn, .cw-buy-btn):focus-visible {
    outline: 3px solid var(--mg-public-focus-outer, #fff);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px var(--mg-public-focus-inner, #111);
}

@media (forced-colors: active) {
    :is(.mga-box__btn, .cw-buy-btn) {
        background: ButtonFace;
        color: ButtonText;
        border: 1px solid ButtonText;
    }

    :is(.mga-box__btn, .cw-buy-btn):focus-visible {
        outline-color: Highlight;
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    :is(.mga-box__btn, .cw-buy-btn):is(:hover, :active, :focus-visible) {
        transform: none;
    }
}

/* Native comparison tables share the scroll region and cell geometry. The
   consuming surface can set density and colors with these custom properties. */
.mg-commerce-table-scroll {
    max-inline-size: 100%;
    overflow: auto;
    border: 1px solid var(--mg-commerce-table-rule, var(--mg-commerce-border, #dfe2eb));
    border-radius: var(--mg-commerce-table-radius, 0.5rem);
    background: var(--mg-commerce-table-surface, var(--mg-commerce-bg, transparent));
}

.mg-commerce-table-scroll:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.mg-commerce-table-scroll > table {
    inline-size: 100%;
    min-inline-size: var(--mg-commerce-table-min, 0);
    margin: 0;
    border: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.mg-commerce-table-scroll > table :is(caption, th, td) {
    padding: var(--mg-commerce-table-padding, 0.5rem 0.75rem);
    border-block-end: 1px solid var(--mg-commerce-table-rule, var(--mg-commerce-border, #dfe2eb));
    text-align: start;
    overflow-wrap: anywhere;
}

.mg-commerce-table-scroll > table :is(caption, th) {
    background: var(--mg-commerce-table-header, var(--mg-commerce-chip-bg, #f0f0f1));
}

.mg-commerce-table-scroll > table tbody tr:last-child > :is(th, td) {
    border-block-end: 0;
}

.mg-commerce-table-scroll > table td {
    font-variant-numeric: tabular-nums;
}

.mg-commerce-table-scroll > table a {
    color: var(--mg-commerce-link, var(--mg-public-link, #1a5fb4));
    text-underline-offset: 0.15em;
}
