/* =========================================================================
   Gear Allowance - app-only styles.
   Uses the design tokens from site.css (copied from the public site). No
   hard-coded colours here: every colour is a token or a mix of tokens.
   ========================================================================= */

:root {
  --tap: 44px;
  --focus: var(--ink);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Tables and long words must not push the page sideways at 320px. */
main, .card, .line-summary, .timeline { overflow-wrap: anywhere; }

.wrap { padding-inline: var(--s-4); }
@media (min-width: 700px) { .wrap { padding-inline: var(--s-5); } }

/* ---------- Prototype banner ---------- */
.proto-banner {
  background: var(--cream);
  color: var(--ink);
  border-bottom: 3px solid var(--red);
  padding: var(--s-2) var(--s-4);
  text-align: center;
  font-size: 0.95rem;
}
.proto-banner p { margin: 0; }

/* ---------- Header and nav ---------- */
.app-header {
  background: var(--ink);
  color: var(--paper);
  border-bottom: 4px solid var(--red);
}
.app-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
  padding-block: var(--s-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--tap);
  color: var(--paper);
}
.brand img { border-radius: 50%; width: 48px; height: 48px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__district { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cream); }
.brand__app { font-size: 1.15rem; font-weight: 800; }

.app-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-2);
}
.app-nav a,
.app-nav__signout {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  color: var(--paper);
  font-weight: 700;
  font-size: 0.95rem;
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.3em;
}
.app-nav a:hover, .app-nav__signout:hover { text-decoration-color: currentColor; }
.app-nav a[aria-current="page"] {
  background: var(--red);
  text-decoration: none;
  /* Not colour alone: a cream bar under the current page (red on the ink
     header is under 3:1). */
  box-shadow: inset 0 -4px 0 var(--cream);
}
.app-nav__signout:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.app-header__who { margin: 0; width: 100%; font-size: 0.85rem; color: var(--cream); }

/* ---------- Main ---------- */
/* Disclosure toggles (request history): a 44px tap target. Keeps the default
   list-item display so the marker stays. */
summary { min-height: var(--tap); padding-block: var(--s-2); cursor: pointer; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
  padding-block: var(--s-6) var(--s-8);
}
.app-main--wide { max-width: var(--wrap); }
.app-main:focus { outline: none; }
.app-main h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.6rem); margin-bottom: var(--s-5); }
.app-main h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem); margin: var(--s-6) 0 var(--s-3); }
.app-main h3 { font-size: 1.15rem; margin: var(--s-5) 0 var(--s-2); }
.app-main a:not(.btn) { color: var(--red-700); text-decoration: underline; text-underline-offset: 0.15em; }
.app-main a:not(.btn):hover { color: var(--red-900); }
.app-main ul:not([class]), .app-main ol:not([class]) { padding-left: var(--s-5); margin-bottom: var(--s-4); }
.muted { color: var(--slate); }
.lead { margin-bottom: var(--s-5); }

/* ---------- Buttons: small variant and tap targets ---------- */
.btn { min-height: var(--tap); justify-content: center; text-decoration: none; }
.btn--small { padding: var(--s-2) var(--s-4); font-size: 0.82rem; }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-4) 0; }
.inline-form { display: inline; margin: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  padding: var(--s-5);
  margin: var(--s-5) 0;
}
.card > h2:first-child { margin-top: 0; }

.balance-card__available { font-size: 1.1rem; margin-bottom: var(--s-3); }
.balance-card__label { font-weight: 700; }
.balance-card__amount { font-size: clamp(1.8rem, 1.4rem + 2vw, 2.4rem); font-weight: 900; }
.balance-card__amount--negative { color: var(--red-700); }
.balance-card__parts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-6); margin: 0; }
.balance-card__parts dt { font-size: 0.85rem; color: var(--slate); font-weight: 700; }
.balance-card__parts dd { margin: 0; font-weight: 700; }

.waiting-list { list-style: none; display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.waiting-list a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--tap);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  text-decoration: none;
}
.waiting-list a:hover { background: var(--paper-2); }
.waiting-list__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2em;
  height: 2.2em;
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--ink);
  font-weight: 800;
}
.waiting-list__count--some { background: var(--red); color: var(--paper); }
.waiting-list__label { color: var(--ink); font-weight: 600; }

.rules-list { padding-left: var(--s-5); }
.rules-list li { margin-bottom: var(--s-2); }

/* ---------- Status words (colour only repeats the words) ---------- */
.status {
  display: inline-block;
  padding: 0.1em 0.6em;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.status--neutral { color: var(--slate); background: var(--paper-2); }
.status--wait { color: var(--ink); background: var(--cream); border-color: var(--cream-600); }
.status--action { color: var(--paper); background: var(--red-700); border-color: var(--red-700); }
.status--ok { color: var(--ink); background: var(--paper-3); }
.status--done { color: var(--ink-3); background: var(--paper); }
.status--stop { color: var(--red-800); background: var(--paper); }
.tag { display: inline-block; padding: 0 0.5em; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 0.8rem; font-weight: 700; color: var(--slate); }

.flags { list-style: none; margin: var(--s-2) 0; }
.flags li { color: var(--red-800); font-weight: 600; }
.flag-label { font-weight: 800; }

/* ---------- Lines and timeline ---------- */
.line-summary p { margin-bottom: var(--s-1); }
.line-summary__title { font-size: 1.05rem; }
.timeline { list-style: none; border-left: 3px solid var(--line); padding-left: var(--s-4); margin: var(--s-4) 0; }
.timeline__item { position: relative; margin-bottom: var(--s-4); }
.timeline__item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--s-4) - 8px);
  top: 0.55em;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--paper);
}
.timeline__item p { margin-bottom: 0; }
.timeline__meta, .timeline__money { font-size: 0.9rem; color: var(--slate); }

/* ---------- Forms ---------- */
.stack-form { max-width: 40rem; }
/* Search and filter forms on list pages: set apart from the results. */
.filter-form { max-width: none; padding: var(--s-4); margin-bottom: var(--s-5); background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.filter-form .field { margin-bottom: var(--s-4); }
.field { margin-bottom: var(--s-5); border: 0; }
.field label, .fieldset legend { display: block; font-weight: 700; margin-bottom: var(--s-1); }
.fieldset { padding: 0; }
.fieldset legend { font-size: 1.05rem; }
.optional { font-weight: 400; color: var(--slate); }
.field-hint { color: var(--slate); font-size: 0.92rem; margin-bottom: var(--s-2); }
.field-error { color: var(--red-700); font-weight: 700; margin-bottom: var(--s-2); }
.field--error { border-left: 4px solid var(--red-700); padding-left: var(--s-3); }
.input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: var(--tap);
  padding: var(--s-2) var(--s-3);
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--slate);
  border-radius: var(--r-sm);
}
textarea.input { min-height: 6rem; }
.input--short { max-width: 12rem; }
.input:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.field--error .input { border-color: var(--red-700); }
.money-input { display: flex; align-items: center; gap: var(--s-1); }
.money-input__sign { font-weight: 700; }
.choices { display: grid; gap: var(--s-2); }
.choice { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); }
.choice input { width: 24px; height: 24px; flex-shrink: 0; accent-color: var(--red-700); }
.choice label { font-weight: 400; margin: 0; }
.choice-hint { display: block; color: var(--slate); font-size: 0.9rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.live-total { font-size: 1.1rem; font-weight: 700; }

/* ---------- Messages ---------- */
.error-summary {
  border: 4px solid var(--red-700);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-5);
  background: var(--paper);
}
.error-summary:focus { outline: 3px solid var(--ink); outline-offset: 3px; }
.error-summary h2 { margin: 0 0 var(--s-2); font-size: 1.2rem; }
.error-summary ul { padding-left: var(--s-5); margin: 0; }
.error-summary a { color: var(--red-700); font-weight: 700; }

.flash { border-radius: var(--r-md); padding: var(--s-3) var(--s-4); margin-bottom: var(--s-5); border-left: 6px solid var(--ink); background: var(--paper); box-shadow: var(--shadow-1); }
.flash p { margin: 0; }
.flash--error { border-left-color: var(--red-700); }
.notice--problem { border-left-color: var(--red-800); }
.empty { color: var(--slate); font-style: italic; }
.back { margin-bottom: var(--s-4); }

/* ---------- Tables ---------- */
.table-scroll:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* site.css styles every th as a red column header. Row headers name the row
   (an item, a person) and would otherwise put dark red links on red. */
tbody th {
  background: none;
  color: inherit;
  font-size: inherit;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

/* ---------- Idle warning (built by app.js) ---------- */
.idle-warning {
  position: fixed;
  inset: auto var(--s-4) var(--s-4) var(--s-4);
  z-index: 400;
  max-width: 32rem;
  margin-inline: auto;
  padding: var(--s-4) var(--s-5);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
}
.idle-warning p { margin-bottom: var(--s-3); }

/* ---------- Dev sign-in ---------- */
.dev-people { list-style: none; display: grid; gap: var(--s-3); }
.dev-person { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.dev-person__role { color: var(--slate); font-size: 0.92rem; }

/* ---------- Footer ---------- */
.app-footer { background: var(--ink-2); color: var(--paper); padding: var(--s-5) 0; font-size: 0.9rem; }
.app-footer p { margin: 0; color: var(--paper); }
.app-footer__links { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin-bottom: var(--s-3); }
.app-footer a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--cream); text-decoration: underline; }
.app-footer a:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .app-header, .app-footer, .proto-banner, .skip-link, .actions, .idle-warning { display: none; }
}
