/* ============================================================
   Commission Rate Ladder — block styles
   All selectors scoped under .commission-rate-ladder. Values pull from the
   shared --clvr-* tokens (with defensive fallbacks). Font weight is capped at
   500 everywhere. Two background colors only: white surface + one subtle tint.
   Solid Clever blue is used for the slider (thumb + fill), links, the CTA, and
   the low-commission bar; other bars are a neutral hue.
   ============================================================ */

.commission-rate-ladder {
    /* Clever-blue CTA. The button background uses the dark accent (#2F65D6) so
       the white 17px/500 label clears WCAG AA (5.31:1); the vivid accent
       (#3878FF) only reaches 3.96:1, which fails for normal-weight text. The
       press/hover state deepens to the brand navy. These are the accent tokens
       from the LWC theme (var(--clvr-orange*) hold Clever blue on LWC). */
    --crl-cta-blue:      var(--clvr-orange-dark, #2F65D6);
    --crl-cta-blue-dark: var(--clvr-blue, #202E5B);
    /* Vivid Clever blue for the low-commission bar (non-text, no contrast gate). */
    --crl-bar-clever:    var(--clvr-orange, #3878FF);
    /* Neutral, non-interactive bar fill. */
    --crl-bar-neutral:    var(--clvr-text-secondary, #4b698b);
    /* Slider fill percentage, driven by JS. */
    --crl-slider-fill:    0%;
    --crl-slider-track:   #d8def0;

    container-type: inline-size;
    box-sizing: border-box;
    max-width: 680px;
    margin: 2rem auto;
    padding: var(--clvr-sp-6, 1.5rem);
    background: var(--clvr-bg, #ffffff);
    border: 1px solid var(--clvr-border-light, #e2e8f0);
    border-radius: var(--clvr-radius, 8px);
    box-shadow: var(--clvr-shadow, 0 1px 3px rgba(12, 20, 42, 0.08), 0 4px 12px rgba(12, 20, 42, 0.06));
    font-family: var(--clvr-font, "Inter", arial, sans-serif);
    color: var(--clvr-text, #22293b);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.commission-rate-ladder *,
.commission-rate-ladder *::before,
.commission-rate-ladder *::after {
    box-sizing: border-box;
}

/* Nothing heavier than 500 anywhere in the block. */
.commission-rate-ladder,
.commission-rate-ladder * {
    font-weight: 400;
}

/* --- Intro (text above the control) ------------------------------------- */
.commission-rate-ladder__intro {
    margin-bottom: var(--clvr-sp-6, 1.5rem);
}

.commission-rate-ladder__lede {
    margin: 0;
    font-size: 1.125rem;
    font-weight: var(--clvr-weight-medium, 500);
    color: var(--clvr-text, #22293b);
    line-height: 1.4;
}

.commission-rate-ladder__intro-text {
    margin: var(--clvr-sp-2, 0.5rem) 0 0;
    font-size: 0.9375rem;
    color: var(--clvr-text-secondary, #4b698b);
    line-height: 1.6;
}

/* --- Controls (tinted box: label + slider/input on one row) ------------- */
.commission-rate-ladder__controls {
    padding: var(--clvr-sp-4, 1rem);
    background: var(--clvr-bg-tint, #f0f5fa);
    border: 1px solid var(--clvr-border-light, #e2e8f0);
    border-radius: var(--clvr-radius, 8px);
}

.commission-rate-ladder__controls-label {
    display: block;
    margin-bottom: var(--clvr-sp-3, 0.75rem);
    font-size: 0.8125rem;
    font-weight: var(--clvr-weight-medium, 500);
    color: var(--clvr-text-secondary, #4b698b);
}

.commission-rate-ladder__controls-row {
    display: flex;
    align-items: center;
    gap: var(--clvr-sp-4, 1rem);
}

/* Boxed value, to the right of the slider (white on the tint surface). */
.commission-rate-ladder__price-input {
    flex: 0 0 auto;
    width: 132px;
    height: 46px;
    padding: 0 var(--clvr-sp-3, 0.75rem);
    text-align: center;
    font-family: inherit;
    font-size: 18px;
    font-weight: var(--clvr-weight-medium, 500);
    color: var(--clvr-text, #22293b);
    background: var(--clvr-bg, #ffffff);
    border: 1px solid var(--clvr-border, #bfcbde);
    border-radius: var(--clvr-radius-sm, 4px);
    font-variant-numeric: tabular-nums;
    transition: box-shadow var(--clvr-transition, 200ms ease),
                border-color var(--clvr-transition, 200ms ease);
}

.commission-rate-ladder__price-input:hover {
    box-shadow: var(--clvr-shadow, 0 1px 3px rgba(12, 20, 42, 0.08));
}

.commission-rate-ladder__price-input:focus {
    outline: 2px solid var(--clvr-orange, #3878ff);
    outline-offset: -2px;
    border-color: var(--clvr-orange, #3878ff);
    box-shadow: none;
}

/* --- Slider ------------------------------------------------------------- */
.commission-rate-ladder__slider {
    flex: 1 1 auto;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: var(--clvr-radius-pill, 9999px);
    outline: none;
    cursor: pointer;
    /* Blue fill up to the thumb, neutral track after. */
    background: linear-gradient(
        to right,
        var(--clvr-orange, #3878ff) 0,
        var(--clvr-orange, #3878ff) var(--crl-slider-fill),
        var(--crl-slider-track) var(--crl-slider-fill),
        var(--crl-slider-track) 100%
    );
}

.commission-rate-ladder__slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--clvr-orange, #3878ff);
    border: 3px solid #ffffff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(56, 120, 255, 0.35);
}

.commission-rate-ladder__slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--clvr-orange, #3878ff);
    border: 3px solid #ffffff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(56, 120, 255, 0.35);
}

.commission-rate-ladder__slider::-moz-range-track {
    height: 6px;
    border-radius: var(--clvr-radius-pill, 9999px);
    background: var(--crl-slider-track);
}

.commission-rate-ladder__slider::-moz-range-progress {
    height: 6px;
    border-radius: var(--clvr-radius-pill, 9999px);
    background: var(--clvr-orange, #3878ff);
}

.commission-rate-ladder__slider:focus-visible {
    outline: 2px solid var(--clvr-orange, #3878ff);
    outline-offset: 4px;
}

/* --- Theme defense (Bricks global input styling) ------------------------
   The Bricks theme applies global rules to every <input> — width:100%,
   background, border, radius, padding, native appearance. Those outweigh the
   single-class rules above, so on the live page the price input stretches to
   full width and the flex slider (flex:1; min-width:0) collapses to a dot with
   no visible track. Re-assert the layout and the slider's custom chrome with
   root-scoped !important, matching the pattern used by the cost-to-buy
   calculator block. The narrow-container rules below override the fixed width
   back to 100% (also root-scoped + !important) so the mobile stack still works. */
.commission-rate-ladder .commission-rate-ladder__price-input {
    flex: 0 0 auto !important;
    width: 132px !important;
    max-width: 132px !important;
    height: 46px !important;
    min-height: 0 !important;
    padding: 0 var(--clvr-sp-3, 0.75rem) !important;
    background: var(--clvr-bg, #ffffff) !important;
    border: 1px solid var(--clvr-border, #bfcbde) !important;
    border-radius: var(--clvr-radius-sm, 4px) !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.commission-rate-ladder .commission-rate-ladder__slider {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 6px !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: var(--clvr-radius-pill, 9999px) !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background: linear-gradient(
        to right,
        var(--clvr-orange, #3878ff) 0,
        var(--clvr-orange, #3878ff) var(--crl-slider-fill),
        var(--crl-slider-track) var(--crl-slider-fill),
        var(--crl-slider-track) 100%
    ) !important;
}

/* --- Hero --------------------------------------------------------------- */
.commission-rate-ladder__hero {
    margin-top: var(--clvr-sp-8, 2rem);
}

.commission-rate-ladder__hero-number {
    display: inline-block;
    padding: 2px 6px;
    margin: -2px -6px 0;
    font-family: var(--clvr-font-heading, "Rubik", "Inter", sans-serif);
    font-size: 40px;
    line-height: 1.1;
    font-weight: var(--clvr-weight-medium, 500);
    color: var(--clvr-text, #22293b);
    font-variant-numeric: tabular-nums;
    border-radius: var(--clvr-radius-sm, 4px);
}

.commission-rate-ladder__hero-caption {
    margin-top: var(--clvr-sp-2, 0.5rem);
    font-size: 0.9375rem;
    color: var(--clvr-text-secondary, #4b698b);
}

/* --- Ladder ------------------------------------------------------------- */
.commission-rate-ladder__ladder {
    margin-top: var(--clvr-sp-6, 1.5rem);
    padding-top: var(--clvr-sp-6, 1.5rem);
    border-top: 1px solid var(--clvr-border-light, #e2e8f0);
}

.commission-rate-ladder__row + .commission-rate-ladder__row {
    margin-top: var(--clvr-sp-6, 1.5rem);
}

.commission-rate-ladder__row-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--clvr-sp-3, 0.75rem);
}

.commission-rate-ladder__row-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1rem;
    font-weight: var(--clvr-weight-medium, 500);
    color: var(--clvr-text, #22293b);
    line-height: 1.35;
}

.commission-rate-ladder__dot {
    margin: 0 var(--clvr-sp-2, 0.5rem);
    color: var(--clvr-text-muted, #86a5c6);
}

.commission-rate-ladder__row-rate {
    font-weight: 400;
    color: var(--clvr-text-secondary, #4b698b);
    white-space: nowrap;
}

.commission-rate-ladder__row-amount {
    flex: 0 0 auto;
    font-size: 1.0625rem;
    font-weight: var(--clvr-weight-medium, 500);
    color: var(--clvr-text, #22293b);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    border-radius: var(--clvr-radius-sm, 4px);
}

.commission-rate-ladder__row-amount--clever {
    color: var(--crl-cta-blue);
}

.commission-rate-ladder__bar-track {
    margin-top: var(--clvr-sp-2, 0.5rem);
    width: 100%;
    height: 10px;
    background: var(--clvr-bg-tint, #f0f5fa);
    border-radius: var(--clvr-radius-pill, 9999px);
    overflow: hidden;
}

.commission-rate-ladder__bar {
    height: 100%;
    width: 0;
    background: var(--crl-bar-neutral);
    border-radius: var(--clvr-radius-pill, 9999px);
}

.commission-rate-ladder__bar--clever {
    background: var(--crl-bar-clever);
}

.commission-rate-ladder__subnote {
    margin-top: var(--clvr-sp-2, 0.5rem);
    font-size: 0.8125rem;
    color: var(--clvr-text-secondary, #4b698b);
    font-variant-numeric: tabular-nums;
}

/* --- Tooltip ------------------------------------------------------------ */
.commission-rate-ladder__tip {
    position: relative;
    display: inline;
}

.commission-rate-ladder__tip-trigger {
    display: inline;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    border-bottom: 1px dotted var(--clvr-text-muted, #86a5c6);
    cursor: help;
}

.commission-rate-ladder__tip-icon {
    margin-left: 3px;
    color: var(--clvr-text-muted, #86a5c6);
    vertical-align: -0.15em;
}

.commission-rate-ladder__tip-trigger:focus-visible {
    outline: 2px solid var(--clvr-orange, #3878ff);
    outline-offset: 2px;
    border-radius: 2px;
}

.commission-rate-ladder__tooltip {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    z-index: 20;
    width: max-content;
    max-width: min(260px, 78cqw);
    padding: var(--clvr-sp-3, 0.75rem);
    /* Stays within the block's two backgrounds (white surface + the one tint);
       a border + shadow makes the light popover read as a distinct floating
       layer. */
    background: var(--clvr-bg-tint, #f0f5fa);
    color: var(--clvr-text, #22293b);
    border: 1px solid var(--clvr-border, #bfcbde);
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.45;
    border-radius: var(--clvr-radius-sm, 4px);
    box-shadow: var(--clvr-shadow-lg, 0 12px 32px rgba(12, 20, 42, 0.10));
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity var(--clvr-transition, 200ms ease),
                visibility var(--clvr-transition, 200ms ease),
                transform var(--clvr-transition, 200ms ease);
    pointer-events: none;
}

/* Pointer: a border-colored triangle with the tint triangle layered on top. */
.commission-rate-ladder__tooltip::before,
.commission-rate-ladder__tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    width: 0;
    height: 0;
    border: 7px solid transparent;
    border-bottom: 0;
}

.commission-rate-ladder__tooltip::before {
    left: 17px;
    border-top-color: var(--clvr-border, #bfcbde);
}

.commission-rate-ladder__tooltip::after {
    left: 18px;
    border-width: 6px;
    border-bottom: 0;
    border-top-color: var(--clvr-bg-tint, #f0f5fa);
}

.commission-rate-ladder__tip-trigger:hover ~ .commission-rate-ladder__tooltip,
.commission-rate-ladder__tip-trigger:focus ~ .commission-rate-ladder__tooltip,
.commission-rate-ladder__tip-trigger:focus-visible ~ .commission-rate-ladder__tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* --- Takeaway ----------------------------------------------------------- */
.commission-rate-ladder__takeaway {
    margin-top: var(--clvr-sp-6, 1.5rem);
    padding: var(--clvr-sp-4, 1rem);
    background: var(--clvr-bg-tint, #f0f5fa);
    border: 1px solid var(--clvr-border-light, #e2e8f0);
    border-radius: var(--clvr-radius, 8px);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--clvr-text, #22293b);
}

.commission-rate-ladder__takeaway-figure {
    font-weight: var(--clvr-weight-medium, 500);
    font-variant-numeric: tabular-nums;
}

/* --- CTA (Clever blue) -------------------------------------------------- */
.commission-rate-ladder__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--clvr-sp-2, 0.5rem);
    width: 100%;
    margin-top: var(--clvr-sp-6, 1.5rem);
    min-height: 52px;
    padding: var(--clvr-sp-3, 0.75rem) var(--clvr-sp-6, 1.5rem);
    background: var(--crl-cta-blue);
    border-radius: var(--clvr-btn-radius, 4px);
    font-size: 1.0625rem;
    font-weight: var(--clvr-weight-medium, 500);
    text-decoration: none;
    transition: background var(--clvr-transition, 200ms ease),
                transform var(--clvr-transition, 200ms ease);
}

/* Defend the label color against the theme's global `a { color }`. */
.commission-rate-ladder a.commission-rate-ladder__cta,
.commission-rate-ladder a.commission-rate-ladder__cta:link,
.commission-rate-ladder a.commission-rate-ladder__cta:visited,
.commission-rate-ladder a.commission-rate-ladder__cta:hover,
.commission-rate-ladder a.commission-rate-ladder__cta:focus {
    color: #ffffff !important;
}

.commission-rate-ladder__cta:hover {
    background: var(--crl-cta-blue-dark);
    transform: translateY(-1px);
}

.commission-rate-ladder__cta:focus-visible {
    outline: 3px solid var(--crl-cta-blue-dark);
    outline-offset: 3px;
}

.commission-rate-ladder__cta-icon {
    flex: 0 0 auto;
    transition: transform var(--clvr-transition, 200ms ease);
}

.commission-rate-ladder__cta:hover .commission-rate-ladder__cta-icon {
    transform: translateX(3px);
}

/* --- Reset button ------------------------------------------------------- */
.commission-rate-ladder__reset-row {
    margin-top: var(--clvr-sp-3, 0.75rem);
    text-align: right;
}

.commission-rate-ladder__reset {
    padding: var(--clvr-sp-1, 0.25rem) var(--clvr-sp-2, 0.5rem);
    background: none;
    border: none;
    color: var(--clvr-link, #3878ff);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: var(--clvr-radius-sm, 4px);
}

.commission-rate-ladder__reset:hover {
    text-decoration: underline;
    color: var(--clvr-link-hover, #598eff);
}

.commission-rate-ladder__reset:focus-visible {
    outline: 2px solid var(--clvr-orange, #3878ff);
    outline-offset: 2px;
}

/* --- Methodology -------------------------------------------------------- */
.commission-rate-ladder__methodology {
    margin-top: var(--clvr-sp-4, 1rem);
    font-size: 13px;
    line-height: 1.6;
    color: var(--clvr-text-muted, #86a5c6);
}

.commission-rate-ladder__methodology p {
    margin: 0;
}

.commission-rate-ladder__methodology a {
    color: var(--clvr-link, #3878ff);
}

/* --- Flash highlight on value change ------------------------------------ */
@keyframes crl-flash-accent {
    0%   { background-color: rgba(56, 120, 255, 0.18); }
    100% { background-color: transparent; }
}

@keyframes crl-flash-clever {
    0%   { background-color: rgba(56, 120, 255, 0.18); }
    100% { background-color: transparent; }
}

.commission-rate-ladder__hero-number.is-flashing {
    animation: crl-flash-accent 750ms ease-out;
}

.commission-rate-ladder__row-amount--clever.is-flashing {
    animation: crl-flash-clever 750ms ease-out;
}

/* Non-essential motion: bar-width easing, gated behind reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
    .commission-rate-ladder__bar {
        transition: width 320ms ease;
    }
}

@media (prefers-reduced-motion: reduce) {
    .commission-rate-ladder__hero-number.is-flashing,
    .commission-rate-ladder__row-amount--clever.is-flashing {
        animation: none;
    }
    .commission-rate-ladder__cta,
    .commission-rate-ladder__cta-icon,
    .commission-rate-ladder__price-input {
        transition: none;
    }
}

/* --- Narrow container: tighten padding + drop the hero to mobile size ---- */
@container (max-width: 460px) {
    .commission-rate-ladder {
        padding: var(--clvr-sp-4, 1rem);
    }
    .commission-rate-ladder__hero-number {
        font-size: 34px;
    }
}

/* Very narrow: stack the value under the slider so neither gets cramped. */
@container (max-width: 380px) {
    .commission-rate-ladder__controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--clvr-sp-3, 0.75rem);
    }
    .commission-rate-ladder .commission-rate-ladder__price-input {
        width: 100% !important;
        max-width: none !important;
    }
}

/* Fallback for engines without container-query support (viewport-based). */
@supports not (container-type: inline-size) {
    @media (max-width: 520px) {
        .commission-rate-ladder__hero-number {
            font-size: 34px;
        }
    }
    @media (max-width: 420px) {
        .commission-rate-ladder__controls-row {
            flex-direction: column;
            align-items: stretch;
            gap: var(--clvr-sp-3, 0.75rem);
        }
        .commission-rate-ladder .commission-rate-ladder__price-input {
            width: 100% !important;
            max-width: none !important;
        }
    }
}
