/* PCC document hub — shared styles.
   Palette borrowed from kington-parishes (public/css/style.css) so the two sites feel related
   without literally sharing a stylesheet — see benefice.config.yaml `theme` for the source values. */

:root {
  --primary: #46596A;
  --accent: #A8813C;
  --ink: #262521;
  --ink-soft: #4A473F;
  --bg: #F8F5EE;
  --line: rgba(38, 37, 33, 0.16);
  --ok: #2E6B3E;
  --ok-bg: #E7F2E9;
  --warn: #8A5A00;
  --warn-bg: #FBF0D9;
  --bad: #9B2C2C;
  --bad-bg: #FBE7E7;
  --gap: #5A5750;
  --gap-bg: #EDEAE1;
  --surface: #FFFFFF;
  --safe-bg: #EAEFF3;
  --field-border: #6B6860;
  --radius: 6px;
  /* WCAG AA contrast, computed (not eyeballed), for every text/background pairing in use:
       --ink on --bg 14.09 · --ink-soft on --bg 8.52 · --ink-soft on --surface 9.27
       --primary on --surface 7.25 · --primary on --bg 6.66
       --ink on --safe-bg 13.25 · --primary on --safe-bg 6.26
       --ink on --gap-bg 12.75 · --ink-soft on --gap-bg 7.71
       #fff on --primary 7.25 (header, skip link)
       Signed-in view, on --surface: --ok 6.39 · --warn 5.93 · --bad 7.53 · --gap 7.21
       #fff on --bad 7.53 (danger button) · --primary on --safe-bg 6.26 (the retired members-only pill; spec 38)
       --ink on --ok-bg 13.35 (notices) · --field-border #6B6860 on #fff 5.56 (form fields)
       --ink on --warn-bg 13.56 · --ink-soft on --warn-bg 8.20 · --warn edge on --bg 5.44 (operator entries in the activity log)
       --ok on --ok-bg 5.56 (New/Updated badge) · --ink on --bad-bg 12.92 · --bad on --bad-bg 6.34 (problem box, upload errors)
       Draft label (spec 16): --bad on --bad-bg 6.34, the same pairing as the problem box; its
       border and the draft section's left edge are --bad on --surface/--bg (7.53 / over 3:1).
       --accent is used only for the focus outline (3.29:1 on --bg, over the 3:1 UI minimum),
       never for text. */
  --max: 880px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: "Public Sans", -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

a { color: var(--primary); }
/* Hover/focus used to turn links brass (--accent), which is only 3.3:1 on --bg. They now go
   darker and keep the underline, and keyboard focus gets a visible outline. */
a:hover { color: var(--ink); text-decoration-thickness: 2px; }
a:focus-visible, .skip-link:focus { outline: 3px solid var(--accent); outline-offset: 2px; }

.site-header {
  background: var(--primary);
  color: #fff;
  padding: 16px 0;
}
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.site-header a { color: #fff; text-decoration: none; }
.site-title { font-weight: 700; font-size: 1.05rem; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.95rem; }
.site-header nav a[aria-current="page"] { text-decoration: underline; }

main.wrap { padding: 32px 20px 64px; }

h1 { margin-top: 0; }
section { margin-top: 40px; }
section h2 {
  font-size: 1.15rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

/* Document lists (spec 04). Each document is one row: a link that says what it opens and how
   big it is, then a quiet line of detail. No status colours on public pages. */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.doc a { font-weight: 600; }
.doc-title { font-weight: 600; }
.doc-note, .doc-meta { font-size: 0.9rem; color: var(--ink-soft); }
.doc-log ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }

/* "Worried about someone?" — first on every document page (spec 04 AC2). */
.safeguarding-panel {
  margin-top: 24px;
  padding: 16px 18px;
  border-left: 6px solid var(--primary);
  border-radius: var(--radius);
  background: var(--safe-bg);
}
.safeguarding-panel h2 { margin: 0 0 6px; border: none; padding: 0; font-size: 1.15rem; color: var(--primary); }
.safeguarding-panel p { margin: 4px 0 0; }

.church-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.church-list a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 600;
  min-height: 44px;
}

/* Gaps, at the foot of the page: transparent, but not leading (spec 04 AC5). */
/* Your PCC and church cards on the signed-in home page (spec 21). Colours already in use (--ink on --surface, --line border): no new pairing. */
.pcc-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.pcc-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.pcc-card h3 { margin: 0 0 4px; }
.pcc-card .doc-meta { margin: 0 0 10px; }
.for-you h3 { margin-bottom: 6px; }
.still-to-come { padding: 16px 18px; border-radius: var(--radius); background: var(--gap-bg); color: var(--ink-soft); }
.still-to-come h2 { margin-top: 0; border: none; padding: 0; color: var(--ink); }
.still-to-come ul { margin: 8px 0 0; padding-left: 20px; }

/* Header account bar (spec 05) */
.account-bar, .account-link { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 0.95rem; }
.account-bar form { margin: 0; }
.link-button { background: none; border: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.site-header .link-button { color: #fff; }

/* Forms and buttons: plain HTML forms, no script (spec 05/06 AC10/AC15). Targets are at least
   44px tall for people using a finger on a phone. */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; max-width: 32rem; margin: 16px 0 24px; }
/* Without minmax(0, …) a grid column grows to its widest child, and a select with a long option made the upload form ~590px wide at phone width. */
.stack > * { min-width: 0; }
.stack select, .stack input[type="file"] { width: 100%; }
.draft-only { display: none; }
form:has(#up-what-draft:checked) .draft-only { display: block; }
form:has(#up-what-draft:checked) .replace-final-text { display: none; }
label { font-weight: 600; }
input[type="email"], input[type="text"], input:not([type]), select {
  font: inherit; padding: 10px 12px; min-height: 44px; border: 2px solid var(--field-border); border-radius: var(--radius); background: #fff; color: var(--ink); max-width: 100%;
}
button { font: inherit; font-weight: 600; min-height: 44px; padding: 8px 18px; border-radius: var(--radius); border: 2px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; }
button:hover { background: var(--ink); border-color: var(--ink); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.danger { background: var(--bad); border-color: var(--bad); }
.checkbox, .radio { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0; }
.checkbox input, .radio input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.checkbox label, .radio label { font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
legend { font-weight: 600; padding: 0 4px; }
.steps { padding-left: 22px; }
.notice { padding: 12px 14px; border-radius: var(--radius); background: var(--ok-bg); color: var(--ink); }
/* A prompt to do something (spec 18b), not a success message: neutral blue-grey with a firm left edge. --ink on --safe-bg 13.25,
   --primary on --safe-bg 6.26 (links), edge --primary on --bg 6.66; the bold lead sentence carries the meaning, not colour. */
.notice-action { background: var(--safe-bg); border-left: 4px solid var(--primary); }
.notice-action h2 { margin: 0 0 4px; font-size: 1.1rem; }
.notice-action p { margin: 4px 0; }
.notice-action .actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 8px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.details dt { font-weight: 600; }
.details dd { margin: 0; overflow-wrap: anywhere; }

/* Signed-in document view (spec 07): status in words; the padlock and globe on each row are tip icons (spec 38). */
.doc-status { font-size: 0.9rem; font-weight: 600; }
.status-ok { color: var(--ok); }
.status-due { color: var(--warn); }
.status-overdue { color: var(--bad); }
.status-gap, .status-na { color: var(--gap); }
.doc-gap { background: transparent; border-style: dashed; }
.icon { flex: none; }

/* Document rows (spec 23). The title is the link: bold, no underline until hover or focus. A stretched ::after makes the whole row
   clickable; every other link or button in the row sits above it. Colours already recorded above: --primary on --surface 7.25,
   --ink-soft on --surface 9.27 (the Public mark and About this document). The row's border turns --primary on hover (UI, over 3:1). */
.doc-card { position: relative; }
.doc-head { display: block; }
.doc-link { text-decoration: none; }
.doc-link:hover, .doc-link:focus-visible { text-decoration: underline; text-decoration-thickness: 2px; }
.doc-card > .doc-head > .doc-link::after { content: ""; position: absolute; inset: 0; }
.doc-card a:not(.doc-link), .doc-card button, .doc-card .button-link { position: relative; z-index: 1; }
.doc-card:hover { border-color: var(--primary); }
.doc-card:has(.doc-link:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.doc-about { margin-top: 4px; font-size: 0.9rem; }
.doc-about a { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; min-height: 24px; }

/* Members management (spec 06) and activity (spec 08) */
.member-list, .activity { list-style: none; margin: 0; padding: 0; }
.member { display: grid; gap: 8px; padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.member-who { overflow-wrap: anywhere; }
.member-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
form.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.activity li { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
/* The operator looking at data (spec 13 AC8) stands out, so managers notice it. */
.activity li.operator-entry, .activity li.purge-entry { padding-inline: 12px; border-left: 4px solid var(--warn); background: var(--warn-bg); }

/* Uploads and documents (spec 09) */
.problem { padding: 12px 16px; border-left: 6px solid var(--bad); border-radius: var(--radius); background: var(--bad-bg); color: var(--ink); }
.problem h2 { margin: 0 0 4px; border: none; padding: 0; font-size: 1.05rem; color: var(--bad); }
.problem p { margin: 0; }
.button-link { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 18px; border-radius: var(--radius); border: 2px solid var(--primary); background: var(--surface); color: var(--primary); font-weight: 600; text-decoration: none; width: fit-content; }
.button-link:hover { background: var(--primary); color: #fff; }
.actions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.actions form { margin: 0; }
input[type="file"], input[type="date"] { font: inherit; min-height: 44px; max-width: 100%; }
/* Drop zone (spec 31): styled only once the script has run (.drop-zone-ready), so without JavaScript the plain picker is unchanged.
   Contrast: --ink-soft on --surface 9.27, on --safe-bg 8.01 · --field-border on --surface 5.56 (dashed edge, UI 3:1) · --primary on --safe-bg 6.26 (active edge) */
.drop-zone-ready { padding: 16px; border: 2px dashed var(--field-border); border-radius: var(--radius); background: var(--surface); }
.drop-zone-ready.drop-zone-active { border-color: var(--primary); background: var(--safe-bg); }
.drop-hint, .drop-status { margin: 0 0 8px; color: var(--ink-soft); }
.drop-status { margin: 8px 0 0; }
.drop-status:empty { display: none; }
input[type="date"] { padding: 8px 12px; border: 2px solid var(--field-border); border-radius: var(--radius); background: #fff; color: var(--ink); }
.badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); font-size: 0.85rem; font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.skip-link { position: absolute; left: -999px; top: 8px; padding: 8px 12px; background: var(--primary); color: #fff; border-radius: var(--radius); z-index: 10; }
.skip-link:focus { left: 8px; }

.lede { color: var(--ink-soft); max-width: 66ch; font-size: 1.05rem; }

/* Help guide (/help, noindex) */
.help-index {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 32px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.help-index a { text-decoration: none; font-size: 0.9rem; }
.help-index [aria-current="page"] a { font-weight: 700; color: var(--ink); text-decoration: underline; }
main h2 { margin-top: 32px; }
main code { background: var(--line); border-radius: 3px; padding: 1px 5px; font-size: 0.92em; }

/* Changelog (/updates, noindex) */
.changelog { list-style: none; margin: 0; padding: 0; }
.changelog > li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.changelog-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.85rem; margin-bottom: 4px; }
.changelog-build { font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.changelog-author { color: var(--ink-soft); }
.changelog-date { color: var(--ink-soft); }
.changelog p { margin: 0; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0 40px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Draft documents (spec 16). The DRAFT label is a word in a box, so it never relies on colour alone. */
.draft-label { display: inline-block; padding: 1px 8px; border: 2px solid var(--bad); border-radius: var(--radius); background: var(--bad-bg); color: var(--bad); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.06em; }
.doc-draft { display: block; font-size: 0.9rem; }
.draft-section { padding-left: 14px; border-left: 6px solid var(--bad); }
.draft-note { margin: 4px 0 0; font-size: 0.9rem; color: var(--ink-soft); }
/* Choosing Draft on the upload form hides the choices that only apply to a final document. The
   server ignores them for a draft regardless, and the note above says so, so this is only tidiness. */
form:has(#up-what-draft:checked) .final-only { display: none; }

/* Page layout (spec 24). Document pages use the width of the screen: a wider column, the document boxes in a grid of columns, the
   section links as a row of buttons. Prose pages (help, forms) keep the narrow column. No new colour pairs: --primary on --surface 7.25,
   the border is --line. */
body.wide { --max: 1240px; }
.jump-links ul { list-style: none; margin: 16px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.jump-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; text-decoration: none; }
.jump-links a:hover { border-color: var(--primary); text-decoration: underline; }
.doc-group { scroll-margin-top: 16px; }
.doc-group .doc-list, .still-to-come .doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; align-items: start; }
.doc-group .doc, .still-to-come .doc { margin-bottom: 0; }
.doc-group .doc-log { grid-column: 1 / -1; }
.safeguarding-panel { scroll-margin-top: 16px; }
.church-list ul { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
body.wide .lede { max-width: 100ch; }

/* File-type and joint icons (spec 25). Each is a small focusable image with a name for screen readers; its words show as a tip on
   hover, keyboard focus and tap. Tip: #FFFFFF on --ink 15.34. Badges: white on #2B579A (Word) 7.16, #1D6F42 (Excel) 6.17, #B3261E (PDF) 6.54. */
.tip { position: relative; z-index: 2; display: inline-flex; align-items: center; margin-left: 6px; vertical-align: middle; cursor: help; border-radius: 4px; color: var(--ink-soft); }
.tip::after { content: attr(data-tip); display: none; position: absolute; left: 0; bottom: calc(100% + 6px); width: max-content; max-width: min(18rem, 78vw); padding: 6px 10px; border-radius: 6px; background: var(--ink); color: #FFFFFF; font-size: 0.85rem; font-weight: 400; line-height: 1.35; text-align: left; white-space: normal; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); pointer-events: none; }
.tip:hover::after, .tip:focus::after, .tip:focus-visible::after { display: block; }
.tip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon-file { border-radius: 3px; }
/* spec 38: the padlock keeps the primary colour (--primary on --surface 7.25, on --bg 6.66); the globe and church icon use the tip's --ink-soft (9.27 / 8.52). Each icon is a graphic, needing 3:1. */
.tip-members { color: var(--primary); }
/* spec 34: the "opens in a new tab" mark after a document link; it is the link's own colour, so it keeps the link's contrast (computed with the link colours above). */
.icon-newtab { margin-left: 0.3em; margin-right: 0.15em; vertical-align: -0.1em; }

/* Add someone (spec 26): a church's name and its role choice on one line, wrapping on a phone. */
.role-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.role-row label { font-weight: 600; flex: 1 1 14rem; }
.role-row select { flex: 0 1 11rem; }
.role-meanings { margin: 12px 0 4px; padding-left: 18px; font-size: 0.9rem; color: var(--ink-soft); }

