/* bleague – base stylesheet. No build step; colours as custom properties with a dark
   variant driven by the operating system setting (prefers-color-scheme). */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1b2333;
  --text-muted: #5b6577;
  --border: #dde2ec;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --accent-soft: #e3eafd;
  --win: #15803d;
  --loss: #b91c1c;
  --focus: #f59e0b;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --container: 72rem;
  --gutter: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141d;
    --surface: #171e2a;
    --surface-2: #1f2836;
    --text: #e6eaf2;
    --text-muted: #9aa5b8;
    --border: #2c3747;
    --accent: #6b9bff;
    --accent-text: #0b1220;
    --accent-soft: #1c2a47;
    --win: #4ade80;
    --loss: #f87171;
    --shadow: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

main {
  flex: 1;
  padding-block: 2rem 3rem;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.25rem); }
h2 { font-size: 1.25rem; }

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius);
  z-index: 10;
}

.skip-link:focus { top: 0.5rem; }

/* --- header --- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-block: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
  margin-right: auto;
}

.brand-logo { flex-shrink: 0; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.brand-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.main-nav,
.lang-switch {
  display: flex;
  gap: 0.25rem;
}

.main-nav a,
.lang-switch a {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.main-nav a:hover,
.lang-switch a:hover { background: var(--surface-2); }

.main-nav a[aria-current="page"],
.lang-switch a[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.lang-switch a {
  font-size: 0.85rem;
  text-transform: uppercase;
}

/* --- content blocks --- */

.hero { margin-bottom: 1.5rem; }

.lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 45rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.feature-list {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.feature-list li { margin-bottom: 0.35rem; }

.button {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover { filter: brightness(1.08); }

.button-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.button-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.link-list {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.link-list li { margin-bottom: 0.35rem; }

.breadcrumbs {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* --- forms --- */

.form-card { max-width: 26rem; margin-inline: auto; }

.form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form label { font-weight: 600; font-size: 0.9rem; }

.form input,
.form select {
  font: inherit;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.65rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.form .button { margin-top: 0.35rem; align-self: flex-start; }

.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid currentColor;
}

.alert-error { color: var(--loss); }
.alert-success { color: var(--win); margin-bottom: 1.25rem; }
.alert-info { color: var(--text-muted); margin-bottom: 1.25rem; }

.form input[aria-invalid="true"],
.form select[aria-invalid="true"] { border-color: var(--loss); }

.field-error {
  color: var(--loss);
  font-size: 0.85rem;
  margin: -0.4rem 0 0.65rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: -0.4rem 0 0.65rem;
}

.form fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem 0.25rem;
  margin: 0 0 0.75rem;
}

.form legend { font-weight: 600; font-size: 0.9rem; padding-inline: 0.25rem; }

.form .radio,
.form .checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.form .radio input,
.form .checkbox input { margin: 0; width: 1.05rem; height: 1.05rem; }

.form .input-narrow { max-width: 8rem; }
.form .input-date { max-width: 12rem; }

/* one row of the new-matches form: "1.  [home] : [visitor]" */
.match-row {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.match-row select { margin: 0; min-width: 0; }
.match-no, .match-vs { color: var(--text-muted); }

/* result form: home and visitors side by side, one row per position */
.result-sides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 0 1.5rem;
}
.form fieldset.result-side { gap: 0; }
.form fieldset.result-side:disabled { opacity: 0.45; }
.result-row {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) 4.75rem 4rem;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.result-row select,
.result-row input { margin: 0; min-width: 0; }
.result-head { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }

/* recorded result */
.result-table tr.result-total td { font-weight: 600; border-top: 2px solid var(--border); }
.result-table tr.result-points td { font-weight: 700; font-size: 1.1rem; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.form .form-actions .button { margin-top: 0; }

.button-danger { background: var(--loss); color: #fff; }

.danger-zone { max-width: 26rem; margin-inline: auto; border-color: var(--loss); }
.danger-zone h2 { color: var(--loss); font-size: 1rem; }

.inline-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.inline-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0.35rem 0.6rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* --- administration layout --- */

.page-head,
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1,
.card-head h2 { margin: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0 1.5rem;
}

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

.item-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

td.actions { text-align: right; }
td.actions form { display: inline; }

.subhead { font-size: 1rem; margin-top: 1.5rem; }

/* checkbox group in columns, e.g. teams to enrol */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0 1rem;
}

/* lineup page: player list on the left, the new-player form on the right (kept in view) */
.lineup-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(16rem, 2fr);
  gap: 0 1.5rem;
  align-items: start;
}

.lineup-new { position: sticky; top: 1rem; }

@media (max-width: 50rem) {
  .lineup-layout { grid-template-columns: minmax(0, 1fr); }
  .lineup-new { position: static; order: -1; } /* on phones above the long list */
}

.player-pick { margin-top: 0.75rem; }
.player-pick .form-actions { margin: 0.5rem 0; }

table.compact { font-size: 0.875rem; }
table.compact td { padding: 0.2rem 0.5rem; }
table.compact td.pick { width: 1.5rem; }
table.compact label { display: block; cursor: pointer; }
table.compact tr.taken td { color: var(--text-muted); }
.table-note { color: var(--text-muted); font-size: 0.85rem; margin: 0.75rem 0 0; }
.duplicates-table { margin-bottom: 0.75rem; }

/* players with the same name, listed before creating a duplicate */
.duplicates {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.9rem 0.5rem 1.8rem;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- logged-in admin in the header --- */

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.user-name { font-size: 0.9rem; color: var(--text-muted); }
a.user-name { text-decoration: none; }
a.user-name:hover { color: var(--text); text-decoration: underline; }

/* --- tables (standings, results, statistics) --- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

th, td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-2);
}

td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 12rem; }

tbody tr:hover { background: var(--surface-2); }

.win { color: var(--win); font-weight: 600; }
.loss { color: var(--loss); }

/* --- public pages --- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  padding: 0.5rem 0.9rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--accent); }
.tabs a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }

.switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: -0.5rem 0 1rem;
}

.league-links { list-style: none; margin: 0 0 0.5rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.league-links a { font-weight: 600; font-size: 1.05rem; }

.jump { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }

td.strong { font-weight: 700; }

table.match-list td { white-space: normal; }
table.match-list td.team-home { text-align: right; width: 42%; }
table.match-list td.team-visitor { width: 42%; }
table.match-list td.score { text-align: center; white-space: nowrap; font-weight: 600; }

/* --- error page --- */

.error-page { text-align: center; padding-block: 2.5rem; }

.error-code {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}

.trace-id code { font-family: var(--font-mono); font-size: 0.9rem; user-select: all; overflow-wrap: anywhere; }

/* --- footer --- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  padding-block: 1rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.site-footer a { color: var(--text-muted); }

.footer-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }

/* running text such as the privacy notice */
.prose { max-width: 42rem; }
.prose p { line-height: 1.6; }

/* a player whose name is not public (administration) */
.badge-hidden { font-size: 0.75rem; padding: 0.05rem 0.4rem; border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); white-space: nowrap; }

@media (max-width: 40rem) {
  .brand-tagline { display: none; }
  .card { padding: 1rem; }
  th, td { padding: 0.45rem 0.4rem; }
  th { letter-spacing: 0; }
  td.name { white-space: normal; min-width: 7rem; } /* team and player names wrap on phones */
  .hide-narrow { display: none; }
}
