/* ========================================================================
   yilao-data-fx.css
   数据强调动效 —— 三种模式可在同一页面共存
   A: data-fx="counter"  (滚动数字 + 差值徽章 + 闪光)
   B: data-fx="bar-compare" (进度条 + 残影 + 增量徽章)
   C: data-fx="gauge"   (仪表盘 + 指针 + 等级跃迁)
   ======================================================================== */

:root {
    --fx-orange-50: #FEF3E8;
    --fx-orange-200: #F8C99A;
    --fx-orange-400: #F39B5A;
    --fx-orange-500: #EE7E2D;
    --fx-orange-600: #C9651E;
    --fx-success: #4E8B49;
    --fx-warn:    #E8A23C;
    --fx-danger:  #C7472E;
    --fx-line: #EFE3D5;
    --fx-ink: #2A1A0F;
    --fx-ink-soft: #5A4634;
    --fx-muted: #8C7B6E;
}

[data-theme="dark"] {
    --fx-orange-50: rgba(238,126,45,.12);
    --fx-orange-200: rgba(238,126,45,.3);
    --fx-line: #3a2a20;
    --fx-ink: #F5EFE8;
    --fx-ink-soft: #C9BFB3;
    --fx-muted: #8E8275;
}

/* ===================== A · COUNTER ===================== */

.fx-counter {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}
.fx-counter .fx-num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    transition: color .3s;
}
.fx-counter .fx-num.fx-highlight {
    color: var(--fx-orange-600);
}
.fx-counter .fx-num.fx-jump {
    animation: fxJump .5s ease;
}
@keyframes fxJump {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

.fx-counter .fx-delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(8px) scale(.9);
    transition: all .4s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
}
.fx-counter .fx-delta.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.fx-counter .fx-delta.up   { background: rgba(199,71,46,.12); color: var(--fx-danger); }
.fx-counter .fx-delta.down { background: rgba(78,139,73,.12); color: var(--fx-success); }
.fx-counter .fx-delta.neutral { background: rgba(140,123,110,.15); color: var(--fx-muted); }

.fx-counter::before {
    content: '';
    position: absolute;
    inset: -10px -16px;
    background: radial-gradient(ellipse at center, rgba(238,126,45,.22), transparent 70%);
    border-radius: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .6s;
}
.fx-counter.fx-flashing::before {
    opacity: 1;
}

/* ===================== B · BAR COMPARE ===================== */

.fx-bar {
    position: relative;
    height: 14px;
    background: var(--fx-line);
    border-radius: 999px;
    overflow: visible;
}
.fx-bar-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    overflow: hidden;
}
.fx-bar-ghost {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: var(--fx-orange-200);
    opacity: 0;
    border-radius: 999px;
    transition: opacity 1s ease 1.6s;
}
.fx-bar-ghost.show {
    opacity: 0.55;
    transition: opacity 0s;
}
.fx-bar-ghost.fading {
    opacity: 0;
    transition: opacity 1.2s ease;
}
.fx-bar-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    background: linear-gradient(90deg, var(--fx-orange-400), var(--fx-orange-500));
    border-radius: 999px;
    transition: width 1.1s cubic-bezier(.4,1.4,.6,1), background 1.1s ease;
}
.fx-bar-fill[data-level="low"]    { background: linear-gradient(90deg, #9DC798, var(--fx-success)); }
.fx-bar-fill[data-level="mid"]    { background: linear-gradient(90deg, var(--fx-orange-400), var(--fx-orange-500)); }
.fx-bar-fill[data-level="high"]   { background: linear-gradient(90deg, var(--fx-orange-500), var(--fx-danger)); }

.fx-bar-hint {
    position: absolute;
    top: -24px;
    transform: translateX(-50%);
    background: var(--fx-orange-600);
    color: #fff;
    font-size: .7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s, transform .4s;
    white-space: nowrap;
}
.fx-bar-hint.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}
.fx-bar-hint::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--fx-orange-600);
}
.fx-bar-hint.down {
    background: var(--fx-success);
}
.fx-bar-hint.down::after {
    border-top-color: var(--fx-success);
}

/* ===================== C · GAUGE ===================== */

.fx-gauge {
    position: relative;
    width: 280px;
    margin: 0 auto;
    max-width: 100%;
}
.fx-gauge svg {
    width: 100%;
    overflow: visible;
}
.fx-gauge-arc {
    fill: none;
    stroke-width: 14;
    stroke-linecap: round;
    transition: stroke-width .3s;
}
.fx-gauge-arc.fx-active {
    filter: drop-shadow(0 0 8px currentColor);
    animation: fxArcPulse 1.6s ease-in-out 2;
}
@keyframes fxArcPulse {
    0%, 100% { stroke-width: 14; }
    50% { stroke-width: 19; }
}
.fx-gauge-needle {
    transform-origin: 100px 100px;
    transition: transform 1.4s cubic-bezier(.34,1.4,.64,1);
}
.fx-gauge-value {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--fx-ink);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.fx-gauge-label {
    position: absolute;
    top: 80%;
    left: 50%;
    transform: translate(-50%, 0);
    font-size: .82rem;
    color: var(--fx-muted);
    pointer-events: none;
}

.fx-level-tag {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    transition: transform .5s cubic-bezier(.34,1.56,.64,1);
}
.fx-level-tag.low  { background: rgba(78,139,73,.15);  color: var(--fx-success); }
.fx-level-tag.mid  { background: rgba(232,162,60,.15); color: var(--fx-warn); }
.fx-level-tag.high { background: rgba(199,71,46,.15);  color: var(--fx-danger); }
.fx-level-tag.fx-changing { transform: scale(1.18); }

.fx-level-jump {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
}
.fx-level-jump .fx-from-tag {
    opacity: .5;
    text-decoration: line-through;
}
.fx-level-jump .fx-arrow {
    color: var(--fx-orange-500);
    font-weight: 700;
    animation: fxArrowSlide 1s ease forwards;
}
@keyframes fxArrowSlide {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.fx-level-jump.fx-hidden { display: none; }

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .fx-counter::before,
    .fx-num.fx-jump,
    .fx-bar-fill,
    .fx-gauge-needle,
    .fx-gauge-arc {
        animation: none !important;
        transition: none !important;
    }
}
