/* Chapter Directory. Mobile-first; no framework, no build step. */

:root {
  --ink: #1b1f23;
  --ink-2: #3d433c;
  --muted: #5b625a;
  --ground: #f3f4f1;
  --surface: #ffffff;
  --line: #d9dcd5;
  --line-soft: #e6e8e3;
  --action: #1d4f73;
  --action-ink: #123650;
  --action-tint: #e3ecf3;
  --nudge-bg: #fff6e8;
  --nudge-line: #f0d9b5;
  --nudge-ink: #5a3b0c;
  --nudge-strong: #6b4410;
  --radius: 10px;
  --sans: "Public Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

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

a { color: var(--action); }
a:hover { color: var(--action-ink); }
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }

.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 16px; }
.page { padding-block: 20px 48px; }
.grow { flex-grow: 1; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Buttons */
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid #c9cec6; border-radius: 8px;
  background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer;
}
.btn--primary { background: var(--action); border-color: var(--action); color: #fff; }
.btn--primary:hover { color: #fff; background: var(--action-ink); }
.btn--ghost-dark { background: transparent; color: var(--ground); border-color: #5b625a; min-height: 40px; }

/* Header */
.site-header { background: var(--ink); color: var(--ground); }
.site-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; min-height: 60px; padding-block: 8px; }
.site-header form { margin: 0; }
.wordmark { color: var(--ground); text-decoration: none; font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.wordmark:hover { color: #fff; }
.chapter-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.chapter-tabs a {
  color: #d5d8d2; text-decoration: none; font-weight: 500; font-size: 14px;
  padding: 6px 12px; border-radius: 6px;
}
.chapter-tabs a[aria-current="page"] { color: var(--ink); background: var(--ground); font-weight: 600; }
.as-of { font-size: 13px; color: #b7bcb4; }

/* The bulk-tools nudge */
.nudge { background: var(--nudge-bg); border-bottom: 1px solid var(--nudge-line); color: var(--nudge-ink); font-size: 14px; }
.nudge__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-block: 10px; }
.nudge a { color: var(--nudge-strong); font-weight: 600; }

/* Directory layout. The form uses display: contents so its two parts (filters,
   search box) and the results, which sit outside it, share one grid. */
.directory__layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.directory__form { display: contents; }
.directory__top { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.narrow { max-width: 720px; }
.btn--block { width: 100%; justify-content: center; min-height: 52px; font-size: 16px; }
.directory__heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }

.searchbox {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 0 14px; min-height: 52px; color: var(--muted);
}
.searchbox:focus-within { outline: 3px solid var(--action-tint); }
.searchbox input {
  font: inherit; font-size: 17px; border: 0; outline: none;
  flex-grow: 1; min-width: 0; background: transparent; color: var(--ink);
}

/* Filters: a drawer on phones, a sidebar on wide screens */
.filters__backdrop { display: none; }
.filters { order: 0; }
.filters__toggle { list-style: none; border-color: var(--ink); }
.filters__toggle::-webkit-details-marker { display: none; }
.filters__body { display: flex; flex-direction: column; gap: 22px; padding: 16px 0 4px; }
.facet { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.facet legend {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px; padding: 0;
}
.facet__option {
  display: flex; align-items: center; gap: 10px; min-height: 40px;
  padding: 0 8px; border-radius: 6px; cursor: pointer;
}
.facet__option:hover { background: #ebedea; }
.facet__option.is-checked { background: #e9eff3; }
.facet__option--child { margin-left: 24px; }
.facet__option--child .facet__label { font-weight: 400; }
.facet__option input { width: 18px; height: 18px; margin: 0; accent-color: var(--action); flex-shrink: 0; }
.facet__label { flex-grow: 1; font-size: 14px; font-weight: 600; }
.facet__count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.facet__empty { margin: 0; color: var(--muted); font-size: 14px; }

/* Results */
.results { display: flex; flex-direction: column; gap: 14px; }
.results__summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px;
  border-radius: 999px; background: var(--action-tint); color: var(--action-ink);
  text-decoration: none; font-size: 13px;
}
.people {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.person + .person { border-top: 1px solid var(--line-soft); }
/* Name and meta, then the status pill under them, button on the right: the
   same shape whatever the status, so "Non-member" lines up with "Member". */
.person__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "who reveal" "status reveal";
  align-items: center; gap: 6px 12px; padding: 12px 14px;
}
.person__who { grid-area: who; min-width: 0; }
.person__row .pill { grid-area: status; justify-self: start; }
.person__reveal { grid-area: reveal; }
.person__name { font-weight: 700; font-size: 16px; }
.person__meta { font-size: 14px; color: #4a5049; }
.empty { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin: 0; }

.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill--member { background: var(--action-tint); color: var(--action-ink); border-color: #c3d4e2; }
.pill--non-member { background: #f1f2ef; color: var(--ink-2); border-color: #d3d6cf; }
.pill--former-member { background: #fff0d6; color: var(--nudge-ink); border-color: #efd3a3; }
.pill--not-employed-or-lapsed { background: var(--surface); color: #4a5049; border-color: #c9cec6; }

.results__bulk { font-weight: 600; }
.person__reveal { margin: 0; }
.person__reveal .btn { padding: 0 14px; min-width: 132px; justify-content: center; border-color: var(--action); color: var(--action); }
.person__reveal .btn--primary { color: #fff; }

/* A revealed contact */
.contact {
  background: #f6f8f9; border-top: 1px dashed #c9d3da;
  padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px;
}
.contact__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 24px; }
.contact__item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 44px; }
.contact__kind { width: 56px; flex-shrink: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.contact__value { font-family: var(--mono); font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.contact__value a { display: inline-block; padding-block: 10px; }
.contact__more a { font-size: 14px; font-weight: 600; padding: 10px 4px; }
.contact__shared {
  font-family: var(--sans); font-size: 11px; font-weight: 600; color: var(--nudge-ink);
  background: #fff0d6; border-radius: 4px; padding: 2px 6px; margin-left: 6px;
}
.contact__note { margin: 0; font-size: 12px; color: var(--muted); }
.contact__note--stop { font-size: 14px; color: var(--nudge-ink); background: var(--nudge-bg); border-radius: 8px; padding: 10px 12px; }
.contact-page .contact { border-top: 0; }

/* The soft-limit page and bulk-tools instructions */
.limit { display: flex; flex-direction: column; gap: 16px; }
.limit form { margin: 0; }
.limit__badge { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--nudge-strong); }
.limit__fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.bulk-tools { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.bulk-tools h2 { margin: 0 0 8px; font-size: 16px; }
.bulk-tools > :last-child { margin-bottom: 0; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.pager__links { display: flex; gap: 8px; }

.messages { list-style: none; padding: 12px 16px; margin: 0 0 16px; background: var(--action-tint); border-radius: 8px; }

/* Sign-in, code and terms pages. allauth's element templates are overridden
   (templates/allauth/) so its forms carry these classes. */
.auth-page { background: var(--ink); }
.auth-brand { max-width: 440px; margin: 0 auto; padding: 40px 16px 20px; color: var(--ground); }
.auth-brand__name { font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.auth-brand__tagline { font-size: 14px; color: #b7bcb4; }
main.auth {
  max-width: 440px; margin: 16px auto 40px; padding: 24px 20px;
  background: var(--surface); border-radius: 16px;
}
.auth-page .site-header + main.auth { margin-top: 24px; }
main.auth--wide { max-width: 640px; }
.auth h1 { font-size: 24px; margin-bottom: 12px; }
.auth p { color: var(--ink-2); margin: 0 0 14px; font-size: 16px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.auth-form p { margin: 0; }
.auth label { display: block; font-size: 14px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.auth input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  display: block; width: 100%; font: inherit; font-size: 17px;
  min-height: 52px; padding: 0 14px; color: var(--ink); background: var(--surface);
  border: 2px solid var(--ink); border-radius: var(--radius);
}
.auth input#id_code {
  font-family: var(--mono); font-size: 28px; letter-spacing: 0.3em; text-align: center;
}
.auth-form__actions, .auth-form__buttons { display: flex; flex-direction: column; gap: 10px; }
.btn--link { border: 0; background: transparent; color: var(--action); }
.auth .errorlist { list-style: none; margin: 0 0 6px; padding: 0; color: #8a1c1c; font-size: 14px; font-weight: 600; }

/* Terms: rendered in the page as a dialog-styled card */
.terms { position: static; display: block; width: 100%; max-width: none; margin: 0; padding: 0; border: 0; background: transparent; color: inherit; }
.terms__body { font-size: 16px; line-height: 1.6; color: #2c312b; margin-bottom: 18px; }
.terms__body ul { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.terms__form { display: flex; flex-direction: column; gap: 12px; margin: 0; border-top: 1px solid var(--line-soft); padding-top: 16px; }
.auth .terms__agree { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: 16px; font-weight: 600; color: var(--ink); margin: 0; cursor: pointer; }
.terms__agree input { width: 24px; height: 24px; margin: 0; accent-color: var(--action); flex-shrink: 0; }

/* Phones: the open filter drawer is a bottom sheet */
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .filters[open], .filters[open] + .filters__backdrop { animation: none !important; }
}
@media (max-width: 599px) {
  .as-of { display: none; }
  /* Wordmark and Sign out on one line; chapter tabs scroll in a row below. */
  .chapter-tabs { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chapter-tabs a { white-space: nowrap; }
  .nudge__detail, .nudge svg { display: none; }
}
@media (max-width: 899px) {
  .filters[open] {
    position: fixed; inset: auto 0 0 0; z-index: 10; max-height: 85vh; overflow-y: auto;
    background: var(--surface); border-radius: 16px 16px 0 0; padding: 12px 16px 24px;
    box-shadow: 0 -8px 40px rgba(27, 31, 35, 0.35);
  }
  .filters[open] { overscroll-behavior: contain; animation: sheet-up 0.22s ease-out; }
  .filters[open] + .filters__backdrop { animation: fade-in 0.22s ease-out; }
  /* A grab handle: the drawer can be swiped down to close. */
  .filters[open]::before {
    content: ""; display: block; width: 40px; height: 5px; border-radius: 3px;
    background: #c9cec6; margin: 0 auto 10px;
  }
  .filters[open] .filters__toggle { width: 100%; justify-content: center; }
  .filters[open] + .filters__backdrop {
    display: block; position: fixed; inset: 0; z-index: 9; background: rgba(27, 31, 35, 0.45);
  }
}

/* Wide screens: filters become a sidebar */
@media (min-width: 900px) {
  .wrap { padding-inline: 24px; }
  .page { padding-block: 28px 48px; }
  h1 { font-size: 30px; }
  .directory__layout {
    grid-template-columns: 270px minmax(0, 1fr);
    grid-template-areas: "filters top" "filters results";
    column-gap: 28px; row-gap: 16px; align-items: start;
  }
  .filters { grid-area: filters; }
  .directory__top { grid-area: top; }
  .results { grid-area: results; }
  .filters__toggle { display: none; }
  .filters__body { padding-top: 0; }
  .person__row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "who status reveal";
    column-gap: 16px; padding: 14px 18px;
  }
  .contact { padding: 12px 18px 16px; }
  .contact__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
