/* Soccer pitch + match-detail hero (loaded from /css/pitch.css) */

.match-detail .md-pitch-hero {
  width: 100%;
  max-width: 960px;
  margin: 0 auto 8px;
  padding: 0 12px;
}
.match-detail .md-pitch-hero .md-pitch-wrap,
.match-detail .md-pitch-hero .mtr-pitch-placeholder {
  width: 100%;
}
.match-detail .md-pitch-hero .soccer-pitch {
  margin: 0;
}
.match-detail .md-pitch-hero .pitch-surface {
  min-height: clamp(168px, 30vw, 280px);
  max-height: min(44vw, 320px);
  border-radius: 12px;
}
.match-detail .md-pitch-hero .pitch-scoreboard {
  font-size: 12px;
  padding: 7px 18px;
}
.match-detail .md-pitch-hero .pitch-scoreboard .pss {
  font-size: 18px;
  font-weight: 900;
}
.match-detail .md-pitch-hero .pitch-badge {
  font-size: 11px;
  padding: 5px 12px;
}
.match-detail .md-pitch-hero .mtr-pitch-placeholder {
  min-height: 140px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #999;
  padding: 24px;
}
.match-detail .md-pitch-hero .soccer-pitch.phase-live .pitch-ball {
  animation: pitchBallDrift2d 2.8s ease-in-out infinite;
}
.match-detail .md-pitch-hero .soccer-pitch.phase-live .pitch-surface {
  animation: pitchGrassPulse 4s ease-in-out infinite;
}

.md-pitch-wrap .soccer-pitch {
  margin: 0;
}

.mtr-pitch-placeholder {
  flex: 1;
  min-height: 160px;
  border: 1px dashed #444;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 16px;
}

/* ── Pitch surface ───────────────────────────────────────────── */
.soccer-pitch {
  margin: 0;
  padding: 0;
  background: transparent;
  width: 100%;
}

.pitch-surface {
  position: relative;
  width: 100%;
  margin: 0 auto;
  min-height: 168px;
  height: auto;
  aspect-ratio: 2 / 1;
  max-height: 220px;
  border-radius: 8px;
  overflow: hidden;
  /* Flat top-down: even frame, no faux tilt */
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.2),
    0 4px 18px rgba(0, 0, 0, 0.45);
}

/* Mowing stripes — 2D orthographic (no diagonal / “stand” lighting) */
.pitch-grass {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.022) 0 10px,
      rgba(0, 0, 0, 0.028) 10px 20px
    ),
    #1e8f55;
}

.pitch-heat {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  z-index: 1;
}
.pitch-heat-l,
.pitch-heat-r {
  flex: 1;
  transition: opacity 0.85s cubic-bezier(0.4, 0, 0.2, 1);
}
.pitch-heat-l {
  background: linear-gradient(90deg, rgba(255, 214, 0, 0.42), rgba(255, 214, 0, 0.12) 50%, transparent);
  opacity: 0.14;
}
.pitch-heat-r {
  background: linear-gradient(270deg, rgba(255, 214, 0, 0.42), rgba(255, 214, 0, 0.12) 50%, transparent);
  opacity: 0.14;
}

.pitch-markings {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.pitch-goalline {
  position: absolute;
  top: 4%;
  bottom: 4%;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.55) 12%,
    rgba(255, 255, 255, 0.55) 88%,
    rgba(255, 255, 255, 0) 100%
  );
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.15);
}
.pitch-goalline-l {
  left: 2%;
}
.pitch-goalline-r {
  right: 2%;
  left: auto;
  margin-left: 0;
  margin-right: -1px;
}

.pitch-midline {
  position: absolute;
  left: 50%;
  top: 4%;
  bottom: 4%;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.12);
}

/* Center circle: % margins use containing-block *width* — broke vertical center; use translate */
.pitch-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 17.5%;
  aspect-ratio: 1;
  max-width: 22vmin;
  max-height: 22vmin;
  border: 2px solid rgba(255, 255, 255, 0.52);
  border-radius: 50%;
  box-sizing: border-box;
  box-shadow: none;
}

.pitch-box {
  position: absolute;
  top: 20%;
  bottom: 20%;
  width: 11%;
  border: 2px solid rgba(255, 255, 255, 0.48);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 2;
}
.pitch-box-l {
  left: 2%;
  border-left: none;
}
.pitch-box-r {
  right: 2%;
  border-right: none;
}

/* Penalty spot inside each box */
.pitch-spot-pen-l,
.pitch-spot-pen-r {
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
}
.pitch-spot-pen-l {
  left: 8.5%;
}
.pitch-spot-pen-r {
  right: 8.5%;
}

/* API-driven markers (cards, corners, possession) — flat top-down */
.pitch-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  font-family: var(--fn-n);
}

.pitch-zone {
  position: absolute;
  top: 22%;
  bottom: 22%;
  width: 11%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 3;
}
.pitch-zone-home {
  left: 0.5%;
}
.pitch-zone-away {
  right: 0.5%;
}

.pitch-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 9px;
  font-weight: 800;
  color: #eee;
  white-space: nowrap;
}
.pitch-pill b {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.pitch-pill-yc b {
  color: #ffeb3b;
}
.pitch-pill-rc b {
  color: #ff8a80;
}
.pitch-pill-sot b {
  color: #b2ffcc;
}

.pitch-poss {
  position: absolute;
  left: 50%;
  bottom: 38%;
  transform: translateX(-50%);
  width: 42%;
  max-width: 200px;
  z-index: 3;
}
.pitch-poss-lbl {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 2px;
}
.pitch-poss-lbl span:first-child {
  color: #9ee5ff;
}
.pitch-poss-lbl span:last-child {
  color: #ffe08a;
}
.pitch-poss-bar {
  display: flex;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.35);
}
.pitch-poss-h {
  flex-shrink: 0;
  height: 100%;
  min-width: 0;
  background: linear-gradient(90deg, #1a6d8f, #2a9fc9);
  transition: width 0.85s cubic-bezier(0.4, 0, 0.2, 1);
}
.pitch-poss-a {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: linear-gradient(90deg, #8a6a1a, #c9a227);
  opacity: 0.88;
}

.pitch-spot-c {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Live situation line (derived from stats + pressure) — bottom band, clears meters + clock */
.pitch-live-caption {
  position: absolute;
  left: 50%;
  right: auto;
  top: auto;
  bottom: 56px;
  transform: translateX(-50%);
  z-index: 6;
  max-width: min(92%, 420px);
  padding: 6px 14px;
  text-align: center;
  font-family: var(--fn-n);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  animation: pitchCaptionBreath 4.5s ease-in-out infinite;
}

@keyframes pitchCaptionBreath {
  0%,
  100% {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  }
  50% {
    border-color: rgba(255, 223, 27, 0.22);
    box-shadow: 0 4px 22px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 223, 27, 0.08);
  }
}

.match-detail .md-pitch-hero .pitch-live-caption {
  font-size: 11px;
  padding: 7px 16px;
  max-width: min(94%, 480px);
  bottom: 60px;
}

/* Phones: smaller type + sit low (just above meters), not visually “mid-pitch” */
@media (max-width: 768px) {
  .pitch-live-caption {
    font-size: 8px;
    font-weight: 700;
    padding: 4px 9px;
    line-height: 1.3;
    letter-spacing: 0.01em;
    bottom: 36px;
    max-width: min(97%, 320px);
    border-radius: 7px;
  }
  .match-detail .md-pitch-hero .pitch-live-caption {
    font-size: 8.5px;
    padding: 5px 10px;
    bottom: 40px;
    max-width: min(97%, 340px);
  }
}

/* Ball cluster: rings + arrows while idle between API ticks */
.pitch-ball-wrap {
  position: absolute;
  z-index: 7;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  margin: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.9s cubic-bezier(0.4, 0, 0.2, 1), top 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.pitch-ball-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 223, 27, 0.38);
  opacity: 0.85;
  pointer-events: none;
}

.pitch-ball-ring--inner {
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.22);
}

.soccer-pitch.phase-live .pitch-ball-ring {
  animation: pitchRingSpin 12s linear infinite;
}
.soccer-pitch.phase-live .pitch-ball-ring.pitch-ball-ring--inner {
  animation: pitchRingSpin 5.5s linear infinite reverse;
}

.soccer-pitch.phase-finished .pitch-ball-ring,
.soccer-pitch.phase-upcoming .pitch-ball-ring {
  display: none;
}
.soccer-pitch.phase-finished .pitch-ball-arrows,
.soccer-pitch.phase-upcoming .pitch-ball-arrows {
  display: none;
}

.pitch-ball-arrows {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1px;
  pointer-events: none;
}

.pitch-ball-arrow {
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  color: rgba(255, 223, 27, 0.2);
  text-shadow: 0 0 6px transparent;
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

.soccer-pitch.phase-live .pitch-ball-wrap--press-l .pitch-ball-arrow--home {
  color: rgba(255, 223, 27, 0.95);
  text-shadow: 0 0 10px rgba(255, 223, 27, 0.55);
  animation: pitchArrowPulse 1.15s ease-in-out infinite;
}

.soccer-pitch.phase-live .pitch-ball-wrap--press-r .pitch-ball-arrow--away {
  color: rgba(255, 223, 27, 0.95);
  text-shadow: 0 0 10px rgba(255, 223, 27, 0.55);
  animation: pitchArrowPulse 1.15s ease-in-out infinite;
}

.soccer-pitch.phase-live .pitch-ball-wrap--press-n .pitch-ball-arrow--home {
  animation: pitchArrowHint 2.8s ease-in-out infinite;
}
.soccer-pitch.phase-live .pitch-ball-wrap--press-n .pitch-ball-arrow--away {
  animation: pitchArrowHint 2.8s ease-in-out infinite;
  animation-delay: 1.4s;
}

@keyframes pitchRingSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pitchArrowPulse {
  0%,
  100% {
    opacity: 0.75;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

@keyframes pitchArrowHint {
  0%,
  100% {
    color: rgba(255, 223, 27, 0.18);
  }
  50% {
    color: rgba(255, 223, 27, 0.55);
  }
}

/* Flat “disc” ball (top-down) */
.pitch-ball {
  position: relative;
  width: 14px;
  height: 14px;
  margin: 0;
  border-radius: 50%;
  background: #f5f5f5;
  border: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  z-index: 2;
  pointer-events: none;
  flex-shrink: 0;
}
.pitch-ball::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1px dashed rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.soccer-pitch.phase-live .pitch-ball {
  animation: pitchBallDrift2d 12s ease-in-out infinite, pitchBallGlow 2.4s ease-in-out infinite;
}

@keyframes pitchBallDrift2d {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(3px, -2px);
  }
}

@keyframes pitchBallGlow {
  0%,
  100% {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(255, 223, 27, 0);
  }
  50% {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 14px 3px rgba(255, 223, 27, 0.4);
  }
}

/* One bottom bar: stats chips + time (no stacked boxes) */
.pitch-footer {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 5;
  pointer-events: none;
}

.pitch-meters {
  position: static;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: flex-start;
  align-items: center;
  font-family: var(--fn-n);
  font-size: 10px;
  font-weight: 800;
  color: #f0f0f0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  line-height: 1.2;
}

.pitch-meter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.pitch-meter b {
  color: #ffdf1b;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.pitch-meter.tick-pulse {
  animation: pitchMeterPop 0.5s ease;
}

@keyframes pitchMeterPop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.07);
    color: #ffdf1b;
    border-color: rgba(255, 223, 27, 0.5);
  }
  100% {
    transform: scale(1);
  }
}

.pitch-surface.pitch-evt-amber {
  animation: pitchStatRipple 0.75s ease;
}
.pitch-surface.pitch-evt-red {
  animation: pitchRedRipple 0.85s ease;
}

@keyframes pitchStatRipple {
  0% {
    box-shadow: inset 0 0 0 0 transparent;
  }
  30% {
    box-shadow: inset 0 0 50px rgba(255, 223, 27, 0.22);
  }
  100% {
    box-shadow: inset 0 0 0 0 transparent;
  }
}

@keyframes pitchRedRipple {
  0% {
    box-shadow: inset 0 0 0 0 transparent;
  }
  35% {
    box-shadow: inset 0 0 55px rgba(229, 57, 53, 0.34);
  }
  100% {
    box-shadow: inset 0 0 0 0 transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pitch-heat-l,
  .pitch-heat-r {
    transition: none !important;
  }
  .pitch-meter,
  .pitch-surface.pitch-evt-amber,
  .pitch-surface.pitch-evt-red,
  .pitch-surface.pitch-flash {
    animation: none !important;
  }
  .pitch-live-caption {
    animation: none !important;
  }
  .soccer-pitch.phase-live .pitch-ball-ring {
    animation: none !important;
  }
  .pitch-ball-arrow {
    animation: none !important;
  }
  .soccer-pitch.phase-live .pitch-ball {
    animation: none !important;
    transform: none !important;
  }
  .match-detail .md-pitch-hero .soccer-pitch.phase-live .pitch-ball {
    animation: none !important;
  }
  .match-detail .md-pitch-hero .soccer-pitch.phase-live .pitch-surface {
    animation: none !important;
  }
}

.mtr-block.expanded .soccer-pitch.phase-live .pitch-ball {
  animation: pitchBallDrift2d 2.8s ease-in-out infinite, pitchBallGlow 2.4s ease-in-out infinite;
}
.mtr-block.expanded .soccer-pitch.phase-live .pitch-surface {
  animation: pitchGrassPulse 4s ease-in-out infinite;
}

@keyframes pitchGrassPulse {
  0%,
  100% {
    filter: saturate(1) brightness(1);
  }
  50% {
    filter: saturate(1.08) brightness(1.04);
  }
}

.pitch-scoreboard {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 18px;
  background: rgba(12, 12, 12, 0.58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  z-index: 5;
  max-width: 94%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pitch-scoreboard .psh,
.pitch-scoreboard .psa {
  opacity: 0.92;
  max-width: 36%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pitch-scoreboard .pss {
  font-size: 13px;
  font-weight: 900;
  color: #ffdf1b;
  padding: 0 6px;
  flex-shrink: 0;
}

.pitch-badge {
  position: static;
  transform: none;
  padding: 5px 12px;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 10px;
  font-weight: 800;
  color: #ffdf1b;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.soccer-pitch.phase-finished .pitch-ball {
  opacity: 0.88;
  animation: none;
}

.pitch-surface.pitch-flash {
  animation: pitchGoalFlash 0.75s ease;
}

@keyframes pitchGoalFlash {
  0% {
    box-shadow: inset 0 0 0 3px rgba(255, 223, 27, 0.95), 0 0 32px rgba(255, 223, 27, 0.5);
  }
  100% {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 6px 24px rgba(0, 0, 0, 0.55);
  }
}
