/*
 * EquitableDocs — Accessible CSS
 *
 * Design rules (from CLAUDE.md):
 * - Teal (#0D7377) + cream (#FAFAF5)
 * - Georgia (serif) for headings, system sans-serif for body
 * - Minimum 16px (1rem) body text, all sizes in rem
 * - 4.5:1 contrast minimum for normal text
 * - Visible focus indicators on all interactive elements
 * - Never override browser zoom, font size, or high contrast
 * - No animation except simple loading indicators
 */

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Root variables ────────────────────────────────── */
:root {
  --color-primary: #0D7377;
  --color-primary-dark: #095557;
  --color-bg: #FAFAF5;
  --color-bg-white: #FFFFFF;
  --color-text: #1A1A1A;
  --color-text-light: #4A4A4A;
  --color-border: #D0D0D0;
  --color-success: #2E7D32;
  --color-error: #C62828;
  --color-warning: #F57F17;
  --color-focus: #0D7377;
  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --max-width: 64rem;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --radius: 0.375rem;
}

/* ── Base typography ───────────────────────────────── */
html {
  font-size: 100%; /* respect user settings */
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.3;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

h1 { font-size: 2rem; margin-top: var(--space-lg); }
h2 { font-size: 1.5rem; margin-top: var(--space-xl); }
h3 { font-size: 1.25rem; margin-top: var(--space-lg); }

p { margin-bottom: var(--space-md); max-width: 65ch; }

a {
  color: var(--color-primary);
  text-decoration: underline;
}
a:hover { color: var(--color-primary-dark); }

/* ── Skip link (hidden until focused) ──────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  z-index: 1000;
  text-decoration: none;
  font-weight: bold;
}
.skip-link:focus {
  top: var(--space-sm);
}

/* ── Focus indicators (WCAG 2.4.7) ────────────────── */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* ── Container ─────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ── Header ────────────────────────────────────────── */
.site-header {
  background: var(--color-bg-white);
  border-bottom: 2px solid var(--color-primary);
  padding: var(--space-md) 0;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}
.site-logo {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--color-primary);
  text-decoration: none;
}
.main-nav ul {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}
.main-nav a {
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
}
.main-nav a:hover,
.main-nav a[aria-current="page"] {
  background: var(--color-primary);
  color: #fff;
}

/* ── Main content ──────────────────────────────────── */
main {
  flex: 1;
  padding: var(--space-lg) var(--space-md);
}

/* ── Footer ────────────────────────────────────────── */
.site-footer {
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-xl) 0;
  margin-top: var(--space-2xl);
  text-align: center;
}
.site-footer a {
  color: #B2DFDB;
}
.site-footer p {
  margin: 0 auto var(--space-sm);
  max-width: none;
}

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-sm);
}
.card h2, .card h3 {
  margin-top: 0;
}

/* ── Status badges ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
}
.badge-pending  { background: #FFF3E0; color: #E65100; }
.badge-review   { background: #E3F2FD; color: #1565C0; }
.badge-complete { background: #E8F5E9; color: #2E7D32; }
.badge-delivered { background: #F3E5F5; color: #6A1B9A; }
.badge-failed   { background: #FFEBEE; color: #C62828; }

/* ── Forms ─────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-lg);
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}
.form-group .hint {
  display: block;
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-bottom: var(--space-xs);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
select,
textarea {
  display: block;
  width: 100%;
  max-width: 30rem;
  padding: var(--space-sm) var(--space-md);
  font-size: 1rem;
  font-family: var(--font-body);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg-white);
  color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
}
textarea {
  min-height: 6rem;
  resize: vertical;
}

/* Error state */
.form-group.error input,
.form-group.error select,
.form-group.error textarea {
  border-color: var(--color-error);
}
.form-group .error-message {
  color: var(--color-error);
  font-size: 0.875rem;
  margin-top: var(--space-xs);
}

/* File upload */
input[type="file"] {
  font-size: 1rem;
  padding: var(--space-sm);
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}
.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
}
.btn-danger {
  background: var(--color-error);
  color: #fff;
  border-color: var(--color-error);
}

/* ── Tables ────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
}
th, td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
th {
  font-weight: 600;
  background: var(--color-bg);
}

/* ── Queue list ────────────────────────────────────── */
.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.queue-item-info {
  flex: 1;
}
.queue-item-meta {
  font-size: 0.875rem;
  color: var(--color-text-light);
}

/* ── Stats grid ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.stat-card {
  text-align: center;
}
.stat-number {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  color: var(--color-primary);
  line-height: 1;
}
.stat-label {
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-top: var(--space-xs);
}

/* ── Guided review steps ───────────────────────────── */
.step-list {
  list-style: none;
  counter-reset: steps;
}
.step-list li {
  counter-increment: steps;
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.step-list li::before {
  content: counter(steps);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  font-weight: bold;
  flex-shrink: 0;
}
.step-list li.done { border-color: var(--color-success); }
.step-list li.done::before { background: var(--color-success); }

/* ── Alert / message boxes ─────────────────────────── */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  border-left: 4px solid;
}
.alert-success { background: #E8F5E9; border-color: var(--color-success); }
.alert-error   { background: #FFEBEE; border-color: var(--color-error); }
.alert-info    { background: #E3F2FD; border-color: #1565C0; }

/* ── Loading spinner ───────────────────────────────── */
.loading {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Visually hidden (screen reader only) ──────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 48rem) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .main-nav ul { flex-wrap: wrap; gap: var(--space-sm); }
  .queue-item { flex-direction: column; align-items: flex-start; }
}

/* ── High contrast mode support ────────────────────── */
@media (forced-colors: active) {
  .btn { border: 2px solid ButtonText; }
  .badge { border: 1px solid; }
  .skip-link:focus { outline: 3px solid Highlight; }
}

/* ── Reduced motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .loading { animation: none; }
}
