/* ============================================================================
   Interactive Rugby Pitch — Squad Builder
   ----------------------------------------------------------------------------
   The one surface in the product that is a PLACE rather than a page: a coach
   stands fifteen shirts on grass. Two colour families live here and they must
   not mix. The turf and its markings are the world of the pitch — green and
   white for every club on earth, so they come from --pitch-turf and white,
   never from the tenant accent. The club's colour appears only where the club
   itself does: on a filled shirt's ring, a hovered bench slot, a selected
   player. That split is why a navy or gold club still gets a green pitch with
   its own colour on the shirts (The Tenant Accent Rule).
   ========================================================================== */

.pitch-wrap {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.pitch {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-width: 460px;
  margin: 0 auto;
  /* Mowing stripes over the documented turf green: the banding is the same
     hue a few percent apart, which reads as grass, not as a gradient. */
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0, rgba(255, 255, 255, 0.05) 1px, transparent 1px, transparent 10%),
    linear-gradient(180deg,
      color-mix(in srgb, var(--pitch-turf) 88%, #e8f5ee) 0%,
      var(--pitch-turf) 50%,
      color-mix(in srgb, var(--pitch-turf) 88%, #e8f5ee) 100%);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.85), inset 0 0 40px rgba(0, 0, 0, 0.15);
}

/* Field markings: painted lines have square corners. */
.pitch::before {
  content: '';
  position: absolute; left: 4%; right: 4%; top: 8%; bottom: 8%;
  border: 2px solid rgba(255, 255, 255, 0.65);
  pointer-events: none;
}
.pitch .halfway-line {
  position: absolute; left: 4%; right: 4%; top: 50%;
  height: 2px; background: rgba(255, 255, 255, 0.65);
  transform: translateY(-50%);
}
.pitch .try-line-top, .pitch .try-line-bottom {
  position: absolute; left: 4%; right: 4%; height: 2px; background: rgba(255, 255, 255, 0.8);
}
.pitch .try-line-top { top: 8%; }
.pitch .try-line-bottom { bottom: 8%; }

/* A spot is a real <button>, so the UA's own face and border are stripped
   here — without this the 44px hit area paints as a grey plate behind the
   40px circle. */
.pitch-spot {
  position: absolute;
  width: 44px; height: 44px;
  padding: 0; border: 0; background: none; font: inherit;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 5;
}
/* The global ring is rectangular and accent-coloured; on grass it hugs the
   circle and goes white, the same ink as the field markings — guaranteed to
   read on turf whatever colour the club plays in. */
.pitch-spot:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: var(--r-full);
}
.pitch-spot .spot-circle {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.94);
  border: 2.5px dashed var(--n-400);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: var(--n-500);
  transition: transform var(--t-fast) var(--ease-spring),
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.pitch-spot:active .spot-circle { transform: scale(0.92); }
/* The circle is white in BOTH themes — it is a shirt on grass, not a card —
   so the number on it is fixed dark ink, never a theme or tenant colour: a
   club whose secondary is pale would otherwise print an unreadable shirt. */
.pitch-spot.filled .spot-circle {
  border-style: solid;
  border-color: var(--accent);
  background: #fff;
  color: var(--ink-shade);
}
/* Captaincy uses the same yellow signal as the armband chip and the bell —
   a rugby fact, deliberately outside the club accent. */
.pitch-spot.filled.captain .spot-circle {
  border-color: var(--notify);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--notify) 40%, transparent);
}
.pitch-spot .spot-label {
  position: absolute;
  top: 100%;
  margin-top: 2px;
  font-size: 11px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  left: 50%;
  transform: translateX(-50%);
}
.pitch-spot .spot-photo { width: 100%; height: 100%; border-radius: var(--r-full); object-fit: cover; }

@media (max-width: 480px) {
  .pitch-spot { width: 34px; height: 34px; }
  .pitch-spot .spot-circle { width: 30px; height: 30px; font-size: 11px; border-width: 2px; }
  .pitch-spot .spot-label { font-size: 11px; max-width: 46px; margin-top: 1px; }
}

/* Bench strip below pitch */
.bench-strip {
  margin-top: 18px;
}
.bench-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 480px) {
  .bench-grid { gap: 8px; }
}
.bench-slot {
  background: var(--n-50);
  border: 2px dashed var(--border-default);
  border-radius: var(--r-md);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  min-height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.bench-slot:hover { border-color: var(--accent); background: var(--n-100); }
.bench-slot.filled { border-style: solid; background: var(--bg-card); border-color: var(--border-default); }
.bench-slot .num { font-size: 11px; font-weight: 800; color: var(--text-tertiary); }
.bench-slot .name { font-size: 11px; font-weight: 700; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Player picker sheet. These are <button>s in a list: strip the UA face and
   keep the row shape. */
.player-pick-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  border: 1.5px solid transparent;
}
.player-pick-item:hover { background: var(--n-50); }
.player-pick-item.disabled { opacity: 0.35; pointer-events: none; }
/* Selection is the accent's job. This used to sit on --danger-bg, which made
   the currently-picked player read as a problem (The State-Only Colour Rule). */
.player-pick-item.selected { border-color: var(--accent); background: var(--accent-wash); }

.formation-legend {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px;
}
.formation-legend .badge { cursor: default; }
