/*
 * The claimant and approver portal. One stylesheet, no framework and no
 * JavaScript (PLAN.md §8): a claimant fills this in on a phone, standing in a
 * car park, on the church wifi.
 *
 * It lived inline in base.html until Milestone 7 brought whitenoise, on the
 * grounds that a static pipeline for a page of CSS was a subsystem to maintain
 * for no gain. That reasoning expired with the pipeline's arrival, and self
 * hosting two typefaces settled it — a font has to be a file whatever happens
 * to the CSS. It is served hashed and immutable, so a returning claimant
 * fetches none of it twice.
 *
 * Colours are the church's own, read off icc-melbourne.org rather than
 * invented: the ink #1E2624, the teal #40ACA1, the cream #F2EEE3, the sand
 * #E4D0A1 and the warm rule #DCDBDA. Two things follow from that palette and
 * both are load-bearing:
 *
 *   - The teal fails WCAG AA as text on a light background (2.75:1), so it
 *     never carries text there. --accent-text is a darkened teal for links
 *     (5.44:1 on white) and the raw teal is used for rules, focus rings and
 *     text on the ink band, where it reaches 5.62:1. Do not swap one for the
 *     other to "match the website more closely"; the website's own white-on-
 *     teal buttons are the thing being corrected here.
 *   - The logo is a single flat #f0f0f0 on transparency, so it is invisible on
 *     a light surface. Every place it appears is a dark one, which is why the
 *     masthead is an ink band rather than a white bar with a rule under it.
 */

/* DM Serif Text and Oswald are what icc-melbourne.org uses. Self-hosted rather
   than linked from Google, so the portal makes no third-party request, works
   with no internet beyond this server, and tells nobody who is logging in.
   Both are SIL Open Font Licence 1.1 — the licences are in static/fonts/.
   Oswald ships as one variable file covering the whole weight range, hence the
   `font-weight: 200 700` on a single @font-face rather than two. */
@font-face {
  font-family: "DM Serif Text";
  src: url("../fonts/dm-serif-text-latin-400.b6fbea2c7171.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Oswald";
  src: url("../fonts/oswald-latin-variable.0243e05f3f8d.woff2") format("woff2");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --display: "DM Serif Text", Georgia, "Times New Roman", serif;
  --label: "Oswald", "Helvetica Neue", Arial, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --band: #1e2624;
  --band-ink: #f2eee3;
  --band-muted: #a9b5b1;
  --paper: #f2eee3;
  --surface: #ffffff;
  --ink: #1e2624;
  --muted: #5f6764;
  --rule: #dcdbda;
  --rule-strong: #c6c4c1;
  --accent: #40aca1;
  --accent-text: #2a756c;
  --sand: #e4d0a1;

  --good: #0b6a3a;
  --bad: #a4262c;
  --warn: #8a5a00;

  --measure: 38rem;
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --lift: 0 1px 2px rgba(30, 38, 36, 0.05), 0 2px 8px rgba(30, 38, 36, 0.04);
}

/* Three surfaces that have to stay three surfaces. In light mode the cream page
   and the white card separate on their own; in the dark they are three shades
   of the same near-black, so the steps between band, page and card are set
   wider than instinct suggests — at the first attempt the login card and the
   band behind it read as one slab. */
@media (prefers-color-scheme: dark) {
  :root {
    --band: #0b100f;
    --band-muted: #97a29e;
    --paper: #1a2120;
    --surface: #242c2a;
    --ink: #edeae1;
    --muted: #9aa5a1;
    --rule: #38433f;
    --rule-strong: #4a5652;
    --accent-text: #6fc9be;

    --good: #7fd1a4;
    --bad: #ff9a9e;
    --warn: #e8b562;

    --lift: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 1rem/1.6 var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  /* A receipt's SHA-256 is 64 characters with nowhere to break, and it is
     printed in full on the request page. Without this it runs off the right of
     a phone and takes the page's whole width with it. `break-word` rather than
     `anywhere`: it only breaks a word that would not fit on a line of its own,
     so ordinary prose is untouched. */
  overflow-wrap: break-word;
}

/* --- The masthead ------------------------------------------------------- */

.masthead {
  background: var(--band);
  color: var(--band-ink);
  border-bottom: 3px solid var(--accent);
}

.masthead-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

/* The mark is a tall portrait lockup — 375 × 632 after its transparent margin
   was trimmed — so it is sized by height and left to find its own width. */
.brand img {
  height: 2rem;
  width: auto;
  display: block;
}

.brand-name {
  display: block;
  font-family: var(--display);
  font-size: 1.1rem;
  line-height: 1.15;
}

.brand-org {
  display: block;
  font-family: var(--label);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sand);
}

.masthead nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-family: var(--label);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.masthead nav a {
  color: var(--band-ink);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.masthead nav a:hover,
.masthead nav a:focus-visible {
  border-bottom-color: var(--accent);
}

.masthead nav form {
  margin: 0;
  display: flex;
}

/* Logging out is a POST, so it is a button; it should not look like one next to
   two links that are links. */
.masthead nav button {
  margin: 0;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--band-muted);
  font: inherit;
  cursor: pointer;
}

.masthead nav button:hover,
.masthead nav button:focus-visible {
  color: var(--band-ink);
  border-bottom-color: var(--accent);
}

/* --- Layout ------------------------------------------------------------- */

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* --- Typography --------------------------------------------------------- */

/* DM Serif Text ships one weight. Saying so stops a browser synthesising a
   bold that is not in the file, which is what makes a serif look muddy. */
h1,
h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.005em;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 1.25rem 0 0.4rem;
}

h2 {
  font-size: 1.2rem;
  margin: 2.25rem 0 0.35rem;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.5rem 0 0.25rem;
}

p.hint,
.helptext,
small {
  color: var(--muted);
  font-size: 0.875rem;
}

p.hint {
  margin: 0.35rem 0 0;
}

a {
  color: var(--accent-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.quiet {
  color: var(--muted);
}

/* Small type set in the label face: table headings, status pills, the eyebrow
   over a section. Uppercase and tracked, because Oswald is condensed and needs
   the air. */
.eyebrow {
  display: block;
  font-family: var(--label);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

/* Or the eyebrow's 0.15rem collapses against the heading's 1.25rem and the
   kicker floats 20px above the thing it is kicking off, reading as a stray
   fragment rather than as a label for the request number under it. */
.eyebrow + h1 {
  margin-top: 0;
}

/* Ink, not the teal, and the reason is the note at the top of this file: the
   teal is 2.75:1 on white and 2.37:1 on the cream page, and WCAG 2.2 SC 1.4.11
   asks 3:1 of a focus indicator. Teal was the obvious choice and it made the
   ring on the two-page submission form nearly invisible on a phone in daylight
   — worse than the browser's own ring, which is what the inline stylesheet this
   replaces had left alone. Ink is 13.34:1 on the page.

   No `border-radius` here. It is not an outline property, so it would reshape
   the element itself, and at (0,1,0) it outranks the bare-element rules that
   set a radius on `button`, `select` and `textarea` — their corners would snap
   square on focus and back on blur. Every current engine already draws the
   outline following the element's own radius. */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* The band is the ink, so the ring has to invert there or it is 1:1. */
.masthead :focus-visible {
  outline-color: var(--band-ink);
}

/* --- Forms -------------------------------------------------------------- */

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  font-weight: 600;
  padding: 0;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 1.1rem;
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.7rem;
  font-size: 1rem;
  font-family: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
}

input.amount {
  font-variant-numeric: tabular-nums;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

/* Radio groups, which arrive in two shapes. Django's RadioSelect renders a
   <div> of <div>s — it stopped rendering a <ul> in 4.0 — so the widgets carry
   class="radio" and these rules key off that rather than off an id. The
   <ul class="radio"> shape is still written by hand where a template lays out a
   lone checkbox itself. */
ul.radio {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
}

ul.radio li,
div.radio > div {
  margin: 0;
}

div.radio {
  margin: 0.4rem 0 0;
}

.radio label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 400;
  font-size: 1rem;
  margin: 0 0 0.4rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}

.radio label:hover {
  border-color: var(--accent);
}

.radio input {
  flex: none;
  width: auto;
  accent-color: var(--accent);
}

/* --- Buttons ------------------------------------------------------------ */

/* Ink, not teal. White on the brand teal is 2.75:1 — the church's own site
   does it, and it is the one thing from there not copied. */
button {
  margin-top: 1.5rem;
  padding: 0.75rem 1.4rem;
  font-family: var(--label);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

button:hover {
  background: var(--accent-text);
  border-color: var(--accent-text);
}

button.secondary {
  margin-top: 0.6rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.78rem;
  color: var(--ink);
  background: var(--surface);
  border-color: var(--rule-strong);
}

button.secondary:hover {
  background: var(--paper);
  border-color: var(--accent);
  color: var(--ink);
}

/* A link that is the page's action rather than a way of reading something else
   — "New request" on an otherwise empty list. It is an <a> because it goes
   somewhere and changes nothing; it looks like a button because it is what the
   page is for. Nothing that mutates is ever styled this way; those are all
   <button> in a POST form (CLAUDE.md, "GET must never mutate"). */
a.button {
  display: inline-block;
  margin-top: 0.9rem;
  padding: 0.65rem 1.3rem;
  font-family: var(--label);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
}

a.button:hover,
a.button:focus-visible {
  background: var(--accent-text);
  border-color: var(--accent-text);
}

/* --- Messages and errors ------------------------------------------------ */

ul.errorlist {
  margin: 0.4rem 0;
  padding: 0 0 0 1.1rem;
  color: var(--bad);
  font-size: 0.875rem;
}

ul.messages {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
}

ul.messages li {
  padding: 0.75rem 0.95rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm);
  box-shadow: var(--lift);
}

ul.messages li.success {
  border-left-color: var(--good);
}

ul.messages li.error {
  border-left-color: var(--bad);
}

ul.messages li.warning {
  border-left-color: var(--warn);
}

/* --- Panels and cards --------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-top: 0.9rem;
  box-shadow: var(--lift);
}

.panel > :first-child {
  margin-top: 0;
}

.panel > :last-child {
  margin-bottom: 0;
}

/* A description list inside a panel is the shape most of this portal is: a
   quiet label in the small caps face over the value it names. */
.panel dl {
  margin: 0;
  display: grid;
  gap: 0.15rem 1rem;
}

.panel dt {
  font-family: var(--label);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel dt + dd {
  margin: 0 0 0.85rem;
  font-variant-numeric: tabular-nums;
}

.panel dd:last-child {
  margin-bottom: 0;
}

.panel.warn {
  border-left: 3px solid var(--warn);
}

.panel.bad {
  border-left: 3px solid var(--bad);
}

.row {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem 1.1rem;
  margin-top: 0.9rem;
}

/* "Line 1", "If it is someone else" — the legend names the box it sits in, so
   it is set like the other labels in the small caps face rather than like a
   heading. `fieldset` has no border here, so it does not interrupt one. */
.row legend {
  font-family: var(--label);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.row label {
  margin-top: 0.9rem;
}

a.card {
  display: block;
  padding: 0.9rem 1rem;
  margin-top: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  text-decoration: none;
  color: inherit;
}

/* On the list of requests the left rule carries the status, the same three
   colours the pill beside it uses. It repeats what the pill says on purpose:
   the question that list is scanned for is "which of mine is still waiting?",
   and a colour answers it a whole card at a time. The chooser's cards have no
   status and keep the neutral rule. */
a.card.APPROVED,
a.card.PAID,
a.card.CLOSED {
  border-left-color: var(--good);
}

a.card.REJECTED,
a.card.VOIDED {
  border-left-color: var(--bad);
}

/* Shadow only. `border-color` here would be the shorthand overwriting the
   status rule above at equal specificity, so hovering a paid request would take
   its green edge off. */
a.card:hover,
a.card:focus-visible {
  box-shadow: 0 2px 10px rgba(30, 38, 36, 0.1);
}

a.card strong {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.1rem;
}

/* --- Tables ------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  font-size: 0.95rem;
}

th {
  font-family: var(--label);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom-color: var(--rule-strong);
}

td.amount,
th.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tr.total td {
  border-bottom: 0;
  border-top: 2px solid var(--rule-strong);
  font-weight: 600;
}

tr.total td.amount {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.2rem;
}

/* --- Lists -------------------------------------------------------------- */

ul.plain {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

ul.plain li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

ul.plain li:last-child {
  border-bottom: 0;
}

/* --- Status ------------------------------------------------------------- */

/* Both of these always follow something on the same line — a request number, a
   date — so the gap belongs to them rather than to whatever they trail. */
.status,
.late {
  margin-left: 0.35rem;
}

.status {
  display: inline-block;
  font-family: var(--label);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: 1rem;
  color: var(--muted);
  vertical-align: 0.18em;
  white-space: nowrap;
}

.status.APPROVED,
.status.PAID,
.status.CLOSED {
  color: var(--good);
  border-color: var(--good);
}

.status.REJECTED,
.status.VOIDED {
  color: var(--bad);
  border-color: var(--bad);
}

.late {
  font-family: var(--label);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warn);
  white-space: nowrap;
}

/* The rail on a request's own page: what has happened to it, in order. The
   states really are a sequence — one state machine, two terminal paths
   (PLAN.md §5) — so numbering them by position says something true. A rejected
   or withdrawn request stops the rail rather than greying out a step it will
   never reach. */
ol.rail {
  display: flex;
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  gap: 0.4rem;
  font-family: var(--label);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

ol.rail li {
  flex: 1;
  padding-top: 0.5rem;
  border-top: 3px solid var(--rule);
  color: var(--muted);
}

/* The same values as the bare `ol.rail li` above. Spelled out because the
   template names all three states explicitly, and a class read off the HTML
   should land somewhere when it is grepped for. */
ol.rail li.upcoming {
  border-top-color: var(--rule);
  color: var(--muted);
}

ol.rail li.done {
  border-top-color: var(--accent);
  color: var(--ink);
}

/* Dashed, and the label stays muted. The step names the milestone rather than
   the state, so a solid teal rule under "Approved" on a request that is only
   waiting to be approved reads as though it already has been — which is the
   one thing this rail must not say. */
ol.rail li.now {
  border-top-style: dashed;
  border-top-color: var(--accent);
  color: var(--muted);
}

ol.rail li.stopped {
  border-top-color: var(--bad);
  color: var(--bad);
}

/* --- Receipts ----------------------------------------------------------- */

img.receipt {
  max-width: 100%;
  margin-top: 0.6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}

/* --- Misc --------------------------------------------------------------- */

form + form {
  margin-top: 1rem;
}

/* Off the screen but still the form's default submit button — see
   request_form.html. Not display:none or hidden, which some engines skip when
   choosing that button, which is the entire job this element has. */
.offscreen {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.75rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
}

/* --- The signed-out pages ----------------------------------------------- */

/* Log in, the invite, and the password-reset flow. The masthead grows into a
   full lockup — this is the one screen where the church's mark is the first
   thing on the page rather than a small mark in a corner — and the content
   becomes a card lifted over the edge of the band. */
body.auth .masthead {
  border-bottom: 0;
}

body.auth .masthead-inner {
  flex-direction: column;
  padding: 2.75rem 1rem 3.25rem;
  text-align: center;
}

body.auth .brand {
  flex-direction: column;
  gap: 0.85rem;
}

body.auth .brand img {
  height: 4.5rem;
}

body.auth .brand-name {
  font-size: 1.5rem;
}

body.auth main {
  max-width: 25rem;
  margin: -2rem auto 3.5rem;
  padding: 1.5rem 1.4rem 1.9rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  box-shadow: 0 8px 28px rgba(30, 38, 36, 0.13);
}

body.auth h1 {
  margin-top: 0;
}

body.auth ul.messages {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

body.auth ul.messages li {
  box-shadow: none;
}

@media (prefers-color-scheme: dark) {
  body.auth main {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  }
}

/* --- Print -------------------------------------------------------------- */

/* Somebody will print a request and staple a receipt to it. The masthead is a
   solid block of ink that no printer should be asked to lay down. */
@media print {
  /* The light values, restated, because a printer does not follow
     `prefers-color-scheme` and some engines do. On a treasurer whose laptop is
     in dark mode, `--ink` is #edeae1 — near-white text, sent to the printer,
     on a background the print dialog drops by default. That is a blank page,
     which is the one outcome this block exists to prevent. */
  :root {
    --ink: #1e2624;
    --muted: #5f6764;
    --rule: #dcdbda;
    --rule-strong: #c6c4c1;
    --accent-text: #2a756c;
    --good: #0b6a3a;
    --bad: #a4262c;
    --warn: #8a5a00;
  }

  .masthead,
  .pager {
    display: none;
  }

  body,
  .panel,
  .row,
  a.card {
    background: #fff;
    box-shadow: none;
  }

  main {
    max-width: none;
    padding: 0;
  }
}
