/* Market price discovery widget. Migrated from market-price-viz.php
   wp_head output. Scoped under .kyt-mv. */

/* Self-contained widget. The first three rules are the mobile-bleed
   defense: the widget itself uses border-box (not just its children),
   it can never exceed the available width, and any accidental
   overflow gets clipped rather than pushing the page wider. */
.kyt-mv {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0a0e27;
    color: #e8edf4;
    padding: 28px;
    border-radius: 12px;
    margin: 2rem 0;
    border: 1px solid rgba(74, 156, 175, 0.15);
}
.kyt-mv * { box-sizing: border-box; min-width: 0; }

/* Play/pause button — sits in the top-right corner.
   Subtle pulse on the play icon while paused, to invite interaction. */
.kyt-mv-toggle {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(74, 156, 175, 0.3);
    background: rgba(74, 156, 175, 0.12);
    color: #5fb4c9;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    z-index: 2;
}
.kyt-mv-toggle:hover,
.kyt-mv-toggle:focus-visible {
    background: rgba(74, 156, 175, 0.25);
    border-color: #7dd3e0;
    color: #7dd3e0;
    transform: scale(1.06);
    outline: none;
}
.kyt-mv-toggle svg {
    width: 14px;
    height: 14px;
    display: block;
    fill: currentColor;
}
.kyt-mv-toggle .icon-play  { display: block; }
.kyt-mv-toggle .icon-pause { display: none; }
.kyt-mv.is-playing .kyt-mv-toggle .icon-play  { display: none; }
.kyt-mv.is-playing .kyt-mv-toggle .icon-pause { display: block; }

/* Pulse to draw the eye while paused (only when widget is visible).
   Stops once playing. Disabled for users who prefer reduced motion. */
@keyframes kytMvPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(125, 211, 224, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(125, 211, 224, 0); }
}
.kyt-mv:not(.is-playing) .kyt-mv-toggle {
    animation: kytMvPulse 2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
    .kyt-mv:not(.is-playing) .kyt-mv-toggle { animation: none; }
}

.kyt-mv-ticker {
    text-align: center;
    margin-bottom: 22px;
    padding: 18px 18px 16px;
    background: rgba(10, 14, 39, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(74, 156, 175, 0.15);
}
.kyt-mv-lbl {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
}
.kyt-mv-px {
    font-size: 32px;
    font-weight: 600;
    color: #e8edf4;
    font-variant-numeric: tabular-nums;
    display: inline-block;
    transition: transform 0.3s ease, color 0.3s ease;
}
.kyt-mv-px.up   { color: #22c55e; }
.kyt-mv-px.down { color: #ef4444; }
.kyt-mv-px.flash { transform: scale(1.08); }
.kyt-mv-trd {
    font-size: 13px;
    color: #9ba3af;
    margin-top: 8px;
    min-height: 18px;
}

.kyt-mv-book {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.kyt-mv-side {
    background: rgba(10, 14, 39, 0.5);
    border-radius: 8px;
    padding: 14px;
    border: 1px solid rgba(74, 156, 175, 0.15);
    min-width: 0;
}
.kyt-mv-ttl {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.kyt-mv-side.bids .kyt-mv-ttl { color: #22c55e; }
.kyt-mv-side.asks .kyt-mv-ttl { color: #ef4444; }

.kyt-mv-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.kyt-mv-row span { white-space: nowrap; }
.kyt-mv-side.bids .kyt-mv-row {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}
.kyt-mv-side.asks .kyt-mv-row {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.kyt-mv-row.matched { animation: kytMvMatch 0.85s ease forwards; }
.kyt-mv-row.new     { animation: kytMvSlide 0.55s ease; }

@keyframes kytMvMatch {
    0%   { transform: scale(1); }
    35%  {
        transform: scale(1.05);
        background: rgba(74, 156, 175, 0.25);
        color: #5fb4c9;
        box-shadow: 0 0 12px rgba(74, 156, 175, 0.4);
    }
    100% {
        opacity: 0;
        transform: scale(0.9);
        padding-top: 0;
        padding-bottom: 0;
        margin: 0;
        height: 0;
    }
}
@keyframes kytMvSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.kyt-mv-cap {
    text-align: center;
    font-size: 14px;
    color: #9ba3af;
    min-height: 44px;
    padding: 12px 14px;
    line-height: 1.5;
    background: rgba(10, 14, 39, 0.3);
    border-radius: 8px;
    transition: opacity 0.3s ease;
}

/* Tighter spacing on tablets and narrow desktop */
@media (max-width: 720px) {
    .kyt-mv { padding: 20px; }
    .kyt-mv-ticker { padding: 14px 14px 12px; }
    .kyt-mv-px { font-size: 26px; }
    .kyt-mv-row { padding: 8px 10px; font-size: 13px; }
    .kyt-mv-side { padding: 12px; }
    .kyt-mv-toggle { top: 10px; right: 10px; width: 32px; height: 32px; }
    .kyt-mv-toggle svg { width: 12px; height: 12px; }
}

/* Phones — keep buyers/sellers side by side, just trim everything */
@media (max-width: 480px) {
    .kyt-mv { padding: 14px; border-radius: 10px; }
    .kyt-mv-ticker { padding: 12px 10px 10px; margin-bottom: 16px; }
    .kyt-mv-px { font-size: 22px; }
    .kyt-mv-trd { font-size: 12px; }
    .kyt-mv-book { gap: 8px; }
    .kyt-mv-side { padding: 10px 8px; }
    .kyt-mv-row { padding: 7px 8px; font-size: 12px; gap: 4px; }
    .kyt-mv-ttl { font-size: 10px; margin-bottom: 8px; }
    .kyt-mv-cap { font-size: 13px; padding: 10px 12px; }
}
