/* ═════════════════════════════════════════════════════════════════════════
   roster.css — the roster board and the athlete page.

   The board is read like a timing tower: every athlete is a row with a number
   plate, and the colour of its leading edge tells you the state at a glance —
   the school's colour when nothing is wrong, amber when not cleared to play, red
   when there is nobody to call. A coach scanning thirty cards sees the two
   exceptions without reading a word.

   Number plates lean forward (--lean) and carry tabular figures, which is the
   whole racing gesture: no gradients, no glow, nothing that muddies on a phone
   under gym lights.
   ═════════════════════════════════════════════════════════════════════════ */

/* ── Shared bits ───────────────────────────────────────────────────────────── */
.dot {
  display: inline-block;
  width: 3px; height: 3px;
  margin: 0 var(--space-2);
  background: var(--slate-300);
  vertical-align: 2px;
}

.flag {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.5;
  white-space: nowrap;
}
.flag-ok    { background: var(--st-success-bg); color: var(--st-success-fg); }
.flag-warn  { background: var(--st-warning-bg); color: var(--st-warning-fg); }
.flag-alert { background: var(--st-danger-bg);  color: var(--st-danger-fg); }

.mini {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  padding: 5px var(--space-3);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-height: var(--tap-min);
  /* A button label must never wrap. "Set role" broke onto two lines whenever the
     control beside it took the width, which made one button in a row of four
     twice the height of the others. */
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.mini:hover  { border-color: var(--text); color: var(--text); }
.mini-danger:hover { border-color: var(--st-danger-fg); color: var(--st-danger-fg); background: var(--st-danger-bg); }

/* ── Board header ──────────────────────────────────────────────────────────── */
.roster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  position: relative;
}
.roster-head::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  width: 3.5rem; height: 2px;
  background: var(--school-primary);
}
.roster-team {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
  text-decoration: none;
}
.roster-team:hover { color: var(--school-primary); }
.roster-meta {
  margin-top: 3px;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
}
.roster-tally { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.tally {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--text-muted);
}
.tally strong {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--text);
  margin-right: 2px;
}
.tally.is-warn  strong { color: var(--st-warning-fg); }
.tally.is-alert strong { color: var(--st-danger-fg); }

/* ── Quick add ─────────────────────────────────────────────────────────────────
   One row that submits and returns with the cursor back in the first field.
   Entering twenty athletes is the real first-run task; a modal reopened twenty
   times is the wrong shape for it. */
.quick-add {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  background: var(--track-dark);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--school-bright, var(--school-primary));
}
.quick-add input {
  min-width: 0;
  min-height: var(--control-compact);
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--fs-md);          /* 16px floor: iOS Safari zooms below it */
  color: #fff;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius-sm);
}
.quick-add input::placeholder {
  color: rgba(255, 255, 255, .42);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--fs-xs);
}
.quick-add input:focus-visible {
  outline: 2px solid var(--school-primary);
  outline-offset: 0;
  background: rgba(255, 255, 255, .12);
}
.qa-jersey {
  flex: 0 0 4rem;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.qa-name { flex: 1 1 9rem; }
.qa-pos  { flex: 0 0 5.5rem; }
.qa-year { flex: 0 0 6rem; font-variant-numeric: tabular-nums; }
.qa-ref  { flex: 0 0 8rem; }
.qa-go   { flex: 0 0 auto; margin-left: auto; }

/* ── The board ─────────────────────────────────────────────────────────────── */
.roster-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
}

.athlete {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  /* The leading edge IS the status. School colour = nothing wrong. */
  border-left: 3px solid var(--school-primary);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition), transform var(--transition);
}
.athlete:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.athlete.is-flagged { border-left-color: var(--st-warning-fg); }
.athlete.is-alert   { border-left-color: var(--st-danger-fg); }
.athlete.is-inactive { opacity: 0.55; }

.athlete-hit {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  grid-template-areas: "jersey id" "jersey flags";
  align-items: center;
  gap: 0 var(--space-3);
  padding: var(--space-3);
  text-decoration: none;
  color: inherit;
}

/* The number plate: graphite, leaning forward, white tabular figures. */
.athlete-jersey {
  grid-area: jersey;
  display: grid;
  place-items: center;
  height: 3rem;
  background: var(--track-dark);
  border-radius: var(--radius-sm);
  transform: skewX(var(--lean));
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  color: #fff;
}
/* Counter-skew the glyphs so the plate leans but the number stays upright. */
.athlete-jersey > * { transform: skewX(calc(var(--lean) * -1)); }
.no-jersey { color: rgba(255, 255, 255, .35); font-weight: 600; }

.athlete-id { grid-area: id; min-width: 0; }
.athlete-name {
  display: block;
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.athlete-sub {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--text-muted);
}
.athlete-flags {
  grid-area: flags;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-2);
}

.athlete-actions {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-3) var(--space-3);
}
@media (hover: hover) and (min-width: 48rem) {
  .athlete-actions { opacity: 0; transition: opacity var(--transition); }
  .athlete:hover .athlete-actions,
  .athlete:focus-within .athlete-actions { opacity: 1; }
}

.roster-empty {
  color: var(--text-muted);
  padding: var(--space-5) 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--fs-xs);
  font-weight: 700;
}

/* ── Athlete page ──────────────────────────────────────────────────────────── */
.ath-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.ath-avatar {
  display: grid;
  place-items: center;
  width: 3rem; height: 3rem;
  flex: 0 0 auto;
  background: var(--track-dark);
  border-radius: var(--radius-sm);
  transform: skewX(var(--lean));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.02em;
}
.ath-id { flex: 1 1 12rem; min-width: 0; }
.ath-name {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.ath-sub {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
}

.ath-clear { display: flex; align-items: center; gap: var(--space-3); flex: 0 0 auto; }
.clear-state {
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.clear-state.is-ok   { color: var(--st-success-fg); }
.clear-state.is-warn { color: var(--st-warning-fg); }
.ath-clearnote { margin: var(--space-2) 0 0; font-size: var(--fs-sm); color: var(--text-muted); }

.ath-cols {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  align-items: start;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--school-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.panel-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.panel-head h2 { margin: 0; }
.panel-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

/* Contacts */
.guardians { list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.guardian {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}
.guardian:first-child { border-top: 0; padding-top: 0; }
.guardian-main { min-width: 0; }
.guardian-name { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; }
.guardian-rel {
  display: block;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--text-muted);
}
.guardian-reach { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin-top: 3px; font-size: var(--fs-sm); }
.guardian-reach a { color: var(--school-primary); font-weight: 600; }

.guardian-add { border-top: 1px dashed var(--border); padding-top: var(--space-3); }
.ga-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }
.ga-row input {
  flex: 1 1 8rem;
  min-width: 0;
  min-height: var(--control-compact);
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--fs-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
}
.ga-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.ga-primary {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 700; color: var(--text-muted);
}

/* Team entries */
.entry {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}
.entry:first-of-type { border-top: 0; padding-top: 0; }
.entry-team { flex: 1 1 auto; min-width: 0; font-weight: 700; color: var(--text); text-decoration: none; }
.entry-team:hover { color: var(--school-primary); }
.entry-season {
  display: block;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--text-muted);
}
.entry-jersey, .entry-pos {
  min-height: var(--control-compact);
  padding: 0 var(--space-2);
  font: inherit;
  font-size: var(--fs-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
}
.entry-jersey {
  flex: 0 0 3.5rem; text-align: center;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums; font-weight: 800;
}
.entry-pos { flex: 0 0 5rem; }

/* Details */
.fields { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.fields label {
  display: flex; flex-direction: column; gap: var(--space-1);
  font-size: var(--fs-table-head); text-transform: uppercase; letter-spacing: 0.09em;
  font-weight: 700; color: var(--text-muted);
}
.fields input {
  min-height: var(--control-compact);
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--fs-md);
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.fields-foot { margin-top: var(--space-4); }

/* ── Phone ─────────────────────────────────────────────────────────────────── */
@media (max-width: 40rem) {
  .roster-grid { grid-template-columns: 1fr; }
  .qa-name, .qa-pos, .qa-year, .qa-ref { flex: 1 1 100%; }
  .qa-jersey { flex: 0 0 4rem; }
  .qa-go { width: 100%; margin-left: 0; }
  .ath-clear { width: 100%; justify-content: space-between; }
}

/* ── Import wizard ─────────────────────────────────────────────────────────────
   Three steps, and the step strip is the only chrome: at the review step the
   operator needs to believe nothing has happened yet, so the page says so and
   the counts carry the colour rather than the buttons. */
.steps {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.steps li::before { content: counter(step) ". "; }
.steps li.is-on   { color: var(--text); border-bottom-color: var(--school-primary); }
.steps li.is-done { color: var(--text-soft); border-bottom-color: var(--slate-300); }

.import .panel { margin-top: var(--space-4); }
.import-note {
  margin: var(--space-3) 0 0;
  font-size: var(--fs-sm);
  color: var(--text-soft);
}
.import-warn {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  background: var(--st-warning-bg);
  color: var(--st-warning-fg);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* Mapping + preview tables. Both scroll inside their own container rather than
   truncating: a mis-read column is only findable if you can see the value. */
.map-table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
.map-table thead th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-sunken);
  border-bottom: 2px solid var(--school-primary);
  font-size: var(--fs-table-head);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}
.map-table tbody th {
  text-align: left;
  font-weight: 700;
  padding: var(--space-2) var(--space-3);
}
.map-table tbody td { padding: var(--space-2) var(--space-3); }
.map-table tbody tr { border-top: 1px solid var(--border); }
.map-table .form-select { min-width: 13rem; }
.map-sample { color: var(--text-muted); font-size: var(--fs-sm); }

.preview-table tbody tr.row-error  { background: var(--st-danger-bg); }
.preview-table tbody tr.row-review { background: var(--st-warning-bg); }
.row-note { margin-left: var(--space-2); font-size: var(--fs-xs); color: var(--text-soft); white-space: normal; }

@media (max-width: 40rem) {
  .steps { width: 100%; }
  .steps li { flex: 1 1 auto; text-align: center; padding: var(--space-1); }
}

/* ═══════════════ Schedule ═════════════════════════════════════════════════
   Shared by the staff schedule and the family one. The only visual difference
   between the two audiences is .is-internal, which marks the bus/dismissal line
   that families never receive — a coach should be able to see at a glance which
   line on their screen is not on the parents'. */
.event-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; }

.event-day {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted);
}
.event-day:first-child { margin-top: 0; }

.event {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-raised);
  margin-bottom: var(--space-2);
}
.event.is-cancelled { opacity: .6; }
.event.is-cancelled .event-title { text-decoration: line-through; }

.event-when {
  flex: 0 0 4.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: var(--fs-sm);
  color: var(--text-strong);
}
.event-main  { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.event-title { font-weight: 600; }
.event-sub   { font-size: var(--fs-xs); color: var(--text-muted); overflow-wrap: anywhere; }

/* Staff-only logistics. Tinted and labelled, never styled the same as a line a
   parent would also see. */
.event-sub.is-internal { color: var(--color-accent); font-weight: 600; }

.event-end   { flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-2); }
.event-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.event-edit  { font-size: var(--fs-xs); }

/* A family roster is numbers and initials, so the cards can be much tighter than
   the staff roster they are derived from. */
.roster-grid.is-compact .athlete-sub { font-size: var(--fs-xs); }

@media (max-width: 30rem) {
  .event { flex-wrap: wrap; }
  .event-when { flex-basis: 100%; }
  .event-end  { flex-basis: 100%; justify-content: flex-start; }
}

/* ═══════════════ Announcements ════════════════════════════════════════════ */
.announcement-meta {
  font-size: var(--fs-xs); color: var(--text-muted);
  margin: 0 0 var(--space-3);
}
.announcement-body {
  font-size: var(--fs-sm); line-height: 1.6;
  overflow-wrap: anywhere;                 /* a pasted URL must not widen the page */
}
/* A draft is visible only to its author; make that unmistakable rather than
   relying on the badge alone. */
.announcement.is-draft { border-style: dashed; opacity: .85; }

/* ═══════════════ Volunteer sign-ups ══════════════════════════════════════ */
/* A covered line recedes; the point of the page is spotting what is NOT done. */
.event.is-covered { opacity: .72; }
.claim-form { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.claim-form .form-input { width: auto; min-width: 9rem; flex: 1 1 9rem; }
@media (max-width: 30rem) {
  .claim-form { width: 100%; }
  .claim-form .form-input { flex-basis: 100%; }
}

/* ═══════════════ Chat ═════════════════════════════════════════════════════
   The visibility line is styled to be READ, not skimmed past — in a system
   carrying messages between adults and children, knowing who else is in the
   room is the most important thing on the page. */
.chat-visibility {
  margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--color-accent);
  background: var(--bg-sunken);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-soft);
}
.chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.chat-msg { display: flex; flex-direction: column; gap: 2px; max-width: 46rem; }
.chat-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.chat-body {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-raised);
  font-size: var(--fs-sm); line-height: 1.55; overflow-wrap: anywhere;
}
.chat-msg.is-mine .chat-body { background: var(--st-info-bg); border-color: transparent; }
/* A withdrawn message keeps its place in the thread — the gap is the record. */
.chat-body.is-withdrawn { font-style: italic; color: var(--text-muted); background: var(--bg-sunken); }
.chat-meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-xs); color: var(--text-muted); }
.chat-withdraw { font-size: var(--fs-xs); color: var(--text-muted); text-decoration: underline; }
.chat-compose { margin-top: var(--space-5); }


/* ── Bulk select ───────────────────────────────────────────────────────────
   The bar appears only once something is ticked (app.js), and sticks to the
   top so it stays reachable part-way down a roster of forty. */
.bulk-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3);
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.bulk-count { font-size: var(--fs-sm); font-weight: 700; margin-right: auto; }
.bulk-all {
  display: inline-flex; align-items: center; gap: var(--space-2);
  margin-bottom: var(--space-3); font-size: var(--fs-sm); color: var(--text-soft);
}

/* The card is a stretched link, so the checkbox has to sit above it in the
   stacking order or the link swallows every click. */
.athlete { position: relative; }
.athlete-pick { position: absolute; top: 6px; left: 6px; z-index: 3; padding: 4px; }
.athlete-pick input { width: 18px; height: 18px; }
