/**
 * Wallet (my-wallet) — hub layout + motion, aligned with my-home / shop / subscription.
 * Typography: --kf-app-* from portal-chrome.css (App Look). Do not redefine font sizes on :root here.
 */

/* ── Page-scoped flashes (recharge modal still uses #cw-msg-*) ── */
body.wallet-page .cw-flash {
    margin: 0 0 var(--kf-app-gutter, 5px);
    padding: 10px 12px;
    border-radius: var(--mh-radius-md, 15px);
    font-family: var(--kf-app-font-family, inherit);
    font-size: var(--kf-app-fs-body);
    font-weight: 600;
    line-height: 1.45;
    border: 1px solid transparent;
}

body.wallet-page .cw-flash--ok {
    color: #14532d;
    background: #ecfdf5;
    border-color: rgba(34, 197, 94, 0.35);
}

body.wallet-page .cw-flash--err {
    color: #7f1d1d;
    background: #fef2f2;
    border-color: rgba(248, 113, 113, 0.45);
}

body.wallet-page .wlt-flash.bh-flash {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 14px;
    font-family: var(--kf-app-font-family, inherit);
    font-size: var(--kf-app-fs-body);
    font-weight: 600;
}

body.wallet-page .wlt-flash.bh-flash--err {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid rgba(248, 113, 113, 0.4);
}

/* ── Hub subtitle + trust row (match subscription / shop density) ── */
.wlt-hub__subtitle {
    margin: 8px 0 0;
    max-width: 22rem;
    margin-inline: auto;
    font-family: var(--kf-app-font-family, inherit);
    font-size: var(--kf-app-fs-body);
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: -0.018em;
    color: var(--mh-muted, #64748b);
}

.wlt-hub__trust {
    margin: 12px auto 0 !important;
    max-width: 100%;
    justify-content: center;
}

@media (prefers-reduced-motion: no-preference) {
    body.wallet-page .wlt-hub__trust > li:nth-child(1) .bh-trust-pill {
        animation: wlt-trust-nudge 2.8s ease-in-out infinite;
    }

    body.wallet-page .wlt-hub__trust > li:nth-child(2) .bh-trust-pill {
        animation: wlt-trust-nudge 2.8s ease-in-out infinite 0.18s;
    }

    body.wallet-page .wlt-hub__trust > li:nth-child(3) .bh-trust-pill {
        animation: wlt-trust-nudge 2.8s ease-in-out infinite 0.36s;
    }

    @keyframes wlt-trust-nudge {
        0%,
        100% {
            transform: translateY(0);
        }
        50% {
            transform: translateY(-1px);
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    body.wallet-page .wlt-hub__trust .bh-trust-pill {
        animation: none !important;
    }
}

/* ── Stage content spacing ── */
.wlt-stage__content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ── Balance panel (enterprise, minimal) ── */
.wlt-balance-hero {
    --wlt-panel-border: rgba(15, 23, 42, 0.08);
    --wlt-panel-ink: #0f172a;
    --wlt-panel-muted: #64748b;
    --wlt-panel-accent: #0f766e;
    --wlt-panel-accent-hover: #0d9488;
    position: relative;
    overflow: hidden;
    padding: 20px 16px 18px;
    border: 1px solid var(--wlt-panel-border);
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.wlt-balance-hero__row {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

@media (min-width: 520px) {
    .wlt-balance-hero__row {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
        gap: 24px;
    }
}

.wlt-balance-hero__meta {
    min-width: 0;
    flex: 1;
}

.wlt-balance-hero__kicker {
    margin: 0 0 6px;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--wlt-panel-muted);
}

.wlt-balance-hero__amount {
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 4px;
    line-height: 1;
}

.wlt-balance-hero__currency {
    font-family: var(--kf-app-font-family, inherit);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--wlt-panel-muted);
    transform: translateY(-0.08em);
}

.wlt-balance-hero__value {
    font-family: var(--kf-app-font-family, inherit);
    font-size: clamp(2rem, 7vw, 2.55rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1;
    color: var(--wlt-panel-ink);
    font-variant-numeric: tabular-nums;
}

.wlt-balance-hero__actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: min(100%, 11.5rem);
}

@media (min-width: 520px) {
    .wlt-balance-hero__actions {
        flex-shrink: 0;
        width: 11.5rem;
    }
}

.wlt-balance-hero__cta {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    margin: 0;
    border: 1px solid var(--wlt-panel-accent);
    border-radius: 0;
    background: var(--wlt-panel-accent);
    color: #fff;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.9rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wlt-balance-hero__cta:hover,
.wlt-balance-hero__cta:focus-visible {
    background: var(--wlt-panel-accent-hover);
    border-color: var(--wlt-panel-accent-hover);
    outline: none;
}

.wlt-balance-hero__cta:active {
    background: #0f766e;
}

.wlt-balance-hero__offline {
    margin: 0;
    padding: 10px 12px;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--wlt-panel-muted);
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.wlt-balance-hero__offline a {
    color: var(--wlt-panel-accent);
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wlt-balance-hero__credit {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--wlt-panel-muted);
}

.wlt-balance-hero__credit strong {
    color: var(--wlt-panel-ink);
    font-weight: 650;
}

/* ── How it works (horizontal snap cards) ── */
.wlt-hiw {
    margin: 2px 0 0;
}

.wlt-hiw__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.wlt-hiw__title {
    margin: 0;
    font-family: var(--kf-app-font-family, inherit);
    font-size: var(--kf-app-fs-heading);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--mh-ink, #0c1222);
}

.wlt-hiw__spark {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
    flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .wlt-hiw__spark {
        animation: wlt-spark-pulse 2s ease-in-out infinite;
    }

    @keyframes wlt-spark-pulse {
        0%,
        100% {
            transform: scale(1);
            opacity: 1;
        }
        50% {
            transform: scale(1.15);
            opacity: 0.85;
        }
    }
}

.wlt-hiw__scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 10px;
    margin: 0 -4px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.wlt-hiw__scroll::-webkit-scrollbar {
    display: none;
}

.wlt-hiw-card {
    flex: 0 0 min(78%, 240px);
    scroll-snap-align: start;
    padding: 14px 14px 16px;
    border-radius: var(--mh-radius-md, 15px);
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
    transition: transform 0.2s var(--mh-ease-out, cubic-bezier(0.22, 1, 0.36, 1)), box-shadow 0.2s var(--mh-ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

@media (prefers-reduced-motion: no-preference) {
    .wlt-hiw-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    }
}

.wlt-hiw-card__icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    margin-bottom: 10px;
    color: #065f46;
}

.wlt-hiw-card__icon--add {
    background: #ecfdf5;
    border: 1px solid rgba(167, 243, 208, 0.85);
}

.wlt-hiw-card__icon--cart {
    background: #fff7ed;
    border: 1px solid rgba(253, 186, 116, 0.5);
    color: #9a3412;
}

.wlt-hiw-card__icon--leaf {
    background: #f0fdf4;
    border: 1px solid rgba(74, 222, 128, 0.45);
}

.wlt-hiw-card__name {
    margin: 0 0 6px;
    font-family: var(--kf-app-font-family, inherit);
    font-size: var(--kf-app-fs-body);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--mh-ink, #0c1222);
}

.wlt-hiw-card__text {
    margin: 0;
    font-family: var(--kf-app-font-family, inherit);
    font-size: var(--kf-app-fs-small);
    font-weight: 600;
    line-height: 1.5;
    color: var(--mh-muted, #64748b);
}

/* ── Empty state ── */
.wlt-empty {
    text-align: center;
    padding: 28px 16px;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.wlt-empty__title {
    margin: 0 0 6px;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.wlt-empty__text {
    margin: 0 0 14px;
    max-width: 22rem;
    margin-inline: auto;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
    color: #64748b;
}

.wlt-empty__btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    margin: 0;
    border: 1px solid #0f766e;
    border-radius: 0;
    background: #0f766e;
    color: #fff;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.9rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wlt-empty__btn:hover,
.wlt-empty__btn:focus-visible {
    background: #0d9488;
    border-color: #0d9488;
    outline: none;
}

/* ── Transaction history ── */
.wlt-activity {
    margin: 18px 0 0;
    padding: 0 4px;
}

.wlt-activity__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.wlt-activity__title {
    margin: 0;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.wlt-activity__sub {
    margin: 4px 0 0;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
    color: #64748b;
}

.wlt-activity__badge {
    flex-shrink: 0;
    min-width: 1.75rem;
    padding: 4px 8px;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.75rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.wlt-feed {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid #e2e8f0;
    background: #fff;
}

.wlt-tx {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 10px;
    align-items: start;
    padding: 14px 14px 14px 12px;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    cursor: default;
    transition: background-color 0.15s ease;
}

.wlt-tx:last-child {
    border-bottom: 0;
}

.wlt-tx:hover,
.wlt-tx:focus-within {
    background: #f8fafc;
}

.wlt-tx:active {
    background: #f1f5f9;
}

.wlt-tx__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-top: 1px;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 1.05rem;
    font-weight: 650;
    line-height: 1;
    border: 1px solid transparent;
}

.wlt-tx--in .wlt-tx__mark {
    color: #0f766e;
    background: #f0fdfa;
    border-color: #ccfbf1;
}

.wlt-tx--out .wlt-tx__mark {
    color: #b45309;
    background: #fffbeb;
    border-color: #fde68a;
}

.wlt-tx__body {
    min-width: 0;
}

.wlt-tx__main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.wlt-tx__title {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.35;
    color: #0f172a;
}

.wlt-tx__chg {
    margin: 0;
    flex-shrink: 0;
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.95rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.35;
    white-space: nowrap;
}

.wlt-tx--in .wlt-tx__chg {
    color: #0f766e;
}

.wlt-tx--out .wlt-tx__chg {
    color: #b45309;
}

.wlt-tx__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 6px;
}

.wlt-tx__detail,
.wlt-tx__when,
.wlt-tx__bal {
    font-family: var(--kf-app-font-family, inherit);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
    color: #64748b;
}

.wlt-tx__detail {
    font-weight: 600;
    color: #475569;
    word-break: break-word;
}

.wlt-tx__meta > *:not(:first-child)::before {
    content: "·";
    margin-right: 10px;
    color: #cbd5e1;
    font-weight: 400;
}

.wlt-tx__bal {
    font-variant-numeric: tabular-nums;
    color: #475569;
}

.wlt-feed-more {
    margin-top: 12px;
}

.wlt-feed-more__btn.kf-feed-more {
    border-radius: 14px;
    text-transform: none;
    letter-spacing: -0.02em;
    font-size: var(--kf-app-fs-body);
}

.wlt-feed-more__end.kf-feed-end {
    font-family: var(--kf-app-font-family, inherit);
}

/* ── Recharge modal on wallet ──
   Base .cw-modal* layout lives in customer-orders.css; this page does not load that
   file, so define the overlay + panel here to avoid a broken in-flow modal. */
body.wallet-page .cw-modal[hidden] {
    display: none !important;
}

body.wallet-page .cw-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}

@media (min-width: 480px) {
    body.wallet-page .cw-modal {
        align-items: center;
        padding: 24px;
    }
}

body.wallet-page .cw-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

body.wallet-page .cw-modal__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    max-height: min(88vh, 560px);
    overflow: auto;
    margin: 0 auto;
    padding: 20px 18px 18px;
    border-radius: 20px;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: #fff;
    box-shadow:
        0 24px 60px rgba(15, 23, 42, 0.16),
        0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

body.wallet-page .cw-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

body.wallet-page .cw-modal__title {
    margin: 0;
    font-size: var(--kf-app-fs-heading);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--mh-ink, var(--kf-shell-ink, #0f172a));
}

body.wallet-page .cw-modal__close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin: -6px -8px 0 0;
    padding: 0;
    border: 0;
    font-size: clamp(var(--kf-app-fs-heading), 5vw, calc(var(--kf-app-fs-heading) * 1.65));
    line-height: 1;
    font-weight: 300;
    color: var(--mh-muted, var(--kf-shell-muted, #64748b));
    background: transparent;
    cursor: pointer;
    border-radius: 10px;
}

body.wallet-page .cw-modal__close:active {
    transform: scale(0.94);
}

body.wallet-page .cw-modal__intro {
    margin: 0 0 16px;
    font-size: var(--kf-app-fs-body);
    line-height: 1.5;
    color: var(--mh-muted, var(--kf-shell-muted, #64748b));
    font-weight: 500;
}

body.wallet-page .cw-modal__label {
    display: block;
    margin: 0 0 6px;
    font-size: var(--kf-app-fs-body);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mh-muted, var(--kf-shell-muted, #64748b));
}

body.wallet-page .cw-modal__input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    font-size: var(--kf-app-fs-heading);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--mh-ink, var(--kf-shell-ink, #0f172a));
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(220, 196, 178, 0.85);
    border-radius: 14px;
    font-family: inherit;
}

body.wallet-page .cw-modal__input:focus {
    outline: 2px solid rgba(45, 72, 40, 0.35);
    outline-offset: 1px;
}

body.wallet-page .cw-modal__hint {
    margin: 8px 0 0;
    font-size: var(--kf-app-fs-body);
    color: var(--mh-muted, var(--kf-shell-muted, #64748b));
    font-weight: 500;
    line-height: 1.4;
}

body.wallet-page .cw-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

body.wallet-page .cw-modal__btn {
    flex: 1 1 auto;
    min-width: 100px;
    font-family: inherit;
    cursor: pointer;
    border: 0;
}

body.wallet-page .cw-modal__btn:active {
    transform: scale(0.99);
}

/* ── Flat unified section (my-wallet): square corners, one continuous surface ── */
body.wallet-page main#cph-main > .mh-basket-hub {
    border-radius: 0 !important;
    box-shadow: none !important;
    border-inline: none !important;
}

body.wallet-page .mh-basket-hub__divider--soft {
    margin-inline: 0;
}

body.wallet-page .mh-basket-hub__zone--basket {
    padding-inline: 0;
    padding-top: 0;
}

body.wallet-page .wlt-stage__content {
    gap: 0;
}

body.wallet-page :is(
    .cw-flash,
    .wlt-flash.bh-flash,
    .wlt-balance-hero,
    .wlt-balance-hero__cta,
    .wlt-balance-hero__offline,
    .wlt-hiw-card,
    .wlt-hiw-card__icon,
    .wlt-hiw__spark,
    .wlt-empty,
    .wlt-activity__badge,
    .wlt-feed,
    .wlt-tx,
    .wlt-tx__mark,
    .wlt-feed-more__btn.kf-feed-more,
    .kf-feed-more,
    .wlt-empty__btn,
    .bh-trust-pill,
    .mh-greet__harvest-cta,
    .cw-modal__panel,
    .cw-modal__close,
    .cw-modal__input,
    .cw-modal__btn
) {
    border-radius: 0 !important;
}

body.wallet-page .wlt-balance-hero {
    box-shadow: none !important;
    border-inline: none;
    border-top: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    padding: 20px var(--kf-space-4, 16px) 18px;
    background: #fff;
}

body.wallet-page .wlt-hiw {
    padding: 14px var(--kf-space-4, 16px);
    border-top: 1px solid rgba(167, 243, 208, 0.45);
}

body.wallet-page .wlt-hiw-card {
    box-shadow: none;
}

body.wallet-page .wlt-activity {
    padding: 14px var(--kf-space-4, 16px) 0;
    border-top: 1px solid rgba(226, 232, 240, 0.95);
}

body.wallet-page .wlt-feed {
    gap: 0;
    border-top: 1px solid rgba(226, 232, 240, 0.95);
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

body.wallet-page .wlt-tx {
    box-shadow: none !important;
    border-inline: none;
    border-block: none;
}

body.wallet-page .wlt-tx + .wlt-tx {
    border-top: 1px solid rgba(241, 245, 249, 0.95);
}

body.wallet-page .wlt-empty {
    border-inline: none;
    box-shadow: none;
}

body.wallet-page .wlt-feed-more {
    padding-inline: var(--kf-space-4, 16px);
}

@media (prefers-reduced-motion: reduce) {
    .wlt-hiw__spark,
    .wlt-empty__orb,
    .wlt-feed .wlt-tx {
        animation: none !important;
    }

    .wlt-hiw-card:hover {
        transform: none;
    }
}
