/*
 * The one stylesheet for every page referees use (the Django admin keeps its own).
 *
 * The design language is the "Tableau d'affichage" scoreboard chosen from the
 * card mockups: a dark ground, dark panels, amber for what matters now, red for
 * what is off, condensed capitals for labels. Everything below is built from
 * the tokens in section 2, and pages compose the shared components of section
 * 4 rather than carrying styles of their own.
 *
 *   1. Fonts        self-hosted Barlow, see ../fonts/README.md
 *   2. Tokens       colour, type, spacing, shape
 *   3. Base         document, text, links, focus
 *   4. Components   header, page, panel, facts, messages, forms, buttons,
 *                   tabs, status line, match cards, region lines, steps
 */

/* 1. Fonts ------------------------------------------------------------------ */

@font-face {
  font-family: "Barlow";
  src: url("../fonts/barlow-latin-400.81419bf5abb5.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("../fonts/barlow-latin-500.8e986e86d57e.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("../fonts/barlow-latin-600.a1e2a2d7d4c0.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/barlow-condensed-latin-500.24f826a7cf9c.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/barlow-condensed-latin-600.ba4513495282.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("../fonts/barlow-condensed-latin-700.e1180918b873.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* 2. Tokens ----------------------------------------------------------------- */

:root {
  /* A single dark look, by design: the scoreboard does not have a day mode.
     color-scheme itself is set on the site's own containers, not here; see
     section 3. */
  --bg: #0b0d10;
  --surface: #161a20;
  --surface-sunken: #0d1014;
  --border: #262c35;
  --border-strong: #2b323c;

  /* Form fields: a shade lighter than the ground, with a quiet outline. */
  --field-bg: #14181e;
  --field-border: #2e3541;
  --field-border-hover: #3b4350;
  --field-height: 52px;
  /* One line of help or error text under each field, reserved in advance. */
  --message-line: 20px;

  --text: #e9edf2;
  --text-muted: #9aa4b1;
  --text-faint: #6f7a88;

  /* Amber: what matters now (the next match, the main action, focus). */
  --accent: #ffb627;
  --accent-glow: rgb(255 182 39 / 0.16);
  --on-accent: #14171c;
  /* Red: what is off (cancelled, refused, wrong). */
  --danger: #ff5d5d;
  --danger-glow: rgb(255 93 93 / 0.14);
  /* Green: what just worked (a successful check). */
  --success: #3ccf7e;

  /* One colour per federation, for league badges. */
  --fed-sbl: #5b3cc4;
  --fed-swb: #d0262f;
  --fed-afbb: #1d63c8;
  --fed-avb: #12805a;

  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-text: "Barlow", system-ui, sans-serif;
  --tracking-label: 0.08em;
  --tracking-eyebrow: 0.16em;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --radius: 8px;
  --radius-small: 6px;
  --touch: 44px;
  --page-width: 40rem;
}

/* 3. Base ------------------------------------------------------------------- */

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

/*
 * Dark form controls, but only inside the site's own containers. Declared on
 * the whole document, it made browser extensions' frames (Bitwarden's autofill
 * menu and save dialog) paint an opaque white backdrop: a frame whose colour
 * scheme differs from the page it sits in loses its transparency.
 */
.site-header,
.page {
  color-scheme: dark;
}

html {
  scrollbar-color: var(--border-strong) var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  text-transform: uppercase;
  text-wrap: balance;
}

h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--text-muted);
}

p {
  margin: 0;
}

a {
  color: var(--text);
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* 4. Components -------------------------------------------------------------- */

/*
 * Site header: brand, navigation, and the sign-out action set apart from it.
 * On a phone the brand and sign-out share the first row, at opposite ends,
 * and the navigation takes the row below; wider screens fit all on one row.
 */
.site-header {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand account"
    "nav nav";
  align-items: center;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
}

@media (min-width: 40rem) {
  .site-header {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand nav account";
    gap: var(--space-5);
  }
}

.site-header > .brand {
  grid-area: brand;
  justify-self: start;
}

.site-nav {
  grid-area: nav;
}

.site-account {
  grid-area: account;
  justify-self: end;
  margin: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

/* The mark, painted amber through its shape: see ../icons/mark.svg. */
.brand::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  mask: url("../icons/mark.41231c4d8931.svg") center / contain no-repeat;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
}

.site-nav a {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
}

/* Page body: one centred column, phone first. */
.page {
  display: grid;
  gap: var(--space-5);
  max-width: var(--page-width);
  margin-inline: auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
}

.page--narrow {
  --page-width: 24rem;
  padding-top: 12vh;
}

.page-intro {
  display: grid;
  gap: var(--space-2);
}

.lead {
  color: var(--text-muted);
  max-width: 60ch;
}

/* A small amber caption above something, like "Prochain match". */
.eyebrow {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow--danger {
  color: var(--danger);
}

/* Panel: the scoreboard surface everything sits on. */
.panel {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel--highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 26px var(--accent-glow);
}

.panel--alert {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger), 0 0 26px var(--danger-glow);
}

/* Facts: label and value pairs, such as a status. */
.facts {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
}

.facts dt {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 1px;
}

.facts dd {
  margin: 0;
}

.facts .is-ok {
  color: var(--accent);
}

.facts .is-error {
  color: var(--danger);
}

@media (max-width: 30rem) {
  .facts {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .facts dd + dt {
    margin-top: var(--space-3);
  }
}

/* Messages: confirmations after an action. */
.messages {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.message {
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}

.message--error {
  border-color: var(--danger);
}

/*
 * Forms: styles Django's own form output ({{ form }}: one <div> per field
 * holding label, help text, errors and input, in that order), so any form
 * looks right without markup of its own.
 *
 * Layout: the label above a large outlined field, then one message line.
 *
 * An error must not move anything when it appears, so every field reserves
 * that line, and the help text and the error share it: while there is an
 * error the help stays in place but invisible, keeping its height. Screen
 * readers still reach both through the field's aria-describedby, which Django
 * sets. The placement is by grid area, whatever order Django writes them in.
 */
.form {
  display: grid;
  gap: var(--space-4);
}

.form > div {
  display: grid;
  grid-template-areas: "label" "field" "message";
  grid-template-rows: auto auto minmax(var(--message-line), auto);
  row-gap: var(--space-2);
}

.form > div > label {
  grid-area: label;
}

.form > div > :is(input, select, textarea) {
  grid-area: field;
}

.form > div > :is(.helptext, .errorlist) {
  grid-area: message;
}

.form > div:has(> .errorlist) > .helptext {
  visibility: hidden;
}

/* The form-wide error ("wrong login or password") goes after the submit
   button, where nothing follows it that it could push down. */
.form > .errorlist.nonfield {
  order: 1;
}

.form label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
}

.form input:is([type="text"], [type="password"], [type="email"], [type="number"]),
.form select,
.form textarea {
  width: 100%;
  min-height: var(--field-height);
  padding: var(--space-3) var(--space-4);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-small);
  color: var(--text);
  /* 16px keeps phones from zooming into the field. */
  font: 500 16px/1.3 var(--font-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form :is(input, select, textarea):hover {
  border-color: var(--field-border-hover);
}

.form :is(input, select, textarea):focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Same specificity as the field rule above, and later, so it wins. */
.form :is(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--danger);
}

.form :is(input, select, textarea)[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px var(--danger-glow);
}

.form .helptext {
  font-size: 14px;
  color: var(--text-faint);
}

/* A checkbox sits before its label, with the message line under the label. */
.form > div:has(> input[type="checkbox"]) {
  grid-template-areas: "field label" ". message";
  grid-template-columns: auto 1fr;
  grid-template-rows: auto minmax(var(--message-line), auto);
  gap: var(--space-1) var(--space-3);
  align-items: center;
}

.form > div:has(> input[type="checkbox"]) > label {
  color: var(--text);
}

.form input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
}

/*
 * A number of minutes or an amount is short: it sits at the end of its label's line, and
 * the message line is reserved under the label, beside the field. A list of
 * them stays compact, and an error still moves nothing.
 */
.form > div:has(> :is(input[type="number"], input[inputmode="decimal"])) {
  grid-template-areas: "label field" "message field";
  grid-template-columns: 1fr 96px;
  grid-template-rows: auto minmax(var(--message-line), auto);
  gap: var(--space-1) var(--space-3);
}

.form > div:has(> :is(input[type="number"], input[inputmode="decimal"])) > label {
  align-self: end;
  color: var(--text);
}

.form > div:has(> :is(input[type="number"], input[inputmode="decimal"])) > :is(.helptext, .errorlist) {
  align-self: start;
}

.form > div:has(> :is(input[type="number"], input[inputmode="decimal"])) > input {
  align-self: center;
}

.form :is(input[type="number"], input[inputmode="decimal"]) {
  text-align: right;
}

/*
 * A group of fields under one heading, such as the arrival time per league:
 * a form of its own, usually in a panel. Floated, the legend is laid out
 * like any heading instead of sitting on the border.
 */
.form fieldset {
  min-width: 0;
  margin: 0;
}

.form legend {
  float: left;
  width: 100%;
  padding: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
}

.errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: 14px;
}

.errorlist.nonfield {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

/* Buttons. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: var(--space-2) var(--space-5);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-small);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}

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

/* Nothing to do yet: shown, greyed, so the referee knows where it will be. */
.button:disabled {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-faint);
  filter: none;
  cursor: default;
}

.button svg {
  width: 18px;
  height: 18px;
  flex: none;
}

/* A secondary action: outlined, never competing with the amber main one. */
.button--quiet {
  background: transparent;
  border-color: var(--field-border-hover);
  color: var(--text);
}

.button--quiet:hover {
  filter: none;
  border-color: var(--text-muted);
}

.button--small {
  gap: var(--space-2);
  min-height: 40px;
  padding: var(--space-1) var(--space-3);
  font-size: 15px;
  font-weight: 600;
}

.button--block {
  width: 100%;
}

/* An action that just worked: green, with a check mark before the label. */
.button--success {
  gap: var(--space-2);
  border-color: var(--success);
  color: var(--success);
}

.button--success:hover {
  border-color: var(--success);
}

/* An action under way (see js/app.js): a spinner before the label. */
.button[aria-busy="true"] {
  gap: var(--space-2);
  cursor: progress;
}

/* Running it again: the earlier success no longer holds. */
.button--success[aria-busy="true"] {
  border-color: var(--field-border-hover);
  color: var(--text);
}

.button[aria-busy="true"]::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Actions: a row of buttons, with an optional hint beside them. */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.hint {
  margin: 0;
  font-size: 14px;
  color: var(--text-faint);
}

/* Tabs: sibling views of one page, such as upcoming and past matches. */
.tabs {
  display: flex;
  /* Four tabs fit on one line down to a 360px phone. */
  gap: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.tabs a {
  margin-bottom: -1px;
  padding: var(--space-2) 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-decoration: none;
  text-transform: uppercase;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

/* Status line: one quiet line on how fresh the page's data is. */
.status-line {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.status-line--error {
  color: var(--danger);
}

/* A page shown from the copy kept on the phone, without a network. */
.offline-line {
  margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--accent);
  border-radius: var(--radius-small);
  color: var(--accent);
  font-size: 14px;
}

.offline-line[hidden] {
  display: none;
}

/*
 * The status line, and for the admin a button to run the update by hand,
 * right after the text: on a narrow screen it wraps with the words.
 */
.status > .status-line {
  display: inline;
}

.status > form {
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
}

/*
 * The desiderata reminder: its day, then this device's notifications, apart
 * below a line. Its button keeps to the left, as the connection test's above.
 */
.reminder-form > .button {
  justify-self: start;
}

.push {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.push-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  color: var(--text-muted);
}

.push-state {
  margin: 0;
}

/* Only the buttons that apply to this device; .button would show them all. */
.push .button[hidden] {
  display: none;
}

/* A small round button holding only an icon; it turns while busy. */
.icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--field-border-hover);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.icon-button svg {
  width: 14px;
  height: 14px;
}

.icon-button[aria-busy="true"] svg {
  animation: turn 1s linear infinite;
}

@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .icon-button[aria-busy="true"] svg {
    animation: none;
  }
}

.empty {
  margin: var(--space-5) 0;
  color: var(--text-muted);
  text-align: center;
}

/*
 * Match cards: the scoreboard. The date panel on the right has a fixed width,
 * so cards line up whatever their content; amber marks the next match, red a
 * match that is off (cancelled by hand, or no longer assigned by basketplan).
 */
.match-list {
  display: grid;
  gap: var(--space-3);
}

.match {
  --fed: var(--text-faint);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "flag flag"
    "tags when"
    "teams when"
    "colleagues when"
    "venue action";
  /* When the date panel is taller than the lines beside it, the extra height
     goes above the teams, not between the lines under them. */
  grid-template-rows: auto auto 1fr auto auto;
  gap: 6px var(--space-3);
  padding: var(--space-3) 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-display);
}

.match p {
  margin: 0;
}

:is(.match, .region-match, .season-fed)[data-fed="sbl"] {
  --fed: var(--fed-sbl);
}

:is(.match, .region-match, .season-fed)[data-fed="swb"] {
  --fed: var(--fed-swb);
}

:is(.match, .region-match, .season-fed)[data-fed="afbb"] {
  --fed: var(--fed-afbb);
}

:is(.match, .region-match, .season-fed)[data-fed="avb"] {
  --fed: var(--fed-avb);
}

.match-when {
  grid-area: when;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: start;
  width: 92px;
  padding: 7px 10px 8px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  line-height: 1.05;
  text-transform: uppercase;
}

.match-weekday,
.match-month {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.match-day {
  font-size: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f4f6f8;
  text-shadow: 0 0 10px rgb(244 246 248 / 0.18);
}

.match-time {
  width: 100%;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--border-strong);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 0 10px rgb(255 182 39 / 0.3);
}

/* When to leave home, under the tip-off, which stays the one in amber. */
.match-departure {
  width: 100%;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.match-departure abbr {
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
}

.match-flag {
  grid-area: flag;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
}

/* A match on a day the referee blocked on basketplan: a mistake to put right. */
.match-blocked {
  color: var(--danger);
}

.match-tags {
  grid-area: tags;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) 6px;
  font-size: 13px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.match-fed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  color: var(--text);
}

.match-fed::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--fed);
}

.match-role {
  color: var(--accent);
}

.match-teams {
  grid-area: teams;
  align-self: end;
  /* The lines below are 32px tap targets with their text centred: this puts
     as much space between the teams and the first of them as between them. */
  padding-bottom: var(--space-2);
  display: flex;
  flex-direction: column;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.1;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.match-vs {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.2em;
  opacity: 0.6;
}

.match-venue {
  grid-area: venue;
}

.match-colleagues {
  grid-area: colleagues;
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Tapped on a phone: tall enough to hit, without making the card taller. */
.match-venue,
.match-colleague {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  min-height: 32px;
  font-family: var(--font-text);
  font-size: 14px;
  color: #c2cad4;
  text-decoration: none;
}

a.match-venue:hover,
a.match-colleague:hover {
  color: var(--text);
  text-decoration: underline;
}

.match-venue svg,
.match-colleague svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.match-colleague--missing {
  color: var(--text-faint);
}

.match-drive {
  color: var(--text-muted);
  white-space: nowrap;
}

/* Beside the name, which calls: a button that opens the chat in WhatsApp. */
.match-colleagues li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.match-whatsapp {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--success);
}

.match-whatsapp:hover {
  border-color: var(--success);
}

.match-whatsapp svg {
  width: 16px;
  height: 16px;
}

.match-action {
  grid-area: action;
  align-self: end;
  justify-self: end;
}

.match-action button {
  min-height: 32px;
  padding: 0;
  background: none;
  border: 0;
  font-family: var(--font-text);
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.match-action button:hover {
  color: var(--text);
}

.match--next {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 26px var(--accent-glow);
}

.match--next .match-when {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* The red counterpart of the amber "next" treatment. */
.match--off {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger), 0 0 26px var(--danger-glow);
}

.match--off .match-when {
  border-color: var(--danger);
  box-shadow: 0 0 12px var(--danger-glow);
}

.match--off .match-when > *,
.match--off .match-teams {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--danger);
}

.match--off .match-day,
.match--off .match-time,
.match--off .match-teams {
  color: var(--text-faint);
  text-shadow: none;
}

.match--off .match-flag {
  color: var(--danger);
}
/*
 * Region lines: the region's matches the referee is not on, one short line
 * each under a heading per day. Red marks a day they already referee. A tap
 * opens the teams and the hall between the league and the referees; the
 * chevron keeps its place and turns (app.js animates the opening).
 */
.region {
  display: grid;
  gap: var(--space-2);
}

/* The search above the region lines; app.js hides what does not match. */
.region-search {
  position: relative;
  margin-bottom: var(--space-1);
}

/* The magnifier. */
.region-search > svg {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  transform: translateY(-50%);
  pointer-events: none;
}

.region-search input {
  width: 100%;
  min-height: var(--field-height);
  /* Room for the icon on the left, the clear button on the right. */
  padding: var(--space-3) var(--touch) var(--space-3) 42px;
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-small);
  color: var(--text);
  /* 16px keeps phones from zooming into the field. */
  font: 500 16px/1.3 var(--font-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.region-search input::placeholder {
  color: var(--text-faint);
}

/* Our own clear button, the same in every browser: hide the native one. */
.region-search input::-webkit-search-cancel-button {
  appearance: none;
}

.region-search-clear {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.region-search-clear:hover {
  color: var(--text);
}

.region-search-clear[hidden] {
  display: none;
}

.region-search-clear svg {
  width: 18px;
  height: 18px;
}

.region-search input:hover {
  border-color: var(--field-border-hover);
}

.region-search input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.region-day {
  display: grid;
  gap: 6px;
}

.region-day[hidden],
.region-match[hidden] {
  display: none;
}

.region-date {
  font-size: 14px;
}

.region-day--busy .region-date {
  color: var(--danger);
}

.region-busy {
  font-size: 11px;
  /* A label moves to the next line whole, never split. */
  white-space: nowrap;
}

/* Two labels on one day: apart, without a dot to clash with the month's. */
.region-busy + .region-busy {
  margin-left: var(--space-2);
}

.region-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.region-day--busy .region-group {
  border-color: var(--danger);
  box-shadow: 0 0 14px var(--danger-glow);
}

/*
 * A day the referee blocked: its matches stay in view, greyed. Unless they
 * referee that day too, a mistake that stays red.
 */
.region-day--off:not(.region-day--busy) .region-date {
  color: var(--text-faint);
}

.region-day--off:not(.region-day--busy) .region-group {
  opacity: 0.45;
}

.region-match {
  --fed: var(--text-faint);
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-areas:
    "time league"
    "time details"
    "time referees";
  column-gap: var(--space-2);
  /* Room on the right for the chevron. */
  padding: 9px 34px 9px var(--space-3);
  cursor: pointer;
}

/* Between the lines left showing, whichever the search hides. */
.region-match:not([hidden]) ~ .region-match:not([hidden]) {
  border-top: 1px solid var(--border);
}

.region-match p {
  margin: 0;
}

.region-time {
  grid-area: time;
  align-self: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  /* No taller than the lines beside it: an empty details row stays empty. */
  line-height: 1;
  color: var(--accent);
}

/* The whole line opens; the button is there for the keyboard and screen readers. */
.region-toggle {
  display: contents;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.region-league {
  grid-area: league;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.region-league .match-fed::before {
  width: 8px;
  height: 8px;
}

/* Where it sits on a closed line; opening only turns it. */
.region-chevron {
  position: absolute;
  top: 24px;
  right: 16px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 220ms ease;
}

.region-match.is-open:not(.is-closing) .region-chevron {
  transform: translateY(2px) rotate(-135deg);
}

.region-details {
  grid-area: details;
  display: grid;
  gap: 4px;
  padding: 6px 0;
  overflow: hidden;
}

.region-details[hidden] {
  display: none;
}

.region-teams {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.15;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.region-teams .match-vs {
  margin: 0 4px;
}

.region-venue,
.region-referees {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-family: var(--font-text);
  font-size: 13px;
  color: #c2cad4;
  text-decoration: none;
}

.region-venue:hover {
  color: var(--text);
  text-decoration: underline;
}

.region-venue svg,
.region-referees svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.region-referees {
  grid-area: referees;
  margin-top: 2px;
}

.region-referees span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .region-chevron {
    transition: none;
  }
}

/*
 * Season: a season's numbers above the played matches, on one line, then
 * the roles, and a bar split by federation in their colours.
 */
.season {
  display: grid;
  gap: var(--space-2);
}

.season p {
  margin: 0;
}

.season-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.season-total {
  color: var(--accent);
  /* On a narrow screen a whole total goes to the next line, never half. */
  white-space: nowrap;
}

.season-split {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--space-4);
  font-size: 13px;
  color: #c2cad4;
}

.season-bar {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.season-fed {
  --fed: var(--text-faint);
  font-weight: 500;
  color: inherit;
}

.season-bar .season-fed {
  background: var(--fed);
}

.season-note {
  font-size: 12px;
  color: var(--text-faint);
}

/*
 * Desiderata: the season as answered on basketplan, a calendar per month.
 * A day the referee can take is plain; a blocked one is red, one with a
 * restriction amber. An amber dot is their own match; a match on a day
 * they blocked is outlined in red, a mistake to put right. Days gone by
 * are dimmed; today is outlined in white.
 */
.desiderata-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--text-muted);
}

.desiderata-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.desiderata-key {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.desiderata-key--match {
  position: relative;
}

.desiderata-key--match::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.desiderata-month {
  display: grid;
  gap: var(--space-2);
}

.desiderata-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.desiderata-grid {
  display: grid;
  gap: 4px;
}

/* A narrow first column for the week switches, then the seven days. */
.desiderata-row {
  display: grid;
  grid-template-columns: 18px repeat(7, 1fr);
  gap: 4px;
}

/* The headings switch a whole column or week: plain text that can be tapped. */
.desiderata-weekday,
.desiderata-week {
  padding: 4px 0;
  background: none;
  border: 0;
  border-radius: var(--radius-small);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--text-faint);
  cursor: pointer;
}

.desiderata-week {
  font-size: 16px;
  line-height: 1;
}

:is(.desiderata-weekday, .desiderata-week):hover:not(:disabled) {
  color: var(--text);
}

:is(.desiderata-weekday, .desiderata-week):disabled {
  cursor: default;
}

/* Locked by an admin: shown as it is, muted, as nothing in it can change. */
.desiderata-month--locked .desiderata-day {
  opacity: 0.6;
}

.desiderata-locked {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: var(--space-2);
  color: var(--text-faint);
}

.desiderata-locked svg {
  width: 13px;
  height: 13px;
}

.desiderata-day {
  position: relative;
  display: grid;
  place-items: center;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

/* The box itself is the whole day: its checkbox stays for keyboards and screen readers. */
.desiderata-day input[type="checkbox"] {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

.desiderata-day:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.desiderata-day[data-fixed] {
  cursor: default;
}

/* A browser swallows taps on a disabled box: let them reach the day, which says why. */
.desiderata-day input:disabled {
  pointer-events: none;
}

.desiderata-day--empty {
  background: none;
  border: 0;
}

:is(.desiderata-day, .desiderata-key)[data-state="unavailable"] {
  background: var(--danger-glow);
  border-color: rgb(255 93 93 / 0.45);
  color: var(--danger);
}

/* Grey like a free day, amber text and border: never mistaken for a blocked one. */
:is(.desiderata-day, .desiderata-key)[data-state="restricted"] {
  border-color: var(--accent);
  color: var(--accent);
}

:is(.desiderata-day, .desiderata-key)[data-required] {
  box-shadow: inset 0 0 0 2px #ffcdcd;
}

/* White, as amber already means a restriction. */
.desiderata-day[aria-current="date"] {
  border: 2px solid var(--text);
}

.desiderata-day[data-past] {
  opacity: 0.35;
}

.desiderata-day[data-match]::after {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.desiderata-day[data-conflict] {
  border: 2px solid var(--danger);
  box-shadow: 0 0 10px var(--danger-glow);
}

/*
 * Switched but not sent yet: the box takes its new look, dashed. Read from
 * the checkbox against basketplan's answer, so it works without app.js.
 */
.desiderata-day[data-state="available"]:has(input[type="checkbox"]:not(:checked)) {
  background: var(--danger-glow);
  border: 1px dashed var(--danger);
  color: var(--danger);
}

.desiderata-day[data-state="unavailable"]:has(input[type="checkbox"]:checked) {
  background: var(--surface);
  border: 1px dashed var(--text-muted);
  color: var(--text);
}

.desiderata-conflicts {
  margin: 0;
  padding-left: var(--space-5);
}

/* Under the months, kept in view: what will be sent, and the way to send it. */
.desiderata {
  display: grid;
  gap: var(--space-5);
}

.desiderata-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  gap: var(--space-2);
  margin: 0 calc(-1 * var(--space-4));
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.desiderata-bar[hidden] {
  display: none;
}

.desiderata-summary {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.desiderata-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/*
 * Dialog: a last look before something is done, over a dimmed page. The
 * browser's own modal: it keeps the focus inside, and Escape closes it.
 */
.dialog {
  width: min(100% - 2 * var(--space-4), 24rem);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.65);
}

.dialog h2 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: 20px;
  text-transform: uppercase;
}

.dialog-changes {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}

/* The label and its days on one baseline, though their fonts differ. */
.dialog-changes > div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: baseline;
  gap: var(--space-3);
}

.dialog-changes > div[hidden] {
  display: none;
}

.dialog-changes dt {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.dialog-changes dd {
  margin: 0;
}

.dialog-changes > [data-changes="block"] dd {
  color: var(--danger);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.dialog-actions[hidden],
.send-progress[hidden] {
  display: none;
}

/*
 * A send followed step by step (see js/app.js): a dot per step, joined by a
 * line, green once over; the step under way an amber pill with its name. A
 * locked month keeps a dashed padlock, a month not all kept an amber "!", and
 * the step that failed turns red.
 */
.send-track {
  display: flex;
  align-items: center;
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
}

/* Each step its dot or pill and the line before it; the room left is shared
   equally between the lines, however many steps there are. */
.send-step {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
}

.send-step:first-child {
  flex: none;
}

.send-step + .send-step::before {
  content: "";
  flex: 1;
  min-width: var(--space-2);
  height: 2px;
  background: var(--border-strong);
}

.send-step:is([data-state="done"], [data-state="locked"], [data-state="warn"]) + .send-step::before {
  background: var(--success);
}

.send-dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-faint);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.send-icon {
  display: grid;
  place-items: center;
}

.send-icon:empty {
  display: none;
}

.send-dot svg {
  width: 14px;
  height: 14px;
}

/* Named only while under way or failed; read out for screen readers always. */
.send-name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.send-step[data-state="done"] .send-dot {
  background: var(--success);
  border-color: var(--success);
  color: var(--on-accent);
}

.send-step[data-state="locked"] .send-dot {
  border-style: dashed;
  color: var(--text-muted);
}

.send-step[data-state="warn"] .send-dot {
  border-color: var(--accent);
  color: var(--accent);
}

.send-step:is([data-state="current"], [data-state="failed"]) .send-dot {
  gap: 6px;
  display: inline-flex;
  width: auto;
  height: 28px;
  padding: 0 10px;
  border-color: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 14px var(--accent-glow);
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.send-step[data-state="failed"] .send-dot {
  border-color: var(--danger);
  box-shadow: 0 0 14px var(--danger-glow);
  color: var(--danger);
}

.send-step:is([data-state="current"], [data-state="failed"]) .send-name {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
}

.send-step[data-state="current"] .send-dot::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.send-now {
  margin: var(--space-4) 0 2px;
}

.send-now:empty {
  display: none;
}

.send-now b {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.send-outcome p {
  margin: var(--space-4) 0 0;
}

.send-outcome p + p {
  margin-top: var(--space-1);
}

.send-outcome [data-level="error"] {
  color: var(--danger);
}

.send-outcome [data-level="warning"] {
  color: var(--accent);
}

/* Steps: numbered instructions, such as subscribing a calendar. */
.steps {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding-left: var(--space-5);
}

.steps li::marker {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
}