/* The design system (.claude/rules/design-system.md), in ONE file both Flask
   units serve at /shared-static/app.css through shared_asset_url(). One copy on
   purpose: design-system.md forbids a separate idiom for the admin, and two
   copies of a stylesheet drift apart one "quick fix" at a time.

   The colour values and the typeface are Pollen's (pollen.io), recorded in
   design-system.md. A change replaces them in all three layers at once, records
   the decision there, and re-runs scripts/rasterize-public-icons.sh after
   updating the same colours in web/public/static/favicon.svg and share.svg.

   Sections: tokens / base / type / nav / layouts (app shell, marketing, notice) /
   cards / buttons / chips / forms / tables / footer / motion. */

/* ── Tokens: all three theming layers, every token in each ─────────────────── */

:root {
  --paper: #F7F7F7;
  --surface: #FFFFFF;
  --surface-2: #EEEEEE;
  --ink: #3F444B;
  --ink-soft: #585F69;
  --ink-faint: #80868E;
  --accent: #A87500;
  --accent-weak: #FDF0CC;
  --pop: #4E9A0E;
  --rule: #DDDDDD;
  --shadow: 0 2px 14px rgba(0, 0, 0, .08);
  --danger: #C9432F;
  /* Text on an --accent or --danger fill. Light text on the light theme's dark
     fills, dark text on the dark theme's light fills. */
  --on-fill: #FFFFFF;

  /* Pollen's typeface, self-hosted below: one family for everything, its italic
     for .display. The system stack is the fallback while it loads. */
  --sans: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1A1C1F;
    --surface: #23262A;
    --surface-2: #2C3035;
    --ink: #ECEDEF;
    --ink-soft: #B9BEC5;
    --ink-faint: #858B93;
    --accent: #F3AE00;
    --accent-weak: #3D300A;
    --pop: #7BCB34;
    --rule: #363A40;
    --shadow: 0 2px 14px rgba(0, 0, 0, .4);
    --danger: #E0705F;
    --on-fill: #1A1C1F;
  }
}

:root[data-theme="dark"] {
  --paper: #1A1C1F;
  --surface: #23262A;
  --surface-2: #2C3035;
  --ink: #ECEDEF;
  --ink-soft: #B9BEC5;
  --ink-faint: #858B93;
  --accent: #F3AE00;
  --accent-weak: #3D300A;
  --pop: #7BCB34;
  --rule: #363A40;
  --shadow: 0 2px 14px rgba(0, 0, 0, .4);
  --danger: #E0705F;
  --on-fill: #1A1C1F;
}

/* ── Typeface ──────────────────────────────────────────────────────────────── */

/* Open Sans (SIL Open Font License, fonts/OFL.txt), Latin subset, variable weight.
   Served from /shared-static/fonts/ rather than Google Fonts, so no visitor's
   address reaches a third party and the privacy page needs no new sub-processor.
   Relative URLs carry no content hash, so these get the shorter un-versioned cache
   (static_assets.py); rename the file if its bytes ever change. */
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/open-sans-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Open Sans";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/open-sans-latin-italic.woff2") format("woff2");
}

/* ── Base ──────────────────────────────────────────────────────────────────── */

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}

main { flex: 1 0 auto; width: 100%; margin: 0 auto; padding: 0 16px; }

p { margin: 0 0 14px; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

/* design-system.md: every interactive element, one outline. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

code { font-size: 0.92em; }

/* ── Type ──────────────────────────────────────────────────────────────────── */

/* Only the page <h1> and card/item titles. Never body copy, labels or buttons. */
.display { font-family: var(--sans); font-style: italic; font-weight: 400; }

h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.2; }
h1.display { font-size: clamp(26px, 4.5vw, 36px); line-height: 1.15; }
h2.display, h3.display { font-size: 19px; }

.num { font-variant-numeric: tabular-nums; }

/* The uppercase label: nav items, section kickers, tags, meta, chip text. */
.label,
.kicker,
.section-label,
.nav-link {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.kicker { color: var(--pop); }
.section-label { color: var(--accent); margin: 0 0 14px; overflow-wrap: anywhere; }

.lede { color: var(--ink-soft); max-width: 64ch; }
.muted { color: var(--ink-faint); font-size: 13px; }

/* ── Nav: shared by all three layouts ─────────────────────────────────────── */

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 16px 24px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.nav-logo { font-size: 19px; color: var(--accent); text-decoration: none; }
.nav-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.nav-link,
.nav-email {
  color: var(--ink-soft);
  text-decoration: none;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
.nav-link:hover,
.nav-email:hover { color: var(--ink); }
.nav-email { font-size: 13px; color: var(--ink-faint); }
/* THE active-state treatment, and the only one (design-system.md). */
.nav-link.active,
.nav-email.active { color: var(--ink); border-bottom-color: var(--pop); }
.nav form { margin: 0; }

/* ── Layout 1: App shell (signed-in pages and the admin UI) ───────────────── */

.layout-app main { max-width: 1040px; padding-top: 32px; padding-bottom: 48px; }
.page-header { margin: 0 0 28px; }
.page-header h1 { margin: 6px 0 10px; }
.app-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.app-grid > .app-main > .card + .card { margin-top: 20px; }
/* Cards stacked straight inside main (the admin lookup's search and results) get the
   same gap rather than touching. */
.layout-app main > .card + .card { margin-top: 20px; }
@media (max-width: 900px) {
  .app-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Layout 2: Marketing (signed-out public pages) ────────────────────────── */

.layout-marketing main { max-width: 1040px; padding-bottom: 56px; }
.hero { display: flex; align-items: center; gap: 40px; padding: 48px 0 24px; }
.hero-copy { flex: 1 1 0; min-width: 0; }
.hero-copy h1 { max-width: 12ch; margin: 10px 0 16px; font-size: clamp(30px, 5.5vw, 46px); }
.hero-copy .lede { margin-bottom: 24px; }
.hero-art { flex: 0 0 auto; width: min(320px, 40vw); height: auto; }
.section { margin-top: 48px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
/* Long-form pages (the terms and privacy policy) in the Marketing layout: the hero's
   copy column alone as a header, then one column of prose at a readable measure, with
   uppercase section labels as its headings (design-system.md, "Layout inventory"). */
.legal-header { padding: 48px 0 16px; }
.legal-header h1 { max-width: 20ch; margin: 10px 0 10px; font-size: clamp(30px, 5.5vw, 46px); }
.prose { max-width: 68ch; }
.prose .section-label { margin: 36px 0 12px; }
.prose h3 { margin: 22px 0 8px; color: var(--ink-soft); }
.prose p, .prose li { color: var(--ink-soft); }
.prose ul { margin: 0 0 14px; padding-left: 1.2em; }
.prose li { margin: 0 0 8px; }
.prose b { color: var(--ink); font-weight: 600; }
@media (max-width: 720px) {
  .hero { flex-direction: column-reverse; align-items: flex-start; gap: 24px; padding-top: 32px; }
  .hero-art { width: min(220px, 60vw); }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Layout 3: Notice (sign-in, confirmations, errors) ────────────────────── */

.layout-notice main { max-width: 560px; padding-top: 48px; padding-bottom: 48px; }
.notice-card h1 { margin: 0 0 12px; }
.notice-card p { color: var(--ink-soft); }
.notice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 20px; }
.notice-actions form { margin: 0; }
.notice-footnote { margin-top: 20px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */

/* No border: the shadow alone separates card from page. */
.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.card h2,
.card h3 { margin: 0 0 8px; }
.card p { color: var(--ink-soft); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */

/* One shape for every button-like control: the pill with an uppercase label.
   Variants differ only by fill/outline. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
/* The one primary button style. One per view where possible. */
.btn-primary { background: var(--accent); color: var(--on-fill); }
.btn-primary:hover { filter: brightness(0.92); }
/* Secondary actions: outlined, never a second filled style. */
.btn-secondary { background: transparent; color: var(--ink-soft); border-color: var(--rule); }
.btn-secondary:hover { color: var(--ink); border-color: var(--ink-soft); }
/* Destructive: --danger outline until the confirmation step... */
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
/* ...where, and only where, it is filled. */
.btn-danger-confirm { background: var(--danger); color: var(--on-fill); }
.btn-danger-confirm:hover { filter: brightness(0.92); }
.btn-small { padding: 6px 14px; }

/* Disabled is never colour alone: the attribute, the opacity and the cursor. */
.btn:disabled,
.btn[aria-disabled="true"],
.chip:disabled,
.is-disabled {
  opacity: .5;
  cursor: not-allowed;
  filter: none;
}

/* ── Chips ─────────────────────────────────────────────────────────────────── */

/* Variants by treatment (filled, outlined, dashed), not by colour alone. A chip
   that filters is a real <button class="chip">, so it can take focus. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
button.chip { cursor: pointer; }
.chip-selected { background: var(--accent-weak); color: var(--accent); }
.chip-outline { background: transparent; border-color: var(--rule); color: var(--ink-faint); }
.chip-dashed { background: transparent; border: 1px dashed var(--ink-faint); color: var(--ink-faint); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 14px; }
.field > span,
.field > .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }
.field input,
.field select,
.field textarea {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
}
/* A set of checkboxes or radio buttons for one choice (roles, permissions, units):
   a borderless fieldset whose legend reads like a .field label, each option a
   label wrapping its input so the whole line is clickable. */
.check-group { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.check-group > legend { padding: 0; margin-bottom: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }
.check-group label { display: flex; gap: 8px; align-items: baseline; margin: 0 0 6px; }
.check-group input { accent-color: var(--accent); }
.check-group .muted { font-size: 13px; }
/* Where static/async-form.js writes an endpoint's {"error": ...} message. */
.async-status { margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.async-status:empty { display: none; }
/* A read-only value to copy (a one-time link) with its Copy button beside it; the
   button and the status line are static/copy-field.js's. */
.copy-field { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.copy-field input { flex: 1 1 16em; min-width: 0; }
.copy-status { margin: 6px 0 0; color: var(--ink-faint); font-size: 13px; }
.copy-status:empty { display: none; }

/* ── Tables ────────────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; }
/* A table wider than a phone scrolls inside its card rather than spilling past the
   card's edge and off the page (the admin account tables at 390px did). */
.card:has(> table) { overflow-x: auto; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }
tr:last-child th,
tr:last-child td { border-bottom: none; }
td.num, th.num { font-variant-numeric: tabular-nums; }
/* A short list laid out as a table (a name, a chip, an action) that should never
   need sideways scrolling: on a phone each row wraps, its first cell on a line of
   its own and the rest beneath it. */
@media (max-width: 720px) {
  table.stack-on-phone tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
  table.stack-on-phone tr:last-child { border-bottom: none; }
  /* Column headings mean nothing once each row wraps, so the heading row goes. */
  table.stack-on-phone tr:has(> th) { display: none; }
  table.stack-on-phone td { padding: 0 12px 0 0; border-bottom: none; }
  table.stack-on-phone td:first-child { flex: 1 0 100%; }
  table.stack-on-phone .btn { white-space: normal; text-align: left; }
}

/* ── Footer: static, on every page ────────────────────────────────────────── */

.site-footer {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 12.5px;
  color: var(--ink-faint);
}
.layout-notice .site-footer { max-width: 560px; }
.site-footer a { color: var(--ink-faint); text-decoration: none; }
.site-footer a:hover { color: var(--ink-soft); text-decoration: underline; }

/* ── Motion: one entrance, first paint only, opt-in by preference ─────────── */

@media (prefers-reduced-motion: no-preference) {
  .card,
  .rise { animation: rise .5s ease-out both; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
}
