/* Coastal Cards Sync — storefront badges (finish pill, condition pill), mana symbols, the
   [cc_condition_guide] shortcode and the cc_card_legalities() table.
   Theme-neutral for the badges and the guide (colours inherit via currentColor); only the
   condition tints (NM → DMG, shared by the condition badge and the [cc_lowest_price] pill)
   and the legality status icons carry fixed colours. */

.cc-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.cc-badge {
    display: inline-block;
    border: 1px solid currentColor;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: .8em;
    line-height: 1.4;
    letter-spacing: .02em;
    color: inherit;
    background: transparent;
    white-space: nowrap;
}

@supports (color: color-mix(in srgb, currentColor 30%, transparent)) {
    .cc-badge {
        border-color: color-mix(in srgb, currentColor 30%, transparent);
        background: color-mix(in srgb, currentColor 8%, transparent);
    }
}

.cc-badge--foil {
    background-image: linear-gradient(
        120deg,
        rgba(255, 120, 120, .18),
        rgba(255, 220, 120, .18),
        rgba(120, 255, 170, .18),
        rgba(120, 190, 255, .18),
        rgba(220, 120, 255, .18)
    );
}

.cc-badge--etched {
    background-image: linear-gradient(
        120deg,
        rgba(200, 200, 200, .22),
        rgba(255, 255, 255, .06),
        rgba(200, 200, 200, .22)
    );
}

.cc-condition-guide {
    margin-top: 12px;
    font-size: .85em;
    opacity: .85;
    color: inherit;
}

/* The guide is a <details>; the title is its <summary> (collapsed by default). */
.cc-condition-guide__title {
    margin: 0 0 4px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.cc-condition-guide__title::-webkit-details-marker {
    display: none;
}

.cc-condition-guide__title::before {
    content: "\25B8";
    display: inline-block;
    width: 1em;
    transition: transform .15s ease;
}

.cc-condition-guide[open] > .cc-condition-guide__title::before {
    transform: rotate(90deg);
}

.cc-condition-guide[open] > .cc-condition-guide__title {
    margin-bottom: 8px;
}

.cc-condition-guide__list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    margin: 0;
}

.cc-condition-guide__list > div {
    display: contents;
}

.cc-condition-guide__list dt {
    font-weight: 600;
    white-space: nowrap;
}

.cc-condition-guide__list dd {
    margin: 0;
}

/* Legality table (cc_card_legalities / Bricks {echo:cc_card_legalities()}): one pill per
   format, name left, ✓ / ✕ right, as in the client's sample. */
.cc-legalities {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.cc-legalities__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: .85em;
    line-height: 1.3;
    color: inherit;
    background: rgba(128, 128, 128, .1);
}

.cc-legalities__status {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: #d33;
}

.cc-legalities__item--legal .cc-legalities__status {
    background: #2a9d4b;
}

.cc-legalities__item--restricted .cc-legalities__status {
    background: #d9a400;
    color: #222; /* white on amber is too faint for a 12 px glyph */
}

/* [cc_conditions] / cc_conditions(): one row per in-stock condition variant with our own
   Add to cart / Buy now buttons (replaces the FluentCart Buy section in the Bricks single
   template). Layout only; the buttons inherit the theme's colours so Bricks CSS can restyle
   `.cc-conditions__add` / `.cc-conditions__buy` without fighting us. */
.cc-conditions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 0;
}

.cc-conditions__row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "condition price actions" "condition stock actions";
    align-items: center;
    column-gap: 16px;
    row-gap: 2px;
    padding: 10px 12px;
    border: 1px solid rgba(128, 128, 128, .25);
    border-radius: 8px;
}

.cc-conditions__condition { grid-area: condition; }
.cc-conditions__price { grid-area: price; font-weight: 600; }
.cc-conditions__stock { grid-area: stock; font-size: .85em; opacity: .75; }
.cc-conditions__actions {
    grid-area: actions;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.cc-conditions__row--sold-out {
    opacity: .55;
}

.cc-conditions__add,
.cc-conditions__buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 1px solid currentColor;
    border-radius: 6px;
    font: inherit;
    font-size: .9em;
    line-height: 1.2;
    color: inherit;
    background: transparent;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

/* FluentCart's cart script toggles fct-loading on the button while the add runs. */
.cc-conditions__add.fct-loading {
    opacity: .6;
    pointer-events: none;
}

/* Quantity stepper (− [n] +) in front of the buttons; its value drives both of them
   (assets/frontend/conditions.js). Inherits the theme font and colour like the buttons.
   Hidden until conditions.js adds `cc-conditions-js` to <html>: without the script (delayed by
   an optimiser, blocked by CSP, failed to load) the buttons add / buy 1, so no stepper shows. */
.cc-conditions__qty {
    display: none;
}

.cc-conditions-js .cc-conditions__qty {
    display: inline-flex;
    align-items: stretch;
    flex: none;
    border: 1px solid currentColor;
    border-radius: 6px;
    font-size: .9em;
    line-height: 1.2;
}

.cc-conditions__qty-dec,
.cc-conditions__qty-inc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    font: inherit;
    color: inherit;
    background: transparent;
    cursor: pointer;
}

.cc-conditions__qty-dec:disabled,
.cc-conditions__qty-inc:disabled {
    opacity: .35;
    cursor: default;
}

.cc-conditions__qty-input {
    width: 3em;
    min-height: 36px;
    margin: 0;
    padding: 0 2px;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: center;
    background: transparent;
    -moz-appearance: textfield;
    appearance: textfield;
}

.cc-conditions__qty-input::-webkit-inner-spin-button,
.cc-conditions__qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cc-conditions__qty-dec:focus-visible,
.cc-conditions__qty-inc:focus-visible,
.cc-conditions__qty-input:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.cc-conditions__empty {
    margin: 0;
    font-size: .9em;
    opacity: .75;
}

@media (max-width: 480px) {
    .cc-conditions__row {
        grid-template-columns: auto 1fr;
        grid-template-areas: "condition price" "condition stock" "actions actions";
    }

    .cc-conditions__actions {
        justify-content: stretch;
    }

    .cc-conditions__add,
    .cc-conditions__buy {
        flex: 1;
    }

    .cc-conditions__qty-dec,
    .cc-conditions__qty-inc {
        min-width: 44px;
        min-height: 44px;
    }
}

/* [cc_lowest_price] / cc_lowest_price(): the lowest in-stock price with its condition as a
   small pill — "$35.54 [LP]" — on the shop-grid cards (feature request lowest-stocked-price).
   The amount inherits the card's text colour; only the pill carries a per-condition tint
   (translucent, so it reads on light and dark cards); the tints are the shared condition
   colours defined just below this block. */
.cc-lowest-price {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    line-height: 1.2;
}

.cc-lowest-price__prefix {
    font-size: .85em;
    opacity: .7;
}

.cc-lowest-price__amount {
    font-weight: 700;
}

.cc-lowest-price__condition {
    --cc-cond-border: rgba(128, 128, 128, .5);
    --cc-cond-bg: rgba(128, 128, 128, .1);
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--cc-cond-border);
    border-radius: 4px;
    font-size: .7em;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: .04em;
    color: inherit;
    background: var(--cc-cond-bg);
    white-space: nowrap;
}

/* Shared condition colours, NM → DMG: one pair of custom properties per condition, read by
   both the [cc_lowest_price] pill (`.cc-lowest-price__condition`, above) and the condition
   badge (`.cc-badge--condition`, printed by [cc_conditions] rows and in FluentCart's own
   variant picker). Override `--cc-cond-border` / `--cc-cond-bg` on these selectors (e.g.
   `.cc-badge--condition.cc-badge--nm`) to recolour both at once. These rules must stay after
   `.cc-lowest-price__condition`, whose grey defaults they replace by source order. */
.cc-lowest-price__condition--nm,
.cc-badge--condition.cc-badge--nm  { --cc-cond-border: rgba(20, 150, 140, .6);  --cc-cond-bg: rgba(20, 150, 140, .1); }
.cc-lowest-price__condition--lp,
.cc-badge--condition.cc-badge--lp  { --cc-cond-border: rgba(110, 180, 60, .65); --cc-cond-bg: rgba(110, 180, 60, .12); }
.cc-lowest-price__condition--mp,
.cc-badge--condition.cc-badge--mp  { --cc-cond-border: rgba(220, 170, 40, .7);  --cc-cond-bg: rgba(220, 170, 40, .12); }
.cc-lowest-price__condition--hp,
.cc-badge--condition.cc-badge--hp  { --cc-cond-border: rgba(230, 120, 50, .7);  --cc-cond-bg: rgba(230, 120, 50, .12); }
.cc-lowest-price__condition--dmg,
.cc-badge--condition.cc-badge--dmg { --cc-cond-border: rgba(210, 60, 60, .65);  --cc-cond-bg: rgba(210, 60, 60, .12); }

/* The coloured condition badge reads the properties above; its shape stays `.cc-badge`'s.
   Two classes (0,2,0) beat both `.cc-badge` and the `@supports (color-mix)` `.cc-badge` rule
   at the top of the file (0,1,0 — @supports adds no specificity), and this rule also comes
   later in the file. Badges without one of these classes keep the currentColor tint. */
.cc-badge--condition.cc-badge--nm,
.cc-badge--condition.cc-badge--lp,
.cc-badge--condition.cc-badge--mp,
.cc-badge--condition.cc-badge--hp,
.cc-badge--condition.cc-badge--dmg {
    border-color: var(--cc-cond-border);
    background: var(--cc-cond-bg);
}

.cc-lowest-price__empty {
    font-size: .9em;
    opacity: .7;
}

/* Mana / card symbols (ManaSymbols, for the {cc_card:mana_cost} and {cc_card:oracle_text}
   Bricks tags): 1em SVGs sitting on the text baseline. Each Oracle ability is a block span
   (valid inside a heading or <p>); parenthesised reminder text is italic via <i>. */
.cc-mana {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    margin: 0 0.05em;
}

.cc-oracle__ability {
    display: block;
}

.cc-oracle__ability + .cc-oracle__ability {
    margin-top: .5em;
}
