/* ─────────────────────────────────────────────────────────────────────────
   Football Intelligence — LIVE Ball Follower (pitch SVG)
   Faza 5.13 + 5.15-polish, redesign v2.

   Top-down pitch z animowaną piłką poruszającą się między event coords.
   F5.15-polish per Karol QA:
   - Ball z football pattern (czarno-biała), nie cała biała
   - Wander random co 5s (handled JS-side w startBallWander)
   - Goal/penalty/corner → ball "wpada" do bramki + announcement overlay
   - Desktop pitch mniejszy max-width (mobile zachowany)
   - Banner header bardziej zachęcający (LIVE pulse + clock + big score)

   prefers-reduced-motion: ball jumps instantly (no transition).
   ───────────────────────────────────────────────────────────────────────── */

.live-pitch {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  position: relative;
  /* F5.15-polish: max-width desktop dla balance UI (Karol "boisko stanowczo
     za duże na komputerze, przyciąga za wiele uwagi"). Mobile = full width
     via 100%. */
  max-width: 640px;
  margin: 0 auto;
}

/* === Score HUD (above pitch — F5.15-polish: zachęcający banner) ======== */

.live-pitch__hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 6px 10px;
  background: linear-gradient(135deg, rgba(0, 65, 40, 0.45) 0%, rgba(0, 80, 50, 0.25) 100%);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 229, 160, 0.15);
}
.live-pitch__hud-team {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-pitch__hud-team--home { text-align: right; }
.live-pitch__hud-team--away { text-align: left; }

.live-pitch__hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 18px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--radius-sm);
  min-width: 110px;
  border: 1px solid rgba(0, 229, 160, 0.25);
}
.live-pitch__hud-clock {
  font-size: 0.6rem;
  font-weight: var(--weight-extrabold);
  letter-spacing: 0.06em;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.live-pitch__live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  animation: live-pitch-live-pulse 1.4s ease-in-out infinite;
}
@keyframes live-pitch-live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50%      { opacity: 0.6; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}
.live-pitch__live-text { color: #ef4444; }
.live-pitch__hud-score-num {
  font-size: 1.45rem;
  font-weight: var(--weight-extrabold);
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.live-pitch__hud-min {
  letter-spacing: 0.04em;
}
@media (prefers-reduced-motion: reduce) {
  .live-pitch__live-dot { animation: none; }
}

/* === Pitch board ======================================================= */

.live-pitch__board {
  position: relative;
  width: 100%;
  aspect-ratio: 105 / 68;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.live-pitch__svg {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(0, 90, 55, 0.55) 0%, rgba(0, 65, 40, 0.55) 100%);
}

/* Ball — smooth transition between coord updates. F5.15-polish: <g>
   element z translate transform (zamiast cx/cy na pojedyńczym circle).
   Pattern children scaleją się razem. */
.live-pitch__ball {
  transition: transform 0.9s cubic-bezier(0.34, 1.2, 0.64, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

/* F5.16-tweak v2: trail = G grupa z per-segment opacity (gradient fade
   z oldest→newest). Per-segment <line> opacities set inline w JS. */
.live-pitch__trail line {
  transition: opacity 0.4s ease-out;
}
.live-pitch__ball-pulse {
  animation: live-pitch-pulse 2s ease-in-out infinite;
  transform-origin: center;
}
@keyframes live-pitch-pulse {
  0%   { opacity: 0.5; r: 18; }
  50%  { opacity: 0;   r: 32; }
  100% { opacity: 0;   r: 32; }
}

/* F5.15-polish: goal animation — ball "wpada do bramki" z fast transition
   + spin. Karol "Piłka musi faktycznie wpaść do bramki". */
.live-pitch__ball--goal {
  transition: transform 0.7s cubic-bezier(0.55, 0.1, 0.95, 0.5);
  animation: live-pitch-goal-spin 0.7s ease-out;
}
@keyframes live-pitch-goal-spin {
  from { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }
  to   { filter: drop-shadow(0 2px 12px rgba(0, 229, 160, 0.85)); }
}

/* Corner kick — ball flies to corner flag z lighter arc */
.live-pitch__ball--corner {
  transition: transform 1.2s cubic-bezier(0.4, 0.2, 0.6, 0.9);
}

/* Penalty — slow build-up then fast release */
.live-pitch__ball--penalty {
  transition: transform 0.9s cubic-bezier(0.7, 0, 0.84, 0);
}

@media (prefers-reduced-motion: reduce) {
  .live-pitch__ball,
  .live-pitch__ball--goal,
  .live-pitch__ball--corner,
  .live-pitch__ball--penalty { transition: none; animation: none; }
  .live-pitch__ball-pulse { animation: none; opacity: 0.4; }
}

/* === Event badge (floating label top of pitch) ======================== */

.live-pitch__event-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: 0.04em;
  white-space: nowrap;
  animation: live-pitch-badge-in 0.4s ease-out;
}
@keyframes live-pitch-badge-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
/* F5.17.c-fix Karol QA: flash the event label once, then fade out — don't
   leave it sitting on the pitch permanently. fade-in (0.4s) then hold then
   fade-out, fill forwards so it ends invisible + click-through. */
.live-pitch__event-label--flash {
  animation: live-pitch-badge-flash 5.5s ease forwards;
  pointer-events: none;
}
@keyframes live-pitch-badge-flash {
  0%   { opacity: 0; transform: translate(-50%, -8px); }
  8%   { opacity: 1; transform: translate(-50%, 0); }
  72%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}
@media (prefers-reduced-motion: reduce) {
  .live-pitch__event-label { animation: none; }
  /* still auto-hide for reduced-motion (no movement, just opacity) */
  .live-pitch__event-label--flash { animation: live-pitch-badge-fade 5.5s linear forwards; }
}
@keyframes live-pitch-badge-fade {
  0%, 72% { opacity: 1; }
  100%    { opacity: 0; }
}
.live-pitch__event-icon { font-size: 0.9rem; line-height: 1; }

/* === Announcement overlay (GOAL!, PENALTY, CORNER) ===================== */
/* F5.15-polish: prominent center announcement gdy goal/penalty/red_card/
   corner — Karol "Wyswietlaj takie komunikaty na środku boiska". */

/* F5.16-tweak v2 Karol QA "GOAL pulsuje cyklicznie. Animacja powinna pokazać się
   raz, hold dłuższy, scorer prominent". Play once (animation-fill-mode forwards),
   8s total z 6s hold faza. JS dedupe key prevents re-fire. */
.live-pitch__announcement {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 5;
  animation: live-pitch-announce 8s cubic-bezier(0.16, 1, 0.3, 1) 1 forwards;
}
@keyframes live-pitch-announce {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  6%   { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  10%  { transform: translate(-50%, -50%) scale(1); }
  90%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
}
.live-pitch__announcement-title {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.9), 0 0 30px currentColor;
  line-height: 1;
}
.live-pitch__announcement-scorer {
  margin-top: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}
.live-pitch__announcement-score {
  margin-top: 6px;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  font-feature-settings: 'tnum' on;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}
.live-pitch__announcement-sub {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  color: var(--text-primary);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  text-transform: uppercase;
}
.live-pitch__announcement--goal    .live-pitch__announcement-title { color: var(--accent); }
.live-pitch__announcement--penalty .live-pitch__announcement-title { color: #facc15; }
.live-pitch__announcement--red-card .live-pitch__announcement-title { color: #ef4444; font-size: 2rem; }
.live-pitch__announcement--corner  .live-pitch__announcement-title { color: #60a5fa; font-size: 1.8rem; }
@media (prefers-reduced-motion: reduce) {
  .live-pitch__announcement { animation: none; opacity: 1; }
}

/* === Recent events rail =============================================== */

.live-pitch__rail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--divider);
}
.live-pitch__rail-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  max-width: 240px;
}
.live-pitch__rail-item--home { border-left: 2px solid var(--accent); }
.live-pitch__rail-item--away { border-right: 2px solid rgba(239, 68, 68, 0.6); }
.live-pitch__rail-min {
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.live-pitch__rail-icon { font-size: 0.9rem; line-height: 1; }
.live-pitch__rail-detail {
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-pitch__hint {
  margin: 0;
  text-align: center;
  padding: 8px;
}

/* === Mobile <600px ===================================================== */

@media (max-width: 600px) {
  .live-pitch { max-width: 100%; padding: var(--space-1); }
  .live-pitch__hud-team { font-size: 0.82rem; }
  .live-pitch__hud-score-num { font-size: 1.2rem; }
  .live-pitch__hud-center { min-width: 84px; padding: 5px 10px; }
  .live-pitch__rail-item { font-size: 0.72rem; padding: 4px 8px; }
  .live-pitch__announcement-title { font-size: 2rem; }
  .live-pitch__announcement-sub { font-size: 0.7rem; }
}


/* (Possession badge usunięty per Karol QA — "obviously nieprawda") */


/* === Wave C2: active commentary ticker (replaces recent-events rail) ==== */

.live-pitch__ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 40px;
  font-size: 0.84rem;
}
.live-pitch__ticker[hidden] { display: none; }

/* Live match-stats strip under the pitch (Karol: stats under Live position) */
.live-pitch__stats {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.live-pitch__stats[hidden] { display: none; }
.live-pitch__stats-head {
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 8px;
}
.live-pitch__stats-rows { display: flex; flex-direction: column; gap: 6px; }
.live-pitch__ticker-pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: live-pitch-live-pulse 1.4s ease-in-out infinite;
}
.live-pitch__ticker-time {
  font-weight: var(--weight-bold);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.live-pitch__ticker-icon { display: inline-flex; align-items: center; flex-shrink: 0; }
.live-pitch__ticker-icon:empty { display: none; }
.live-pitch__ticker-text {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-pitch__ticker--flash { animation: live-pitch-ticker-flash 0.7s ease-out; }
@keyframes live-pitch-ticker-flash {
  0%   { background: rgba(0, 229, 160, 0.16); }
  100% { background: var(--surface-1); }
}
@media (prefers-reduced-motion: reduce) {
  .live-pitch__ticker-pulse { animation: none; }
  .live-pitch__ticker--flash { animation: none; }
}


/* === Wave C2: overlay (half-time card / kick-off intro) ================= */

.live-pitch__overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(3, 18, 12, 0.84);
  backdrop-filter: blur(3px);
  animation: live-pitch-overlay-fade 0.4s ease-out;
}
.live-pitch__overlay[hidden] { display: none; }
@keyframes live-pitch-overlay-fade { from { opacity: 0; } to { opacity: 1; } }

/* Half-time card */
.live-pitch__ht {
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: live-pitch-ht-in 0.5s ease-out;
}
@keyframes live-pitch-ht-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.live-pitch__ht-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: var(--weight-extrabold);
  letter-spacing: 0.12em;
  color: var(--accent);
  border: 1px solid rgba(0, 229, 160, 0.35);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
  margin-bottom: 14px;
}
.live-pitch__ht-score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.live-pitch__ht-team { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.live-pitch__ht-crest { width: 44px; height: 44px; object-fit: contain; }
.live-pitch__ht-crest--ph {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface-2);
  font-weight: var(--weight-bold); font-size: 0.78rem; color: var(--text-secondary);
}
.live-pitch__ht-name {
  font-size: 0.78rem; color: var(--text-secondary);
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.live-pitch__ht-num {
  font-size: 2rem; font-weight: 900; color: var(--text-primary);
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.live-pitch__ht-venue { font-size: 0.76rem; color: var(--text-tertiary); margin-bottom: 14px; }
.live-pitch__ht-stats { display: flex; flex-direction: column; gap: 6px; }
.live-pitch__ht-stat {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; font-size: 0.8rem;
}
.live-pitch__ht-stat-h { text-align: left;  font-weight: var(--weight-bold); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.live-pitch__ht-stat-a { text-align: right; font-weight: var(--weight-bold); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.live-pitch__ht-stat-label { text-align: center; color: var(--text-tertiary); font-size: 0.72rem; letter-spacing: 0.03em; }
.live-pitch__ht-bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; margin: -1px 0 5px; }
.live-pitch__ht-bar span:first-child { background: var(--accent); }
.live-pitch__ht-bar span:last-child  { background: rgba(239, 68, 68, 0.6); }
.live-pitch__ht-nostats { text-align: center; margin: 4px 0 0; }

/* Kick-off intro */
.live-pitch__intro { text-align: center; width: 100%; }
.live-pitch__intro-teams {
  display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 16px;
}
.live-pitch__intro-team {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--text-primary); font-weight: var(--weight-semibold);
  max-width: 120px;
}
.live-pitch__intro-team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.live-pitch__intro-team--home { animation: live-pitch-intro-left 0.6s ease-out; }
.live-pitch__intro-team--away { animation: live-pitch-intro-right 0.6s ease-out; }
.live-pitch__intro-crest { width: 56px; height: 56px; object-fit: contain; }
.live-pitch__intro-crest--ph {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface-2); font-weight: var(--weight-bold); color: var(--text-secondary);
}
.live-pitch__intro-vs { font-size: 1rem; font-weight: 900; color: var(--text-tertiary); letter-spacing: 0.1em; }
.live-pitch__intro-kick {
  font-size: 1.6rem; font-weight: 900; letter-spacing: 0.1em; color: var(--accent);
  animation: live-pitch-kick-in 0.6s 0.3s both;
}
@keyframes live-pitch-intro-left  { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes live-pitch-intro-right { from { opacity: 0; transform: translateX(28px); }  to { opacity: 1; transform: none; } }
@keyframes live-pitch-kick-in     { from { opacity: 0; transform: scale(0.7); }        to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .live-pitch__overlay, .live-pitch__ht,
  .live-pitch__intro-team--home, .live-pitch__intro-team--away, .live-pitch__intro-kick { animation: none; }
}

@media (max-width: 600px) {
  .live-pitch__ticker { font-size: 0.78rem; padding: 7px 10px; min-height: 36px; }
  .live-pitch__ht-num { font-size: 1.6rem; }
  .live-pitch__ht-crest, .live-pitch__intro-crest { width: 40px; height: 40px; }
  .live-pitch__intro-kick { font-size: 1.3rem; }
}
