/* Styles for the server-rendered About and documentation pages. */

:root {
  --target-red: #cc0000;
  --text: #1a1a1a;
  --muted: #444444;
  --bg: #ffffff;
  --bg-off: #f9f9f9;
  --border: #d0d0d0;
  --link: #005a9c;          /* 7:1 on white, passes WCAG AA for text */
  --focus-ring: #005a9c;
  --focus-ring-on-dark: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-off);
}

/* --- Skip link: first focusable element, off-screen until focused --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: #ffffff;
  color: var(--link);
  font-weight: bold;
  text-decoration: underline;
  border: 2px solid var(--link);
}
.skip-link:focus {
  left: 0;
}

/* --- Header + primary navigation --- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  background: var(--target-red);
  color: #ffffff;
  padding: 1rem 1.5rem;
}
.site-title {
  font-size: 1.25rem;
  font-weight: bold;
}
.site-header nav { margin-left: auto; }
.header-nav {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0;
  padding: 0;
}
.header-nav a {
  color: #ffffff;
  text-decoration: underline;   /* distinguished by more than color (1.4.1) */
}

/* --- Layout: in-page docs nav + main content --- */
.docs-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  align-items: flex-start;
}
.docs-nav {
  flex: 0 0 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.docs-nav-heading {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}
.docs-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.docs-nav-list li { margin: 0.15rem 0; }

main {
  flex: 1 1 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  min-width: 0;
}
main :first-child { margin-top: 0; }
main h1 { font-size: 1.8rem; }
main h2 { font-size: 1.3rem; margin-top: 1.75rem; }
main h3 { font-size: 1.1rem; margin-top: 1.25rem; }
main a {
  color: var(--link);
  text-decoration: underline;   /* not color-alone (1.4.1) */
}
main a:hover { text-decoration: none; }
main code {
  background: #eef1f4;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
}
.site-footer p { margin: 0.25rem 0; }
.site-footer small { font-size: 0.85rem; }

/* --- Target size: nav links at least 24x24 CSS px (2.5.8) --- */
.header-nav a,
.docs-nav-list a {
  display: inline-block;
  padding: 0.4rem 0.6rem;
  min-height: 24px;
}

/* --- Focus indicators (2.4.13 Focus Appearance, 1.4.11 Non-text Contrast) --- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}
:where(a, button, input, select, textarea, summary):focus:not(:focus-visible) {
  outline: none;
}
/* On the red header, #005a9c fails contrast; switch the ring to white. */
.site-header :where(a, button):focus-visible {
  outline-color: var(--focus-ring-on-dark);
}

/* The skip-link target should not show a focus ring when reached programmatically. */
main:focus { outline: none; }

@media (max-width: 640px) {
  .site-header nav { margin-left: 0; width: 100%; }
}

/* --- Admin feedback dashboard --- */

/* Summary as a description list of metric name/value pairs. */
.feedback-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0 0 1.5rem;
  padding: 0;
}
.feedback-summary .summary-item {
  border: 1px solid #949494;     /* >= 3:1 on white, not the faint --border token */
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--bg);
}
.feedback-summary dt {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}
.feedback-summary dd {
  margin: 0;
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--text);
}

/* Horizontal scroll region for the data table. Focusable so keyboard-only team
   members can scroll it; named via aria-labelledby on the section heading.
   Inherits the existing [tabindex]:focus-visible outline. */
.table-scroll {
  overflow-x: auto;
  border-radius: 8px;
}

.feedback-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;              /* prefer scrolling over crushing columns */
}
.feedback-table caption {
  text-align: left;
  color: var(--muted);
  padding: 0 0 0.5rem;
  font-size: 0.95rem;
}
.feedback-table th,
.feedback-table td {
  border: 1px solid #767676;     /* 4.5:1 on white, easy to track across rows */
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.feedback-table thead th {
  background: var(--bg-off);
}
.feedback-table tbody tr:nth-child(even) td,
.feedback-table tbody tr:nth-child(even) th {
  background: var(--bg-off);     /* zebra striping is decorative only */
}
.feedback-table td:last-child {
  max-width: 28rem;
  overflow-wrap: anywhere;       /* let long notes wrap instead of forcing scroll */
}

.cell-empty,
.empty-state {
  color: var(--muted);
}
.empty-state { font-style: italic; }

/* --- Date-range filter + CSV toolbar --- */
:root {
  --field-border: #767676;   /* 4.5:1 on white, meets 3:1 component contrast */
  --error: #b00000;          /* ~5.9:1 on white, AA for normal text */
}

.feedback-filter { margin: 0 0 2rem; }
.filter-set {
  border: 1px solid var(--border);
  padding: 1rem 1.25rem 1.25rem;
}
.filter-set > legend { font-weight: bold; padding: 0 0.4rem; }

.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  border: 0;
}
.preset {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 24px;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
}
/* Non-color signal for the chosen preset (1.4.1). */
.preset:has(input:checked) { font-weight: bold; text-decoration: underline; }

.filter-custom {
  border: 1px solid var(--border);
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.filter-custom > legend { padding: 0 0.4rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field label { font-weight: 600; }
.field input[type="date"] {
  min-height: 32px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--field-border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.field-hint { flex-basis: 100%; margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }

.btn-apply {
  min-height: 24px;
  padding: 0.55rem 1.1rem;
  background: var(--target-red);
  color: #ffffff;
  border: 1px solid var(--target-red);
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}
.btn-apply:hover { background: #a30000; border-color: #a30000; }
/* Focus ring must contrast with the red fill: use the white on-dark ring. */
.btn-apply:focus-visible {
  outline-color: var(--focus-ring-on-dark);
  outline-offset: 2px;
}

.results-summary { margin: 0 0 1rem; font-weight: 600; }
.results-summary:focus { outline: none; }

.field-error {
  margin: 0 0 1rem;
  padding: 0.6rem 0.85rem;
  border: 2px solid var(--error);
  color: var(--error);
  font-weight: 600;
  background: #fff5f5;
}
.field-error:focus { outline: none; }
.field input[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }

.table-toolbar { margin: 0 0 0.75rem; }
.download-csv { font-weight: 600; }
