/* Base elements and page layout (DESIGN.md §3, §4, §6, §7). */

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

html { -webkit-text-size-adjust: 100%; }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--space-4);
  font-variant-numeric: lining-nums;
}
h1 { font-size: var(--title-page); }
h2 { font-size: var(--title-section); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 var(--space-4); }
a { color: var(--text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; display: block; }
code, kbd, .mono { font-family: var(--font-mono); font-weight: 500; }
small, .text-small { font-size: var(--text-sm); }
.text-muted { color: var(--text-muted); }

/* Visible focus on every interactive element: brown outline on a beige halo. */
:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--focus);
}

/* Components set `display`, which would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-small);
}
.skip-link:focus { top: var(--space-4); }

.container {
  max-width: calc(var(--content-width) + 2 * var(--gutter));
  margin: 0 auto;
  padding-inline: var(--gutter);
}

main { display: block; flex: 1 0 auto; width: 100%; padding-block: var(--space-8) var(--space-12); }

.prose { max-width: 70ch; }
.prose h2 { margin-top: var(--space-8); }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 var(--space-4); }

.todo {
  background: var(--badge-error-bg);
  color: var(--badge-error-fg);
  padding: 0 var(--space-1);
  border-radius: 4px;
  font-weight: 600;
}

.stack > * + * { margin-top: var(--space-4); }
.section + .section { margin-top: var(--space-12); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.cluster > a:not([class]), .audit-filters__actions > a { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); }
/* A small control's label, 44px to tap without making the table row taller. */
.tap-area { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); margin: -12px; }

/* ---------- Header ---------- */
.site-header { background: var(--header); border-bottom: 1px solid var(--border); }
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 64px;
}
.site-header nav ul {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-weight: 500;
  text-decoration: none;
}
.site-header nav a:hover { text-decoration: underline; }
.site-header nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; }
.site-header__actions { display: flex; align-items: center; gap: var(--space-3); }

/*
 * Logo. logo.svg is a large beige canvas with the wordmark in the middle, so
 * the frame crops to the wordmark (plus some of its own beige margin) without
 * editing, recolouring or stretching the file. Crop box, in the SVG's
 * 1123x794 rendering: x 376-739, y 223-566.
 */
.logo {
  position: relative;
  display: block;
  flex: none;
  height: 56px;
  aspect-ratio: 363 / 343;
  overflow: hidden;
  border-radius: var(--radius-small);
}
.logo img {
  position: absolute;
  width: 309.37%;   /* 1123 / 363 */
  max-width: none;
  height: auto;
  left: -103.58%;   /* 376 / 363 */
  top: -65.01%;     /* 223 / 343 */
}

/* Phone menu: a <details> disclosure, so it works without JavaScript. */
.menu { display: none; position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  z-index: 20;
  min-width: 220px;
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.menu__panel ul { list-style: none; margin: 0; padding: 0; }
.menu__panel a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius-small);
  text-decoration: none;
}
.menu__panel a:hover { background: var(--header); }

/* Account menu (desktop header, logged in). Shares the panel style above. */
.account-menu { position: relative; }
.account-menu > summary { list-style: none; cursor: pointer; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu__chevron { transition: transform 0.15s; }
.account-menu[open] .account-menu__chevron { transform: rotate(180deg); }

@media (max-width: 860px) {
  .site-header nav.primary-nav,
  .site-header__actions { display: none; }
  .menu { display: block; }
  .logo { height: 48px; }
}

/* ---------- Bottom tab bar (logged-in members on phones) ---------- */
.tab-bar { display: none; }
@media (max-width: 860px) {
  .tab-bar {
    display: flex;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    background: var(--header);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tab-bar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
    font-size: var(--text-xs);
    font-weight: 600;
    text-decoration: none;
  }
  .tab-bar a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; }
  body.has-tab-bar { padding-bottom: 72px; }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--header);
  border-top: 1px solid var(--border);
  padding-block: var(--space-8);
  font-size: var(--text-sm);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  justify-content: space-between;
  align-items: center;
}
.site-footer ul { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); list-style: none; margin: 0; padding: 0; }
.site-footer a { display: inline-flex; align-items: center; min-height: var(--tap); }

.theme-toggle { display: inline-flex; gap: var(--space-1); padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface); }
.theme-toggle button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.theme-toggle button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* ---------- Staff layout ---------- */
.staff-layout {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.staff-sidebar { background: var(--header); border-right: 1px solid var(--border); padding: var(--space-4); }
.staff-sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.staff-sidebar a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius-small);
  text-decoration: none;
  font-weight: 500;
}
.staff-sidebar a:hover { background: var(--surface); }
.staff-sidebar a[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.staff-sidebar .count {
  min-width: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-xs);
  text-align: center;
}
.staff-content { padding: var(--space-6) var(--gutter); min-width: 0; }
@media (max-width: 860px) {
  .staff-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .staff-sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .staff-sidebar ul { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.site-footer__name { margin: 0; }
.site-header .phone-only { display: none; }
@media (max-width: 860px) {
  .site-header .phone-only { display: inline-flex; margin-left: auto; }
}
