/*
  Base styles for every page.

  Design target (requirements, "Accessibility and ease of use"): a 75-year-old
  volunteer on a small phone with reading glasses.
    UX-8   body text >= 18px, headings >= 24px, works at 200% text size
    UX-9   body text contrast >= 7:1 on volunteer pages, 4.5:1 everywhere
    UX-10  touch targets >= 48 x 48px, >= 8px apart, full-width primary buttons on phones
    UX-13  one column, no hover-only menus
  Sizes use rem so phone and browser text-size settings scale everything (UX-16).
  Contrast ratios for each colour are checked in tests/test_accessibility_tokens.py.
*/

:root {
  /* Volunteer Toolbox brand colours (static/brand). Ratios are on the cream page. */
  --color-text: #183D26;          /* deep green: 11.6:1 on cream, 12.1:1 on white */
  --color-text-muted: #4A5563;    /* gray: 7.3:1 on cream, 7.6:1 on white */
  --color-bg: #FBFAF6;            /* cream page */
  --color-surface: #FFFFFF;       /* panels are white cards on the cream page */
  --color-surface-edge: #CFE0D4;  /* mist: decorative card edge */
  --color-border: #6b6b6b;        /* 5.1:1, visible field edges */
  --color-heading: #245536;       /* green: 8.3:1 on cream */
  --color-primary: #245536;       /* green button fill; white text 8.6:1 */
  --color-primary-hover: #183D26; /* deep green; white text 12.1:1 */
  --color-selected: #E3EEE6;      /* chosen slot; text on it 10.2:1 */
  --color-link: #245536;
  --color-error: #8a1c1c;         /* 8.9:1 on cream */
  --color-success: #1d5e2a;       /* 7.5:1 on cream */
  --color-focus: #D9651B;         /* brand orange focus ring: 3.5:1 on cream. Never text. */
  --color-accent: #D9651B;        /* brand orange, decoration only */

  /* Atkinson Hyperlegible, made by the Braille Institute for low-vision readers.
     Served from this site (no third-party requests, NFR-5); system fonts until it loads. */
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-base: 1.125rem;          /* 18px */
  --text-lg: 1.25rem;             /* 20px */
  --text-h2: 1.5rem;              /* 24px */
  --text-h1: 2rem;                /* 32px */
  --line-height: 1.5;

  --space-1: 0.5rem;              /* 8px: minimum gap between targets */
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --target-min: 3rem;             /* 48px */
  --radius: 0.5rem;
  --content-width: 40rem;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-regular.5d75ec521214.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-bold.450ed50b7005.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

html {
  font-size: 100%;                /* respect the browser's text-size setting */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg);
  overflow-wrap: break-word;
}

/* Layout: a single centred column at every width (UX-13, UX-17). */
.site-header, main, .site-footer {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--space-2);
}
.site-header {
  padding-block: var(--space-2);
  border-bottom: 4px solid var(--color-heading);
}
/* The Volunteer Toolbox logo: never smaller than 32px tall (brand rules). */
/* align-items: flex-start keeps the logo at its own width, on the left, when the
   organization's name below it is wider (otherwise the logo is stretched and centred). */
.brand { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; text-decoration: none; }
.brand-logo { display: block; height: 2.5rem; width: auto; }
.brand-org { font-size: var(--text-base); font-weight: 700; color: var(--color-text); }
.made-with { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; }
.made-with img { width: 1.5rem; height: 1.5rem; }
.site-header .site-name {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}
main { padding-block: var(--space-3) var(--space-4); }
.site-footer {
  padding-block: var(--space-3);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-2); color: var(--color-heading); }
h1 { font-size: var(--text-h1); }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h2); }  /* nothing smaller than 24px for headings */
p, ul, ol { margin: 0 0 var(--space-2); }

a { color: var(--color-link); text-decoration-thickness: 0.1em; text-underline-offset: 0.15em; }

/* Skip link for keyboard and screen-reader users (UX-16). */
.skip-link {
  position: absolute;
  left: var(--space-1);
  top: -10rem;
  padding: var(--space-1) var(--space-2);
  background: var(--color-bg);
  color: var(--color-text);
  border: 2px solid var(--color-text);
}
.skip-link:focus { top: var(--space-1); }

/* A highly visible focus ring on everything (WCAG 2.2 focus appearance). */
:focus-visible {
  outline: 3px solid var(--color-text);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--color-focus);
}

/* Buttons: large, plain-word labels (UX-10, UX-11). */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target-min);
  min-width: var(--target-min);
  padding: 0.75rem var(--space-3);
  font: inherit;
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #ffffff;
  cursor: pointer;
}
.button:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.button--secondary { background: var(--color-bg); color: var(--color-primary); }
.button--secondary:hover { background: var(--color-surface); color: var(--color-primary-hover); }

/* Stack of choices, e.g. one button per time slot. */
.button-stack { display: flex; flex-direction: column; gap: var(--space-2); margin-block: var(--space-3); }
.button-stack .button { width: 100%; }

/* Primary buttons fill the width on phones (UX-10). */
@media (max-width: 40em) {
  .button--primary-block, form .button[type="submit"] { width: 100%; }
}

/* Forms: labels above fields, errors next to the field (UX-15). */
.field { margin-bottom: var(--space-3); }
.field label, .field legend { display: block; font-weight: 700; margin-bottom: var(--space-1); }
.field .hint { display: block; color: var(--color-text-muted); margin-bottom: var(--space-1); }
.field input[type="text"], .field input[type="email"], .field input[type="tel"],
.field input[type="number"], .field input[type="password"], .field input[type="date"],
.field input[type="time"], .field input[type="datetime-local"],
.field select, .field textarea {
  display: block;
  width: 100%;
  min-height: var(--target-min);
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
}
.field textarea { min-height: 8rem; }
.field--error input, .field--error select, .field--error textarea { border-color: var(--color-error); border-width: 3px; }
.error-message { display: block; color: var(--color-error); font-weight: 700; margin-bottom: var(--space-1); }

/* Checkboxes and radios with a full 48px tap row (UX-4, UX-10). */
.choice { display: flex; align-items: center; gap: var(--space-2); min-height: var(--target-min); margin-bottom: var(--space-1); }
.choice input { width: 1.75rem; height: 1.75rem; margin: 0; flex: none; accent-color: var(--color-primary); }
.choice label { font-weight: 400; margin: 0; padding-block: 0.5rem; cursor: pointer; }
fieldset.field { border: 0; padding: 0; margin-inline: 0; }

/* Messages after an action (UX-14). */
.notice { padding: var(--space-2); border-left: 6px solid var(--color-primary); background: var(--color-surface); margin-bottom: var(--space-3); }
.notice--success { border-color: var(--color-success); }
.notice--error { border-color: var(--color-error); }

.panel { background: var(--color-surface); border: 1px solid var(--color-surface-edge); border-radius: var(--radius); padding: var(--space-2); margin-bottom: var(--space-3); }

.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;
}

/* Honour reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .skip-link { display: none; }
  body { font-size: 12pt; }
}

/* Navigation for signed-in staff: wraps onto several lines on phones, no hover menus (UX-13). */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1); }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1); }
.site-nav a, .link-button {
  display: inline-flex; align-items: center; min-height: var(--target-min); padding: 0 var(--space-1);
  font: inherit; color: var(--color-link); text-decoration: underline; text-underline-offset: 0.15em;
  background: none; border: 0; cursor: pointer;
}
.site-nav form { margin: 0; }

/* Lists of people or requests, one card each. */
.card-list { list-style: none; padding: 0; margin: 0 0 var(--space-3); }
.card-list h2, .card-list h3, .card-title { font-size: var(--text-h2); margin-bottom: var(--space-1); }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.button-row form { margin: 0; }
@media (max-width: 40em) { .button-row .button, .button-row form { width: 100%; } }
.tag { display: inline-block; font-size: var(--text-base); font-weight: 700; padding: 0 0.5rem; border: 2px solid var(--color-text-muted); border-radius: var(--radius); color: var(--color-text-muted); }
.optional { font-weight: 400; color: var(--color-text-muted); }

/* Tables: simple, with room to read. */
.table { width: 100%; border-collapse: collapse; margin-bottom: var(--space-3); }
.table th, .table td { text-align: left; padding: var(--space-1); border-bottom: 1px solid var(--color-border); vertical-align: top; }

/* Two-step setup. */
.qr { margin: var(--space-2) 0; }
.qr svg { display: block; width: 14rem; max-width: 100%; height: auto; background: #fff; }
.qr svg path { shape-rendering: crispEdges; }
.secret { font-size: var(--text-lg); word-break: break-all; letter-spacing: 0.05em; }
.notice h2 { font-size: var(--text-lg); }
.notice ul { margin-bottom: 0; }

/* Roster */
.volunteer-card { display: flex; gap: var(--space-2); align-items: flex-start; }
.volunteer-card .choice { min-height: var(--target-min); margin: 0; }
.filter .field { margin-bottom: var(--space-2); }
.tag--warning { border-color: var(--color-error); color: var(--color-error); }
.pager { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-block: var(--space-3); }
.summary-list { list-style: none; padding: 0; font-size: var(--text-lg); }
.summary-list li { padding-block: 0.25rem; }
.details dt { font-weight: 700; margin-top: var(--space-2); }
.details dd { margin: 0; }
fieldset.panel legend h2 { margin: 0; }
.table td, .table th { overflow-wrap: break-word; }
.row-list { list-style: none; padding: 0; margin: 0 0 var(--space-3); }
.row-list > li { padding-block: var(--space-1); border-bottom: 1px solid var(--color-border); overflow-wrap: break-word; }
.row-list ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }

/* Events */
.event-when { font-size: var(--text-lg); }
.tag--open { border-color: var(--color-success); color: var(--color-success); }
.tag--cancelled { border-color: var(--color-error); color: var(--color-error); }
details.panel > summary { cursor: pointer; min-height: var(--target-min); display: flex; align-items: center; }
details.panel > summary h3 { display: inline; margin: 0; font-size: var(--text-lg); }
.inline-actions { margin-top: 0.25rem; align-items: center; }
main > section { margin-top: var(--space-4); }

/* Volunteer response page: big, plain, one column, no script (RSP-1, UX-8 to UX-13). */
.slot-field legend h2 { margin-bottom: var(--space-1); }
.slot-option {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 4rem; margin-bottom: var(--space-2); padding: var(--space-2);
  border: 3px solid var(--color-primary); border-radius: var(--radius);
  background: var(--color-bg); color: var(--color-text); cursor: pointer; font-weight: 400;
}
.slot-option input { width: 2rem; height: 2rem; flex: none; margin: 0; accent-color: var(--color-primary); }
.slot-option:has(input:checked) { background: var(--color-selected); box-shadow: inset 0 0 0 2px var(--color-primary); }
.slot-option:has(input:focus-visible) { outline: 3px solid var(--color-text); outline-offset: 2px; box-shadow: 0 0 0 6px var(--color-focus); }
.slot-text { font-size: var(--text-lg); line-height: 1.35; }
.slot-count { font-size: var(--text-base); color: var(--color-text-muted); }
.volunteer-page .button--primary-block { width: 100%; margin-top: var(--space-2); }
.decline-row { margin-top: var(--space-3); }
.choose-instead { margin-top: var(--space-3); }
.event-card h2 { margin-bottom: var(--space-1); }
.email-preview { width: 100%; height: 40rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: #fff; }
.slot-option--full { border-color: var(--color-border); border-style: dashed; cursor: default; color: var(--color-text-muted); }
.slot-option--waitlist { border-style: dashed; }
.slot-action { font-weight: 700; font-size: var(--text-lg); color: var(--color-primary); }
.waitlist { margin-top: var(--space-1); }
.waitlist ol { margin: 0.25rem 0 0; }
.inline-form { display: inline; }
.needed-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin-bottom: var(--space-2); }
.needed-row label { flex: 1 1 12rem; margin: 0; }
.needed-row input { flex: 0 0 7rem; width: 7rem; min-height: var(--target-min); padding: 0.5rem 0.75rem; font: inherit; border: 2px solid var(--color-border); border-radius: var(--radius); }

/* Reports (RPT-1 to RPT-7) */
.report-slot h2 { margin-top: 0; }
.report-totals { font-size: var(--text-lg); font-weight: 700; }
.person-list > li { padding-block: var(--space-2); }
.answers { margin: var(--space-1) 0 0; }
.answers > div { display: flex; flex-wrap: wrap; gap: 0 0.5rem; }
.answers dt { font-weight: 700; }
.answers dd { margin: 0; }
.person-actions { margin-top: var(--space-1); }
.change-signup > summary { cursor: pointer; min-height: var(--target-min); display: flex; align-items: center; color: var(--color-link); text-decoration: underline; }
.change-signup form { margin-top: var(--space-1); }
.live-bar { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); align-items: center; margin-block: var(--space-2); }
.live-bar p { margin: 0; }
.report-invitees .tag { white-space: nowrap; }
.person-actions .inline-form { display: block; margin-bottom: var(--space-1); }
@media print {
  .live-bar, .person-actions, #add, .button-row { display: none !important; }
}

/* Phase 7 */
.button--danger { background: var(--color-error); border-color: var(--color-error); color: #fff; }
.button--danger:hover { background: #6e1515; border-color: #6e1515; }
.danger-link { margin-top: var(--space-4); }
.danger-link a { color: var(--color-error); }
.hint--warning { color: var(--color-error); font-weight: 700; }
/* A table that becomes stacked blocks on narrow screens and at high zoom (UX-17). */
@media (max-width: 40em) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack th, .table--stack td { display: block; width: auto; }
  .table--stack tr { border-bottom: 1px solid var(--color-border); padding-block: var(--space-1); }
  .table--stack th, .table--stack td { border: 0; padding: 0.25rem 0; }
  .table--stack td[data-label]::before { content: attr(data-label) ": "; font-weight: 700; }
}

/* Multi-date events (EVT-15) */
.day-heading { font-size: var(--text-lg); margin: var(--space-3) 0 var(--space-1); padding-top: var(--space-1); border-top: 1px solid var(--color-surface-edge); }
.slot-field .day-heading:first-of-type { border-top: 0; margin-top: var(--space-1); }
.slot-option--past { background: var(--color-surface); border-style: dashed; }
.weekday-group .field { margin-bottom: var(--space-2); }
