/* Registration block — block-scoped styles.
   Field layout (.reg-grid/.reg-row/.reg-section-title/.reg-radio/.reg-terms)
   is ported from the design system course-page.css. Theme-global styles
   (.mandatory-empty, .onSuccess, .onError, .normally-hidden, .g-recaptcha,
   .cta-button, .recaptcha-terms) live in style.css and are NOT repeated here. */

.fs-registration {
  background: var(--color-surface-alt);
  padding: 28px;
  margin-top: 32px;
  /* Anchor jumps to #inscription (sidebar CTA, deep links) must clear the same
     sticky chrome the sidebar clears: header + session rail + gap. */
  scroll-margin-top: calc(
    var(--fs-header-h, 76px) + var(--fs-rail-h, 0px) + var(--sl-sticky-gap, 16px)
  );
}

.fs-registration .reg-head {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border-light);
}

.fs-registration .reg-head h2 {
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: -0.01em;
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.fs-registration .reg-head .for-session {
  color: var(--color-text-sub);
  font-size: 0.9rem;
  margin: 0;
}

.fs-registration .reg-head .for-session strong {
  color: var(--color-primary);
}

/* ----- Section titles -------------------------------------------------- */
.fs-registration .reg-section-title {
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: -0.01em;
  font-size: 1.05rem;
  margin: 1.5rem 0 0.8rem;
}

.fs-registration .reg-note {
  color: var(--color-text-sub);
  font-size: 0.9rem;
  margin: 0 0 0.8rem;
}

/* ----- Field grid ------------------------------------------------------ */
.fs-registration .reg-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 600px) {
  .fs-registration .reg-grid {
    grid-template-columns: 1fr;
  }
}

.fs-registration .reg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fs-registration .reg-row.span-2 {
  grid-column: 1 / -1;
}

.fs-registration .reg-row label {
  font-size: 0.8rem;
  color: var(--color-primary);
  font-weight: 600;
}

.fs-registration .reg-row input,
.fs-registration .reg-row select,
.fs-registration .reg-row textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  padding: 9px 12px;
  font: inherit;
  background: #fff;
  outline: none;
}
.fs-registration .reg-row input:focus,
.fs-registration .reg-row select:focus,
.fs-registration .reg-row textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-color: var(--color-accent);
}

/* ----- Billing radios -------------------------------------------------- */
.fs-registration .reg-radio {
  display: flex;
  gap: 24px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  border: 0;
  padding: 0;
  min-inline-size: 0;
}
.fs-registration .reg-radio label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 0.95rem;
  color: var(--color-text);
}
.fs-registration .reg-radio input[type="radio"] {
  width: auto;
}

/* ----- Terms checkbox -------------------------------------------------- */
.fs-registration .reg-terms {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 18px;
  font-size: 0.9rem;
  color: var(--color-text-sub);
}
.fs-registration .reg-terms input[type="checkbox"] {
  width: auto;
}
.fs-registration .reg-terms.mandatory-empty label,
.fs-registration .reg-terms.mandatory-empty label a {
  color: var(--color-error);
}

/* Visually hidden legend (accessible label for the radio group). */
.fs-registration .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;
}

/* ----- Required / optional markers ------------------------------------- */
.fs-registration .reg-row label .req {
  color: var(--color-cta, #e2001a);
  font-weight: 600;
}
.fs-registration .reg-row label .opt {
  color: var(--color-text-sub);
  font-weight: 400;
  font-size: 0.75rem;
}

/* ----- Editor-only placeholder box ------------------------------------- */
/* Inline-editable placeholder box shown in the block editor only (render.php
   emits real inputs). Styled like the field so editors type the placeholder
   straight in. Never appears on the front end. */
.fs-registration .reg-row .fs-ph-edit {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  padding: 9px 12px;
  background: #fff;
  color: var(--color-text-muted, #6b7280);
  min-height: 40px;
  cursor: text;
}
.fs-registration .reg-row .fs-ph-edit.fs-ph-edit--area {
  min-height: 96px;
}

/* ----- ph-label: placeholder acts as the label on mobile --------------- */
/* On desktop the visible <label> already names the field, so hide the
   duplicate placeholder text (revealed at the mobile breakpoint below).
   Fields with a genuine hint (e-mail example) are NOT ph-label, so their hint
   stays visible everywhere. */
.fs-registration .reg-row input.ph-label::placeholder {
  color: transparent;
}

/* Phone field (intl-tel-input wraps the input in .iti and sets a left padding
   for the flag); keep it full width and match the other inputs' height. */
.fs-registration .reg-row .iti {
  display: block;
  width: 100%;
}
.fs-registration .reg-row input[type="tel"] {
  padding-top: 9px !important;
  padding-bottom: 9px !important;
}

@media (max-width: 600px) {
  /* Compact form: placeholders act as labels. Hide each field's visible label
     but keep it in the DOM (visually hidden, never display:none) so screen
     readers still announce the field. Radio labels (in .reg-radio) and the
     terms label (in .reg-terms) are not .reg-row children, so they stay. */
  .fs-registration .reg-row > label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  .fs-registration .reg-row {
    gap: 0;
  }
  /* Reveal the ph-label placeholders that are transparent on desktop. */
  .fs-registration .reg-row input.ph-label::placeholder {
    color: var(--color-text-muted, #6b7280);
  }
}

/* ----- Civilité segmented control (Mme / M) — reused from contact-form --- */
.fs-registration .seg {
  display: inline-flex;
  border: 1px solid var(--color-rule, #d8dde3);
  background: #fff;
}
.fs-registration .seg input {
  position: absolute;
  width: auto; /* undo .reg-row input width:100% — these are visually hidden and would otherwise stretch to the viewport, causing horizontal overflow */
  opacity: 0;
  pointer-events: none;
}
.fs-registration .seg label {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  border-right: 1px solid var(--color-rule, #d8dde3);
}
.fs-registration .seg label:last-of-type {
  border-right: 0;
}
.fs-registration .seg input:checked + label {
  background: var(--color-primary);
  color: #fff;
}

/* ----- Foldable "unfold" variant --------------------------------------- */
/* Progressive enhancement: the form ships open and the toggle is hidden.
   view.js adds `is-ready` (revealing the toggle) then `is-collapsed`, so a
   no-JS visitor still sees the full, usable form. */
.fs-registration.reg-unfold .reg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.fs-registration.reg-unfold.is-collapsed .reg-head {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}
.fs-registration.reg-unfold .reg-head-text {
  min-width: 0;
}

.fs-registration .reg-toggle {
  display: none;
  flex: none;
  white-space: nowrap;
}
.fs-registration.reg-unfold.is-ready .reg-toggle {
  display: inline-flex;
}
.fs-registration .reg-toggle--open {
  padding: 12px 22px;
}
.fs-registration .reg-toggle--close {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-sub);
  padding: 8px 16px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.fs-registration .reg-toggle--close:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.fs-registration.reg-unfold .reg-foldable {
  transition: max-height 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}
.fs-registration.reg-unfold.is-collapsed .reg-foldable {
  overflow: hidden;
  max-height: 0;
}
@media (prefers-reduced-motion: reduce) {
  .fs-registration.reg-unfold .reg-foldable {
    transition: none;
  }
}

/* Success / error feedback panels — revealed by js/script.js after submit. The
   global style.css only sets the text colour on .onSuccess/.onError; this adds
   the filled tint + accent left border from the design system's .reg-success
   treatment (course-page.css), with the error state mirrored in the error
   colour. Scoped to .fs-registration so the shared classes on the contact form
   and legacy forms are untouched. Text/link colours stay inherited from global. */
.fs-registration .onSuccess,
.fs-registration .onError {
  padding: 16px 20px;
  font-size: 0.95rem;
  border-left: 3px solid;
}
.fs-registration .onSuccess {
  background: #f0f7f0;
  border-left-color: var(--color-success);
}
.fs-registration .onError {
  background: #fbf0f0;
  border-left-color: var(--color-error);
}
.fs-registration .onSuccess p,
.fs-registration .onError p {
  margin: 0;
}

/* Print: the registration form is interactive (Bexio submission) and useless on
   paper — drop it entirely. */
@media print {
  .fs-registration {
    display: none;
  }
}
