/* live_scene.css — Behind-batter MLB-The-Show style scene
 * v5: behind-batter camera, no umpire/catcher, floating perspective strike zone,
 *     prominent pitch dots with hover tooltips.
 */

/* === ROOT SCENE === */
.lg-scene {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #060a14;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.45), 0 4px 14px rgba(0,0,0,0.35);
    isolation: isolate;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #fff;
}

/* === STADIUM BACKGROUND === */
.lg-scene__bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 55%;
    z-index: 1;
}
.lg-scene__bg::after {
    /* subtle vignette so HUD text reads better */
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 35%, transparent 30%, rgba(0,0,0,0.35) 90%),
        linear-gradient(180deg, rgba(0,0,0,0.20) 0%, transparent 25%, transparent 70%, rgba(0,0,0,0.45) 100%);
    pointer-events: none;
}

/* === STAGE: hosts characters === */
.lg-scene__stage {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}
.lg-scene__char {
    position: absolute;
    height: auto;
    pointer-events: none;
    image-rendering: -webkit-optimize-contrast;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
}

/* PITCHER: small, standing ON the mound dirt.
 * Feet anchored to the mound rubber (~36% from bottom of scene). */
.lg-scene__char--pitcher {
    left: 50%;
    bottom: 30%;
    height: 13%;
    transform: translate(-50%, 0);
    z-index: 3;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
    transition: opacity 200ms ease;
}
.lg-scene__char--pitcher.is-windup {
    animation: lgPitcherWindup 900ms ease-in-out;
}
@keyframes lgPitcherWindup {
    0%   { transform: translate(-50%, 0) scale(1); }
    40%  { transform: translate(-50%, -4%) scale(1.04); }
    100% { transform: translate(-50%, 0) scale(1); }
}

/* BATTER: stands in the batter's box right next to home plate.
 * MLB The Show convention: camera looks past batter toward mound.
 * RH batter -> appears on screen LEFT (batter's box on 3B side from camera view).
 * LH batter -> appears on screen RIGHT (batter's box on 1B side from camera view).
 */
.lg-scene__char--batter {
    left: 2%;
    bottom: 2%;
    height: 84%;
    z-index: 7;
    filter: drop-shadow(8px 10px 14px rgba(0,0,0,0.65));
    transform-origin: bottom center;
    transition: transform 180ms ease;
}
/* LH batter: flip to the right side (1B side of plate from camera view) */
.lg-scene.is-lefty .lg-scene__char--batter {
    left: auto;
    right: 2%;
    filter: drop-shadow(-8px 10px 14px rgba(0,0,0,0.65));
}
.lg-scene__char--batter.is-swing {
    animation: lgSwing 480ms cubic-bezier(.4, .0, .2, 1);
}
@keyframes lgSwing {
    0%   { transform: rotate(0) translateX(0); }
    25%  { transform: rotate(-8deg) translateX(-2%); }
    55%  { transform: rotate(6deg) translateX(2%); }
    100% { transform: rotate(0) translateX(0); }
}

/* === FLOATING PERSPECTIVE STRIKE ZONE ===
 * Sits directly over home plate, proportional to the batter (knees-to-letters height).
 * Big enough to read pitch dots from a distance — MLB The Show style.
 * Slight trapezoid perspective for depth. */
.lg-scene__zone-wrap {
    position: absolute;
    left: 50%;
    bottom: 24%;
    width: 28%;
    height: 26%;
    transform: translate(-50%, 0) perspective(1100px) rotateX(14deg);
    transform-style: preserve-3d;
    z-index: 6;
    pointer-events: auto;
}
.lg-scene__zone-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}
.lg-scene__zone-frame {
    stroke: rgba(255,255,255,0.92);
    stroke-width: 1.6;
    fill: rgba(255,255,255,0.04);
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.35));
    transition: stroke 220ms ease, fill 220ms ease;
}
.lg-scene__zone-grid line {
    stroke: rgba(255,255,255,0.30);
    stroke-width: 0.6;
    stroke-dasharray: 2 2;
}
.lg-scene__zone-chase {
    stroke: rgba(255,255,255,0.22);
    stroke-width: 0.8;
    stroke-dasharray: 3 3;
    fill: none;
}

/* === PITCH DOTS — large and prominent like MLB The Show === */
.lg-scene__pitch-dot {
    fill: #4dd2ff;
    stroke: #fff;
    stroke-width: 1.2;
    filter: drop-shadow(0 0 6px rgba(77, 210, 255, 0.95));
    cursor: pointer;
    pointer-events: auto;
    transition: r 160ms ease, fill 160ms ease, filter 160ms ease;
}
.lg-scene__pitch-dot.is-ball {
    fill: #ff5252;
    filter: drop-shadow(0 0 7px rgba(255, 82, 82, 0.95));
}
.lg-scene__pitch-dot.is-strike {
    fill: #4dd2ff;
    filter: drop-shadow(0 0 7px rgba(77, 210, 255, 0.95));
}
.lg-scene__pitch-dot.is-inplay {
    fill: #ffd93d;
    filter: drop-shadow(0 0 8px rgba(255, 217, 61, 0.95));
}
.lg-scene__pitch-dot--latest {
    stroke: #ffc72c;
    stroke-width: 2;
    animation: lgDotPulse 1.6s ease-in-out infinite;
}
.lg-scene__pitch-dot:hover {
    filter: drop-shadow(0 0 14px rgba(255,255,255,0.95)) brightness(1.4);
}
@keyframes lgDotPulse {
    0%, 100% { r: 6.5; }
    50%      { r: 8.2; }
}

/* === PITCH TOOLTIP (analytics on hover) === */
.lg-scene__tooltip {
    position: absolute;
    z-index: 30;
    background: linear-gradient(180deg, rgba(12,18,32,0.97) 0%, rgba(6,10,20,0.97) 100%);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 200px;
    max-width: 260px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -100%) translateY(-12px) scale(0.96);
    transform-origin: bottom center;
    transition: opacity 140ms ease, transform 180ms cubic-bezier(.2,.7,.4,1);
    box-shadow: 0 14px 36px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.05);
    font-size: 12px;
    line-height: 1.45;
    color: #fff;
}
.lg-scene__tooltip.is-visible {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(-14px) scale(1);
}
.lg-scene__tooltip::after {
    /* arrow */
    content: '';
    position: absolute;
    left: 50%;
    bottom: -7px;
    width: 12px;
    height: 12px;
    background: rgba(6,10,20,0.97);
    border-right: 1px solid rgba(255,255,255,0.18);
    border-bottom: 1px solid rgba(255,255,255,0.18);
    transform: translateX(-50%) rotate(45deg);
}
.lg-scene__tip-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
    gap: 10px;
}
.lg-scene__tip-type {
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.lg-scene__tip-mph {
    font-weight: 800;
    font-size: 16px;
    color: #ffc72c;
    font-variant-numeric: tabular-nums;
}
.lg-scene__tip-mph span {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,199,44,0.7);
    margin-left: 3px;
    letter-spacing: 0.06em;
}
.lg-scene__tip-result {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    display: inline-block;
    margin-bottom: 6px;
}
.lg-scene__tip-result.is-strike { background: rgba(77,210,255,0.22); color: #4dd2ff; }
.lg-scene__tip-result.is-ball   { background: rgba(255,107,107,0.22); color: #ff6b6b; }
.lg-scene__tip-result.is-inplay { background: rgba(255,217,61,0.22);  color: #ffd93d; }
.lg-scene__tip-result.is-foul   { background: rgba(255,140,90,0.22);  color: #ff8c5a; }

.lg-scene__tip-rows {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 10px;
    font-size: 11px;
    margin-top: 2px;
}
.lg-scene__tip-rows .k {
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 10px;
    font-weight: 600;
}
.lg-scene__tip-rows .v {
    color: #fff;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* === ANIMATED BALL (pitch travel) === */
.lg-scene__ball {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff 0%, #f4f4f4 55%, #d0d0d0 100%);
    box-shadow: 0 0 12px rgba(255,255,255,0.85), inset 0 -2px 4px rgba(0,0,0,0.2);
    z-index: 9;
    pointer-events: none;
    transform: translate(-50%, 50%) scale(0.4);
    opacity: 0;
}
.lg-scene__ball.is-flying {
    box-shadow:
        0 0 14px rgba(255,255,255,0.95),
        -6px 4px 16px rgba(77,210,255,0.55),
        -12px 8px 22px rgba(77,210,255,0.30),
        inset 0 -2px 4px rgba(0,0,0,0.2);
}

/* === STATUS BAR (top): inning, matchup, LIVE === */
.lg-scene__status {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 12;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    pointer-events: none;
}
.lg-scene__status-left {
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.10);
}
.lg-scene__inning {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 700;
    color: #ffc72c;
    line-height: 1;
    margin-bottom: 3px;
}
.lg-scene__matchup {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
    line-height: 1;
}
.lg-scene__live {
    background: #e23434;
    color: #fff;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.12em;
    padding: 6px 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 14px rgba(226,52,52,0.5);
}
.lg-scene__live span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
    animation: lgPulse 1.2s ease-in-out infinite;
}
@keyframes lgPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.7); }
}

/* === HUD (bottom-left): BSO === */
.lg-scene__hud {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 12;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.10);
    pointer-events: none;
}
.lg-scene__hud-card {
    display: flex;
    align-items: center;
    gap: 14px;
}
.lg-scene__bso {
    display: flex;
    align-items: baseline;
    gap: 5px;
}
.lg-scene__bso-label {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.10em;
    text-transform: uppercase;
}
.lg-scene__bso-val {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* === SPEED (bottom-right): MPH + pitch type === */
.lg-scene__speed {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 12;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.10);
    pointer-events: none;
    text-align: right;
    min-width: 110px;
    opacity: 0;
    transition: opacity 280ms ease;
}
.lg-scene__speed.is-visible { opacity: 1; }
.lg-scene__speed-mph {
    font-size: 22px;
    font-weight: 800;
    color: #ffc72c;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.lg-scene__speed-mph span {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,199,44,0.75);
    margin-left: 4px;
    letter-spacing: 0.08em;
}
.lg-scene__speed-type {
    margin-top: 3px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    font-weight: 700;
    color: rgba(255,255,255,0.78);
    line-height: 1;
}

/* === CALLOUTS === */
.lg-scene__callout {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    z-index: 14;
    pointer-events: none;
    opacity: 0;
    font-weight: 900;
    font-size: clamp(38px, 6vw, 76px);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-shadow:
        0 0 18px rgba(0,0,0,0.85),
        0 6px 20px rgba(0,0,0,0.75);
    -webkit-text-stroke: 2px rgba(0,0,0,0.55);
    transition: opacity 220ms ease, transform 280ms cubic-bezier(.2,.7,.4,1.3);
    white-space: nowrap;
}
.lg-scene__callout.is-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.lg-scene__callout.is-hr {
    color: #ffd93d;
    font-size: clamp(52px, 8vw, 110px);
    -webkit-text-stroke: 3px #c2410c;
    text-shadow:
        0 0 30px rgba(255,217,61,0.85),
        0 0 60px rgba(255,140,40,0.65),
        0 8px 30px rgba(0,0,0,0.7);
    animation: lgHrShake 700ms cubic-bezier(.3,.0,.2,1) 1;
}
.lg-scene__callout.is-k     { color: #ff6b6b; -webkit-text-stroke: 3px #7a1d1d; }
.lg-scene__callout.is-hit   { color: #4dffae; -webkit-text-stroke: 3px #0a5a36; }
.lg-scene__callout.is-ball  { color: #6fb4ff; -webkit-text-stroke: 2px #1a3a6a; }
.lg-scene__callout.is-strike{ color: #ffd93d; -webkit-text-stroke: 2px #6a4a00; }
.lg-scene__callout.is-foul  { color: #ff8c5a; -webkit-text-stroke: 2px #5a2a10; }
.lg-scene__callout.is-hbp   { color: #ff4d8a; -webkit-text-stroke: 2px #5a0a30; }

@keyframes lgHrShake {
    0%   { transform: translate(-50%, -50%) scale(0.4) rotate(-3deg); }
    35%  { transform: translate(-50%, -50%) scale(1.18) rotate(2deg); }
    55%  { transform: translate(-50%, -50%) scale(0.95) rotate(-2deg); }
    100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}

/* === CONFETTI === */
.lg-scene__confetti {
    position: absolute;
    inset: 0;
    z-index: 13;
    pointer-events: none;
    overflow: hidden;
}
.lg-conf {
    position: absolute;
    width: 9px;
    height: 14px;
    border-radius: 2px;
    --dx: 0; --dy: 200px; --rot: 360deg;
    animation: lgConf 1.8s cubic-bezier(.2, .7, .4, 1) forwards;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
@keyframes lgConf {
    0%   { transform: translate(0, 0) rotate(0); opacity: 0; }
    8%   { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* === SCREEN SHAKE === */
.lg-scene.is-shake     { animation: lgShake 480ms cubic-bezier(.36,.07,.19,.97) both; }
.lg-scene.is-shake-big { animation: lgShakeBig 720ms cubic-bezier(.36,.07,.19,.97) both; }
@keyframes lgShake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-3px); }
    40%, 60% { transform: translateX(3px); }
}
@keyframes lgShakeBig {
    10%, 90% { transform: translate(-2px, 1px); }
    20%, 80% { transform: translate(4px, -2px); }
    30%, 50%, 70% { transform: translate(-6px, 3px); }
    40%, 60% { transform: translate(6px, -3px); }
}

/* === ZONE FLASH on call === */
.lg-scene__zone-wrap.is-flash-strike .lg-scene__zone-frame {
    stroke: #4dd2ff;
    fill: rgba(77,210,255,0.18);
    filter: drop-shadow(0 0 14px rgba(77,210,255,0.9));
}
.lg-scene__zone-wrap.is-flash-ball .lg-scene__zone-frame {
    stroke: #ff6b6b;
    fill: rgba(255,107,107,0.15);
    filter: drop-shadow(0 0 14px rgba(255,107,107,0.9));
}

/* === LEGEND === */
.lg-scene__legend {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    background: rgba(0,0,0,0.50);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    gap: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    pointer-events: none;
}
.lg-scene__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,0.78);
}
.lg-scene__legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.6);
}

/* === MOBILE === */
@media (max-width: 640px) {
    .lg-scene__matchup { font-size: 13px; }
    .lg-scene__inning { font-size: 9px; }
    .lg-scene__char--batter { height: 74%; }
    .lg-scene__char--pitcher { height: 12%; }
    .lg-scene__zone-wrap { width: 22%; height: 18%; }
    .lg-scene__tooltip { min-width: 170px; font-size: 11px; }
    .lg-scene__callout { font-size: clamp(28px, 8vw, 60px); }
    .lg-scene__legend { gap: 8px; padding: 5px 10px; font-size: 9px; }
}
