/* Hover Stats — a 24h-change chip that reveals supporting stats on hover, expanding RIGHT inline
   when the host slot has room or dropping a chrome-free chip panel DOWN when it doesn't.
   Ported from the "Hover Stats Component" Claude Design handoff.

   The `.hs--hover` / `.hs--fits` classes and the `--hs-supp-w` measurement are driven by
   js/hover-stats.js; everything visual (direction, transitions, colours) lives here. Down/up
   colours map onto the MudBlazor palette so the chip themes with the rest of the app; the neutral
   surface tokens keep the design's dark-UI values. */

.hover-stats {
    --hs-text: #f2f2f4;
    --hs-text-muted: rgba(242, 242, 244, 0.45);
    --hs-divider: rgba(255, 255, 255, 0.07);
    --hs-border: rgba(255, 255, 255, 0.08);
    --hs-chip-bg: #2a2a31;
    --hs-supp-w: 0px;

    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    position: relative;
    font-family: inherit;
}

/* ── shared stat cell (label + value), used in the measurer and the inline reveal ── */
.hover-stats .hs-stat {
    display: flex;
    align-items: baseline;
    gap: 5px;
    padding: 0 12px;
    border-left: 1px solid var(--hs-divider);
}

.hover-stats .hs-stat--first {
    border-left: none;
}

.hover-stats .hs-lbl {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--hs-text-muted);
    white-space: nowrap;
}

.hover-stats .hs-val {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--hs-text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.hover-stats .hs-val--down { color: var(--mud-palette-error); }
.hover-stats .hs-val--up   { color: var(--mud-palette-success); }
.hover-stats .hs-val--flat { color: var(--hs-text-muted); }

/* ── hidden measurer = natural width of the full inline readout ── */
.hover-stats .hs-measurer {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    visibility: hidden;
    pointer-events: none;
    white-space: nowrap;
}

/* ── the chip group (24h change + chevron + inline reveal) ── */
.hover-stats .hs-chip {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 10px;
    padding: 5px 4px;
    cursor: pointer;
}

/* hover highlight that grows with the inline reveal */
.hover-stats .hs-highlight {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    border-radius: 10px;
    background: transparent;
    pointer-events: none;
    transition: width 0.32s cubic-bezier(0.2, 0.7, 0.3, 1), background 0.25s ease;
}

.hover-stats.hs--hover.hs--fits .hs-highlight {
    width: calc(var(--hs-supp-w) + 116px);
    background: rgba(255, 255, 255, 0.05);
}

.hover-stats .hs-change {
    position: relative;
}

/* chevron: fades on inline expand, rotates to point down for the panel */
.hover-stats .hs-chevron {
    position: relative;
    width: 18px;
    opacity: 0.6;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    color: var(--hs-text-muted);
    transition: width 0.25s ease, opacity 0.2s ease;
}

.hover-stats .hs-chevron svg {
    transition: transform 0.26s ease;
}

.hover-stats.hs--hover.hs--fits .hs-chevron {
    width: 0;
    opacity: 0;
}

.hover-stats.hs--hover:not(.hs--fits) .hs-chevron svg {
    transform: rotate(90deg);
}

/* inline reveal (right) — max-width animates 0 -> natural */
.hover-stats .hs-reveal {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(-6px);
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-width 0.32s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.26s ease, transform 0.3s ease;
}

.hover-stats.hs--hover.hs--fits .hs-reveal {
    max-width: calc(var(--hs-supp-w) + 8px);
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    /* Hit-testable only while open: the reveal is a chip descendant, so the cursor over the
       revealed stats stays inside the chip's pointerenter scope instead of falling through to
       the root and collapsing the readout mid-read. Closed, it stays pointer-events: none so the
       empty slot area can never trigger the expand. */
    pointer-events: auto;
}

/* drop-down panel (down) — chrome-free chips anchored under the chip */
.hover-stats .hs-panel {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 8px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    max-width: 100%;
    transform-origin: top left;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.hover-stats.hs--hover:not(.hs--fits) .hs-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.hover-stats .hs-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--hs-chip-bg);
    border: 1px solid var(--hs-border);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    .hover-stats .hs-highlight,
    .hover-stats .hs-chevron,
    .hover-stats .hs-chevron svg,
    .hover-stats .hs-reveal,
    .hover-stats .hs-panel {
        transition: none;
    }
}
