/* Officer hub: the Roster tab (/js/hub/roster.js), for the President and the Faculty Advisors. The
   numbers at the top, the search and filters, the Microsoft form import, the sign-ups table (a card
   per person on phones) and the end of year card. Tokens come from app.css, so light and dark both
   work; badges are .hub-badge from hub.css. Class names start with rst-. */

/* ---------- at a glance ---------- */

/* The count pills are the hub's (.hub-stat in hub.css). */
.rst-stats { margin: 0 0 10px; }
.rst-promise { margin: 0 0 18px; color: var(--muted); font-size: 14px; max-width: 760px; }

/* ---------- search, Show G numbers, Remove selected ---------- */

.rst-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }
.rst-search { flex: 1 1 300px; max-width: 520px; }
.rst-check {
  display: inline-flex; align-items: center; gap: 9px; min-height: 44px; margin: 0;
  font-weight: 650; font-size: 14px; color: var(--text); cursor: pointer;
}
.rst-remove-picked { margin-left: auto; }

.rst-chips {
  display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; margin: 0 0 14px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.rst-chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 0 11px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 650; white-space: nowrap; cursor: pointer;
}
.rst-chip:hover { color: var(--text); background: var(--surface-2); }
.rst-chip[aria-pressed="true"] { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--accent); }
.rst-chip:focus-visible { outline-offset: -2px; }
.rst-chip-n {
  min-width: 20px; padding: 0 6px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--bg); color: var(--muted);
}
.rst-chip[aria-pressed="true"] .rst-chip-n { color: var(--text); }
/* "Showing 3 of 42 sign-ups: Ready for roles, matching "ada"." over the list. */
.rst-shown { margin: -4px 0 12px; color: var(--muted); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Import Microsoft form ---------- */

.rst-import { margin: 0 0 16px; }
.rst-import-title { margin: 0 0 6px; font-size: 18px; }
.rst-steps { margin: 8px 0 16px; padding-left: 20px; color: var(--muted); }
.rst-steps li { margin: 4px 0; }
.rst-steps b { color: var(--text); }
.rst-file {
  display: block; width: 100%; max-width: 460px; padding: 10px;
  border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit;
}
.rst-import .hint { margin: 6px 0 0; }
.rst-import-error { margin: 10px 0 0; }
.rst-import-preview { margin-top: 16px; }
.rst-import-summary { color: var(--muted); font-size: 14px; }
.rst-preview-box { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.rst-preview-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 13px; }
.rst-preview-table th, .rst-preview-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.rst-preview-table th { color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; }
.rst-import-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.rst-import-result { margin: 12px 0 0; color: var(--ok); font-weight: 650; }
.rst-import-result:empty { margin: 0; }

/* ---------- the sign-ups table ---------- */

/* Scrolls down and sideways inside its box, so the column titles and the names stay in view. It starts
   under the hub's tab bar, which sticks to the top of the screen. While more columns are off to the
   right (roster.js sets more-after), the right edge fades. */
.rst-table-wrap { position: relative; }
.rst-table-wrap::after {
  content: ""; position: absolute; top: 1px; bottom: 1px; right: 1px; z-index: 4; width: 48px;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: linear-gradient(to left, var(--surface), transparent);
  pointer-events: none; opacity: 0;
}
.rst-table-wrap.more-after::after { opacity: 1; }
.rst-table-box {
  /* Positioned, so screen reader only text in a cell stays inside the scrolling box instead of
     widening the page. */
  position: relative;
  max-height: max(360px, calc(100vh - 150px));
  overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.rst-table-box:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rst-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.rst-table th, .rst-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top; background: var(--surface);
}
.rst-table tbody tr:last-child td { border-bottom: 0; }
.rst-table th {
  position: sticky; top: 0; z-index: 2;
  color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
}
.rst-table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.rst-table tbody tr.is-picked td { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }

/* The name stays at the left while the rest scrolls sideways. */
.rst-table .rst-name { position: sticky; left: 0; z-index: 1; min-width: 200px; max-width: 280px; box-shadow: 1px 0 0 var(--line); }
.rst-table th.rst-name { z-index: 3; }
.rst-person { font-weight: 750; overflow-wrap: anywhere; }
.rst-dup { --c: var(--danger); margin-left: 6px; vertical-align: 1px; }
.rst-email { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

.rst-pick { width: 40px; padding-right: 0; }
.rst-pick-row { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.rst-pick-all { display: inline-flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; }
/* Beside the box only on phones, where the column titles are hidden. */
.rst-pick-all-text {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.rst-num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.rst-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.rst-nowrap { white-space: nowrap; }
.rst-wide { min-width: 200px; max-width: 340px; overflow-wrap: anywhere; }
.rst-stack { display: grid; gap: 6px; justify-items: start; }
.rst-major { font-weight: 600; }
.rst-build { color: var(--muted); font-size: 13px; }
.rst-signed { display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.rst-source { color: var(--muted); font-size: 12px; }
.rst-warn-text { color: var(--warn); }
.rst-role.is-ready { --c: var(--ok); }
.rst-role.is-check { --c: var(--warn); }
.rst-role.is-quiet { --c: var(--muted); }

.rst-del { width: 48px; }
.rst-del-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--muted); font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.rst-del-button:hover { border-color: var(--danger); color: var(--danger); }
.rst-del-button:disabled { opacity: 0.45; cursor: default; }

.rst-empty { margin: 4px 0 16px; }

/* ---------- End of the school year ---------- */

.rst-year-end { margin-top: 20px; padding: 16px 20px; box-shadow: none; }
/* A chevron at the right says the card opens (display: flex drops the browser's own triangle). */
.rst-year-end summary {
  cursor: pointer; font-weight: 750; min-height: 32px; display: flex; align-items: center; gap: 12px;
  list-style: none; user-select: none; -webkit-user-select: none;
}
.rst-year-end summary::-webkit-details-marker { display: none; }
.rst-year-end summary::after {
  content: ""; flex: none; width: 8px; height: 8px; margin: -4px 4px 0 auto;
  border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.rst-year-end summary:hover::after { border-color: var(--text); }
.rst-year-end[open] summary::after { transform: rotate(225deg); margin-top: 4px; }
.rst-year-end p { color: var(--muted); font-size: 14px; margin: 10px 0 14px; max-width: 680px; }
.rst-year-end-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rst-clear-input { width: 100%; text-transform: uppercase; letter-spacing: 0.08em; }

.rst-refusal { max-width: 620px; }

/* ---------- up to 1010px: a card per person ---------- */

/* Below 1010px the table's columns scrolled sideways and hid Remove: each person is a card instead,
   two across from 760px. */
@media (max-width: 1010px) {
  .rst-table-box { max-height: none; overflow: visible; background: transparent; border: 0; box-shadow: none; border-radius: 0; }
  .rst-table-wrap::after { display: none; }
  .rst-table, .rst-table thead, .rst-table tbody { display: block; width: 100%; min-width: 0; }
  /* The column titles give way to a label on each line; only "Select every row shown" stays. */
  .rst-table thead tr { display: block; margin-bottom: 10px; }
  .rst-table th { display: none; }
  .rst-table th.rst-pick { display: block; position: static; width: auto; padding: 0; border: 0; background: transparent; text-transform: none; letter-spacing: 0; }
  .rst-pick-all { min-height: 44px; padding: 0 4px; font-size: 14px; font-weight: 650; color: var(--text); }
  .rst-pick-all-text { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; }

  .rst-table tbody tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px;
    margin-bottom: 10px; padding: 12px 8px 14px 14px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  }
  .rst-table tbody tr.is-picked { border-color: var(--accent); }
  .rst-table td { display: block; padding: 0; border: 0; background: transparent; }
  .rst-table tbody tr:hover td, .rst-table tbody tr.is-picked td { background: transparent; }
  .rst-table td.rst-pick { grid-column: 1; grid-row: 1; width: auto; padding-top: 11px; }
  .rst-table td.rst-name { grid-column: 2; grid-row: 1; position: static; min-width: 0; max-width: none; box-shadow: none; padding-top: 8px; }
  .rst-table td.rst-del { grid-column: 3; grid-row: 1; width: auto; }
  /* overflow-wrap: a long word (a 32 letter Discord name, a pasted link) breaks inside the card
     instead of pushing the page sideways. */
  .rst-table td[data-label] {
    grid-column: 2 / 4; display: flex; gap: 10px; align-items: baseline;
    margin-top: 8px; padding-right: 6px; min-width: 0; max-width: none; white-space: normal; overflow-wrap: anywhere;
  }
  .rst-table td[data-label]::before {
    content: attr(data-label); flex: none; width: 92px;
    color: var(--muted); font: 650 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  }
  .rst-table td[data-label]:empty { display: none; }
  .rst-table td.rst-num { display: none; }
  .rst-del-button { width: 44px; height: 44px; }
}

@media (min-width: 760px) and (max-width: 1010px) {
  .rst-table tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
  .rst-table tbody tr { margin-bottom: 0; }
}

/* Narrower laptops: tighter chips, so "Needs a look" stays in the row. */
@media (max-width: 1100px) {
  .rst-chip { padding: 0 8px; gap: 5px; }
}

/* ---------- phones ---------- */

@media (max-width: 759px) {
  /* A 44 by 44 target around each row's box; the negative margin keeps the row as it was. */
  .rst-pick-row { min-width: 44px; min-height: 44px; margin: -13px; }
  /* Download spreadsheet and Import Microsoft form: one width when they stack. */
  .hub-section-roster .hub-head-actions { width: 100%; }
  .hub-section-roster .hub-head-actions .btn { flex: 1 1 auto; }
  .rst-tools { gap: 8px 12px; }
  .rst-search { flex-basis: 100%; max-width: none; }
  .rst-remove-picked { margin-left: 0; min-height: 44px; }
  .rst-chip { min-height: 44px; }
  /* One row that scrolls sideways; its right edge fades to say there are more. The spacer at the end
     lets the last chip scroll clear of the fade. */
  .rst-chips {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
  }
  .rst-chips::after { content: ""; flex: none; width: 28px; }
  .rst-chips::-webkit-scrollbar { display: none; }

  .rst-signed { display: flex; flex-wrap: wrap; gap: 2px 8px; }
  .rst-year-end { padding: 14px 16px; }
  .rst-year-end .btn { width: 100%; min-height: 46px; }
}
