/* ==========================================================================
   MASE FORMS — [mase_form] shortcode + "MASE Form" page template.
   Two-column grid from 640px, single column on phones.
   ========================================================================== */

/* --- Page template --- */
.mase-form-page { padding: var(--section-py-sm) 0 var(--section-py); }

.mase-form-page__container {
  width: 100%;
  max-width: calc(860px + 2 * var(--container-gutter));
  margin: 0 auto;
  padding: 0 var(--container-gutter);
}

.mase-form-page__content {
  color: var(--navy-80);
  font-size: var(--fs-md);
  line-height: var(--lh-loose);
}

.mase-form-page__content > :first-child { margin-top: 0; }
.mase-form-page__content h2 { font-size: var(--fs-2xl); margin-top: var(--space-10); }
.mase-form-page__content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* --- Form card --- */
.mase-form {
  --mf-border: rgba(0, 0, 56, 0.16);
  --mf-error: var(--danger, #a10f18);
  margin: var(--space-8) 0;
  color: var(--navy);
  scroll-margin-top: calc(var(--header-height) + var(--space-6));
}

.mase-form-page__content > .mase-form:first-child { margin-top: 0; }

.mase-form__title {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
}

.mase-form__intro {
  max-width: 680px;
  margin-bottom: var(--space-6);
  color: var(--navy-80);
}

.mase-form__intro p { margin: 0; }
.mase-form__intro p + p { margin-top: var(--space-3); }

.mase-form__form {
  padding: clamp(20px, 4.5vw, 48px);
  background: var(--white);
  border: 1px solid var(--navy-08);
  border-top: 4px solid var(--navy);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.mase-form__required-note {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-3);
  margin: 0 0 var(--space-6);
  padding-bottom: var(--space-5);
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--navy-60);
  border-bottom: 1px solid var(--navy-08);
}

.mase-form__req { color: var(--mf-error); font-weight: 700; }

/* --- Grid --- */
.mase-form__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5) var(--space-6);
}

@media (min-width: 640px) {
  .mase-form__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mase-form__field--full { grid-column: 1 / -1; }
}

/* --- Field --- */
.mase-form__field { min-width: 0; }

.mase-form__label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: var(--space-2);
  cursor: pointer;
}

.mase-form__label-main {
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.35;
  color: var(--navy);
}

.mase-form__label-sub {
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.35;
  color: var(--navy-60);
}

.mase-form__input {
  display: block;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: var(--fs-md); /* ≥16px: no iOS zoom on focus */
  line-height: 1.4;
  color: var(--navy);
  background: #fafafc;
  border: 1.5px solid var(--mf-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.mase-form__input::placeholder { color: rgba(0, 0, 56, 0.38); }

.mase-form__select {
  padding-right: 46px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000038' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
  cursor: pointer;
  text-overflow: ellipsis;
}

.mase-form__select:invalid { color: rgba(0, 0, 56, 0.45); }
.mase-form__select option { color: var(--navy); }

.mase-form__input:hover { border-color: var(--navy-50); }

.mase-form__input:focus {
  background: var(--white);
  border-color: var(--navy);
  box-shadow: 0 0 0 4px var(--navy-08);
}

.mase-form__field.has-error .mase-form__input {
  border-color: var(--mf-error);
  background: #fffafa;
}

.mase-form__field.has-error .mase-form__input:focus { box-shadow: 0 0 0 4px rgba(161, 15, 24, 0.12); }

/* The shorthand backgrounds above (focus / error) must keep the dropdown arrow. */
.mase-form__field .mase-form__select,
.mase-form__field .mase-form__select:focus,
.mase-form__field.has-error .mase-form__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000038' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
}

.mase-form__error {
  display: flex;
  gap: 6px;
  margin: var(--space-2) 0 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--mf-error);
}

.mase-form__error::before {
  content: "!";
  flex: 0 0 16px;
  height: 16px;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  color: var(--white);
  background: var(--mf-error);
  border-radius: 50%;
}

.mase-form__error[hidden] { display: none; }

/* --- Consent checkbox --- */
.mase-form__consent { margin-top: var(--space-6); }

.mase-form__check {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--navy-80);
  cursor: pointer;
}

.mase-form__check input {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: 0;
  opacity: 0;
}

.mase-form__check-box {
  flex: 0 0 22px;
  height: 22px;
  background: #fafafc;
  border: 1.5px solid var(--mf-border);
  border-radius: 5px;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.mase-form__check input:checked + .mase-form__check-box {
  background: var(--navy) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 6 9 17l-5-5' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat;
  border-color: var(--navy);
}

.mase-form__check input:focus-visible + .mase-form__check-box { box-shadow: 0 0 0 4px var(--navy-08); border-color: var(--navy); }
.mase-form__consent.has-error .mase-form__check-box { border-color: var(--mf-error); }
.mase-form__check-text a { color: var(--accent); text-decoration: underline; }

/* --- Honeypot --- */
.mase-form__hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --- Submit --- */
.mase-form__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--navy-08);
}

.mase-form__submit {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: 14px var(--space-8);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--white);
  background: var(--navy);
  border: 2px solid var(--navy);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform 0.1s ease;
}

.mase-form__submit:hover { background: transparent; color: var(--navy); }
.mase-form__submit:active { transform: translateY(1px); }
.mase-form__submit:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.mase-form__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: mase-form-spin 0.7s linear infinite;
}

.mase-form__submit.is-loading { pointer-events: none; opacity: 0.85; }
.mase-form__submit.is-loading .mase-form__spinner { display: inline-block; }

@keyframes mase-form-spin { to { transform: rotate(360deg); } }

/* --- Status panels --- */
.mase-form__status {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  font-size: var(--fs-md);
  line-height: 1.6;
  border-radius: var(--radius-md);
  outline: none;
}

.mase-form__status p { margin: 0; }
.mase-form__status p + p { margin-top: var(--space-1); }

.mase-form__status--success {
  padding: clamp(24px, 4vw, 40px);
  color: #0f3d24;
  background: #eef8f2;
  border: 1px solid #b7e1c6;
  border-top: 4px solid #1f7a45;
}

.mase-form__status--success p:first-child { font-size: var(--fs-lg); font-weight: 700; }

.mase-form__status-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 9px;
  color: var(--white);
  background: #1f7a45;
  border-radius: 50%;
}

.mase-form__status--closed {
  color: var(--navy-80);
  background: var(--light);
  border-left: 4px solid var(--navy-50);
}

.mase-form__status--error {
  margin-bottom: var(--space-6);
  font-size: var(--fs-base);
  color: #6f0a10;
  background: #fdf2f2;
  border-left: 4px solid var(--mf-error);
}

.mase-form__admin-note {
  padding: var(--space-3) var(--space-4);
  background: #fff8e5;
  border-left: 4px solid var(--bullet);
}

/* --- Tablet & phone --- */
@media (max-width: 767px) {
  .mase-form__form { border-radius: var(--radius-sm); box-shadow: none; }
  .mase-form__required-note { flex-direction: column; }
  .mase-form__actions { justify-content: stretch; }
  .mase-form__submit { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .mase-form__spinner { animation-duration: 2s; }
}
