/* The design system (.claude/rules/design-system.md, direction K3 "Crewel on
   linen"), 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.

   This file is the CALM half of the system: tokens, type, and every control a
   task page or the admin needs. It carries no fabric. The patterned "Wall" layout
   of the public homepage and catalogue lives in web/public/static/site.css, which
   builds on these tokens.

   The two typefaces are self-hosted (web/_shared/static/fonts/); their @font-face
   rules are written into each page's <head> by static_assets.font_faces(), so the
   font URLs carry a content hash like every other static file.

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

/* ── Tokens: one designed theme, no dark mode ─────────────────────────────── */

:root {
  color-scheme: light;

  --paper: #F2EAD6;
  --wall: #EFE6D0;
  --surface: #FBF8F2;
  --surface-2: #E8DEC6;
  --duck: #B5CED6;
  --periwinkle: #6F62AD;
  --accent: #5D5199;
  --accent-weak: #DCD8EC;
  --pop: #E3A018;
  --gilt: #C9A24A;
  --ink: #231A2C;
  --ink-soft: #4A3F55;
  --ink-faint: #6E6478;
  --rule: #D5C9AE;
  --danger: #A32A2A;
  --on-fill: #FFFFFF;
  /* The embroidery colours: pattern and illustration only, never text or controls. */
  --thread-red: #B33A2B;
  --thread-rose: #C96A8A;
  --thread-green: #8A9455;
  --thread-blue: #7F96D6;

  /* Bodoni Moda never below 24px: its hairlines vanish. */
  --display: "Bodoni Moda", "Bodoni 72", Didot, "Times New Roman", serif;
  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── 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: 16px;
  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); text-underline-offset: 3px; }
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 ──────────────────────────────────────────────────────────────────── */

/* The page <h1>, section headings, look names and numerals. Never body copy,
   labels or buttons, and never below 24px. */
.display { font-family: var(--display); font-style: italic; font-weight: 400; letter-spacing: -0.015em; }

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

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

/* Labels are sentence case. No tracked-out uppercase (design-system.md). */
.label,
.kicker,
.section-label,
.nav-link {
  font-size: 13px;
  font-weight: 600;
}
.kicker { color: var(--accent); }
.section-label { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 12px; overflow-wrap: anywhere; }

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

/* ── Nav: shared by every layout ──────────────────────────────────────────── */

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 28px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--ink);
  background: var(--duck);
}
.nav-logo { display: inline-flex; align-items: center; min-height: 44px; font-size: 30px; font-weight: 500; line-height: 1.1; color: var(--ink); text-decoration: none; }
.nav-right { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 26px; }
.nav-link,
.nav-email {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* tap targets are at least 44px (design-system.md) */
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  padding: 2px 0 0;
  border-bottom: 2px solid transparent;
}
.nav-link:hover,
.nav-email:hover { border-bottom-color: var(--ink); }
.nav-email { color: var(--ink-soft); }
/* 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; }
@media (max-width: 560px) {
  .nav { padding: 10px 16px; }
  .nav-logo { font-size: 26px; }
}

/* ── Calm layout: signed-in pages and the admin UI ────────────────────────── */

.layout-app main { max-width: 1040px; padding-top: 40px; padding-bottom: 56px; }
.page-header { margin: 0 0 28px; padding-bottom: 20px; border-bottom: 1px solid var(--gilt); }
.page-header h1 { margin: 6px 0 10px; }
.app-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; 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); }
}

/* ── Calm layout, long-form: the terms, the privacy policy ───────────────── */

.layout-marketing main { max-width: 1040px; padding-bottom: 64px; }
.section { margin-top: 48px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.legal-header { padding: 56px 0 20px; margin-bottom: 28px; border-bottom: 1px solid var(--gilt); }
.legal-header h1 { max-width: 20ch; margin: 8px 0 12px; }
.prose { max-width: 68ch; }
.prose .section-label { margin: 36px 0 12px; font-size: 19px; }
.prose h3 { margin: 22px 0 8px; font-size: 16px; color: var(--ink); }
.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) {
  .card-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ── Notice layout: sign-in, confirmations, errors ────────────────────────── */

.layout-notice main { max-width: 600px; padding-top: 64px; padding-bottom: 64px; }
/* The one decoration a calm page gets: a single saffron rule. */
.card.notice-card { border-top: 8px solid var(--pop); padding: 36px 36px 34px; }
.notice-card h1 { margin: 0 0 14px; }
.notice-card p { color: var(--ink-soft); }
.notice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 24px; }
.notice-actions form { margin: 0; }
.notice-footnote { margin-top: 20px; }
@media (max-width: 560px) {
  .layout-notice main { padding-top: 32px; }
  .card.notice-card { padding: 26px 22px; }
}

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

/* Square, no shadow: a hairline separates card from page. */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 24px;
}
.card h2,
.card h3 { margin: 0 0 10px; }
.card p { color: var(--ink-soft); }
/* Two forms stacked in one card (a time zone, then units) get air between them. */
.card form + form, .card form + .check-group, .card form + h2, .card form + h3 { margin-top: 22px; }

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

/* One shape for every button-like control: square, sentence case. Variants
   differ only by fill/outline. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 24px;
  border-radius: 0;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  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 { background: var(--ink); }
/* Secondary actions: outlined, never a second filled style. */
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); }
/* 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 { background: var(--ink); }
.btn-small { min-height: 44px; padding: 7px 14px; font-size: 14px; }
.btn-large { padding: 16px 34px; font-size: 18px; }

/* 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;
}

/* ── 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;
  padding: 3px 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
button.chip { cursor: pointer; }
.chip-selected { background: var(--accent-weak); color: var(--accent); }
.chip-outline { background: transparent; border-color: var(--ink-faint); color: var(--ink-soft); }
.chip-dashed { background: transparent; border: 1px dashed var(--ink-faint); color: var(--ink-soft); }

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

.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 16px; }
.field > span,
.field > .label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input,
.field select,
.field textarea {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 0;
  border: 1px solid var(--ink-faint);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
}
/* 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 16px; padding: 0; min-width: 0; }
.check-group > legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.check-group label { display: flex; gap: 8px; align-items: center; min-height: 44px; margin: 0; }
.check-group input { accent-color: var(--accent); }
.check-group .muted { font-size: 14px; }
/* Where static/async-form.js writes an endpoint's {"error": ...} message. */
.async-status { margin: 10px 0 0; color: var(--danger); font-size: 14px; }
/* A refusal the person must act on: a clear danger-outlined panel, not small print
   (design-system.md: --danger is for errors; no fills beyond the plaque). */
.async-status[role="alert"] { margin: 0 0 20px; padding: 14px 16px; border: 2px solid var(--danger);
  background: var(--surface); color: var(--danger); font-size: 16px; font-weight: 600; }
.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: 14px; }
.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: 13px; font-weight: 600; color: var(--ink-soft); border-bottom-color: var(--ink); }
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 public page ─────────────────────────────────── */

.site-footer {
  width: 100%;
  padding: 26px 32px 30px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 28px;
  font-size: 15px;
  color: var(--ink);
  background: var(--duck);
  border-top: 1px solid var(--ink);
}
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .site-footer-mark { font-family: var(--display); font-style: italic; font-weight: 500; font-size: 26px; margin-right: auto; }
@media (max-width: 560px) {
  .site-footer { padding: 20px 16px 24px; }
  .site-footer .site-footer-mark { flex: 1 0 100%; }
}
address { font-style: normal; }

/* A table wider than a phone scrolls inside its own box, never the page. */
.table-scroll { overflow-x: auto; max-width: 100%; }

/* The photo picker: the browser's own control is about 25px tall. Its button gets the
   outlined secondary style and a 44px tap target (design-system.md). */
input[type="file"] { min-height: 44px; max-width: 100%; font: inherit; font-size: 15px; }
input[type="file"]::file-selector-button {
  min-height: 44px;
  margin-right: 12px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
