/* ============================================================
   CHURCH SECURITY READINESS ASSESSMENT
   The Rural Impact Group
   WCAG 2.2 AA compliant
   Font: Lora (headings) + Source Sans 3 (body)
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --color-bg:           #faf8f5;
  --color-surface:      #ffffff;
  --color-border:       #ddd8d0;
  --color-border-focus: #5a7a5a;

  --color-text:         #1e1e1e;
  --color-text-muted:   #5a5650;
  --color-text-light:   #7a7470;

  --color-primary:      #3d5c3d;   /* deep forest green */
  --color-primary-dark: #2c4330;
  --color-primary-light:#eef3ee;

  --color-accent:       #8b5e3c;   /* warm earth brown */
  --color-accent-light: #f5ede5;

  --color-success:      #2e6b3e;
  --color-error:        #b5261e;
  --color-error-bg:     #fdf2f1;

  --color-step-done:    #3d5c3d;
  --color-step-active:  #3d5c3d;
  --color-step-future:  #ccc8c0;

  --font-heading:       'Lora', Georgia, serif;
  --font-body:          'Source Sans 3', 'Segoe UI', sans-serif;

  --radius-sm:          4px;
  --radius-md:          8px;
  --radius-lg:          12px;

  --shadow-card:        0 2px 12px rgba(0,0,0,0.08);
  --shadow-focus:       0 0 0 3px rgba(61, 92, 61, 0.35);

  --max-width:          720px;
  --transition:         0.18s ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Accessibility Utilities ────────────────────────────────── */

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Skip-to-content link (WCAG 2.1 AA) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 9999;
  background: var(--color-primary);
  color: #ffffff;
  padding: 0.6rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 var(--radius-md) 0;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid #ffffff;
  outline-offset: 2px;
}

/* Bot trap */
.bot-trap { display: none !important; }

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  background: var(--color-primary);
  padding: 1rem 1.5rem;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.logo { text-decoration: none; }
.logo-name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.01em;
}

/* ── Hero ───────────────────────────────────────────────────── */
.assessment-hero {
  background: var(--color-primary);
  padding: 3rem 1.5rem 3.5rem;
  position: relative;
  overflow: hidden;
}
.assessment-hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: var(--color-bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}
.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  color: #e8f0e8;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.3em 0.85em;
  border-radius: 100px;
  margin-bottom: 1rem;
  border: 1px solid rgba(255,255,255,0.25);
}
.assessment-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 600;
  color: #ffffff;
  line-height: 1.25;
  margin-bottom: 1rem;
}
.hero-lead {
  font-size: 1.05rem;
  color: #d4e4d4;
  max-width: 560px;
  margin-bottom: 1.5rem;
}
.hero-lead strong { color: #ffffff; }

.hero-facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.hero-facts li {
  font-size: 0.9rem;
  color: #c8dcc8;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.fact-icon {
  color: #8fc98f;
  font-size: 0.95rem;
}

/* ── Form Section ───────────────────────────────────────────── */
.form-section {
  padding: 2.5rem 1.5rem 4rem;
}
.form-outer {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-container {
  margin-bottom: 1.5rem;
}
.progress-bar-track {
  height: 6px;
  background: var(--color-border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 100px;
  transition: width 0.4s ease;
  width: calc((1/8) * 100%);
}
.progress-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: right;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Step Nav ───────────────────────────────────────────────── */
.step-nav {
  margin-bottom: 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.step-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0;
  min-width: max-content;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}
/* connector line between steps */
.step-item + .step-item::before {
  content: '';
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-step-future);
  flex-shrink: 0;
  transition: background var(--transition);
}
.step-item.done + .step-item::before,
.step-item.active + .step-item::before {
  background: var(--color-step-done);
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-step-future);
  border: 2px solid var(--color-step-future);
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.step-item.active .step-dot {
  background: var(--color-step-active);
  border-color: var(--color-step-active);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.step-item.done .step-dot {
  background: var(--color-step-done);
  border-color: var(--color-step-done);
}
.step-name {
  font-size: 0.72rem;
  color: var(--color-text-light);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: color var(--transition);
}
.step-item.active .step-name { color: var(--color-primary); }
.step-item.done .step-name  { color: var(--color-text-muted); }

/* ── Form Card ──────────────────────────────────────────────── */
.form-step {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem 2rem 1.5rem;
  box-shadow: var(--shadow-card);
  animation: stepIn 0.25s ease forwards;
}
@keyframes stepIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.form-step[hidden] { display: none; }

/* ── Legend / Section Header ────────────────────────────────── */
.step-legend {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  /* Override browser fieldset legend quirks */
  float: left;
  width: 100%;
  padding: 0;
}
/* Clear float after legend so fieldset flows correctly */
.form-step > *:not(legend) { clear: both; }

.step-number {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 0.2em 0.55em;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  flex-shrink: 0;
  position: relative;
  top: -1px;
}
.step-intro {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  margin-bottom: 1.75rem;
  padding-top: 0.25rem;
}

/* ── Field Groups ───────────────────────────────────────────── */
.field-group {
  margin-bottom: 1.5rem;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.field-col { display: flex; flex-direction: column; }

.field-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.4rem;
  line-height: 1.4;
}
/* When field-label is a <legend>, reset browser default */
fieldset > .field-label,
.radio-group > .field-label,
.checkbox-group > .field-label {
  float: left;
  width: 100%;
  margin-bottom: 0.65rem;
}
fieldset.radio-group,
fieldset.checkbox-group {
  border: none;
  padding: 0;
  margin: 0;
}

.hint {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.85em;
}
.field-note {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  background: var(--color-accent-light);
  border-left: 3px solid var(--color-accent);
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 0.75rem;
  clear: both;
}

.required {
  color: var(--color-error);
  margin-left: 2px;
}

/* ── Text Inputs & Select ───────────────────────────────────── */
.field-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
select.field-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a5650' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}
.field-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--shadow-focus);
}
.field-input[aria-invalid="true"] {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(181, 38, 30, 0.15);
}

/* ── Radio Options ──────────────────────────────────────────── */
.radio-options,
.checkbox-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  clear: both;
}
.radio-options--stacked {
  flex-direction: column;
  gap: 0.35rem;
}

.radio-label,
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--color-text);
  cursor: pointer;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  line-height: 1.45;
  user-select: none;
}
/* Inline (non-stacked) radios are compact */
.radio-options:not(.radio-options--stacked) .radio-label {
  flex: 0 0 auto;
}
.radio-label:hover,
.checkbox-label:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.radio-label:has(input:checked),
.checkbox-label:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 1px var(--color-primary);
}
.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.radio-label input:focus-visible,
.checkbox-label input:focus-visible {
  outline: 3px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Textarea ──────────────────────────────────────────────── */
.field-textarea {
  resize: vertical;
  min-height: 4.5rem;
  font-family: var(--font-body);
  line-height: 1.5;
}

/* ── Step Subheading ───────────────────────────────────────── */
.step-subheading {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-top: 1rem;
  margin-bottom: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

/* ── Conditional Fields ────────────────────────────────────── */
.conditional-field[hidden] {
  display: none;
}

/* ── Report Promise Box ─────────────────────────────────────── */
.report-promise {
  background: var(--color-primary-light);
  border: 1px solid #b8ccb8;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.65;
}
.report-promise p + p { margin-top: 0.75rem; }
.report-promise strong { color: var(--color-primary-dark); }

/* ── Privacy Note ───────────────────────────────────────────── */
.privacy-note {
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* ── Buttons ────────────────────────────────────────────────── */
.step-nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  gap: 1rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform 0.1s ease;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  margin-left: auto;
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-bg);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.btn-submit {
  background: var(--color-accent);
  color: #ffffff;
  border-color: var(--color-accent);
  padding: 0.8rem 2rem;
  font-size: 1rem;
  margin-left: auto;
}
.btn-submit:hover {
  background: #7a5233;
  border-color: #7a5233;
}

/* ── Error Summary ──────────────────────────────────────────── */
.error-summary {
  background: var(--color-error-bg);
  border: 1.5px solid var(--color-error);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--color-error);
}
.error-summary[hidden] { display: none; }
.error-summary ul { padding-left: 1.25rem; margin-top: 0.4rem; }
.error-summary li { margin-bottom: 0.2rem; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--color-primary-dark);
  padding: 2rem 1.5rem;
  text-align: center;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.site-footer p {
  font-size: 0.85rem;
  color: #a8c0a8;
  line-height: 1.6;
}
.footer-tagline {
  font-style: italic;
  color: #7a9a7a;
  margin-top: 0.25rem;
}
.footer-home-link {
  margin-top: 0.75rem;
}
.footer-home-link a {
  color: #c8dcc8;
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition);
}
.footer-home-link a:hover,
.footer-home-link a:focus {
  color: #ffffff;
}
.footer-home-link a:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .form-step { padding: 1.5rem 1.25rem; }
  .field-row { grid-template-columns: 1fr; }
  .step-nav  { margin-bottom: 1.25rem; }
  .step-name { display: none; }
  .btn-submit { width: 100%; justify-content: center; }
  .step-nav-buttons { flex-wrap: wrap; }
  .btn-primary,
  .btn-submit { width: 100%; justify-content: center; margin-left: 0; }
  .assessment-hero { padding: 2rem 1.25rem 3rem; }
}

/* ── High contrast / forced colors ─────────────────────────── */
@media (forced-colors: active) {
  .radio-label:has(input:checked),
  .checkbox-label:has(input:checked) {
    outline: 2px solid ButtonText;
  }
  .progress-bar-fill { background: ButtonText; }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
