/* Ligo's one stylesheet: plain CSS, light and dark from the system setting. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --line: #dde1e6;
  --accent: #1f5fbf;
  --zone-champion: #f5c84b;
  --zone-promotion: #3fa66b;
  --zone-barrage_promotion: #8fd1a8;
  --zone-qualification: #5b8def;
  --zone-barrage_relegation: #f2a65a;
  --zone-relegation: #d9534f;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --line: #2c313a;
    --accent: #7aa7ff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header.site,
main,
footer.site {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}

nav.account {
  display: flex;
  align-items: center;
  gap: 12px;
}

nav.account form {
  margin: 0;
}

header.site .brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}

footer.site {
  padding-top: 32px;
  padding-bottom: 32px;
  color: var(--muted);
  font-size: 0.875rem;
}

h1 {
  font-size: 1.75rem;
  margin: 8px 0 16px;
}

h2 {
  font-size: 1.25rem;
  margin: 32px 0 12px;
}

h3 {
  font-size: 1rem;
  margin: 20px 0 8px;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
}

.muted {
  color: var(--muted);
}

/* Tables scroll inside their card on a phone instead of widening the page. */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th.team,
td.team {
  text-align: left;
  white-space: normal;
}

tr:last-child td {
  border-bottom: none;
}

td.rank {
  border-left: 4px solid transparent;
}

tr.excluded td {
  color: var(--muted);
  text-decoration: line-through;
}

.zone-champion td.rank {
  border-left-color: var(--zone-champion);
}
.zone-promotion td.rank {
  border-left-color: var(--zone-promotion);
}
.zone-barrage_promotion td.rank {
  border-left-color: var(--zone-barrage_promotion);
}
.zone-qualification td.rank {
  border-left-color: var(--zone-qualification);
}
.zone-barrage_relegation td.rank {
  border-left-color: var(--zone-barrage_relegation);
}
.zone-relegation td.rank {
  border-left-color: var(--zone-relegation);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

.legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
  background: var(--swatch);
}

ul.matches {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.matches li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

ul.matches li:last-child {
  border-bottom: none;
}

.score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.team-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.team-head img {
  width: 64px;
  height: 64px;
}

.swatches {
  display: flex;
  gap: 6px;
}

.swatches span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

form.card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

form.card p {
  flex-basis: 100%;
  margin: 0;
}

select,
input,
button {
  font: inherit;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}

button {
  cursor: pointer;
  border-color: var(--accent);
  color: var(--accent);
}

.flash {
  border-left: 4px solid var(--zone-promotion);
}

.flash.error {
  border-left-color: var(--zone-relegation);
}

/* The staff queue: one card per item, its decisions side by side. */
ul.queue {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.queue-item p {
  margin: 0 0 6px;
}

blockquote {
  margin: 6px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 16px;
  margin-top: 8px;
}

.actions form {
  margin: 0;
}

form.refuse {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px 8px;
  flex: 1 1 280px;
}

form.refuse label {
  flex-basis: 100%;
  font-size: 0.875rem;
  color: var(--muted);
}

textarea {
  font: inherit;
  flex: 1 1 200px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}

button.danger {
  border-color: var(--zone-relegation);
  color: var(--zone-relegation);
}

.overdue {
  color: var(--zone-relegation);
  font-weight: 600;
}

/* A score screenshot in the staff queue: as wide as the card, opens full size. */
a.shot {
  display: block;
  margin: 8px 0;
}

a.shot img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

/* A form whose fields run one under the other, each under its label (the rulebook). */
form.card.stack {
  flex-direction: column;
  align-items: stretch;
}

form.card.stack label {
  font-weight: 600;
}

form.card.stack textarea {
  flex: none;
  min-height: 24em;
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
}

form.card.stack button {
  align-self: flex-start;
}

/* The rulebook's text: long, read from top to bottom, linked to by section. */
article.rules {
  line-height: 1.6;
  overflow-wrap: anywhere;
}

article.rules :is(h1, h2, h3, h4) {
  scroll-margin-top: 16px;
}

article.rules table {
  display: block;
  overflow-x: auto;
}

/* Registration: a field's problem under it, the colour pickers side by side, a link to copy. */
.field-error {
  color: var(--zone-relegation);
  font-size: 0.875rem;
}

p.colors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

p.colors .color {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

p.colors [hidden] {
  display: none;
}

input.copy {
  width: 100%;
  font-family: ui-monospace, monospace;
}

dl.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
}

dl.facts dd {
  margin: 0;
}

/* A one-button form inside a line of a list, such as removing an official. */
form.inline {
  display: inline;
  margin-left: 8px;
}

/* A form shown closed, such as the mercato's outside its windows. */
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

fieldset legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 8px;
}

fieldset:disabled {
  opacity: 0.6;
}

button.inline {
  margin-left: 8px;
}

/* The stat grid (pages/match-stats.ts). */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.tabs a[aria-current='page'] {
  font-weight: bold;
  text-decoration: none;
}

.stat-grid {
  border-collapse: collapse;
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.stat-grid th,
.stat-grid td {
  padding: 0.25rem 0.5rem;
  text-align: left;
}

.stat-grid input {
  width: 4rem;
}

.stat-grid input[aria-invalid='true'] {
  outline: 2px solid var(--zone-relegation);
}

.scoreboard {
  margin-top: 0.75rem;
}

.scoreboard caption {
  font-weight: bold;
  text-align: left;
}

/* The admin panel's settings forms (pages/settings-fields.ts). */
fieldset {
  border: 1px solid var(--line);
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
}

.select-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.settings-rows input {
  width: 100%;
}
