/* Component layer (#282): the shell chrome and the component
 * vocabulary every member page rides. Skin-agnostic — every colour is
 * a token from tokens.css and scripts/lint.sh refuses literals here.
 *
 * Two selector families live in this file:
 *
 * 1. The vocabulary — .card, .panel, .badge, .btn, .banner, .stat,
 *    .table, .field, .list-plain, .meter, .toast, .htmx-indicator.
 *    New surfaces (#283 onward) are built from these names directly.
 *
 * 2. Compatibility — the member pages' working classes (.wallet-card,
 *    .event-card, .slot-actions, .debt-banner, ...), formerly styled
 *    by the retired wallet.css. The names stay because JavaScript
 *    hooks (copy_list.js, fund_confirm.js), server-rendered markup
 *    and the test suites key on them; they are styled to the same
 *    token-driven look as their vocabulary counterparts, and each
 *    block names the counterpart it mirrors. Retire a name when its
 *    page is rebuilt on the vocabulary.
 */

/* ---------- Site shell ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.6rem var(--sp-4);
  /* Notch clearance (#282 supplement): viewport-fit=cover lets the
     page reach under a status bar, so the sticky header pads itself
     by the top safe-area inset. env() is zero everywhere else. */
  padding-top: calc(0.6rem + env(safe-area-inset-top, 0px));
  /* Landscape clearance (#283 iOS exercise): rotated, the notch moves
     onto a side and the same opt-in would let it impinge on the brand
     and the nav — the side insets pad them too. */
  padding-left: calc(var(--sp-4) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--sp-4) + env(safe-area-inset-right, 0px));
  background: var(--header-bg);
  color: var(--header-ink);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--radius);
  background: var(--brand-bg);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.site-name {
  font-weight: 650;
  font-size: var(--text-base);
}

.club-name {
  color: var(--muted);
  font-size: var(--text-sm);
}

.site-header .club-name {
  color: var(--header-muted, var(--muted));
}

/* Header navigation: hidden below 64rem, where the bottom tab bar
   owns navigation instead. */
.site-nav {
  display: none;
  margin-left: auto;
  gap: var(--sp-4);
}

.site-nav a {
  color: var(--header-nav-ink);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 550;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  border-bottom-color: currentColor;
}

.site-nav a[aria-current="page"] {
  border-bottom-color: currentColor;
}

.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--header-muted, var(--muted));
}

.site-nav + .header-user {
  margin-left: 0;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--header-nav-ink);
  text-decoration: underline;
  cursor: pointer;
  font-size: var(--text-sm);
}

.logout-form {
  display: inline;
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) calc(5.25rem + env(safe-area-inset-bottom, 0px));
  /* Landscape clearance (#283 iOS exercise): content stays clear of a
     notch or home indicator rotated onto the sides. */
  padding-left: calc(var(--sp-4) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--sp-4) + env(safe-area-inset-right, 0px));
}

@media (min-width: 64rem) {
  .site-nav {
    display: flex;
  }

  .tabbar {
    display: none !important;
  }

  main {
    padding-bottom: var(--sp-6);
  }
}

/* ---------- Bottom tab bar (below 64rem) ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--surface);
  border-top: 1px solid var(--line);
  /* Home-indicator clearance (#282 supplement). */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Landscape clearance (#283 iOS exercise): the bar's background
     still bleeds edge-to-edge; the tabs inset from a notch or home
     indicator rotated onto the sides. */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  box-shadow: var(--shadow-tabbar);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem 0.25rem 0.45rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 550;
}

.tab svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

/* The sign-out tab is a POST form: the wrapper leaves the grid so the
   button itself is the grid item, matching the link tabs. */
.tabbar .tab-form {
  display: contents;
}

button.tab {
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
}

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

/* .wallet-card and .event-card are the member pages' working names
   for .card; they share its surface exactly. */
.card,
.wallet-card,
.event-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: var(--card-accent-width, 0px) solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.card-header h2,
.card-header h3 {
  margin: 0;
}

/* The collapsing cards' header ticks (#320): the tick row sits level
   with the title, and its label reads as part of the header rather
   than as a stacked form field. */
.card-header .field-row {
  align-self: center;
}

.card-header .field-row label {
  margin-bottom: 0;
  font-weight: 550;
}

.card-title,
.wallet-card h2,
.club-events h2,
.event-card h3 {
  font-size: var(--text-lg);
  font-weight: 650;
}

.card-title,
.wallet-card h2,
.club-events h2 {
  margin: 0 0 var(--sp-1);
}

.event-card h3 {
  margin: 0 0 var(--sp-1);
}

.card-sub {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: 0 0 var(--sp-2);
}

.grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
}

/* ---------- Stats ---------- */

.stat-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  margin-bottom: var(--sp-4);
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-3) var(--sp-4);
}

.stat-label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge--success {
  background: var(--success-soft);
  color: var(--success-ink);
}

.badge--info {
  background: var(--info-soft);
  color: var(--info-ink);
}

.badge--warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.badge--accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--muted {
  background: var(--surface-sunken);
  color: var(--muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  /* <a> and <button> must render identically: anchors inherit the
     body's line-height but buttons fall back to the UA default
     (normal), leaving real buttons a few pixels shorter in any row
     that mixes the two. */
  line-height: inherit;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.btn--secondary:hover {
  background: var(--accent-soft);
}

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

.btn--ghost:hover {
  background: var(--surface-sunken);
}

/* The club sub-nav's current destination (#320 founder review): the
   ghost row stays quiet, but the button carrying aria-current takes
   the accent-soft fill and accent ink, so the page being rendered
   stands out without the nav competing with the page's one solid
   primary action. */
.btn--ghost[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.btn--ghost[aria-current="page"]:hover {
  background: var(--accent-soft);
  filter: brightness(0.97);
}

.btn--danger {
  background: var(--danger);
  color: var(--on-danger);
}

.btn--danger:hover {
  filter: brightness(0.92);
}

.btn--danger-soft {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.btn--danger-soft:hover {
  filter: brightness(0.97);
}

.btn--sm {
  padding: 0.3rem 0.7rem;
  font-size: var(--text-xs);
  border-radius: var(--radius);
}

.btn:disabled {
  background: var(--surface-sunken);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

/* Separation (#293 founder exercise): a button row directly after the
   page heading keeps a full space below, so the row never crowds the
   first panel under it. */
h1 + .btn-row {
  margin-bottom: var(--sp-4);
}

/* The organiser club pages interpose the club nav — itself a .btn-row
   — between the heading and the page's action row (#337), breaking
   the adjacency above; the action row keeps the same space below. */
h1 + .btn-row + .btn-row {
  margin-bottom: var(--sp-4);
}

/* An action row directly under a card header (the dashboard's Manage
   members, #289 founder review): the row keeps a space below, so at
   phone widths — where the stacked table rows become bordered cards —
   the button never crowds the first card's border. */
.card-header + .btn-row {
  margin-bottom: var(--sp-3);
}

/* ---------- Banners / messages ---------- */

.banner {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-3);
  border: 1px solid transparent;
}

.banner--info {
  background: var(--info-soft);
  color: var(--info-ink);
}

.banner--success {
  background: var(--success-soft);
  color: var(--success-ink);
}

.banner--warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-color: var(--warn-line);
}

.banner--error {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

/* The Django messages flash list: banner semantics on the messages'
   own tag classes. Success flashes never arrive here — they ride the
   toast stack (#293) — so the list must only take up room when it
   actually carries errors or info: an empty render reserves nothing
   and a flash never shifts the page down. */
.messages {
  list-style: none;
  margin: 0;
  padding: 0;
}

.messages:has(li) {
  margin: var(--sp-4) 0;
}

.message {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  margin-bottom: var(--sp-2);
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.message.info {
  background: var(--info-soft);
  color: var(--info-ink);
}

.message.success {
  background: var(--success-soft);
  color: var(--success-ink);
}

/* The impersonation banner: warn semantics — an operator is acting on
   a member's account. */
.impersonation-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--warn-line);
  margin: var(--sp-4) 0;
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-size: var(--text-sm);
}

.impersonation-banner form {
  display: inline;
}

/* ---------- Toasts ----------
   Born for htmx-driven surfaces (#282 supplement), now the home of
   every success flash too (#293): transient confirmations stack here
   and dismiss themselves, while errors and info persist in .messages
   above. The stack hangs below the sticky header — never over it. */

.toast-stack {
  position: fixed;
  /* Below the header (#293 founder exercise): a toast at the very
     top covered the brand and the sign-out. The header's box is
     deterministic — 0.6rem padding above and below the 1.9rem brand
     mark, plus its 1px border ≈ 3.1rem — so the stack starts a space
     under it, the notch inset riding along. Move this with the
     header's metrics. */
  top: calc(3.1rem + var(--sp-3) + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: grid;
  gap: var(--sp-2);
  /* The stack renders on every page (#293) and must never intercept a
     click through its empty box; the toasts themselves re-enable it. */
  pointer-events: none;
  /* Side insets subtracted (#283 iOS exercise): a landscape notch
     never overlaps a toast either. */
  width: min(
    28rem,
    calc(100vw - 2 * var(--sp-4) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))
  );
}

.toast {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  color: var(--ink);
  pointer-events: auto;
}

.toast--success {
  background: var(--success-soft);
  color: var(--success-ink);
}

.toast--error {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.toast--info {
  background: var(--info-soft);
  color: var(--info-ink);
}

.toast--warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-color: var(--warn-line);
}

/* The dismissal fade (#293): toast_dismiss.js adds the class, then
   removes the node once the fade has run. */
.toast--leaving {
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* ---------- htmx request indicator (#282 supplement) ----------
   htmx adds .htmx-request to the triggering element while a request
   is in flight; an indicator inside it shows for the duration. */

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

.spinner {
  width: 1em;
  height: 1em;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: var(--radius-pill);
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Panels & lists ---------- */

/* The member events page's panels (slot, join, funded, roster,
   reserve, leavers, offer) share .panel's divider treatment. */
.panel,
.slot-panel,
.join-form,
.funded-panel,
.roster-panel,
.reserve-panel,
.leavers-panel,
.offer-panel {
  border-top: 1px solid var(--line);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
}

/* Row-anchor restoration (#287): a successful roster action redirects
   with the acted-on row's fragment, so the browser returns the
   organiser to their place in the list instead of the page top. The
   scroll margin keeps the row clear of the sticky site header, and a
   one-shot flush lets the eye find it again even where the action moved
   it to another section — panels are transparent over their card, so
   the flush fades back to nothing. */
.panel[id] {
  scroll-margin-top: 4rem;
}

.panel:target {
  animation: roster-row-flush 1.6s ease-out;
}

@keyframes roster-row-flush {
  from {
    background-color: var(--accent-soft);
  }
  to {
    background-color: transparent;
  }
}

/* .join-form is both a panel and a flex row; the row wins below. */

.panel-title,
.roster-panel h4,
.reserve-panel h4,
.leavers-panel h4,
.offer-panel h4,
.funded-panel h4 {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--sp-2);
}

.leavers-panel h5 {
  font-size: var(--text-sm);
  margin: var(--sp-2) 0 0.2rem;
  color: var(--muted);
}

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

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-main {
  min-width: 0;
}

.list-title {
  font-weight: 600;
  font-size: var(--text-sm);
}

.list-sub {
  color: var(--muted);
  font-size: var(--text-xs);
}

.empty-state {
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--sp-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---------- Tables ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--line-strong);
}

.table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Narrow widths (the Pixel Fold's cover screen included): rows become
   stacked cards, cells labelled via data-label. */
@media (max-width: 40rem) {
  .table--stack thead {
    display: none;
  }

  .table--stack tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.35rem 0.7rem;
    margin-bottom: var(--sp-2);
  }

  /* Stacked-row layout (#287 founder phone review, superseding the
     FND-3 right-aligned-value idiom): the label holds a fixed column
     and the value starts left-aligned after it, so every value begins
     at the same x — a wrapped long value (the events list's venue)
     aligns under itself instead of spanning mid-card to the right
     edge, and a badged value (the Event cell's link plus its auto
     pill) no longer has the pill shoving the link left of the other
     rows, as right-alignment did. */
  .table--stack td {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    border-bottom: 0;
    padding: 0.3rem 0;
  }

  /* 7rem covers the longest data-label in use ("Next session" and
     friends) at the label's uppercase text-xs. */
  .table--stack td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 0 0 auto;
    min-width: 7rem;
  }

  /* Stacked values read left like every other cell; this cancels the
     desktop table's right-aligned numerics. */
  .table--stack td.num {
    text-align: left;
  }

  /* A stacked cell with nothing in it — the offers table's action
     column on a resolved row (#288) — hides rather than rendering a
     bare label column. */
  .table--stack td:empty {
    display: none;
  }

  /* A cell whose value is several elements — the organiser events
     list's Event cell, a link plus its conditional auto badge —
     rides one container so the pair stays a single flex item beside
     the label with its own tight gap; bare siblings would each
     become their own item, spaced by the row's wider label-to-value
     gap (UI test plan FND-3). */
  .table--stack .cell-value {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
  }
}

/* The members table's score explanation (#289 founder review): a
   collapsed native disclosure above the table — with a long member
   list the information must not sit below it, and the collapsed
   summary costs one line. The race-times idiom: no JavaScript
   reaches the page. */
.reliability-help {
  margin: 0 0 var(--sp-3);
}

.reliability-help summary {
  color: var(--muted);
  font-size: var(--text-sm);
  cursor: pointer;
}

.reliability-help .card-sub {
  margin: var(--sp-1) 0 0;
}

/* ---------- Forms ---------- */

label {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field {
  margin-bottom: var(--sp-3);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.field-row input[type="number"] {
  width: 7rem;
}

.field-hint {
  color: var(--muted);
  font-size: var(--text-xs);
  margin: 0.25rem 0 0;
}

.field-error {
  color: var(--danger-ink);
  font-size: var(--text-xs);
  margin: 0.25rem 0 0;
}

/* The adjust-balance amount only ever holds a currency entry (#289
   founder review): capped like the wallet's top-up input, and widened
   from its 7rem so the adjustment contract's widest value
   (-999999.99, max_digits=8) is never clipped. */
input.amount-input {
  width: 9rem;
}

/* The adjust-balance amount's live sign colouring (#289): the vivid
   base semantics paint the field's text as the organiser types — green
   for a credit, red for a debit — toggled by amount_sign.js; without
   JavaScript the field stays neutral. Both clear AA on the field's
   white surface (the contrast gate in tests/api/test_theme_shell.py). */
input.amount-input--credit {
  color: var(--success);
}

input.amount-input--debit {
  color: var(--danger);
}

/* The roster's Add-a-player member chooser (#287): capped like the
   fund picker, so a member dropdown never spans the whole panel. */
.field--chooser {
  max-width: 24rem;
}

/* The auth pages' form (sign-in, two-factor steps): stacked fields
   under a full-width action. */
.login-form p {
  margin: 0 0 var(--sp-3);
}

.login-form button {
  width: auto;
}

/* The token step's error line: danger-banner semantics inline. */
.form-error {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger-ink);
}

/* ---------- Meter (headcount vs break-even) ---------- */

.meter {
  position: relative;
  height: 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  margin: 0.45rem 0 0.3rem;
  overflow: visible;
}

.meter-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
}

.meter-tick {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 1px;
  background: var(--ink);
  opacity: 0.45;
}

.meter-label {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ---------- Misc ---------- */

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

.small {
  font-size: var(--text-sm);
}

.money {
  font-variant-numeric: tabular-nums;
}

/* Roster lists — the playing squad and the reserve queue both use
   this idiom: positions render as text inside the row rather than
   list markers — markers are excluded from text selection, so a
   copied list would lose its numbers. */
.roster {
  list-style: none;
  margin: 0;
  padding: 0;
}

.roster li {
  display: flex;
  gap: 0.5rem;
  padding: 0.22rem 0;
  font-size: var(--text-sm);
}

.roster-position {
  display: inline-block;
  min-width: 1.75em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.own-place {
  color: var(--accent);
  font-weight: 650;
}

/* ---------- Member events page (#103, #127, #130, #85) ---------- */

.club-events {
  margin-bottom: var(--sp-5);
}

/* The club's cash line above its event cards. */
.membership-status {
  color: var(--muted);
  margin: 0 0 var(--sp-2);
  font-size: var(--text-sm);
}

.event-when,
.event-location,
.event-meta,
.event-policy {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: var(--text-sm);
}

.event-meta strong {
  color: var(--ink);
}

/* The meta-line split (#287 founder phone review): the platform's
   middot-joined meta lines — the session rows, the roster header and
   rows, the dashboard's week panel, the cancel confirmation and the
   member events cards — broke between a label and its value at phone
   widths and wrapped raggedly. Where a line's template carries the
   segment spans, a long free-text place rides its own line and every
   labelled segment is unbreakable, so "Signed up:" keeps its number,
   "Paid:" its amount and "Venue:" its pill; the place's separator is
   hidden whichever side of it the place sits, since a block line
   needs none. Lines without the spans read exactly as before. */
@media (max-width: 40rem) {
  .meta-place {
    display: block;
  }

  .meta-place + .meta-sep,
  .meta-sep:has(+ .meta-place) {
    display: none;
  }

  .meta-seg {
    white-space: nowrap;
  }
}

.kit-note {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* Type-scale alignment (#332): the status line rides --text-sm like
   the card's other detail rows — without a size it fell back to the
   body's --text-base, a full step over the .event-meta lines above. */
.slot-status {
  margin: 0 0 var(--sp-2);
  font-size: var(--text-sm);
}

.slot-actions,
.slot-actions form,
.join-form,
.rejoin-form,
.funded-slot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
}

/* The slot actions' primary buttons mirror .btn, and the .secondary
   modifier mirrors .btn--secondary. */
.slot-actions button,
.join-form button,
.funded-slot button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.slot-actions button:hover,
.join-form button:hover,
.funded-slot button:hover {
  background: var(--accent-hover);
}

.slot-actions button.secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.slot-actions button.secondary:hover {
  background: var(--accent-soft);
}

.slot-actions button:disabled,
.join-form button:disabled {
  background: var(--surface-sunken);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

.reserve-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 400;
  margin: 0;
}

.reserve-opt input[type="checkbox"] {
  width: auto;
}

/* Type-scale alignment (#332): the same omission as .slot-status —
   the funded entry fell back to --text-base beside the --text-sm
   roster, reserve and leavers rows. */
.funded-slot p {
  margin: 0;
  font-size: var(--text-sm);
}

/* The club debt banner (#130): danger-banner semantics. */
.debt-banner {
  background: var(--danger-soft);
  color: var(--danger-ink);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  font-size: var(--text-sm);
  margin: 0 0 var(--sp-3);
}

/* The PAY_ON_SIGNUP shortfall hint (#130): warn-banner semantics. */
.shortfall-hint {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font-size: var(--text-sm);
  margin: var(--sp-2) 0 0;
}

/* The earmarked top-up note: info-banner semantics. */
.earmark-note {
  color: var(--info-ink);
  background: var(--info-soft);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font-size: var(--text-sm);
  margin: 0 0 var(--sp-3);
}

/* The leavers lists keep their bullets — an informational group, not
   a numbered order; reserve rows use the .roster idiom directly. */
.roster-panel .leavers,
.leavers-panel .leavers {
  margin: 0;
  padding-left: 1.2rem;
}

.leavers {
  font-size: var(--text-sm);
}

.race-time {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* Race-times disclosure (#347): the joined/queued/left stamps left the
   inline rows and ride one ADMIN-only <details> per card — a native
   disclosure like the wallet's bank-details one, so no JavaScript
   reaches the page. */
.race-times {
  border-top: 1px solid var(--line);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
}

.race-times summary {
  color: var(--muted);
  font-size: var(--text-sm);
  cursor: pointer;
}

.race-times-list {
  list-style: none;
  margin: var(--sp-2) 0 0;
  padding: 0;
  font-size: var(--text-sm);
}

/* Reserve offers (#127). */
.offer-deadline {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* Ad-hoc funding picker (#85, #338): one select and one button under
   the roster replace the per-row buttons — a full roster of unpaid
   places stays readable. The label rides the flex row rather than
   stacking above it, and the row is capped so the form reads as one
   control rather than a band across the card. */
.fund-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  max-width: 24rem;
}

.fund-picker label {
  margin: 0;
  font-size: var(--text-sm);
}

.fund-picker select {
  flex: 1 1 10rem;
  width: auto;
  font-size: var(--text-sm);
}

/* The reserve row's queue-move picker (#287): the fund-picker idiom —
   a capped row, a native select and one Move button. The legal moves
   are the options' own full sentences, so an edge row simply lists
   fewer of them; no JavaScript reaches the control. The select's
   placeholder names it, so no visible label rides the row and the
   pair fits one line at phone width. Unlike the fund-picker's, the
   select's width is definite: the picker sits in the flex .btn-row,
   where an auto-width select sizes to its widest option, and an edge
   row (which never lists "Move down one place") would render
   narrower than the others. */
.queue-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  max-width: 24rem;
}

.queue-picker select {
  flex: 1 1 12rem;
  width: 12rem;
  font-size: var(--text-sm);
}

/* Copy list (organiser convenience): the ADMIN membership's clipboard
   button on each event card and on the two-factor pages. The action
   controls are excluded from manual text selection so a hand-dragged
   roster copy never carries button labels; the clipboard text lives
   in hidden textarea sources copy_list.js reads. */
.copy-panel {
  margin: 0 0 0.35rem;
}

.copy-list-button {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-size: var(--text-xs);
  cursor: pointer;
}

.copy-list-button:hover {
  background: var(--accent-soft);
}

.slot-actions,
.join-form,
.fund-picker,
.queue-picker,
.funded-slot form,
.copy-panel {
  user-select: none;
}

/* ---------- Member wallet page (#67, #126) ---------- */

.balance {
  font-size: var(--text-lg);
  margin: 0 0 var(--sp-3);
  font-variant-numeric: tabular-nums;
}

.topup-form label {
  display: block;
}

.topup-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

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

.topup-row input[type="number"] {
  width: 7rem;
}

/* The pay/withdraw actions mirror .btn. */
.topup-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.topup-row button:hover {
  background: var(--accent-hover);
}

.topup-row button:disabled {
  background: var(--surface-sunken);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

/* The htmx fee preview under the amount input. */
.fee-preview {
  margin-top: var(--sp-2);
  color: var(--muted);
  font-size: var(--text-sm);
  min-height: 1.4em;
}

.preview-breakdown {
  display: inline-block;
  margin-bottom: 0.2rem;
}

.preview-invalid {
  color: var(--danger-ink);
}

.topup-note {
  color: var(--muted);
  font-size: var(--text-xs);
  margin: var(--sp-3) 0 0;
}

/* Withdrawals (#126): the form's bank-details disclosure and the
   recent-withdrawals list. */
.withdraw-form {
  border-top: 1px solid var(--line);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
}

.withdraw-form label {
  display: block;
}

.withdraw-destination {
  margin-top: var(--sp-2);
}

.withdraw-destination summary {
  color: var(--muted);
  font-size: var(--text-sm);
  cursor: pointer;
}

.withdraw-destination label {
  margin-top: var(--sp-2);
}

.withdrawals h2 {
  margin: var(--sp-4) 0 var(--sp-2);
}

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

.withdrawal-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
}

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

/* ---------- Two-factor sign-in (#202) ---------- */

.two-factor-qr {
  display: block;
  padding: var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  image-rendering: pixelated;
}

.two-factor-key {
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}

.two-factor-recovery-codes {
  padding: 0.75rem 1rem 0.75rem 2.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  columns: 2;
}

.two-factor-recovery-codes code {
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}

/* ---------- Settings surfaces (#293) ---------- */

/* The palette picker and the sport-pack chooser: each option is a
   full-width card carrying its radio. */
.picker {
  display: grid;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
}

/* The save row keeps a full space from the options it acts on (#293
   founder exercise). */
.picker + .btn-row {
  margin-top: var(--sp-4);
}

.picker-option {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.75rem var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
}

.picker-option input[type="radio"] {
  width: auto;
  accent-color: var(--accent);
}

.picker-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* The option's label: radio plus its text. A separate element so an
   option can also carry a sibling action — the sport-pack preview
   link — outside the label's click forwarding. */
.picker-main {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 1;
  min-width: 0;
  margin: 0;
  cursor: pointer;
}

.picker-label {
  font-weight: 650;
  font-size: var(--text-base);
  margin: 0;
}

.picker-hint {
  color: var(--muted);
  font-size: var(--text-xs);
  margin: 0.15rem 0 0;
}

/* Reserved space (#293 founder exercise): the hint and the sport
   pack's Preview link render on every option and go invisible when
   off-state, so moving the selection or the preview never resizes an
   option. visibility:hidden keeps the box exactly, and drops a
   hidden link from tab order and the accessibility tree. */
.picker .is-reserved {
  visibility: hidden;
}

/* Swatch chip: a miniature of the palette — page background, accent,
   brand mark, ink — painted through the same var()s the page uses.
   The chip carries data-theme, which tokens.css matches on any
   element, so it renders the palette's real colours with no copy of
   them and no colour literal here. */
.swatch {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.swatch-chip {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
}

.swatch-chip--accent {
  background: var(--accent);
}

.swatch-chip--brand {
  background: var(--brand-bg);
}

.swatch-chip--ink {
  background: var(--ink);
}

.swatch-text {
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 650;
}
