/* Reusable pieces: buttons, chips, cards, tables, banners. */

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: var(--weight-medium);
  text-decoration: none;
}

.btn--primary {
  background: var(--ui-accent);
  border-color: var(--ui-accent);
  color: #ffffff;
}

.btn--ghost {
  border-color: var(--border);
  background: transparent;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Sidebar buttons ---------- */

.navbtn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  color: var(--sidebar-text);
  font-weight: var(--weight-medium);
  font-size: 0.92rem;
  text-align: left;
}

.navbtn:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.16);
}

.navbtn[aria-current="true"] {
  background: rgba(255, 255, 255, 0.2);
  border-color: currentColor;
}

.navbtn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* The colour is a tinted fill plus an edge plus a labelled dot — never colour
 * alone. The tint is deliberately translucent `rgba()` over the sidebar's own
 * (always dark) background, not a solid fill: a solid orange, for instance,
 * would be unreadable with dunkel's bright orange-400 and unreadable with
 * white text either way. Blending toward the dark sidebar sidesteps that
 * per-theme contrast risk entirely instead of hand-tuning ink colours per
 * theme per group colour (GSN-0033). The text label stays the actual
 * accessible signal — never colour alone, red-green colour blindness. */
.navbtn[data-color]:not([data-color=""]) {
  background: var(--fill);
  border-left: 4px solid var(--edge);
  border-top-color: transparent;
  border-right-color: transparent;
  border-bottom-color: transparent;
}

.navbtn[data-color]:not([data-color=""]):hover:not([disabled]) {
  filter: brightness(1.2);
}

.navbtn[data-color]:not([data-color=""])[aria-current="true"] {
  border-top-color: var(--edge);
  border-right-color: var(--edge);
  border-bottom-color: var(--edge);
}

.navbtn__dot {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--dot, transparent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.navbtn__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbtn__badge {
  flex: none;
  padding: 0 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--ui-warn);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: var(--weight-bold);
}

/* Secondary nav entries (Turniere, Doku, Änderungen) live in a submenu under
 * "Admin" (GSN-0084) — dimmed and smaller so the group buttons stay the anchor. */
.navbtn--secondary {
  background: transparent;
  color: var(--sidebar-mute);
  font-size: 0.82rem;
}

.navbtn--secondary:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.1);
}

.navbtn--secondary[aria-current="true"] {
  background: rgba(255, 255, 255, 0.14);
  color: var(--sidebar-text);
}

/* "Admin" and its submenu. The caret marks that there is more; the submenu
 * opens on hover (mouse) or, on touch, once you are on an admin-side route. */
.navgroup {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.navbtn--parent .navbtn__label::after {
  content: " ›";
  color: var(--sidebar-mute);
}

.navgroup:hover .navbtn--parent .navbtn__label::after {
  content: " ⌄";
}

.navsub {
  display: none;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: var(--space-3);
}

.navsub.is-open,
.navgroup:hover .navsub {
  display: flex;
}

.navbtn--tool {
  justify-content: center;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  font-size: 0.8rem;
}

.scalebar {
  display: flex;
  gap: var(--space-1);
}

.scalebar .navbtn--tool {
  flex: 1;
  font-size: 1.1rem;
  font-weight: var(--weight-bold);
}

/* ---------- Colour tokens per group colour ---------- */

/* --headbg / --headfg drive the filled group headers on the Tableau and the
 * Ergebnisse page (GSN-0088, retuned GSF-0089). Fixed values, identical in all
 * three themes: a header is an accent block, not a themed surface, so it keeps a
 * strong, recognisable hue rather than tracking the theme's lightness. Gruen,
 * Rot and Orange stay dark enough for white text; Gelb cannot be both yellow
 * and dark, so it keeps a bright fill and takes dark ink — the rule already
 * stated for Gelb in tokens.css. Not a color-mix in sight: mixing toward black
 * turned Gelb brown and desaturated Orange. */
[data-color="gruen"] {
  --dot: var(--gruppe-gruen);
  --edge: var(--gruppe-gruen);
  --fill: rgba(var(--gruppe-gruen-rgb), 0.42);
  --headbg: #1f7a3d;
  --headfg: #ffffff;
}
[data-color="gelb"] {
  --dot: var(--gruppe-gelb);
  --edge: var(--gruppe-gelb);
  --fill: rgba(var(--gruppe-gelb-rgb), 0.42);
  --headbg: #f6c40f;
  --headfg: #4a3a00;
}
[data-color="rot"] {
  --dot: var(--gruppe-rot);
  --edge: var(--gruppe-rot);
  --fill: rgba(var(--gruppe-rot-rgb), 0.42);
  --headbg: #b3261e;
  --headfg: #ffffff;
}
[data-color="orange"] {
  --dot: var(--gruppe-orange);
  --edge: var(--gruppe-orange);
  --fill: rgba(var(--gruppe-orange-rgb), 0.42);
  --headbg: #d2600c;
  --headfg: #ffffff;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  /* A form or a short list reads worse the wider it stretches — cap it
   * regardless of how wide the window is. The assignment board is the one
   * card that genuinely needs the space (`.card--wide` below). */
  max-width: var(--content-max);
}

.card--edged {
  border-left: 6px solid var(--edge, var(--border-strong));
}

/* Group cards on the Ergebnisse page: a thick colour edge and a filled,
 * group-coloured header (GSN-0088, retuned GSF-0089 — see --headbg above). */
.card--colorhead {
  border-left-width: 12px;
  border-left-color: var(--headbg, var(--edge));
}

.card--colorhead .card__head {
  background: var(--headbg);
  color: var(--headfg);
  border-bottom: 0;
}

.card--colorhead .card__meta {
  color: var(--headfg);
  opacity: 0.8;
}

/* The group card on a single-group view carries a "N Spieler" chip in the head;
 * on the filled header it borrows the header ink instead of the group edge. */
.card--colorhead .card__head .chip {
  border-color: var(--headfg);
  color: var(--headfg);
  background: rgba(127, 127, 127, 0.18);
}

.card--wide {
  max-width: none;
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.card__title {
  font-size: 1.05rem;
  font-weight: var(--weight-bold);
}

.card__meta {
  margin-left: auto;
  color: var(--text-mute);
  font-size: 0.85rem;
}

.card__body {
  padding: var(--space-4);
}

.card__body--flush {
  padding: 0;
}

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.15rem var(--space-2);
  border: 2px solid var(--edge, var(--border-strong));
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.chip--muted {
  border-color: var(--border);
  color: var(--text-mute);
  font-weight: var(--weight-medium);
}

/* ---------- Match rows ---------- */

.matchlist {
  display: flex;
  flex-direction: column;
}

.round-label {
  padding: var(--space-2) var(--space-4);
  background: var(--surface-sunken);
  border-block: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 3.25rem;
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}

.match:last-child {
  border-bottom: 0;
}

.match__side {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-medium);
}

.match__side--right {
  text-align: right;
}

.match__side.is-winner {
  font-weight: var(--weight-bold);
}

.match__side.is-winner::after {
  content: " ✓";
  color: var(--gruppe-gruen);
}

.match__score {
  flex: none;
  min-width: 4.5rem;
  padding: 0.1rem var(--space-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-num);
  font-size: 1.05rem;
  font-weight: var(--weight-bold);
  text-align: center;
}

.match__score--open {
  border-style: dashed;
  color: var(--text-mute);
  font-size: 0.8rem;
  font-weight: var(--weight-medium);
}

/* ---------- Standings ---------- */

.standings th,
.standings td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.standings th {
  background: var(--surface-2);
  font-size: 0.72rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-mute);
  white-space: nowrap;
}

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

.standings td:nth-child(1) {
  width: 2rem;
  font-weight: var(--weight-bold);
}

.standings td:nth-child(2) {
  font-weight: var(--weight-medium);
}

.standings tbody tr:last-child td {
  border-bottom: 0;
}

.standings .col-points {
  font-weight: var(--weight-bold);
  font-size: 1.05rem;
}

.tie-flag {
  color: var(--ui-warn);
  font-weight: var(--weight-bold);
}

/* The results overview's compact ranking — position + name only, no
 * points/wins/losses columns. That detail stays on the group's own page. */
.results__ranking {
  margin: 0;
  padding-left: 1.5rem;
}

.results__ranking li {
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
}

.results__ranking li:last-child {
  border-bottom: 0;
}

/* Narrow screens drop the derived columns, never points or difference. */
@media (max-width: 30rem) {
  .standings th:nth-child(n + 4):nth-child(-n + 6),
  .standings td:nth-child(n + 4):nth-child(-n + 6) {
    display: none;
  }
}

/* ---------- Banners and empty states ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--ui-warn);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: var(--weight-medium);
}

.empty {
  padding: var(--space-6) var(--space-4);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-mute);
}

.empty__big {
  font-size: 1.15rem;
  font-weight: var(--weight-bold);
  color: var(--text);
  margin-bottom: var(--space-2);
}
