/* The score-entry grid and the per-match action menu (04-UI-SPEC "New Component Patterns"), shared
   by every page that enters a score: the Pools page, the bracket page, the court board and the
   player's phone. Palette tokens only, light only, the site-wide :focus-visible ring is never
   overridden, and every control is at least 44px. State is carried by words and icons as well as
   color. */

/* ---- the action menu ---- */

.match-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.match-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
}

.match-action-button:hover {
  background: var(--tint);
}

.match-action-button svg {
  width: 20px;
  height: 20px;
}

/* The word "Match" beside the icon (review E-13): the match menu reads differently from the court
   menu on a busy court card. */
.match-action-label {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding-right: var(--space-xs);
}

.match-action-menu {
  position: absolute;
  left: 0;
  top: 48px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 240px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(10, 26, 34, 0.12);
  padding: var(--space-xs) 0;
}

.match-action-menu[hidden] {
  display: none;
}

.match-action-item {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-md);
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}

.match-action-item:hover {
  background: var(--tint);
}

.match-action-slot {
  flex-basis: 100%;
}

.match-action-slot:empty {
  display: none;
}

.match-disputed-state {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 14px;
  color: var(--error);
}

.match-disputed-state svg {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ---- the score panel and the grid ---- */

.score-panel,
.forfeit-panel,
.match-clear-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.match-clear-panel p {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

.score-panel-title {
  font-size: 16px;
  line-height: 1.4;
  font-weight: 600;
  margin: 0;
}

.score-grid-table {
  border-collapse: collapse;
}

.score-grid-table th,
.score-grid-table td {
  padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
  text-align: left;
  vertical-align: middle;
}

.score-grid-team {
  font-size: 14px;
  line-height: 1.45;
  font-weight: 600;
  max-width: 140px;
}

.score-grid-game {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.score-input {
  min-height: 44px;
  min-width: 44px;
  width: 64px;
  padding: var(--space-sm);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid var(--control);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.score-input[aria-invalid="true"] {
  border-color: var(--error);
  border-width: 2px;
}

.score-grid-error {
  margin: var(--space-xs) 0 0;
}

.score-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* "Save anyway" reads as a link; the reason panel opens beside it. */
.score-override {
  position: relative;
}

.score-override:empty {
  display: none;
}

.score-override .link-button {
  background: none;
  border: none;
  padding: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
}

.score-override .reason-panel {
  left: 0;
  right: auto;
}

.match-actions .btn-danger {
  color: var(--error);
  border-color: var(--error);
}

/* ---- standings (the Pools page fills each pool card's slot) ---- */

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.standings-table th,
.standings-table td {
  padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  text-align: left;
}

.standings-table td {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.standings-table td.standings-team {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-weight: 600;
}

.standings-ties {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  margin: var(--space-xs) 0 0;
}

.standings-winner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 700;
  margin: 0;
}

.standings-winner svg {
  width: 16px;
  height: 16px;
}

/* ---- print controls on screen ---- */

.print-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.print-controls fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  border: 0;
  padding: 0;
  margin: 0;
}

.print-controls legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.print-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--control);
  border-radius: 8px;
  cursor: pointer;
  /* A choice reads as a sentence, not as a form label (app.css capitalizes labels). */
  font-size: 15px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}

.print-option input[type="radio"] {
  width: 20px;
  height: 20px;
  flex: none;
}

.print-controls .btn svg {
  width: 20px;
  height: 20px;
}

/* Print-only pieces stay off the screen. */
.print-caption,
.print-boxes {
  display: none;
}

/* ---- Record a forfeit (04-11): who forfeits, then the reason panel ---- */

.forfeit-options {
  display: flex;
  flex-direction: column;
}

.forfeit-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  font-size: 15px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  cursor: pointer;
}

.forfeit-option input[type="radio"] {
  width: 20px;
  height: 20px;
  flex: none;
}

.forfeit-panel .error-message {
  margin: 0;
  font-size: 14px;
  color: var(--error);
}

.forfeit-panel .error-message[hidden] {
  display: none;
}

/* The reason is part of the forfeit panel, so it sits in the flow instead of floating as a popover. */
.forfeit-panel .reason-panel {
  position: static;
  width: auto;
  max-width: none;
  padding: 0;
  border: none;
  box-shadow: none;
}

/* ---- late corrections (04-13): the reseed, reversal, swap and pool edit panels, in place ---- */

.late-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

.late-panel p {
  margin: 0;
}

/* The reseed panel leads the pools or the bracket: keep it apart from what follows. */
.reseed-panel {
  margin-bottom: var(--space-md);
}

.late-title {
  font-weight: 600;
}

.late-list {
  margin: 0;
  padding-left: var(--space-lg);
}

.late-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.late-panel .field {
  margin-bottom: 0;
}

.late-panel select {
  width: 100%;
  min-height: 44px;
  font: inherit;
  font-size: 16px;
  padding: 0 var(--space-md);
  border: 1px solid var(--control);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.late-panel .error-message {
  margin: 0;
  color: var(--error);
}

.late-panel .error-message[hidden] {
  display: none;
}

/* The reason is part of the panel, so it sits in the flow instead of floating as a popover. */
.late-panel .reason-panel {
  position: static;
  width: auto;
  max-width: none;
  padding: 0;
  border: none;
  box-shadow: none;
}

/* D-24's warning: a plain sentence above the confirm button, in words, never color alone. */
.late-warning {
  font-weight: 600;
}

/* The one primary action that destroys recorded results (D-28): white on the error red, 6.5:1. */
.btn-error {
  background: var(--error);
  color: var(--paper);
  border-color: var(--error);
}

.btn-error:hover {
  background: #8f1c13; /* error darkened */
}

.btn-error:disabled {
  background: var(--control);
  color: var(--subtle);
  border-color: var(--control);
}

.late-panel .btn-danger {
  color: var(--error);
  border-color: var(--error);
}

/* D-27's post-bracket note under a pool's standings: informational, muted, no button. */
.late-note {
  margin: var(--space-sm) 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.pool-edit-slot:empty,
.late-slot:empty {
  display: none;
}
