/* Copyright (c) 2026 Brownie, LLC. All rights reserved. */

/*
 * Tournaments (views/tournaments.ts), laid out by the approved design's
 * Tournaments page: the season's tournaments down the side, then the
 * tournament's card with its team scores, the results table, "Type results
 * quickly" beside the batch scanner's card, and cards to link. Builds on
 * the components in app.css; the number boxes are in team-season.css.
 */

/* A panel under the header that's closed takes no room. */
.page-panel-slot:has(> [hidden]:only-child) {
  display: none;
}

/* ---------- The list ---------- */

.tournament-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* On the Tournaments page, the cards share the width. */
.tournament-index .tournament-list {
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
}

.tournament-link {
  display: grid;
  gap: 2px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
}

.tournament-link:hover {
  border-color: var(--color-control-border);
}

.tournament-link[aria-current="page"] {
  padding: 11px 13px;
  border: 2px solid var(--color-tournament);
  background: var(--color-tournament-soft);
}

.tournament-link-name {
  font-size: 1rem;
}

.tournament-link-days {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.tournament-link-timing {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- A tournament: the list beside it on a wide screen ---------- */

.tournament-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tournament-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}

/* A phone has no room for the list beside the tournament: "All tournaments" goes back to it. */
.tournament-side {
  display: none;
}

/* The list beside the tournament only where the results table still has
   room for its columns; narrower, the app bar's Tournaments goes back to it. */
@media (min-width: 1200px) {
  .tournament-side {
    display: block;
  }

  .tournament-layout {
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  }
}

.tournament-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tournament-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.tournament-title h2:focus:not(:focus-visible),
.tournament-detail h2:focus:not(:focus-visible) {
  outline: none;
}

.tournament-days {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.tournament-manage-panel {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-divider);
}

.tournament-manage-panel[hidden] {
  display: none;
}

.tournament-small {
  margin: 0;
  font-size: 0.85rem;
}

/* ---------- Team scores ---------- */

.team-score-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.team-score {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.team-score.is-team {
  padding: 11px 13px;
  border: 2px solid var(--color-tournament);
  background: var(--color-tournament-soft);
}

.team-score-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.team-score-total {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.team-score-total b {
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
}

.team-score-note {
  color: var(--color-accent-strong);
  font-size: 0.8rem;
  font-weight: 600;
}

.team-score.is-short .team-score-note {
  color: var(--color-review-text);
}

.tournament-gender-note {
  margin: 0;
  color: var(--color-review-text);
  font-size: 0.85rem;
  font-weight: 600;
}

.tournament-gender-note:empty {
  display: none;
}

/* ---------- Results ---------- */

.tournament-results-toolbar {
  align-items: center;
  justify-content: space-between;
}

.tournament-results-toolbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
}

.tournament-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

.tournament-results .is-total {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.tournament-results .is-tens {
  color: var(--color-ten-text);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.tournament-check {
  font-size: 0.85rem;
  white-space: normal;
}

.tournament-check.is-ok {
  color: var(--color-accent-strong);
  font-weight: 600;
}

.tournament-check.is-check {
  color: var(--color-review-text);
  font-weight: 600;
}

.tournament-check.is-quiet {
  color: var(--color-text-muted);
}

/* The Check column wraps its flag rather than widening the table without end. */
.tournament-results td:has(.tournament-check) {
  min-width: 12em;
  white-space: normal;
}

.tournament-nasp {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tournament-nasp .button {
  min-height: 40px;
  padding-inline: 10px;
}

.tournament-unlink .button {
  min-height: 40px;
}

.table-note[hidden] {
  display: none;
}

/* ---------- Typing results, and the batch scanner ---------- */

.tournament-grid-card h2,
.tournament-batch-card h2,
.tournament-unlinked h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
}

.quick-grid {
  width: 100%;
  border-collapse: collapse;
}

.quick-grid th,
.quick-grid td {
  padding: 4px 8px 4px 0;
  text-align: left;
  vertical-align: top;
}

.quick-grid thead th {
  position: static;
  background: none;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quick-grid tbody th {
  padding-top: 12px;
  font-weight: 500;
  white-space: normal;
}

.quick-grid .tournament-box {
  min-height: var(--size-control);
  background: var(--color-field);
}

.quick-grid .tournament-box:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 0;
}

.tournament-batch-card {
  border: 2px dashed var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
}

.tournament-batch-card p {
  margin: 0;
}

.tournament-batch-card .button,
.tournament-grid-card .button-row {
  justify-self: start;
}

.tournament-batch-card .button {
  text-decoration: none;
}

/* An archer with no result yet: quieter than a result, so the table reads as results first. */
.tag.is-missing {
  padding: 3px 9px;
  border: 1px dashed var(--color-control-border);
  background: none;
  color: var(--color-text-muted);
  font-weight: 500;
}
