/* MTM People — every colour is a custom property. No literals below the :root blocks. */

:root {
  --ink: #16151a;
  --ink-soft: #55525e;
  --ink-faint: #6e6a79;        /* AA: 4.82:1 on --paper. Was #8b8794 = 3.22:1 — FAILED. */
  --paper: #f7f5f2;
  --surface: #ffffff;
  --line: #e2ddd6;
  --line-strong: #cec7bd;

  /* ── MTM brand, from MTM Tracker. The header is this colour in BOTH themes:
     it is the brand, not a surface, so it does not follow the light/dark palette. ── */
  --mtm-blue: #0039A6;         /* Georgia State blue */
  --mtm-blue-ink: #ffffff;     /* wordmark on the bar */
  --mtm-blue-dim: #bfdbfe;     /* version stamp — Tracker's blue-200 */
  --mtm-blue-nav: #dbeafe;     /* inactive nav item — Tracker's blue-100 */
  --mtm-blue-hover: rgba(255, 255, 255, .10);
  --mtm-blue-active: rgba(255, 255, 255, .20);

  --accent: var(--mtm-blue);  /* the one accent — the brand blue, referenced not repeated */
  --accent-ink: #ffffff;
  --accent-soft: #dde7f8;

  --flag-student: #1d4e7a;
  --flag-student-bg: #e0ecf6;
  --flag-staff: #7a4a11;
  --flag-staff-bg: #f7ead6;
  --flag-artist: #6b1f52;
  --flag-artist-bg: #f6e2ef;
  --flag-faculty: #2f4a20;
  --flag-faculty-bg: #e5efdc;

  --danger: #99301f;
  --danger-bg: #f8e3df;
  --shadow: 0 1px 2px rgba(22, 21, 26, .06), 0 8px 24px rgba(22, 21, 26, .07);

  --radius: 4px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ── Dark palette, applied in two situations, which is what lets the toggle and the
   system setting coexist:
     1. the system says dark AND the user has not explicitly chosen light
     2. the user explicitly chose dark
   the user asked for the system setting to be the default; YM People uses an explicit
   `data-theme` attribute with a toggle. This does both — the media query is the
   default and `data-theme` overrides it in either direction.

   🔴 These only ever REDEFINE tokens that already exist in `:root`. A colour whose sole
   definition lives in one theme's block is how you get one theme's text on the other
   theme's background — `tests/test_theme.py` asserts parity in both directions.

   🔴 `--mtm-blue` is deliberately absent: it is the brand, not a surface. ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ece9e4;
    --ink-soft: #a5a0a9;
    --ink-faint: #8b8694;      /* AA: 4.87:1 on --surface. Was #746f7b = 3.53:1 — FAILED. */
    --paper: #131217;
    --surface: #1c1a21;
    --line: #2e2b35;
    --line-strong: #453f4d;

    --accent: #6f9be8;   /* lifted for contrast on a dark surface */
    --accent-ink: #0b1220;
    --accent-soft: #16233d;

    --flag-student: #8fc0e8;
    --flag-student-bg: #1a2e40;
    --flag-staff: #e0b271;
    --flag-staff-bg: #3a2c17;
    --flag-artist: #dd9dc9;
    --flag-artist-bg: #3a1c30;
    --flag-faculty: #a9cf8c;
    --flag-faculty-bg: #23331b;

    --danger: #e8907e;
    --danger-bg: #3a1e18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .45);
  }
}

:root[data-theme="dark"] {
    --ink: #ece9e4;
    --ink-soft: #a5a0a9;
    --ink-faint: #8b8694;      /* AA: 4.87:1 on --surface. Was #746f7b = 3.53:1 — FAILED. */
    --paper: #131217;
    --surface: #1c1a21;
    --line: #2e2b35;
    --line-strong: #453f4d;

    --accent: #6f9be8;   /* lifted for contrast on a dark surface */
    --accent-ink: #0b1220;
    --accent-soft: #16233d;

    --flag-student: #8fc0e8;
    --flag-student-bg: #1a2e40;
    --flag-staff: #e0b271;
    --flag-staff-bg: #3a2c17;
    --flag-artist: #dd9dc9;
    --flag-artist-bg: #3a1c30;
    --flag-faculty: #a9cf8c;
    --flag-faculty-bg: #23331b;

    --danger: #e8907e;
    --danger-bg: #3a1e18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 20px; }

/* ── The [hidden] guard ───────────────────────────────────────────────────────
   An author rule that sets `display` beats the browser's built-in
   `[hidden] { display: none }`, so a `hidden` element renders anyway. `!important`
   keeps this ahead of every component rule, present and future.
   Full reasoning: CLAUDE.md. */
[hidden] { display: none !important; }

/* ── Gate ─────────────────────────────────────────────────────────────────── */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  display: grid;
  gap: 10px;
}
.gate-logo { width: 64px; height: 64px; border-radius: 50%; display: block; }
.gate-card h1 { font-size: 22px; }
.gate-sub { color: var(--ink-soft); margin: 0 0 12px; font-size: 14px; }
.gate-card label { font-size: 13px; color: var(--ink-soft); }
.gate-note { font-size: 14px; color: var(--ink-soft); margin: 0; }
.gate-quiet { color: var(--ink-faint); font-size: 13px; margin-top: 4px; }

input, select, textarea, button {
  font: inherit;
  color: inherit;
}
input[type="text"], input[type="password"], input[type="search"], input[type="email"], select, textarea {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 8px 14px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
button.ghost:hover { color: var(--ink); }
.topbar button.ghost { color: var(--mtm-blue-nav); border-radius: 6px; }
.topbar button.ghost:hover { color: var(--mtm-blue-ink); background: var(--mtm-blue-hover); }
button.danger { color: var(--danger); border-color: var(--line-strong); background: transparent; }

/* ── Chrome ───────────────────────────────────────────────────────────────── */
/* Layout from the YM app (logo · wordmark+version · nav · right), colour and marks
   from MTM Tracker: h-16, max-w-7xl container, GSU blue. */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
  padding: 0 16px;
  background: var(--mtm-blue);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 4px 12px rgba(0, 0, 0, .10);
  position: sticky;
  top: 0;
  z-index: 5;
}
@media (min-width: 640px) { .topbar { padding: 0 24px; } }
@media (min-width: 1024px) { .topbar { padding: 0 32px; } }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;   /* a round mark — never squared */
  display: block;
}
.brand-name {
  color: var(--mtm-blue-ink);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.02em;
}
.brand-ver {
  color: var(--mtm-blue-dim);
  font-family: var(--mono);
  font-size: 10px;
  align-self: flex-end;
  padding-bottom: 3px;
}

/* Four tabs fit MTM Tracker's single h-16 bar comfortably, so this app keeps the
   one-row header. (Command Center went two-row because seven tabs plus a workspace
   switcher genuinely do not fit — that ruling is about its tab count, not a house
   style.) On a narrow screen the row scrolls rather than overflowing the page. */
.tabs {
  display: flex;
  gap: 2px;
  margin-right: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.header-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
#theme-toggle { font-size: 15px; line-height: 1; padding: 8px 10px; }
.tab {
  border: none;
  background: transparent;
  flex-shrink: 0;
  color: var(--mtm-blue-nav);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color .15s, color .15s;
}
.tab:hover { color: var(--mtm-blue-ink); background: var(--mtm-blue-hover); }
.tab.is-active { color: var(--mtm-blue-ink); background: var(--mtm-blue-active); }

main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 64px; }
@media (min-width: 640px) { main { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 1024px) { main { padding-left: 32px; padding-right: 32px; } }
.view { display: none; }
.view.is-active { display: block; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar h2 { margin-right: auto; }
.toolbar input[type="search"] { max-width: 260px; }
.toolbar select { width: auto; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
.check input { width: auto; }

.lede { color: var(--ink-soft); max-width: 62ch; margin: 6px 0 18px; }
.hint { color: var(--ink-faint); font-size: 13px; margin: 0 0 10px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--paper); }
td.name { font-weight: 500; white-space: nowrap; }
td .slug { display: block; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); font-weight: 400; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-soft); }

/* ── Chips ────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 10px;
  margin: 0 4px 3px 0;
  white-space: nowrap;
}
.chip-student { background: var(--flag-student-bg); color: var(--flag-student); }
.chip-staff   { background: var(--flag-staff-bg);   color: var(--flag-staff); }
.chip-artist  { background: var(--flag-artist-bg);  color: var(--flag-artist); }
.chip-faculty { background: var(--flag-faculty-bg); color: var(--flag-faculty); }
.chip-org { background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line); text-transform: none; letter-spacing: 0; font-size: 12px; }
.chip-inactive { background: var(--danger-bg); color: var(--danger); }
.chip-dnc { background: var(--danger); color: var(--paper); font-weight: 600; }
.chip-past { opacity: .6; font-style: italic; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h3 { font-size: 15px; }
.card .slug { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

/* ── Drawer ───────────────────────────────────────────────────────────────── */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); }
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-y: auto;
  padding: 24px 24px 60px;
}
.drawer-panel h2 { margin-bottom: 2px; }
.drawer-panel .slug { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.drawer-section { margin-top: 26px; }
.drawer-section > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); margin-bottom: 8px; }
.drawer-note { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.row .grow { flex: 1 1 120px; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--ink-soft); }
.flags { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 12px; }
.flags label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.flags input { width: auto; }
.grant {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 14px;
}
.grant code { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.callout-warn { border-left-color: var(--danger); background: var(--danger-bg); }
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 12px;
  font-size: 13px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 12px;
}

/* ── Name check ───────────────────────────────────────────────────────────── */
#namecheck-input { max-width: 520px; margin-bottom: 10px; font-family: var(--mono); font-size: 13px; }
#namecheck-result { margin-top: 20px; }
.resolved-list { list-style: none; padding: 0; margin: 0; }
.resolved-list li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.resolved-list code { font-family: var(--mono); font-size: 12px; }
.miss { color: var(--danger); }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--ink-faint);
  font-size: 12px;
}
.footer-note em { font-style: normal; color: var(--ink-soft); }

/* ── Phone ─────────────────────────────────────────────────────────────────
 * Phone is a first-class target, not a nice-to-have. Checked at 390px.
 *
 * The rule that matters: **nothing overflows the BODY.** Wide content — tables,
 * the tab row — scrolls inside its own container. A page that scrolls sideways is
 * the single most obvious sign an app was never opened on a phone.
 */
@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand { gap: 8px; }
  .brand-name { font-size: 15px; }
  .brand-ver { display: none; }        /* the version lives in /api/me; the bar is tight */

  main { padding: 16px 12px 48px; }

  .toolbar { gap: 8px; }
  .toolbar input[type="search"] { max-width: none; flex: 1 1 100%; }
  .toolbar select, .toolbar button { flex: 1 1 auto; }

  .drawer-panel { padding: 20px 16px 48px; }
  .cards { grid-template-columns: 1fr; }
  #namecheck-input { max-width: none; }

  /* A slug is one long unbroken token and will push a table wider than the screen. */
  td .slug, .card .slug { overflow-wrap: anywhere; }
}

/* Thumbs, not mice. 44px is the smallest reliably tappable target, and it applies to
   anything a coarse pointer has to hit — including table rows that open a drawer. */
@media (pointer: coarse) {
  .tab, button, .toolbar select { min-height: 44px; }
  .check { min-height: 44px; }
  tbody td { padding-top: 14px; padding-bottom: 14px; }
  .grant button { min-height: 44px; }
}

/* Belt and braces: no descendant may widen the page itself. Wide things scroll in
   their own container (`.table-wrap`, `.tabs`), never here. */
html, body { max-width: 100%; overflow-x: hidden; }

/* Paste a roster.
   🔴 The unmatched block must be the loudest thing on the page: it is the only part
   that needs a human, and a screen that leads with "42 matched" reads as success.
   Reuses --danger, which is defined in all three theme states. No new token, and no
   coloured left border. */
.roster-controls { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; }
.roster-controls label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--ink-soft);
}
.roster-controls select {
  font: inherit; padding: 7px 9px; min-height: 38px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.roster-summary { font-weight: 600; margin: 16px 0 8px; color: var(--ink); }
.roster-warn {
  color: var(--danger); background: var(--danger-bg);
  border: 1px solid var(--danger); padding: 12px 14px; border-radius: var(--radius);
}
.roster-block { margin: 18px 0; }
.roster-block h3 { font-size: 14px; margin-bottom: 6px; color: var(--ink); }
.roster-block-warn {
  background: var(--danger-bg); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: 12px 14px;
}
.roster-block-warn h3 { color: var(--danger); }
#roster-input { width: 100%; font-family: var(--mono); font-size: 13px; }

@media (pointer: coarse) {
  .roster-controls select { min-height: 44px; }
}
