/**
 * Pro Per Clinic Portal - WCAG 2.1 AA Compliant Styles
 * Clean, accessible styling without complex overrides
 */

/* ========================================
   Form Container
   ======================================== */

/* ========================================
   Progress Tracker - Full Implementation
   Replaces missing progress-tracker library
   ======================================== */

.webform-progress {
  margin-bottom: 2rem;
  padding: 2rem 0;
}

.webform-progress-tracker {
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 700px;
  counter-reset: step;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  padding-top: 0;
}

/* Connector line between steps: drawn via ::after on every step except the last */
.progress-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 22px; /* center of 44px marker */
  left: calc(50% + 22px); /* start right of circle */
  width: calc(100% - 44px); /* span to next circle's left edge */
  height: 3px;
  background-color: #dfe1e2;
  z-index: 0;
}

/* Completed step connector turns green */
.progress-step.is-complete:not(:last-child)::after {
  background-color: #198038;
}

/* Active step connector: line from completed to active stays green on the completed side */
/* (already handled above — completed steps get green, others stay gray) */

/* The marker circle */
.progress-marker {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #757575 !important;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.125rem;
  position: relative;
  z-index: 1;
  border: 3px solid #757575;
  /* WCAG 2.1: 44x44px touch target, 4.6:1 contrast */
}

/* Display step number from data-text attribute */
.progress-marker[data-text]::before {
  content: attr(data-text) !important;
  color: #ffffff !important;
  background-color: transparent !important;
}

/* Kill any leftover ::after stubs from webform CSS */
.progress-marker::after {
  display: none !important;
  content: none !important;
}

/* Active step */
.progress-step.is-active .progress-marker {
  background-color: #005ea2 !important;
  border-color: #005ea2;
  box-shadow: 0 0 0 4px rgba(0, 94, 162, 0.25);
  /* WCAG: 8.59:1 contrast - AAA */
}

.progress-step.is-active .progress-marker[data-text]::before {
  color: #ffffff !important;
  background-color: transparent !important;
}

/* Completed step */
.progress-step.is-complete .progress-marker {
  background-color: #198038 !important;
  border-color: #198038;
  /* WCAG: 6.4:1 contrast - AAA */
}

.progress-step.is-complete .progress-marker[data-text]::before {
  content: "\2713" !important; /* checkmark */
  font-size: 1.5rem;
  color: #ffffff !important;
  background-color: transparent !important;
}

/* Step labels */
.progress-text {
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  color: #1b1b1b;
}

.progress-title {
  font-weight: 500;
  color: #000000;
}

.progress-step.is-active .progress-text {
  color: #1b1b1b;
}

.progress-step.is-active .progress-title {
  font-weight: bold;
}

.progress-step.is-complete .progress-text {
  color: #1b1b1b;
}

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

/* ========================================
   Form Fields
   ======================================== */

.jcc-form-input,
.jcc-form-select {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-weight: bold;
  color: #1b2b85;
  margin-bottom: 0.5rem;
  /* WCAG 2.1: Clear label association */
}

input[type="text"],
input[type="email"],
input[type="date"],
select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #71767a;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  background-color: #ffffff;
  color: #1b1b1b;
  /* WCAG 2.1: 3:1 contrast for UI components */
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
select:focus {
  outline: 3px solid #005ea2;
  outline-offset: 0;
  border-color: #005ea2;
  /* WCAG 2.1: Clear focus indicator */
}

/* Required field indicator */
.form-required {
  color: #b50909;
  font-weight: bold;
  /* WCAG 2.1: 4.54:1 contrast ratio on white */
}

.form-required::after {
  content: "";
}

/* ========================================
   Radio Buttons and Fieldsets
   ======================================== */

.jcc-fieldset {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Add border and background to form wrapper */
.js-form-wrapper.form-wrapper.usa-form-group,
.js-form-wrapper.form-wrapper {
  border: 2px solid #dfe1e2;
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background-color: #f9f9f9;
}

/* Remove box from the email + submit container */
.ppl-final-section.js-form-wrapper.form-wrapper {
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 0;
  background-color: transparent;
}

fieldset legend,
.js-form-wrapper.form-wrapper legend {
  font-weight: bold;
  color: #1b1b1b;
  font-size: 1.125rem;
  padding: 0;
  margin-bottom: 1rem;
}

.form-radios {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-radio {
  display: flex;
  align-items: center;
}

input[type="radio"] {
  width: 24px;
  height: 24px;
  margin-right: 0.75rem;
  cursor: pointer;
  /* WCAG 2.1: Adequate touch target */
}

input[type="radio"]:focus {
  outline: 3px solid #005ea2;
  outline-offset: 3px;
}

.form-radio label {
  margin-bottom: 0;
  cursor: pointer;
  font-weight: normal;
}

/* ========================================
   Child Fieldsets
   ======================================== */

.child-fieldset {
  background-color: #ffffff;
  border-left: 4px solid #005ea2;
}

.child-fieldset legend {
  color: #005ea2;
}

/* ========================================
   Buttons
   ======================================== */

.webform-button--submit,
.webform-button--previous,
.webform-button--next {
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-width: 120px;
  min-height: 44px;
  /* WCAG 2.1: 44x44px touch target */
}

.webform-button--submit,
.webform-button--next {
  background-color: #005ea2;
  color: #ffffff;
  /* WCAG 2.1: 8.59:1 contrast - AAA */
}

.webform-button--submit:hover,
.webform-button--next:hover {
  background-color: #1b2b85;
  /* WCAG 2.1: 11.16:1 contrast - AAA */
}

.webform-button--submit:focus,
.webform-button--next:focus,
.webform-button--previous:focus {
  outline: 3px solid #005ea2;
  outline-offset: 3px;
  background-color: #fff2c4;
}

.webform-button--previous {
  background-color: #f0f0f0;
  color: #1b1b1b;
  border: 2px solid #71767a;
}

.webform-button--previous:hover {
  background-color: #e0e0e0;
}

/* ========================================
   Error Messages
   ======================================== */

.form-item--error-message,
.messages--error {
  background-color: #fff0f0;
  border: 2px solid #950808;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
  color: #950808;
  font-weight: bold;
  /* WCAG 2.1: 5.9:1 contrast on #fff0f0 */
}

.form-item--error input,
.form-item--error select {
  border-color: #950808;
  border-width: 3px;
}

/* ========================================
   Responsive Design
   ======================================== */

@media screen and (max-width: 640px) {
  .webform-submission-pro-per-portal-form {
    padding: 0 1rem;
  }

  .webform-button--submit,
  .webform-button--previous,
  .webform-button--next {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .progress-text {
    font-size: 0.7rem;
  }

  .progress-marker {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .progress-step:not(:last-child)::after {
    top: 20px;
    left: calc(50% + 20px);
    width: calc(100% - 40px);
  }
}

/* ========================================
   High Contrast Mode
   ======================================== */

@media (prefers-contrast: high) {
  input,
  select,
  .progress-marker,
  .jcc-fieldset {
    border-width: 3px;
  }

  .progress-step:not(:last-child)::after {
    height: 4px;
    background-color: #000;
  }

  .progress-step.is-complete:not(:last-child)::after {
    background-color: #000;
  }

  .progress-marker {
    border-width: 4px !important;
  }

  button:focus,
  input:focus,
  select:focus {
    outline-width: 4px;
  }
}

/* ========================================
   Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
  .webform-progress,
  .webform-button--previous,
  .webform-button--next {
    display: none;
  }

  .webform-button--submit {
    display: none;
  }

  input,
  select {
    border: 1px solid #000;
  }
}

/* "Married to respondent = Yes" dissolution redirect notice */
.ppl-married-notice {
  background-color: #faf3d1;
  border-left: 4px solid #ffbe2e;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 4px;
}

.ppl-married-notice__text {
  margin: 0;
  color: #1b1b1b;
  line-height: 1.6;
}

/* Confirmation message after form submission */
.ppl-confirmation {
  text-align: center;
  padding: 4rem 2rem;
  max-width: 700px;
  margin: 0 auto;
}

.ppl-confirmation p {
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.ppl-confirmation__link {
  display: inline-block;
  background-color: #005ea2;
  color: #fff;
  padding: 0.75rem 2rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: bold;
  min-height: 44px;
}

.ppl-confirmation__link:hover {
  background-color: #1b2b85;
  color: #fff;
}

.ppl-confirmation__link:focus {
  outline: 3px solid #005ea2;
  outline-offset: 2px;
  color: #fff;
}

.ppl-confirmation__link:visited {
  color: #fff;
}

/* Force-hide elements that Drupal states.js keeps re-showing */
.ppl-force-hidden {
  display: none !important;
}

/* "Selected Case Type:" / "Selected County:" display paragraphs */
.ppl-selected-display {
  margin: 0.75rem 0 1rem 0;
  padding: 0.5rem 0.75rem;
  background-color: #e7f2fa;
  border-left: 4px solid #005ea2;
  border-radius: 2px;
}

.ppl-selected-label {
  font-weight: bold;
  color: #1b2b85;
}

.ppl-selected-value {
  color: #1b1b1b;
}

@media (prefers-contrast: high) {
  .ppl-selected-display {
    border: 2px solid #000;
    background-color: #fff;
  }

  .ppl-married-notice {
    border: 2px solid #000;
    background-color: #fff;
  }
}

@media print {
  .ppl-selected-display {
    border-left: 2px solid #000;
    background-color: #fff;
  }
}

/* Screen reader only announcer (used by JS) */
#ppl-sr-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
