/* ================================================================
   TeamKick — LIVE match stage (2.5D futsal court)
   Used by league-match.ejs while a match is in progress; driven by
   /js/live-pitch.js. Runs on the league theme variables (--primary,
   --secondary, --accent) defined on the page, so it retints per league.
   ================================================================ */

.stage-card {
  --stage-bg-a: #0c1023;
  --stage-bg-b: #070a18;
  --court-a: #1e6fb8;
  --court-b: #14508c;
  --apron-a: #10375f;
  --apron-b: #0b2848;
  --chalk: rgba(255, 255, 255, 0.85);
  --wedge-home: color-mix(in srgb, var(--secondary) 70%, white);
  --wedge-away: color-mix(in srgb, var(--accent) 80%, white);

  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 8% -10%, color-mix(in srgb, var(--primary) 34%, transparent), transparent 55%),
    radial-gradient(120% 90% at 92% -10%, color-mix(in srgb, var(--secondary) 30%, transparent), transparent 55%),
    linear-gradient(180deg, var(--stage-bg-a) 0%, var(--stage-bg-b) 100%);
  box-shadow: 0 14px 40px rgba(10, 12, 30, 0.35);
  margin-bottom: 18px;
}

/* broadcast top rule in league colors */
.stage-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
  z-index: 5;
}

/* ---- top bar: LIVE + minute + attacking chip ---- */
.stage-top {
  position: relative; z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px 6px;
  color: #fff;
}

.stage-top .left { display: inline-flex; align-items: center; gap: 10px; }

.stage-top .live-pill { margin-top: 0; }

.stage-minute {
  font-family: 'League Gothic', sans-serif;
  font-size: 30px; line-height: 1; letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
}

.stage-minute .tick { animation: minuteBlink 2s steps(1) infinite; }

@keyframes minuteBlink { 50% { opacity: 0.25; } }

.attack-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 12px; border-radius: 999px;
  max-width: 55%; white-space: nowrap;
  transition: box-shadow 0.4s ease;
}

.attack-chip .name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.attack-chip .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--chip-color, #fff);
  box-shadow: 0 0 8px var(--chip-color, #fff);
  flex-shrink: 0;
}

.attack-chip .arrow { font-size: 12px; opacity: 0.85; }

/* ---- 3D viewport ---- */
.stage-viewport {
  position: relative;
  perspective: 1150px;
  perspective-origin: 50% 26%;
  height: 400px;
  margin-top: -6px;
}

.pitch-plane {
  position: absolute;
  left: 50%; top: 50%;
  width: 1000px; height: 640px;
  transform-style: preserve-3d;
  transform: translate(-50%, -54%) scale(var(--s, 1)) rotateX(52deg);
}

.pitch-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* chalk lines draw themselves in, same signature move as the hero */
.pitch-svg .chalk {
  fill: none;
  stroke: var(--chalk);
  stroke-width: 2.5;
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: chalkDraw 2.2s ease 0.3s forwards;
}

@keyframes chalkDraw { to { stroke-dashoffset: 0; } }

.pitch-svg .chalk.spot { fill: var(--chalk); stroke: none; animation: chalkFade 0.6s ease 2s backwards; }

@keyframes chalkFade { from { opacity: 0; } }

/* ---- attack wedge (momentum arrow) ---- */
.wedge-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.wedge {
  transform-origin: 500px 320px;
  transition: transform 0.7s cubic-bezier(0.6, 0, 0.3, 1), opacity 0.4s ease;
}

.wedge.flip { transform: scaleX(-1); }

.wedge.hidden { opacity: 0; }

.wedge .body { opacity: 0.5; filter: blur(1px); }

.wedge .chev {
  fill: none; stroke: #ffffff; stroke-width: 10;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0;
  animation: march 1.6s ease-in-out infinite;
}

.wedge .chev:nth-child(2) { animation-delay: 0.26s; }

.wedge .chev:nth-child(3) { animation-delay: 0.52s; }

@keyframes march {
  0%   { opacity: 0; transform: translateX(-26px); }
  35%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateX(36px); }
}

/* ---- billboards: children stand upright out of the tilted court ---- */
.bb-wrap { position: absolute; left: 0; top: 0; transform-style: preserve-3d; }

.bb { transform: rotateX(-52deg); transform-origin: 50% 100%; }

/* goals — true 3D boxes: the frame stands ON the goal line, mouth
   facing the court. Faces are flat divs rotated out of the court plane:
   rotateY(-90deg) lifts a face's width upright along the goal line,
   rotateX(90deg) lifts one along the court length (side nets). */
.goal3d { position: absolute; left: 0; top: 0; transform-style: preserve-3d; z-index: 1; }

.goal3d > div {
  position: absolute; left: 0; top: 0;
  transform-style: preserve-3d;
  animation: goalIn 0.5s ease 1.9s backwards;
}

@keyframes goalIn { from { opacity: 0; } }

.g-frame {
  width: 52px; height: 86px; /* futsal 3m x 2m: narrow mouth, tall frame */
  border-top: 5px solid #fff;
  border-bottom: 5px solid #fff;
  border-right: 5px solid #fff; /* maps to the crossbar (element x = up) */
  transform-origin: 0 0;
}

.g-mesh, .g-back .mesh {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.30) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.30) 0 1px, transparent 1px 11px);
}

.g-back { width: 52px; height: 86px; transform-origin: 0 0; border: 1px solid rgba(255,255,255,0.45); }

.g-top { width: 22px; height: 86px; }

.g-side { width: 22px; height: 52px; transform-origin: 0 0; }

.g-side .g-mesh, .g-top .g-mesh { opacity: 0.55; }

.goal3d.ripple .g-back .mesh { animation: netRipple 0.55s ease; }

@keyframes netRipple {
  0% { transform: skewX(0deg) scaleY(1); }
  30% { transform: skewX(-5deg) scaleY(0.93); }
  60% { transform: skewX(3.5deg) scaleY(1.04); }
  100% { transform: none; }
}

/* ---- the ball ---- */
.ball-wrap {
  transition: transform 1s cubic-bezier(0.35, 0, 0.25, 1);
  will-change: transform;
  z-index: 2;
}

.ball-shadow {
  position: absolute; left: -16px; top: -7px;
  width: 32px; height: 14px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.4), transparent 70%);
}

.ball { width: 22px; height: 22px; margin-left: -11px; margin-top: -22px; position: relative; }

.ball .core {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffffff 0 42%, #cfd4e6 75%, #9aa2c0 100%);
  box-shadow: 0 0 14px rgba(255,255,255,0.75), 0 0 34px color-mix(in srgb, var(--ball-glow, #ffffff) 55%, transparent);
}

.ball .ring {
  position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ball-glow, #ffffff) 80%, transparent);
  animation: ringPulse 1.5s ease-out infinite;
}

@keyframes ringPulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* suspense hold: shot on goal awaiting the keeper's answer — the ball's
   pulse tightens and quickens at the goal mouth */
.stage-card.shot-pending .ball .ring {
  animation-duration: 0.55s;
  border-width: 3px;
}

/* impact shockwave on the court (stays flat in the plane) */
.shockwave {
  position: absolute; width: 26px; height: 26px;
  margin: -13px 0 0 -13px; border-radius: 50%;
  border: 3px solid #ffffff;
  pointer-events: none;
}

/* event card / disc billboards */
.fx-card {
  width: 34px; height: 48px; margin-left: -17px; margin-top: -48px; border-radius: 5px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45), inset 0 0 0 2px rgba(255,255,255,0.35);
}

.fx-disc {
  width: 40px; height: 40px; margin-left: -20px; margin-top: -40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}

/* ---- screen-space atmosphere (not tilted) ---- */
.floodlights { position: absolute; inset: 0; pointer-events: none; z-index: 3; }

.floodlights::before, .floodlights::after {
  content: '';
  position: absolute; top: -12%; width: 58%; height: 125%;
  background: linear-gradient(215deg, rgba(255,255,255,0.10), transparent 55%);
}

.floodlights::before { left: -6%; transform: skewX(14deg); }

.floodlights::after { right: -6%; transform: skewX(-14deg) scaleX(-1); }

.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(115% 90% at 50% 42%, transparent 55%, rgba(5, 7, 18, 0.55) 100%);
}

/* goal flash covers the stage for a beat */
.stage-flash {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: #ffffff; opacity: 0;
}

.stage-flash.on { animation: stageFlash 0.5s ease-out; }

@keyframes stageFlash { 0% { opacity: 0.85; } 100% { opacity: 0; } }

/* GOOOOAL overlay */
.goal-shout {
  position: absolute; inset: 0; z-index: 7;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; overflow: hidden;
}

.goal-shout span {
  font-family: 'League Gothic', sans-serif;
  font-size: clamp(64px, 13vw, 150px);
  letter-spacing: 6px;
  color: #ffffff;
  text-shadow: 0 6px 30px rgba(0,0,0,0.45), 0 0 60px color-mix(in srgb, var(--accent) 70%, transparent);
  opacity: 0;
}

.goal-shout.on span { animation: shout 2s cubic-bezier(0.2, 0.7, 0.2, 1); }

@keyframes shout {
  0% { opacity: 0; transform: translateX(-42%) skewX(-8deg) scale(0.85); letter-spacing: 22px; }
  16% { opacity: 1; transform: translateX(0) skewX(-8deg) scale(1.06); letter-spacing: 8px; }
  30% { transform: translateX(0) skewX(-8deg) scale(1); }
  78% { opacity: 1; transform: translateX(4%) skewX(-8deg) scale(1); }
  100% { opacity: 0; transform: translateX(18%) skewX(-8deg) scale(0.96); }
}

/* localized action callout — a mini GOOOOAL-style label that pops up at
   the projected screen position of the court spot where the action
   happened (spawned by JS into the flat .fx-screen overlay) */
.fx-screen {
  position: absolute; inset: 0; z-index: 6;
  overflow: hidden; pointer-events: none;
}

.fx-label { position: absolute; transform: translate(-50%, -100%); }

.fx-label span {
  display: inline-block;
  font-family: 'League Gothic', sans-serif;
  font-size: clamp(20px, 2.6vw, 32px);
  letter-spacing: 2px;
  line-height: 1;
  color: #ffffff;
  white-space: nowrap;
  padding: 5px 14px 3px;
  border-radius: 8px;
  background: rgba(8, 11, 26, 0.78);
  border-left: 5px solid var(--label-color, #ffffff);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45), 0 0 26px color-mix(in srgb, var(--label-color, #ffffff) 45%, transparent);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  opacity: 0;
}

/* confetti bits (spawned by JS) */
.confetti { position: absolute; width: 9px; height: 13px; z-index: 6; pointer-events: none; top: 0; left: 0; }

/* ---- ticker: latest event ---- */
.stage-ticker {
  position: relative; z-index: 4;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px 16px;
  color: #ffffff; min-height: 46px;
}

.ticker-min {
  font-family: 'League Gothic', sans-serif; font-size: 20px; letter-spacing: 1px;
  background: var(--tick-color, var(--primary));
  border-radius: 7px; padding: 2px 8px 1px; flex-shrink: 0;
}

.ticker-text {
  font-size: 13px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; opacity: 0.95;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ticker-player { opacity: 0.6; font-weight: 700; text-transform: none; letter-spacing: 0; }

.stage-ticker.slide .ticker-min, .stage-ticker.slide .ticker-text { animation: tickIn 0.45s cubic-bezier(0.2, 0.8, 0.3, 1); }

@keyframes tickIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* fresh live timeline rows fade in once the pitch animation has played */
.tl-row.tl-new { animation: fadeUp 0.6s ease both; }

/* ---- pause notice: amber pills + dimmed court with a PAUSED banner ---- */
.live-pill.paused { background: #FF9800; }

.live-pill.paused .live-dot { animation: none; }

.stage-card.is-paused .stage-viewport::after {
  content: 'PAUSED';
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  font-family: 'League Gothic', sans-serif;
  font-size: clamp(40px, 8vw, 84px);
  letter-spacing: 8px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(7, 10, 24, 0.45);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  animation: fadeUp 0.4s ease;
}

@media (max-width: 760px) {
  .stage-viewport { height: 250px; }
  .attack-chip { max-width: 46%; }
}

@media (prefers-reduced-motion: reduce) {
  .wedge .chev, .ball .ring, .stage-minute .tick { animation: none !important; }
  .ball-wrap { transition-duration: 0.01s; }
}
