:root {
  /* Every colour on the site is one of these, so honouring a dark device is
     a matter of restating them rather than hunting down declarations. Pages
     name them by meaning (--danger, not a particular red) for the same
     reason: a red legible on white is not the red legible on near-black. */
  --verde: #00B140;
  --verde-ink: #046a29;
  --ink: #14181f;
  --bg: #fff;
  --muted: #555;
  --rule: #d8e8dd;
  --danger: #b00020;
  --success: #137333;
  --warn: #a15c00;
  /* A form field's edge (#431): firmer than --rule, which is a hairline
     between table rows, so an empty field still reads as a place to type. */
  --field-border: #93ab9b;
  /* The staging banner (#338): amber, the one colour nothing else on the
     site uses, with near-black text (9.7:1). The same in both schemes, so
     staging looks the same on every device. */
  --env-banner-bg: #ffb000;
  --env-banner-ink: #14181f;
  /* The way back to the store, for a member who came from it: the verde
     that carries text, under white (6.78:1). The same in both schemes, like
     the staging banner. */
  --store-banner-bg: #046a29;
  --store-banner-ink: #fff;

  /* Lets the browser dark-render what we don't control: form fields, the
     canvas behind a short page, scrollbars. Without it those stay white and
     the page comes apart at the edges. */
  color-scheme: light dark;
}

/* Honouring a dark device (#141). Only the tokens change; no rule below is
   restated, which is what keeps the two modes from drifting apart.

   Every value clears 4.5:1 against --bg, except --rule, which only has to be
   seen rather than read -- a hairline as bright as text turns the admin
   tables into stripes. The light palette's colours all fail when inverted
   (--muted 2.39:1, --danger 2.43, --success 2.99, --warn 3.43), so these are
   lighter, less saturated versions of the same hues rather than the same
   values reused.

   --verde stays as it is: #00B140 measures 6.24:1 here, better than the
   2.85 it manages on white, which is why --verde-ink can simply become it --
   the darker shade exists for the light page, and here it would be the one
   that fails (2.63:1). */
@media (prefers-color-scheme: dark) {
  :root {
    /* Near-black rather than #000: pure black behind light text haloes on
       OLED, and the page reads as harsher than the light one. */
    --bg: #14181f;
    --verde-ink: #00B140;
    --ink: #e7eaee;
    --muted: #a7b0bd;
    --rule: #2b323c;
    --danger: #ff9d9d;
    --success: #7fd69a;
    --warn: #e8bd76;
    --field-border: #56616f;
  }
}

/* Bungee is a display face: all caps, heavy, for headings only. Swap rather
   than block -- a heading in the system font for one frame beats a blank
   page on a slow connection at a stadium gate. */
@font-face {
  font-family: "Bungee";
  src: url("/assets/bungee.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

body {
  margin: 2rem auto;
  padding: 0 1rem;
  color: var(--ink);
  background: var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

/* The member's own pages: one narrow centred column, which is the shape that
   works on a phone held at a gate.
   The measure is on the column rather than the body so that anything outside
   it -- today only the admin nav, shown to admins on their own card -- can be
   as wide as it needs without widening the card for everyone else. */
body.member {
  text-align: center;
}

body.member main {
  max-width: 28rem;
  margin: 0 auto;
}

/* Admin pages are tables, and tables want room. */
body.admin {
  max-width: 72rem;
  margin: 1.5rem auto;
}

/* A report table's headings, once src/admin/tableSort.ts has made them
   buttons: still read as headings, with an arrow on the sorted one. */
table[data-sortable] th button.sort {
  all: unset;
  cursor: pointer;
  font-weight: bold;
}

table[data-sortable] th button.sort:focus-visible {
  outline: 2px solid var(--verde-ink);
  outline-offset: 2px;
}

table[data-sortable] th[aria-sort="ascending"] button.sort::after {
  content: " \25B2";
  font-size: 0.7em;
}

table[data-sortable] th[aria-sort="descending"] button.sort::after {
  content: " \25BC";
  font-size: 0.7em;
}

/* The box above a report table that narrows it (src/admin/tableFilter.ts).
   Wide enough for a name and a year; the count sits beside it, muted. */
.table-filter input[type="search"] {
  width: 22rem;
  max-width: 100%;
}

.table-filter [data-filter-count] {
  color: var(--muted);
}

/* The membership-over-time charts (src/admin/lineChart.tsx). The most recent
   line is verde and heavier, so it reads first; earlier ones take distinct
   mid-tone hues that hold up on either background. */
.line-chart {
  margin: 1rem 0;
  max-width: 48rem;
}

.line-chart svg {
  width: 100%;
  height: auto;
}

.line-chart .line {
  fill: none;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.line-chart .gridline line {
  stroke: var(--rule);
}

.line-chart text {
  fill: var(--muted);
  font-size: 12px;
}

.line-chart figcaption {
  color: var(--muted);
  font-size: 0.85rem;
}

.line-chart .swatch {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.5em;
}

.line-chart .latest { stroke: var(--verde-ink); background: var(--verde-ink); }
.line-chart path.latest { stroke-width: 2.5; }
.line-chart .series-0 { stroke: #3b82f6; background: #3b82f6; }
.line-chart .series-1 { stroke: #f59e0b; background: #f59e0b; }
.line-chart .series-2 { stroke: #a855f7; background: #a855f7; }
.line-chart .series-3 { stroke: #ef4444; background: #ef4444; }
.line-chart .series-4 { stroke: #14b8a6; background: #14b8a6; }
.line-chart .series-5 { stroke: #8b8b8b; background: #8b8b8b; }

/* The orders chart's bars (src/admin/barChart.tsx), in the same colours. */
.bar-chart rect.latest { fill: var(--verde-ink); stroke: none; }
.bar-chart rect.series-0 { fill: #3b82f6; stroke: none; }
.bar-chart rect.series-1 { fill: #f59e0b; stroke: none; }
.bar-chart rect.series-2 { fill: #a855f7; stroke: none; }
.bar-chart rect.series-3 { fill: #ef4444; stroke: none; }
.bar-chart rect.series-4 { fill: #14b8a6; stroke: none; }
.bar-chart rect.series-5 { fill: #8b8b8b; stroke: none; }

/* No image, whatever its intrinsic size, may be wider than what holds it.
   The card carries its own sizing inline as well; this is the net for
   anything added later that forgets. */
img {
  max-width: 100%;
}

h1, h2, h3 {
  font-family: "Bungee", system-ui, sans-serif;
  color: var(--verde-ink);
  line-height: 1.2;
}

body.member h1 {
  font-size: 1.6rem;
}

a {
  color: var(--verde-ink);
}

/* The label is the page background's colour rather than white: on a light
   page that is white on the darker verde, on a dark page near-black on
   Bright Verde -- the legacy site's own button -- and both read, where white
   on Bright Verde does not. */
button {
  font: inherit;
  color: var(--bg);
  background: var(--verde-ink);
  border: 0;
  border-radius: 0.5rem;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
}

/* A submitted form's button, while the next page loads (src/formBusy.ts).
   Dimmed with a small spinner before the label; the spinner holds still for
   anyone who has asked for less motion, and the label change still says it. */
button[aria-disabled="true"] {
  cursor: progress;
  opacity: 0.75;
}

button[aria-disabled="true"]::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.5em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: busy-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  button[aria-disabled="true"]::before {
    animation: none;
  }
}

/* The member's actions -- wallet passes, emailing a card. Outlined rather
   than filled: there are several in a row, and a column of solid verde
   blocks reads as a warning rather than as a menu. */
.action {
  display: block;
  margin: 0.75rem 0;
  padding: 0.75rem;
  border: 1px solid var(--verde-ink);
  border-radius: 0.5rem;
  color: inherit;
  text-decoration: none;
}

/* The membership card. The width and height attributes on the element give
   the browser its aspect ratio before the image exists, so the space is
   reserved and nothing below moves when it arrives; these rules make that
   reserved space look
   deliberate rather than like a gap. The tint is the card's own background,
   so what appears first is the right shape and roughly the right colour, and
   the image resolves into it. */
.card-image {
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--verde) 12%, var(--bg));
}

.order {
  margin: 0.75rem 0;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  text-align: left;
}

/* The theme leaderboard (src/member/portal.tsx): a row per theme, its name
   and count on one line and a bar beneath sized by its share of members. */
.leaderboard h2 {
  margin: 0;
  font-size: 1.2rem;
}

.leaderboard .tally p {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
}

.leaderboard .bar {
  min-width: 2px;
  height: 0.5rem;
  border-radius: 0.25rem;
  background: var(--verde-ink);
}

.muted {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* A member in an admin table: their card's name, with the address beneath
   in smaller, quieter type (MemberLink in src/admin/layout.tsx). An order
   given by its address looks the same, with the order's own name
   (OrderLink in src/admin/orders.tsx). */
a.member-link .member-email,
a.order-link .order-email {
  display: block;
  font-size: 0.8em;
  color: var(--muted);
}

/* The readiness page's manual steps. Ticking one is only a way of keeping
   your place while working down a long list on a second screen -- there is no
   JavaScript here and nothing is stored, so a reload starts over, which is
   the honest behaviour for a list whose real state lives in the world rather
   than in the page. Checked steps fade and strike through rather than
   disappearing, so the list keeps its shape and you can see what is left
   against what is done. */
ul.checklist {
  list-style: none;
  padding-left: 0;
}

ul.checklist label {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.3rem 0;
  cursor: pointer;
}

ul.checklist input {
  accent-color: var(--verde-ink);
  flex: none;
}

ul.checklist input:checked + span {
  text-decoration: line-through;
  color: var(--muted);
}

/*
 * The admin navigation. Eleven links in one middot-separated run were
 * unreadable -- every destination looked equally important and finding one
 * meant reading all of them. Grouped instead, with the group's name carrying
 * the shared word so each link only has to say what makes it different:
 * "Active" under Reports rather than "Active memberships" among everything
 * else.
 *
 * Flex with wrapping rather than a fixed row, because the admin pages are
 * read on a phone at a match as often as at a desk, and a group is the right
 * unit to wrap at.
 */
nav.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.4rem;
  align-items: baseline;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

nav.admin-nav .nav-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  align-items: baseline;
}

/*
 * Small and quiet: it labels the group rather than competing with the links
 * inside it.
 */
nav.admin-nav .nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

nav.admin-nav a {
  white-space: nowrap;
}

/* A label that is also a page (the index of reports): the same small
   capitals, in the link colour so it reads as somewhere to go. */
nav.admin-nav a.nav-label {
  color: var(--verde-ink);
}

/* Every page that is not production (#338). Across the top of the page's own
   column, cancelling the body's padding and top margin, and it stays in view
   as the page scrolls: the point is that it cannot be missed. */
.env-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -2rem -1rem 1.5rem;
  padding: 0.5rem 1rem;
  background: var(--env-banner-bg);
  color: var(--env-banner-ink);
  font-weight: bold;
  text-align: center;
}

body.admin .env-banner {
  margin-top: -1.5rem;
}

/* The way back to the store, for a member who came from it. Across the top
   like the staging banner, but not sticky: it is an offer, not a warning.
   Under the staging banner on staging, closing the gap that banner leaves. */
.store-banner {
  margin: -2rem -1rem 1.5rem;
  padding: 0.5rem 1rem;
  background: var(--store-banner-bg);
  color: var(--store-banner-ink);
  font-weight: bold;
  text-align: center;
}

.store-banner a {
  color: inherit;
}

.env-banner + .store-banner {
  margin-top: -1.5rem;
}

/* "Production", first in the admin nav on the live site: an admin action
   here is the real thing. */
nav.admin-nav .env-label {
  padding: 0.1rem 0.5rem;
  border-radius: 0.25rem;
  background: var(--danger);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* On a member page the nav is the one wide thing on a narrow page, and the
   only left-aligned one. */
body.member nav.admin-nav {
  max-width: 72rem;
  margin: 0 auto 1.25rem;
  text-align: left;
}

/* The page you are already on: still in its place in the nav, so the shape
   of the list doesn't change as you move around it, but not offering to take
   you where you are. */
nav.admin-nav .nav-here {
  color: var(--muted);
}

/* A report of things wanting action, with nothing in it: still a link, but
   one that steps back so the ones with something in them stand out. */
nav.admin-nav a.nav-quiet {
  color: var(--muted);
}

/* How many rows such a report has. Warn rather than danger: these are
   questions for a person, not failures. */
nav.admin-nav .nav-count {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.4em;
  border-radius: 0.7em;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  color: var(--bg);
  background: var(--warn);
}

/* Forms (#431): one layout for every form. Each label above its field;
   fields one readable width, and the full width of a phone; "optional" and
   help text in a quieter line under the label (.hint); the button ends the
   form. A form inside a table row or a sentence is marked .inline and keeps
   flowing, and the theme page's choices (.order) keep their card layout. */
form:not(.inline, .order) {
  margin: 0.75rem 0 1.5rem;
}
/* A member page centres its column; its forms read left to right in it. */
body.member form:not(.inline, .order) {
  max-width: 24rem;
  margin-inline: auto;
  text-align: left;
}
/* A form that is only a button (disconnect the store account, log out, go
   back to the default theme) has no fields to line up, so it stays centred
   like the rest of the column. */
body.member form:not(.inline, .order):not(:has(label)) {
  text-align: center;
}
form:not(.inline, .order) label {
  display: block;
  font-weight: 600;
  margin: 0.75rem 0 0.3rem;
}
form:not(.inline, .order) label:first-of-type {
  margin-top: 0;
}
/* A checkbox's label sits beside it, in ordinary weight. */
form label:has(> input[type="checkbox"]) {
  display: inline-flex;
  gap: 0.4rem;
  align-items: baseline;
  font-weight: 400;
}
.hint {
  display: block;
  font-weight: 400;
  font-size: 0.85em;
  color: var(--muted);
}
input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: 26rem;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--field-border);
  border-radius: 0.4rem;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--verde-ink);
  outline-offset: 1px;
}
form:not(.inline, .order) button {
  margin-top: 0.75rem;
}
/* What takes a card or a sign-in away is in the danger colour. Revoking and
   expelling sit behind a disclosure, and ask once more on a page of their
   own before they happen. */
button.danger {
  background: var(--danger);
}
button.quiet {
  color: var(--verde-ink);
  background: transparent;
  border: 1px solid currentColor;
}
button.quiet.danger {
  color: var(--danger);
}
details.danger-zone {
  max-width: 30rem;
  margin: 0.75rem 0;
  padding: 0.4rem 1rem;
  border: 1px solid var(--danger);
  border-radius: 0.5rem;
}
details.danger-zone > summary {
  padding: 0.2rem 0;
  color: var(--danger);
  font-weight: 600;
  cursor: pointer;
}
