/*
 * Loyalty styles — covers:
 *   1. .dealer-loyalty-strip   — dashboard tier strip (title + bar + 4 pills)
 *   2. .dealer-loyalty-page    — public /loyalty/ rules page
 *
 * Loaded on:
 *   - all /my-account/ pages (strip on the dashboard)
 *   - the /loyalty/ page (rules + tier table)
 *
 * Uses global tokens from DESIGN-TOKENS.md for shared color and typography.
 * The dashboard strip uses a plain black-and-white progress baseline.
 */

/* =========================================================================
 * 1. Dashboard tier strip
 * -------------------------------------------------------------------------
 * Lives inside `.dealer-account__content` (the cabinet card). Every rule
 * is scoped with `body.woocommerce-account` so it wins over Storefront's
 * `.woocommerce-MyAccount-content h2 { font-size: 2em }` rule
 * (specificity 0,1,1) without resorting to `!important`. The strip is a
 * regular dashboard section — same heading typography and same vertical
 * rhythm as the other dashboard blocks (orders / address / profile).
 * Outer spacing comes from the dashboard parent's `gap` — the strip
 * itself adds no `margin-bottom`.
 * ========================================================================= */

body.woocommerce-account .dealer-loyalty-strip {
    display: flex;
    align-items: top;
    justify-content: space-between;
    gap: 50px;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    color: var(--color-black);
}

body.woocommerce-account .dealer-loyalty-strip__head {
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

body.woocommerce-account .dealer-loyalty-strip__title {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--color-black);
}

body.woocommerce-account .dealer-loyalty-strip__more {
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    line-height: 1.3;
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.woocommerce-account .dealer-loyalty-strip__more:hover,
body.woocommerce-account .dealer-loyalty-strip__more:focus {
    color: var(--color-header);
}

body.woocommerce-account .dealer-loyalty-strip__chart {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 60%;
}

/* Bar — outer track */
body.woocommerce-account .dealer-loyalty-strip__bar {
    position: relative;
    width: 100%;
    height: 28px;
    border: var(--border-width-thin) solid rgba(0, 0, 0, 0.28);
    border-radius: 999px;
    overflow: hidden;
}

/* Filled progress from 0% to the maximum 20% loyalty tier. */
body.woocommerce-account .dealer-loyalty-strip__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--dealer-loyalty-fill, 0%);
    height: 100%;
    background: var(--color-black);
    border-radius: 999px;
    transition: width 0.4s ease;
}

body.woocommerce-account .dealer-loyalty-strip__label {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: clamp(24px, var(--dealer-loyalty-label, 0%), calc(100% - 30px));
    transform: translate(-50%, -50%);
    color: var(--dealer-loyalty-label-color, var(--color-black));
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-small);
    line-height: 1;
    white-space: nowrap;
}

/* Pills row beneath the bar */
body.woocommerce-account .dealer-loyalty-strip__pills {
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    width: 100%;
}

body.woocommerce-account .dealer-loyalty-strip__pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    padding: 5px 10px;
    border: var(--border-width-thin) solid var(--color-black);
    border-radius: 999px;
    background: var(--color-white);
    color: var(--color-black);
    font-size: var(--font-size-micro);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    text-align: center;
}

body.woocommerce-account .dealer-loyalty-strip__pill--black {
    min-width: 88px;
}

body.woocommerce-account .dealer-loyalty-strip__pill--active {
    background: var(--color-black);
    color: var(--color-white);
}

/* =========================================================================
 * 2. /loyalty/ rules page
 * ========================================================================= */

.dealer-loyalty-page {
    padding: 40px 0 80px;
    font-family: var(--font-family);
    color: var(--color-black);
}

.dealer-loyalty-page__head {
    margin-bottom: 40px;
    text-align: center;
}

.dealer-loyalty-page__title {
    margin: 0 0 12px;
    font-size: 32px;
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
}

.dealer-loyalty-page__lede {
    margin: 0 auto;
    max-width: 720px;
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-light);
    line-height: 1.5;
    color: var(--color-brown-dark);
}

.dealer-loyalty-page__subtitle {
    margin: 0 0 16px;
    font-size: var(--font-size-h2);
    font-weight: var(--font-weight-medium);
    color: var(--color-header);
}

.dealer-loyalty-page__tiers,
.dealer-loyalty-page__rules {
    margin: 0 auto 40px;
    max-width: 720px;
}

.dealer-loyalty-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border: var(--border-width-thin) solid rgba(0, 0, 0, 0.10);
    border-radius: 8px;
    overflow: hidden;
    font-size: 15px;
}

.dealer-loyalty-table th,
.dealer-loyalty-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: var(--border-width-thin) solid rgba(0, 0, 0, 0.08);
}

.dealer-loyalty-table thead th {
    background: var(--color-black);
    font-weight: var(--font-weight-semibold);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-white);
}

.dealer-loyalty-table tbody th {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
}

.dealer-loyalty-table tbody tr:last-child th,
.dealer-loyalty-table tbody tr:last-child td {
    border-bottom: 0;
}

.dealer-loyalty-table tbody tr:hover {
    background: var(--color-beige-pale);
}

.dealer-loyalty-rules {
    margin: 0;
    padding: 0 0 0 20px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-header);
}

.dealer-loyalty-rules li {
    margin: 0 0 10px;
}

.dealer-loyalty-rules li:last-child {
    margin: 0;
}

/* Bottom CTAs: primary "go shopping" + secondary "cabinet / my discount".
 * The cabinet button opens the shared login popup for guests (header
 * pattern) and navigates to the dashboard for logged-in customers. */
.dealer-loyalty-page__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin: 8px auto 0;
    max-width: 720px;
}

.dealer-loyalty-page__action {
    flex: 0 1 auto;
    min-width: 240px;
}

/* =========================================================================
 * 3. Mobile (≤768px)
 * ========================================================================= */

@media (max-width: 768px) {
    body.woocommerce-account .dealer-loyalty-strip {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    body.woocommerce-account .dealer-loyalty-strip__title {
        font-size: 14px;
    }
    body.woocommerce-account .dealer-loyalty-strip__chart {
        width: 100%;
        max-width: none;
    }
    body.woocommerce-account .dealer-loyalty-strip__bar {
        height: 22px;
    }
    body.woocommerce-account .dealer-loyalty-strip__pills {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-start;
    }
    body.woocommerce-account .dealer-loyalty-strip__pill {
        min-width: 0;
        padding: 4px 12px;
        font-size: var(--font-size-micro);
    }
    .dealer-loyalty-page__title {
        font-size: var(--font-size-h1);
    }
    .dealer-loyalty-table th,
    .dealer-loyalty-table td {
        padding: 12px 14px;
    }
    .dealer-loyalty-table {
        font-size: var(--font-size-small);
    }
    .dealer-loyalty-page__actions {
        flex-direction: column;
    }
    .dealer-loyalty-page__action {
        width: 100%;
        min-width: 0;
    }
}
