/* Rebate · item-page hint. Floating liquid-glass pill, theme-agnostic.
   Armour: every rule is rooted at #rebate-hint (1,1,0); component nodes carry .rbh-ui and start from
   all:revert so theme globals (a, button, span, p …) cannot leak in. Scheme comes from hint.js. */

#rebate-hint {
    all: initial;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 125;
    display: block;
    width: 0;
    height: 0;

    --rbh-left: max(12px, calc(env(safe-area-inset-left, 0px) + 8px));
    --rbh-bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 10px));
    --rbh-max: min(360px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    --rbh-tuck: 48px;

    --rbh-spring: cubic-bezier(.34, 1.36, .64, 1);
    --rbh-spring-soft: cubic-bezier(.22, 1.1, .36, 1);
    --rbh-ease-out: cubic-bezier(.16, 1, .3, 1);

    --rbh-ink: #1d1d1f;
    --rbh-ink-2: #4d4e56;
    --rbh-accent-ink: #a3360a;
    --rbh-surface: rgb(255 255 255 / .84);
    --rbh-surface-solid: #fbfbfd;
    --rbh-gloss: rgb(255 255 255 / .55);
    --rbh-fill: rgb(120 120 128 / .13);
    --rbh-fill-2: rgb(120 120 128 / .22);
    --rbh-rim-hi: rgb(255 255 255 / .95);
    --rbh-rim-lo: rgb(255 255 255 / .18);
    --rbh-hair: rgb(0 0 0 / .07);
    --rbh-badge-ink: #7a3300;
    --rbh-badge-bg: rgb(255 159 10 / .2);
    --rbh-focus: #ff6a3d;
    --rbh-shadow:
        0 18px 38px -16px rgb(20 20 40 / .4),
        0 4px 12px -4px rgb(20 20 40 / .14),
        0 0 0 .5px rgb(0 0 0 / .05);

    --rbh-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "HarmonyOS Sans SC",
        "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, "Segoe UI", Roboto, sans-serif;

    font-family: var(--rbh-font);
    font-size: 14px;
    line-height: 1.35;
    font-weight: 400;
    color: var(--rbh-ink);
    color-scheme: light;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

@supports (animation-timing-function: linear(0, 1)) {
    #rebate-hint {
        --rbh-spring: linear(0, .0274, .0981, .1972, .312, .4324, .5506, .6611, .7601, .8456, .9166, .9732, 1.0164, 1.0473, 1.0676, 1.079, 1.0834, 1.0822, 1.0771, 1.0693, 1.0599, 1.0499, 1.04, 1.0305, 1.022, 1.0146, 1.0083, 1.0033, .9994, .9966, .9947, .9936, .9931, .9931, .9934, .994, .9948, .9956, .9965, .9973, 1);
        --rbh-spring-soft: linear(0, .0177, .0637, .1289, .2061, .2895, .3746, .4581, .5376, .6116, .6789, .7392, .7922, .8381, .8773, .9101, .9373, .9593, .9769, .9906, 1.0009, 1.0085, 1.0138, 1.0172, 1.0191, 1.0199, 1.0198, 1.019, 1.0179, 1.0164, 1.0148, 1.0131, 1.0114, 1.0098, 1.0082, 1.0069, 1.0056, 1.0045, 1.0035, 1.0027, 1);
    }
}

#rebate-hint[data-scheme="dark"] {
    --rbh-ink: #f5f5f7;
    --rbh-ink-2: #c3c4cc;
    --rbh-accent-ink: #ffab70;
    --rbh-surface: rgb(38 38 46 / .82);
    --rbh-surface-solid: #26262e;
    --rbh-gloss: rgb(255 255 255 / .07);
    --rbh-fill: rgb(150 150 160 / .2);
    --rbh-fill-2: rgb(150 150 160 / .32);
    --rbh-rim-hi: rgb(255 255 255 / .42);
    --rbh-rim-lo: rgb(255 255 255 / .04);
    --rbh-hair: rgb(255 255 255 / .1);
    --rbh-badge-ink: #ffd08a;
    --rbh-badge-bg: rgb(255 159 10 / .2);
    --rbh-focus: #ff9a6b;
    --rbh-shadow:
        0 18px 40px -14px rgb(0 0 0 / .72),
        0 4px 12px -4px rgb(0 0 0 / .4),
        0 0 0 .5px rgb(255 255 255 / .06);
    color-scheme: dark;
}

#rebate-hint:lang(zh-TW),
#rebate-hint:lang(zh-HK),
#rebate-hint:lang(zh-Hant) {
    --rbh-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Microsoft JhengHei UI",
        "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

#rebate-hint:lang(ja) {
    --rbh-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
        "Yu Gothic UI", "Meiryo UI", "Noto Sans JP", system-ui, sans-serif;
}

#rebate-hint:lang(ko) {
    --rbh-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Malgun Gothic",
        "Noto Sans KR", system-ui, sans-serif;
}

/* ------------------------------------------------------------------ reset */

#rebate-hint .rbh-ui {
    all: revert;
    box-sizing: border-box;
}

#rebate-hint *::before,
#rebate-hint *::after {
    box-sizing: border-box;
}

#rebate-hint [hidden] {
    display: none !important;
}

#rebate-hint svg {
    display: block;
    flex: none;
    overflow: visible;
    pointer-events: none;
}

/* ------------------------------------------------------------------ pill */

#rebate-hint .rbh-pill {
    position: fixed;
    left: var(--rbh-left);
    bottom: var(--rbh-bottom);
    isolation: isolate;
    display: flex;
    align-items: center;
    width: var(--rbh-w, auto);
    height: var(--rbh-h, auto);
    min-height: var(--rbh-tuck);
    max-width: var(--rbh-max);
    margin: 0;
    padding: 6px;
    border: 0;
    border-radius: 24px;
    overflow: hidden;
    background-color: var(--rbh-surface);
    background-image: linear-gradient(180deg, var(--rbh-gloss), transparent 60%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    box-shadow: var(--rbh-shadow);
    color: var(--rbh-ink);
    font: inherit;
    text-align: start;
    transform-origin: 24px 100%;
    opacity: 1;
    visibility: visible;
    translate: 0 0;
    scale: 1;
    transition:
        width .56s var(--rbh-spring-soft),
        height .56s var(--rbh-spring-soft),
        translate .6s var(--rbh-spring),
        scale .5s var(--rbh-spring),
        opacity .3s var(--rbh-ease-out),
        bottom .5s var(--rbh-ease-out),
        background-color .4s var(--rbh-ease-out),
        visibility 0s linear 0s;
}

/* specular rim */
#rebate-hint .rbh-pill::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(150deg, var(--rbh-rim-hi), var(--rbh-rim-lo) 30%, var(--rbh-rim-lo) 70%, var(--rbh-rim-hi));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    pointer-events: none;
}

#rebate-hint[data-state="hidden"] .rbh-pill {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    translate: -14px 10px;
    scale: .92;
    transition:
        translate .32s var(--rbh-ease-out),
        scale .32s var(--rbh-ease-out),
        opacity .22s var(--rbh-ease-out),
        visibility 0s linear .32s;
}

#rebate-hint[data-state="shown"][data-arrive] .rbh-pill {
    animation: rbh-arrive .72s var(--rbh-spring) both;
}

@keyframes rbh-arrive {
    from {
        opacity: 0;
        translate: -18px 14px;
        scale: .86;
    }

    40% {
        opacity: 1;
    }
}

/* main area */
#rebate-hint .rbh-main {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 11px;
    min-width: 0;
    margin: 0;
    padding: 0 6px 0 0;
    border-radius: 18px;
    color: inherit;
    text-decoration: none;
    cursor: default;
    outline: none;
    transition: background-color .2s var(--rbh-ease-out);
}

#rebate-hint a.rbh-main {
    cursor: pointer;
}

#rebate-hint a.rbh-main:hover {
    background-color: var(--rbh-fill);
}

#rebate-hint a.rbh-main:focus-visible {
    box-shadow: 0 0 0 2.5px var(--rbh-focus);
}

#rebate-hint .rbh-icon {
    position: relative;
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(140deg, #ffb340, #ff6a3d 55%, #ff3d71);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -1px 0 rgb(0 0 0 / .08), 0 6px 14px -6px rgb(255 90 60 / .75);
}

#rebate-hint .rbh-icon svg {
    width: 21px;
    height: 21px;
}

#rebate-hint .rbh-text {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 1px;
    width: var(--rbh-text-w, auto);
    min-width: 0;
    margin: 0;
    padding: 2px 0;
    transition: opacity .28s var(--rbh-ease-out) .08s;
}

#rebate-hint .rbh-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 7px;
    margin: 0;
    font-size: 14.5px;
    font-weight: 650;
    line-height: 1.3;
    letter-spacing: -.005em;
    color: var(--rbh-ink);
    overflow-wrap: anywhere;
}

#rebate-hint .rbh-badge {
    display: inline-flex;
    align-items: center;
    height: 18px;
    margin: 0;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--rbh-badge-bg);
    color: var(--rbh-badge-ink);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
}

#rebate-hint .rbh-sub {
    display: block;
    margin: 0;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--rbh-ink-2);
    overflow-wrap: anywhere;
}

#rebate-hint .rbh-cta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: 1px 0 0;
    font-size: 12.5px;
    font-weight: 650;
    line-height: 1.35;
    color: var(--rbh-accent-ink);
}

#rebate-hint .rbh-cta svg,
#rebate-hint .rbh-chev svg {
    width: 14px;
    height: 14px;
}

#rebate-hint .rbh-chev {
    display: grid;
    flex: none;
    place-items: center;
    width: 18px;
    height: 18px;
    margin: 0 0 0 -2px;
    color: var(--rbh-ink-2);
    transition: opacity .2s var(--rbh-ease-out);
}

/* close */
#rebate-hint .rbh-close {
    position: relative;
    display: grid;
    flex: none;
    place-items: center;
    align-self: flex-start;
    width: 28px;
    height: 28px;
    margin: 0 0 0 2px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--rbh-ink-2);
    cursor: pointer;
    outline: none;
    transition: background-color .2s var(--rbh-ease-out), color .2s var(--rbh-ease-out), opacity .2s var(--rbh-ease-out);
}

#rebate-hint .rbh-close::after {
    content: "";
    position: absolute;
    inset: -7px;
    border-radius: 50%;
}

#rebate-hint .rbh-close svg {
    width: 15px;
    height: 15px;
}

#rebate-hint .rbh-close:hover {
    background: var(--rbh-fill);
    color: var(--rbh-ink);
}

#rebate-hint .rbh-close:focus-visible {
    box-shadow: 0 0 0 2.5px var(--rbh-focus);
}

/* peek (only while tucked) */
#rebate-hint .rbh-peek {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: transparent;
    cursor: pointer;
    outline: none;
}

#rebate-hint .rbh-peek:focus-visible {
    box-shadow: inset 0 0 0 2.5px var(--rbh-focus);
}

/* ------------------------------------------------------------------ tucked */

#rebate-hint[data-state="tucked"] .rbh-pill {
    width: var(--rbh-tuck);
    height: var(--rbh-tuck);
    translate: calc(-20px - var(--rbh-left)) 0;
    opacity: .94;
    scale: .96;
}

#rebate-hint[data-state="tucked"] .rbh-text,
#rebate-hint[data-state="tucked"] .rbh-close,
#rebate-hint[data-state="tucked"] .rbh-chev {
    opacity: 0;
    transition-delay: 0s;
    transition-duration: .14s;
}

#rebate-hint[data-state="tucked"] .rbh-pill:hover,
#rebate-hint[data-state="tucked"] .rbh-pill:focus-within {
    translate: 0 0;
    opacity: 1;
    scale: 1;
}

/* the tucked edge sits on a theme control: let taps through */
#rebate-hint[data-state="tucked"][data-yield] .rbh-pill {
    opacity: .38;
    pointer-events: none;
}

#rebate-hint[data-nudge] .rbh-icon {
    animation: rbh-nudge 1.6s var(--rbh-ease-out) .35s both;
}

@keyframes rbh-nudge {
    0%, 100% {
        box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), 0 6px 14px -6px rgb(255 90 60 / .75), 0 0 0 0 rgb(255 106 61 / .5);
    }

    18% {
        transform: rotate(-14deg) scale(1.08);
    }

    36% {
        transform: rotate(10deg) scale(1.08);
    }

    52% {
        transform: rotate(0) scale(1);
    }

    60% {
        box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), 0 6px 14px -6px rgb(255 90 60 / .75), 0 0 0 9px rgb(255 106 61 / 0);
    }
}

@media (hover: none) {
    #rebate-hint a.rbh-main:hover {
        background-color: transparent;
    }

    #rebate-hint[data-state="tucked"] .rbh-pill:hover {
        translate: calc(-20px - var(--rbh-left)) 0;
        scale: .96;
        opacity: .94;
    }
}

/* measuring pass: natural size, no animation */
#rebate-hint[data-measure] .rbh-pill {
    width: auto !important;
    height: auto !important;
    translate: none !important;
    scale: none !important;
    transition: none !important;
    animation: none !important;
}

#rebate-hint[data-measure] .rbh-text {
    flex: 0 1 auto !important;
    width: auto !important;
}

/* content swap between items */
#rebate-hint[data-swap] .rbh-text {
    animation: rbh-swap .42s var(--rbh-ease-out) both;
}

@keyframes rbh-swap {
    from {
        opacity: 0;
        translate: 0 4px;
    }
}

/* ------------------------------------------------------------------ preferences */

@media (prefers-reduced-motion: reduce) {
    #rebate-hint .rbh-pill,
    #rebate-hint[data-state="hidden"] .rbh-pill {
        transition: opacity .16s linear, visibility 0s linear .16s, background-color .2s linear;
        translate: 0 0;
        scale: 1;
    }

    #rebate-hint[data-state="tucked"] .rbh-pill {
        translate: calc(-20px - var(--rbh-left)) 0;
        scale: 1;
    }

    #rebate-hint[data-state="tucked"] .rbh-pill:hover,
    #rebate-hint[data-state="tucked"] .rbh-pill:focus-within {
        translate: 0 0;
    }

    #rebate-hint[data-state="shown"][data-arrive] .rbh-pill {
        animation: rbh-fade .2s linear both;
    }

    #rebate-hint[data-swap] .rbh-text {
        animation: none;
    }

    #rebate-hint[data-nudge] .rbh-icon {
        animation: none;
    }

    #rebate-hint .rbh-text,
    #rebate-hint .rbh-close,
    #rebate-hint .rbh-chev {
        transition: opacity .12s linear;
    }
}

@keyframes rbh-fade {
    from {
        opacity: 0;
    }
}

@media (prefers-reduced-transparency: reduce) {
    #rebate-hint .rbh-pill {
        background-color: var(--rbh-surface-solid);
        background-image: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    #rebate-hint .rbh-pill {
        background-color: var(--rbh-surface-solid);
    }
}

@media (prefers-contrast: more) {
    #rebate-hint {
        --rbh-ink-2: var(--rbh-ink);
    }

    #rebate-hint .rbh-pill {
        background-color: var(--rbh-surface-solid);
        box-shadow: 0 0 0 1.5px var(--rbh-ink), var(--rbh-shadow);
    }
}

@media (forced-colors: active) {
    #rebate-hint .rbh-pill {
        border: 1px solid CanvasText;
        background: Canvas;
        color: CanvasText;
        forced-color-adjust: auto;
    }

    #rebate-hint .rbh-icon {
        border: 1px solid CanvasText;
    }
}

@media print {
    #rebate-hint {
        display: none !important;
    }
}
