/* ============================================================
   Anime Batter v3 — Profile/side-view stadium scene
   Strike zone centered over the plate (which is in the sprite),
   home/away backdrop swap via data-game-loc, no jersey lettering
   ============================================================ */

/* The strike-zone area becomes a stadium scene */
.lg-zone-area {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: 1200px;
    margin: 0 auto;
    aspect-ratio: 16 / 10;
    background-image: url('./batter_frames/stadium_bg.png');
    background-size: cover;
    background-position: center 62%;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.55),
                inset 0 0 0 2px rgba(255, 255, 255, 0.08);
    isolation: isolate;
    transition: background-image 250ms ease;
}

/* Away game backdrop */
.lg-zone-area[data-game-loc="away"] {
    background-image: url('./batter_frames/stadium_bg_away.png');
}

@media (min-width: 1280px) {
    .lg-zone-area { max-width: 1100px; }
}

@media (min-width: 1500px) {
    .lg-zone-area { max-width: 1200px; }
}

@media (max-width: 700px) {
    .lg-zone-area {
        aspect-ratio: 4 / 3;
    }
}

/* Vignette overlay */
.lg-zone-area::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center 60%,
                transparent 38%,
                rgba(0, 0, 0, 0.45) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Header floats over scene */
.lg-zone-header {
    position: relative;
    z-index: 4;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.65), transparent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
    font-size: 13px;
    letter-spacing: 0.05em;
}

/* ---------- Strike zone SVG — centered over home plate ---------- */
/* The batter sprite occupies the right 62% of the scene, anchored to the
   bottom-right. Within that sprite, home plate sits at roughly 15-20% from
   the left of the sprite. So in scene coordinates the plate is at about
   (100% - 62%) + (62% * 0.18) = ~49% horizontal. The strike zone sits above
   the plate at roughly chest height (~50% vertical). */
.lg-zone-area > svg.lg-zone-svg,
.lg-zone-area .lg-zone-svg-wrap {
    position: absolute;
    left: 49%;
    top: 48%;
    transform: translate(-50%, -50%);
    width: 22%;
    max-width: 220px;
    height: auto;
    z-index: 3;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.6));
}

.lg-zone-area .lg-zone-svg-wrap svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ---------- The batter at the plate ---------- */
/* The sprite is composed so the figure occupies the right portion and
   home plate is at bottom-left of the sprite. We position the sprite
   wrapper to fill the right half of the scene, anchored to the bottom. */
.ab-batter-wrap {
    position: absolute;
    /* Sprite anchored bottom-right; takes up ~62% of width.
       Home plate (bottom-left of sprite) lands around 42% of scene width. */
    right: 0;
    bottom: 0;
    width: 62%;
    max-width: 720px;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    transform-origin: 50% 100%;
    transition: transform 220ms cubic-bezier(.34, 1.56, .64, 1),
                filter 300ms ease;
    will-change: transform, filter;
}

@media (max-width: 900px) {
    .ab-batter-wrap {
        width: 70%;
    }
}

@media (max-width: 600px) {
    .ab-batter-wrap {
        width: 78%;
    }
}

.ab-batter-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: bottom right;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.55))
            drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
    transition: opacity 140ms ease;
}

/* Celebration aura */
.ab-aura {
    position: absolute;
    inset: -10% -5% -5% -5%;
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 60%,
                rgba(0, 92, 92, 0.65) 0%,
                rgba(0, 92, 92, 0.2) 35%,
                transparent 70%);
    opacity: 0;
    transition: opacity 250ms ease;
    pointer-events: none;
    z-index: -1;
    filter: blur(14px);
}

/* Impact spark — positioned where the bat meets the ball */
.ab-spark {
    position: absolute;
    left: 28%;
    top: 38%;
    width: 25%;
    height: 25%;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.4);
    background: radial-gradient(circle at 50% 50%,
                #fff 0%,
                #ffe27a 22%,
                #ff9d3a 50%,
                rgba(255, 80, 0, 0) 75%);
    border-radius: 50%;
    mix-blend-mode: screen;
}

.ab-spark--burst {
    animation: ab-spark-burst 500ms cubic-bezier(.2, .8, .4, 1) forwards;
}

@keyframes ab-spark-burst {
    0%   { opacity: 0; transform: scale(0.3) rotate(0deg); }
    25%  { opacity: 1; transform: scale(1.1) rotate(15deg); }
    100% { opacity: 0; transform: scale(2.0) rotate(40deg); }
}

/* ---------- Confetti ---------- */
.ab-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 6;
}

.ab-conf-piece {
    position: absolute;
    width: 8px;
    height: 14px;
    border-radius: 2px;
    transform-origin: 50% 50%;
    animation: ab-conf-fly linear forwards;
    opacity: 0.95;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

@keyframes ab-conf-fly {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    70%  { opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---------- State styles ---------- */
.ab-state-idle .ab-batter-img {
    animation: ab-breathe 3.2s ease-in-out infinite;
}

@keyframes ab-breathe {
    0%, 100% { transform: translateY(0)    scale(1); }
    50%      { transform: translateY(-1px) scale(1.005); }
}

.ab-state-load {
    transform: translateX(2px) scale(1.01);
}

.ab-state-swing_impact {
    transform: scale(1.04) translate(-2px, -2px);
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.65))
            drop-shadow(0 0 22px rgba(255, 200, 80, 0.5));
}

.ab-state-swing_follow {
    transform: scale(1.02);
}

.ab-state-foul {
    transform: scale(1.02);
}

.ab-state-dejected,
.ab-state-strikeout {
    transform: scale(0.98) translateY(2px);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5))
            grayscale(0.25) brightness(0.9);
}

.ab-state-hbp {
    animation: ab-recoil 600ms cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes ab-recoil {
    0%, 100% { transform: translateX(0); }
    10%      { transform: translateX(6px) rotate(2deg); }
    25%      { transform: translateX(-4px) rotate(-1deg); }
    45%      { transform: translateX(3px); }
    65%      { transform: translateX(-2px); }
    85%      { transform: translateX(1px); }
}

.ab-state-celebrating {
    animation: ab-celebrate 800ms cubic-bezier(.34, 1.56, .64, 1) both;
}

.ab-state-celebrating .ab-batter-img {
    filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.55))
            drop-shadow(0 0 32px rgba(0, 200, 200, 0.8))
            drop-shadow(0 0 50px rgba(255, 220, 80, 0.6));
    animation: ab-celebrate-img 1.6s ease-in-out infinite;
}

.ab-state-celebrating .ab-aura {
    opacity: 1;
    animation: ab-aura-pulse 1.8s ease-in-out infinite;
}

@keyframes ab-celebrate {
    0%   { transform: scale(1) translateY(0); }
    40%  { transform: scale(1.1) translateY(-10px); }
    70%  { transform: scale(1.03) translateY(-2px); }
    100% { transform: scale(1.05) translateY(-4px); }
}

@keyframes ab-celebrate-img {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50%      { transform: translateY(-6px) rotate(1deg); }
}

@keyframes ab-aura-pulse {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50%      { opacity: 1;    transform: scale(1.15); }
}

/* ---------- Callout bubble ---------- */
.ab-callout {
    position: absolute;
    top: 8%;
    left: 49%;
    transform: translate(-50%, -10px) scale(0.8);
    background: #fff;
    color: #0c2c54;
    font-family: 'Russo One', 'Bebas Neue', 'Arial Black', sans-serif;
    font-size: 14px;
    letter-spacing: 0.06em;
    padding: 5px 12px;
    border-radius: 14px;
    border: 2px solid #0c2c54;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 180ms ease, transform 220ms cubic-bezier(.34, 1.56, .64, 1);
    z-index: 7;
}

.ab-callout::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid #0c2c54;
}

.ab-callout--visible {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
}

.ab-callout--ball   { background: #fff;     color: #0c2c54; border-color: #0c2c54; }
.ab-callout--strike { background: #f5d52d;  color: #0c2c54; border-color: #0c2c54; }
.ab-callout--swing  { background: #fff;     color: #c1272d; border-color: #c1272d; }
.ab-callout--foul   { background: #ffd166;  color: #5c3d00; border-color: #5c3d00; }
.ab-callout--hit    { background: #ff5722;  color: #fff;    border-color: #fff; font-size: 16px; }
.ab-callout--hr     {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #fff;
    border-color: #fff;
    font-size: 18px;
    padding: 7px 16px;
    box-shadow: 0 8px 20px rgba(255, 140, 0, 0.6),
                0 0 0 2px rgba(0, 0, 0, 0.25);
    animation: ab-callout-hr-pulse 700ms ease-in-out infinite alternate;
}
.ab-callout--k      { background: #c1272d;  color: #fff;    border-color: #fff; }
.ab-callout--hbp    { background: #c1272d;  color: #fff;    border-color: #fff; }

@keyframes ab-callout-hr-pulse {
    0%   { transform: translate(-50%, 0)    scale(1); }
    100% { transform: translate(-50%, -4px) scale(1.08); }
}

/* Hide legacy SVG batter remnants */
.ab-batter-svg,
.ab-bb-head,
.ab-bb-body,
.ab-bb-bat,
.ab-bb-ball {
    display: none !important;
}

/* SVG strike zone overrides — make field show through, zone box readable */
.lg-zone-area .lg-pitch-dot,
.lg-zone-area circle.lg-pitch-dot {
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}

/* First rect = full background — make it nearly transparent so field shows */
.lg-zone-svg > rect:first-of-type {
    fill: rgba(12, 28, 50, 0.12) !important;
    stroke: rgba(255, 255, 255, 0.06);
}

/* Strike zone box (third rect after bg + chase zone) */
.lg-zone-svg > rect:nth-of-type(3) {
    fill: rgba(0, 0, 0, 0.25) !important;
    stroke: rgba(255, 255, 255, 0.92) !important;
    stroke-width: 2 !important;
}

/* Grid lines */
.lg-zone-svg line {
    stroke: rgba(255, 255, 255, 0.32) !important;
}

/* Labels */
.lg-zone-svg text {
    fill: rgba(255, 255, 255, 0.92) !important;
    font-weight: 600;
}
