/*
 * REGE Membership — Form Stylesheet
 *
 * Follows the REGE design system exactly:
 *   Fonts:  Inter (headings) · Jost (UI/body)
 *   Radius: 4px everywhere
 *   Transitions: 150–300ms ease
 *   Content width: 620px max
 *
 * CSS custom properties mirror the WordPress theme variables so the form
 * inherits any future theme color updates automatically.
 */

/* ── Custom properties ──────────────────────────────────────────────────── */

:root {
  --rege-bg:            #EBEBEF;
  --rege-white:         #ffffff;
  --rege-text:          #1C2930;
  --rege-muted:         #37505d;
  --rege-hint:          #96A5B2;
  --rege-base-2:        #DCE0E6;
  --rege-border:        #ccc;
  --rege-border-subtle: #e2e2e2;
  --rege-gold:          #C5A033;
  --rege-gold-hover:    #b08d2a;
  --rege-error:         #c0392b;
  --rege-success:       #27ae60;
  --rege-radius:        4px;
  --rege-transition:    150ms ease;
  --rege-field-height:  40px;
  --rege-font-body:     "Jost", sans-serif;
  --rege-font-heading:  "Inter", sans-serif;
}

/* ── Form wrapper ───────────────────────────────────────────────────────── */

.rege-form-wrap {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  font-family: var(--rege-font-body);
  color: var(--rege-text);
  line-height: 1.55;
}

/* ── Server-side error banner ───────────────────────────────────────────── */

.rege-form-errors {
  background: #fdf3f2;
  border: 1px solid var(--rege-error);
  border-left: 4px solid var(--rege-error);
  border-radius: var(--rege-radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  color: var(--rege-error);
  font-size: 0.875rem;
}

.rege-form-errors__title {
  font-weight: 700;
  margin-bottom: 8px;
}

.rege-form-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.rege-form-errors li {
  margin-bottom: 4px;
}

/* ── Form card (the white panel containing each step) ───────────────────── */

#rege-beitritt-form {
  background: var(--rege-white);
  border: 1px solid var(--rege-border-subtle);
  border-radius: var(--rege-radius);
  padding: 28px 32px 24px;
}

/* ── Progress bar ───────────────────────────────────────────────────────── */

.rege-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
}

.rege-progress-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--rege-base-2);
  transition: background 300ms ease;
}

.rege-progress-step.done   { background: var(--rege-muted); }
.rege-progress-step.active { background: var(--rege-gold); }

/* ── Step panel ─────────────────────────────────────────────────────────── */

.rege-step__title {
  font-family: var(--rege-font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rege-text);
  line-height: 1.2;
  margin: 0 0 4px;
}

.rege-step__subtitle {
  font-family: var(--rege-font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--rege-hint);
  margin: 0 0 24px;
}

/* ── Section headings ───────────────────────────────────────────────────── */

.rege-section-head {
  font-family: var(--rege-font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--rege-hint);
  margin: 20px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rege-border-subtle);
}

/* ── Field groups ───────────────────────────────────────────────────────── */

.rege-field-group {
  margin-bottom: 14px;
  position: relative;
}

/* Two-column row */
.rege-field-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.rege-field-row .rege-field-group {
  flex: 1;
  margin-bottom: 0;
}

/* PLZ/Hausnummer — narrower column */
.rege-field-row .rege-field-group--plz,
.rege-field-row .rege-field-group--hausnummer {
  flex: 0 0 120px;
}

/* ── Labels ─────────────────────────────────────────────────────────────── */

.rege-label {
  display: block;
  font-family: var(--rege-font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--rege-muted);
  margin-bottom: 5px;
}

.rege-label__hint {
  font-weight: 400;
  color: var(--rege-hint);
  font-size: 0.8125rem;
}

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

/* ── Inputs ─────────────────────────────────────────────────────────────── */

.rege-input {
  display: block;
  width: 100%;
  height: var(--rege-field-height);
  padding: 0 12px;
  border: 1px solid var(--rege-border);
  border-radius: var(--rege-radius);
  background: var(--rege-white);
  color: var(--rege-text);
  font-family: var(--rege-font-body);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.55;
  transition: border-color var(--rege-transition), box-shadow var(--rege-transition);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.rege-input::placeholder {
  color: var(--rege-hint);
}

.rege-input:focus {
  outline: none;
  border-color: var(--rege-muted);
  box-shadow: 0 0 0 3px rgba(55, 80, 93, 0.12);
}

.rege-input.has-error,
.rege-field-error .rege-input {
  border-color: var(--rege-error);
}

/* Number input — remove browser spinners */
.rege-input[type="number"] {
  -moz-appearance: textfield;
}
.rege-input[type="number"]::-webkit-outer-spin-button,
.rege-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* IBAN input — monospace for readability */
.rege-input--iban {
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 2px;
  font-size: 0.9375rem;
  text-transform: uppercase;
}

/* Factor input — narrower, inline with unit label */
.rege-input--factor {
  width: 80px;
  text-align: center;
}

/* Factor wrap: input + unit label inline */
.rege-factor-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rege-factor-unit {
  font-size: 0.875rem;
  color: var(--rege-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Hint text beneath inputs */
.rege-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--rege-hint);
  margin-top: 4px;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */

.rege-divider {
  border: none;
  border-top: 1px solid var(--rege-border-subtle);
  margin: 16px 0;
}

/* ── Radio / Checkbox option cards ──────────────────────────────────────── */

.rege-radio-group,
.rege-check-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.rege-radio-group--compact {
  gap: 6px;
}

/* Option card — shared for radio and checkbox */
.rege-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--rege-border-subtle);
  border-radius: var(--rege-radius);
  background: var(--rege-white);
  cursor: pointer;
  transition: border-color var(--rege-transition), background var(--rege-transition);
  user-select: none;
}

.rege-option:hover {
  border-color: var(--rege-muted);
  background: #f5f7f8;
}

.rege-option.selected {
  border-color: var(--rege-text);
  background: var(--rege-base-2);
}

/* Compact option used inside meter cards */
.rege-option--sm {
  padding: 8px 12px;
}

/* Checkbox variant */
.rege-option--check {
  align-items: flex-start;
}

/* Hide native input visually; keep it accessible */
.rege-option__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Custom radio dot */
.rege-option__check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--rege-border);
  background: var(--rege-white);
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--rege-transition);
  box-sizing: border-box;
}

.rege-option.selected .rege-option__check {
  border-color: var(--rege-text);
}

.rege-option.selected .rege-option__check::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rege-text);
}

/* Custom checkbox box */
.rege-option__check--box {
  border-radius: 3px;
}

.rege-option.selected .rege-option__check--box {
  background: var(--rege-text);
  border-color: var(--rege-text);
}

.rege-option.selected .rege-option__check--box::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--rege-white);
  border-bottom: 2px solid var(--rege-white);
  transform: rotate(-45deg) translate(1px, -1px);
  background: none;
  border-radius: 0;
}

/* Option text body */
.rege-option__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.rege-option__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--rege-text);
  line-height: 1.4;
}

.rege-option__hint {
  font-size: 0.8125rem;
  color: var(--rege-hint);
  line-height: 1.4;
}

/* Fieldset reset for groups of radio/checkbox */
fieldset.rege-field-group {
  border: none;
  padding: 0;
  margin: 0 0 14px;
}

fieldset.rege-field-group legend.rege-label {
  display: block;
  margin-bottom: 8px;
}

/* ── Zählpunkt number input (Variante A) ────────────────────────────────── */

.rege-zp-input-wrap {
  display: flex;
  border: 1px solid var(--rege-border);
  border-radius: var(--rege-radius);
  overflow: hidden;
  background: var(--rege-white);
  height: var(--rege-field-height);
  transition: border-color var(--rege-transition), box-shadow var(--rege-transition);
}

.rege-zp-input-wrap:focus-within {
  border-color: var(--rege-muted);
  box-shadow: 0 0 0 3px rgba(55, 80, 93, 0.12);
}

.rege-zp-input-wrap.has-error {
  border-color: var(--rege-error);
}

/* Locked gray prefix — mimics a telephone country code prefix */
.rege-zp-prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f5f7f8;
  border-right: 1px solid var(--rege-border);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.8125rem;
  color: var(--rege-muted);
  letter-spacing: 0.5px;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

/* 8-digit suffix input */
.rege-zp-suffix {
  border: none;
  border-radius: 0;
  flex: 1;
  height: 100%;
  padding: 0 10px;
  font-family: "Courier New", Courier, monospace;
  font-size: 1rem;
  letter-spacing: 3px;
  color: var(--rege-text);
  background: transparent;
  min-width: 0;
  width: auto;
}

.rege-zp-suffix:focus {
  outline: none;
  box-shadow: none;
}

.rege-zp-suffix::placeholder {
  color: var(--rege-hint);
  letter-spacing: 3px;
}

/* Full 33-char preview below the input */
.rege-zp-preview {
  margin-top: 5px;
  font-size: 0.75rem;
  color: var(--rege-hint);
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0.5px;
  word-break: break-all;
}

.rege-zp-preview__label {
  font-family: var(--rege-font-body);
  letter-spacing: 0;
  margin-right: 4px;
}

.rege-zp-preview__suffix {
  color: var(--rege-text);
}

/* ── Conditional / expandable blocks ────────────────────────────────────── */

.rege-conditional {
  background: #f5f7f8;
  border: 1px dashed var(--rege-base-2);
  border-radius: var(--rege-radius);
  padding: 14px 14px 4px;
  margin: 10px 0 14px;
}

.rege-conditional__label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--rege-hint);
  margin-bottom: 10px;
}

/* ── Legal text blocks ───────────────────────────────────────────────────── */

.rege-legal {
  background: #f5f7f8;
  border-left: 3px solid var(--rege-hint);
  border-radius: 0 var(--rege-radius) var(--rege-radius) 0;
  padding: 12px 14px;
  font-family: var(--rege-font-body);
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--rege-muted);
  line-height: 1.6;
  margin: 12px 0 16px;
}

/* Declaration text in step 7 — slightly more prominent */
.rege-legal--declaration {
  font-style: normal;
  font-size: 0.875rem;
  color: var(--rege-text);
  border-left-color: var(--rege-muted);
}

/* GDPR notice in step 7 */
.rege-legal--gdpr {
  margin-top: 16px;
}

/* ── Meter point cards ───────────────────────────────────────────────────── */

.rege-meter-card {
  border: 1px solid var(--rege-border-subtle);
  border-radius: var(--rege-radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--rege-white);
}

.rege-meter-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.rege-meter-card__title {
  font-family: var(--rege-font-heading);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--rege-muted);
}

.rege-meter-card__badge {
  font-size: 0.75rem;
  color: var(--rege-hint);
}

/* ── Add / Remove buttons ────────────────────────────────────────────────── */

/* "Add meter point" ghost button */
.rege-btn-add-meter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: 1px dashed var(--rege-hint);
  border-radius: var(--rege-radius);
  color: var(--rege-muted);
  font-family: var(--rege-font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color var(--rege-transition), color var(--rege-transition);
}

.rege-btn-add-meter:hover,
.rege-btn-add-meter:focus {
  outline: none;
  border-color: var(--rege-muted);
  color: var(--rege-text);
}

/* Remove button inside meter card header */
.rege-btn-remove {
  font-size: 0.75rem;
  font-family: var(--rege-font-body);
  font-weight: 600;
  color: var(--rege-error);
  background: none;
  border: 1px solid var(--rege-error);
  border-radius: 3px;
  padding: 3px 9px;
  cursor: pointer;
  transition: background var(--rege-transition), color var(--rege-transition);
}

.rege-btn-remove:hover,
.rege-btn-remove:focus {
  outline: none;
  background: var(--rege-error);
  color: var(--rege-white);
}

/* ── Empty state (step 5 before any Einspeisung added) ──────────────────── */

.rege-empty-state {
  background: #f5f7f8;
  border: 1px dashed var(--rege-border);
  border-radius: var(--rege-radius);
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 12px;
}

.rege-empty-state__text {
  font-size: 0.875rem;
  color: var(--rege-hint);
  line-height: 1.5;
  margin: 0;
}

.rege-empty-state__text small {
  font-size: 0.8125rem;
}

/* ── Turnstile widget wrapper ────────────────────────────────────────────── */

.rege-turnstile-wrap {
  margin: 14px 0;
}

/* ── Navigation bar ─────────────────────────────────────────────────────── */

.rege-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rege-border-subtle);
  gap: 12px;
}

/* Back button (secondary) */
.rege-btn-back {
  background: transparent;
  color: var(--rege-muted);
  font-family: var(--rege-font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 20px;
  border: 1px solid var(--rege-base-2);
  border-radius: var(--rege-radius);
  cursor: pointer;
  transition: border-color var(--rege-transition), color var(--rege-transition);
}

.rege-btn-back:hover,
.rege-btn-back:focus {
  outline: none;
  border-color: var(--rege-muted);
  color: var(--rege-text);
}

/* Next button (primary — gold) */
.rege-btn-next {
  background: var(--rege-gold);
  color: var(--rege-white);
  font-family: var(--rege-font-body);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--rege-radius);
  cursor: pointer;
  transition: background 300ms ease;
}

.rege-btn-next:hover,
.rege-btn-next:focus {
  outline: none;
  background: var(--rege-gold-hover);
}

.rege-btn-next:disabled {
  background: var(--rege-hint);
  cursor: not-allowed;
}

/* Submit button (primary — gold) */
.rege-btn-submit {
  background: var(--rege-gold);
  color: var(--rege-white);
  font-family: var(--rege-font-body);
  font-size: 0.9375rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--rege-radius);
  cursor: pointer;
  transition: background 300ms ease;
}

.rege-btn-submit:hover,
.rege-btn-submit:focus {
  outline: none;
  background: var(--rege-gold-hover);
}

.rege-btn-submit:disabled {
  background: var(--rege-hint);
  cursor: not-allowed;
}

/* ── Validation error messages ───────────────────────────────────────────── */

.rege-error-msg {
  display: block;
  color: var(--rege-error);
  font-size: 0.75rem;
  font-family: var(--rege-font-body);
  font-weight: 400;
  margin-top: 4px;
}

.rege-error-msg:empty {
  display: none;
}

/* Field-level error state — wraps the input */
.rege-field-error .rege-input,
.rege-field-error .rege-zp-input-wrap {
  border-color: var(--rege-error);
}

/* ── Accessibility helpers ───────────────────────────────────────────────── */

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

/* ── Statut/AGB link inside consent label ────────────────────────────────── */

.rege-option__label a {
  color: var(--rege-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rege-option__label a:hover {
  color: var(--rege-gold);
}

/* ── Responsive — stack columns below 600px ─────────────────────────────── */

@media (max-width: 600px) {

  #rege-beitritt-form {
    padding: 20px 16px 18px;
  }

  .rege-field-row {
    flex-direction: column;
    gap: 0;
  }

  .rege-field-row .rege-field-group {
    margin-bottom: 14px;
  }

  /* PLZ and Hausnummer: full width on mobile */
  .rege-field-row .rege-field-group--plz,
  .rege-field-row .rege-field-group--hausnummer {
    flex: unset;
    width: 100%;
  }

  .rege-zp-prefix {
    font-size: 0.6875rem;
    letter-spacing: 0;
    padding: 0 6px;
  }

  .rege-btn-add-meter {
    font-size: 0.8125rem;
  }

  .rege-btn-next,
  .rege-btn-submit {
    padding: 12px 20px;
    font-size: 0.875rem;
  }

  .rege-nav {
    flex-wrap: wrap;
    gap: 8px;
  }

  .rege-btn-submit {
    width: 100%;
    order: -1;
  }
}

/* ── Print — hide navigation, show all steps ─────────────────────────────── */

@media print {
  .rege-step { display: block !important; }
  .rege-progress,
  .rege-nav { display: none; }
}
