/* CNIB Orion Accessible Experience Standard — form controls.
   Behaviours from cnib-style field renderers; colour is CNIB only.
   Targets ≥ 44×44px. Selected state is yellow fill, black text, black border. */

.question-group { margin: 2.5rem 0 1rem; padding-top: 1.5rem; border-top: 3px solid var(--border); }
.group-heading { font-size: 1.75rem; margin-bottom: 0.35rem; }
.group-description { margin-bottom: 1.25rem; }

.question-item,
.form-group {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
}
.question-item:focus,
.question-item:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  background: var(--cnib-yellow-soft);
}
.question-text:focus,
.question-help:focus {
  outline: 2px dashed var(--focus);
  outline-offset: 2px;
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  border-radius: 4px;
}

.question-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.question-number {
  font-weight: 700;
  font-size: 0.875rem;
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  border: 2px solid var(--cnib-black);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.question-text {
  flex: 1;
  font-weight: 700;
  font-size: 1.25rem;
}
.required { font-weight: 700; }
.question-help { margin-bottom: 0.85rem; }

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 0.875rem 1.125rem;
  border: 2px solid var(--cnib-black);
  border-radius: 8px;
  background: var(--cnib-white);
  color: var(--cnib-black);
  min-height: var(--target);
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: 3px solid var(--cnib-black);
  outline-offset: 2px;
  background: var(--cnib-yellow-soft);
}
.field-textarea { resize: vertical; min-height: 7.5rem; line-height: 1.6; }

input[aria-invalid="true"] {
  border-color: var(--cnib-black);
  box-shadow: 0 0 0 3px var(--cnib-yellow);
}
.field-error:not([hidden]) {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  border: 2px solid var(--cnib-black);
  border-left-width: 6px;
  border-radius: 4px;
  font-weight: 700;
}

.submission-errors-panel[hidden] { display: none; }
.submission-errors-panel {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  border: 3px solid var(--cnib-black);
  border-left-width: 8px;
  border-radius: 6px;
}
.submission-errors-heading { margin: 0 0 0.5rem; font-size: 1.125rem; }
.submission-errors-heading:focus {
  outline: 3px solid var(--cnib-black);
  outline-offset: 2px;
}

.survey-success[hidden] { display: none; }
.survey-success {
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  border: 3px solid var(--cnib-black);
  border-radius: 6px;
}

.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 0.5rem; }

.radio-label, .checkbox-label {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 2px solid var(--cnib-black);
  background: var(--cnib-white);
  color: var(--cnib-black);
  min-height: 48px;
}
.radio-label:hover, .checkbox-label:hover { background: var(--cnib-yellow-soft); }
.radio-label:has(input:checked),
.checkbox-label:has(input:checked) {
  background: var(--cnib-yellow);
}
.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.radio-label input[type="radio"] + span::before,
.checkbox-label input[type="checkbox"] + span::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--cnib-black);
  margin-right: 0.75rem;
  flex-shrink: 0;
  background: var(--cnib-white);
  vertical-align: middle;
}
.radio-label input[type="radio"] + span::before { border-radius: 50%; }
.checkbox-label input[type="checkbox"] + span::before { border-radius: 6px; }
.radio-label input[type="radio"]:checked + span::before {
  border-width: 7px;
  background: var(--cnib-yellow);
}
.checkbox-label input[type="checkbox"]:checked + span::before {
  background: var(--cnib-yellow);
}
.checkbox-label input[type="checkbox"]:checked + span::after {
  content: "✓";
  position: absolute;
  left: 1.35rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cnib-black);
  font-weight: 700;
  font-size: 16px;
}
.radio-label input:focus-visible + span::before,
.checkbox-label input:focus-visible + span::before {
  outline: 3px solid var(--cnib-black);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--cnib-yellow);
}

.range-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--cnib-yellow-soft);
  border: 2px solid var(--cnib-black);
  border-radius: 12px;
}
.range-labels { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.875rem; }
.field-range {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--cnib-white);
  border: 2px solid var(--cnib-black);
  cursor: pointer;
}
.field-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: var(--cnib-yellow);
  border: 3px solid var(--cnib-black);
  border-radius: 50%;
  cursor: pointer;
}
.field-range::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: var(--cnib-yellow);
  border: 3px solid var(--cnib-black);
  border-radius: 50%;
  cursor: pointer;
}
.field-range:focus { outline: 3px solid var(--cnib-black); outline-offset: 3px; }
.range-value {
  text-align: center;
  font-weight: 700;
  font-size: 1.5rem;
  padding: 0.5rem;
  background: var(--cnib-white);
  border: 2px solid var(--cnib-black);
  border-radius: 8px;
  color: var(--cnib-black);
}

.likert-container, .numeric-scale-container {
  padding: 1.25rem;
  background: var(--cnib-yellow-soft);
  border: 2px solid var(--cnib-black);
  border-radius: 12px;
}
.likert-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}
.likert-option, .numeric-option { position: relative; cursor: pointer; }
.likert-option input, .numeric-option input, .likert-neutral input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.likert-visual, .numeric-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem 0.6rem;
  border: 2px solid var(--cnib-black);
  border-radius: 10px;
  background: var(--cnib-white);
  color: var(--cnib-black);
  min-height: 88px;
  min-width: var(--target);
}
.likert-option input:checked + .likert-visual,
.numeric-option input:checked + .numeric-visual,
.likert-neutral input:checked + .likert-visual {
  background: var(--cnib-yellow);
  border-width: 3px;
}
.likert-option input:focus-visible + .likert-visual,
.numeric-option input:focus-visible + .numeric-visual,
.likert-neutral input:focus-visible + .likert-visual {
  outline: 3px solid var(--cnib-black);
  outline-offset: 3px;
}
.likert-option:hover .likert-visual,
.numeric-option:hover .numeric-visual { background: var(--cnib-yellow-soft); }
.likert-number, .numeric-number { font-weight: 700; font-size: 1.5rem; }
.likert-label, .numeric-label { font-size: 0.9375rem; text-align: center; line-height: 1.3; font-weight: 700; }
.likert-neutral { margin-top: 1rem; padding-top: 1rem; border-top: 2px solid var(--cnib-black); display: block; cursor: pointer; }
.likert-neutral .likert-visual {
  padding: 0.875rem 1.125rem;
  min-height: 48px;
  flex-direction: row;
  justify-content: flex-start;
}

.numeric-labels { display: flex; justify-content: space-between; margin-bottom: 1rem; font-weight: 700; font-size: 0.875rem; }
.numeric-scale { display: flex; flex-wrap: nowrap; gap: 0.5rem; justify-content: center; }
.numeric-option { flex: 1 1 0; min-width: 0; }
.numeric-visual { min-height: 56px; min-width: 56px; padding: 0.75rem 0.5rem; }

.matrix-container { overflow-x: auto; }
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid var(--cnib-black);
}
.matrix-table th, .matrix-table td {
  padding: 0.85rem 0.65rem;
  border: 1px solid var(--cnib-black);
  text-align: center;
}
.matrix-table th {
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  font-weight: 700;
}
.matrix-row-label { text-align: left; font-weight: 700; background: var(--cnib-yellow-soft); }
.matrix-table input[type="radio"] {
  width: 24px;
  height: 24px;
  accent-color: var(--cnib-black);
  cursor: pointer;
}
.matrix-table input[type="radio"]:focus-visible {
  outline: 3px solid var(--cnib-black);
  outline-offset: 2px;
}

.field-file {
  width: 100%;
  padding: 1rem;
  border: 2px dashed var(--cnib-black);
  border-radius: 8px;
  cursor: pointer;
  background: var(--cnib-white);
  min-height: 48px;
}
.field-file:hover { background: var(--cnib-yellow-soft); }
.field-file:focus-visible { outline: 3px solid var(--cnib-black); outline-offset: 2px; }
.file-help { display: block; margin-top: 0.5rem; font-size: 0.875rem; }

.form-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
  display: flex;
  justify-content: center;
}
.btn-submit {
  background: var(--cnib-black);
  color: var(--cnib-white);
  border: 3px solid var(--cnib-black);
  padding: 1rem 3rem;
  border-radius: 12px;
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
}
.btn-submit:hover,
.btn-submit:focus-visible {
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  outline: 3px solid var(--cnib-black);
  outline-offset: 3px;
}

.progress-bar-container {
  width: 100%;
  height: 1rem;
  background: var(--cnib-white);
  border: 3px solid var(--cnib-black);
  border-radius: 4px;
  margin: 0 0 1.5rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--cnib-yellow);
  width: 0%;
}

html.cnib-high-contrast .question-item,
html.cnib-high-contrast .field-block,
html.cnib-high-contrast .likert-container,
html.cnib-high-contrast .numeric-scale-container,
html.cnib-high-contrast .range-container {
  background: var(--cnib-black);
  color: var(--cnib-white);
  border-color: var(--cnib-yellow);
}
html.cnib-high-contrast .field-input,
html.cnib-high-contrast .field-select,
html.cnib-high-contrast .field-textarea,
html.cnib-high-contrast .radio-label,
html.cnib-high-contrast .checkbox-label,
html.cnib-high-contrast .likert-visual,
html.cnib-high-contrast .numeric-visual,
html.cnib-high-contrast .field-file {
  background: var(--cnib-black);
  color: var(--cnib-white);
  border-color: var(--cnib-white);
}
html.cnib-high-contrast .radio-label:has(input:checked),
html.cnib-high-contrast .checkbox-label:has(input:checked),
html.cnib-high-contrast .likert-option input:checked + .likert-visual,
html.cnib-high-contrast .numeric-option input:checked + .numeric-visual,
html.cnib-high-contrast .btn-submit:hover {
  background: var(--cnib-yellow);
  color: var(--cnib-black);
}
html.cnib-high-contrast .btn-submit {
  background: var(--cnib-yellow);
  color: var(--cnib-black);
  border-color: var(--cnib-yellow);
}

@media (max-width: 768px) {
  .likert-scale { grid-template-columns: 1fr; }
  .likert-visual { flex-direction: row; justify-content: flex-start; min-height: 48px; }
  .numeric-scale { flex-wrap: wrap; }
  .numeric-option { flex: 0 0 auto; }
  .btn-submit { width: 100%; }
  .field-meta { grid-template-columns: 1fr; }
}
