/* AIOBEU Membership Form — desktop + mobile */
:root {
  --paper: #ffffff;
  --ink: #000000;
  --muted: #333333;
  --bg: #eceff3;
  --ok: #166534;
  --danger: #991b1b;
  --accent: #8b1515;
  --accent-dark: #6f1010;
  --font: Arial, Helvetica, sans-serif;
  --tap: 48px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
}

.page {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 1rem 0.75rem 2.5rem;
}

.alert {
  padding: 0.85rem 1rem;
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
  border: 1px solid transparent;
  border-radius: 6px;
  word-break: break-word;
}

.alert-success {
  background: #e7f6ec;
  border-color: #9cccaf;
  color: var(--ok);
}

.alert-error {
  background: #fdecec;
  border-color: #e5b4b4;
  color: var(--danger);
}

.pdf-download {
  margin-top: 0.6rem;
}

.pdf-download a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: #0b3d91;
  font-weight: 700;
  text-decoration: underline;
}

.form.sheet {
  background: var(--paper);
  border: 1px solid #c8c8c8;
  border-radius: 8px;
  padding: 1rem 1.15rem 1.35rem;
}

.org-header {
  margin: 0 0 0.85rem;
}

.header-banner {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.meta-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 320px;
  padding-top: 0.35rem;
  min-width: 0;
}

.line-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--tap);
}

.line-lbl {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  flex: 0 0 auto;
  min-width: 4.2rem;
}

.line-field input {
  flex: 1;
  border: none;
  border-bottom: 1px solid #000;
  border-radius: 0;
  background: transparent;
  padding: 0.55rem 0.2rem;
  font: inherit;
  font-size: 16px;
  min-width: 0;
  min-height: var(--tap);
}

.photo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.photo-hint {
  display: none;
  font-size: 12px;
  font-weight: 700;
  color: #555;
}

.is-hidden {
  display: none !important;
}

.photo-box {
  width: 120px;
  height: 140px;
  border: 2px solid #222;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  background: #fafafa;
  flex-shrink: 0;
  overflow: hidden;
  touch-action: manipulation;
}

.photo-box.has-file {
  border: none;
  background: #fff;
}

.photo-box input[type="file"],
.signature-box input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
  font-size: 16px;
}

.photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  background: #fff;
  z-index: 2;
}

.photo-placeholder,
.signature-placeholder {
  pointer-events: none;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: #666;
  text-align: center;
  padding: 0.5rem;
}

.photo-placeholder small,
.signature-placeholder small {
  font-size: 11px;
  font-weight: 600;
}

.signature-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-top: 1.5rem;
  gap: 0.4rem;
}

.signature-box {
  width: min(280px, 100%);
  height: 100px;
  border: 1px dashed #bbb;
  background: #ffffff;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}

.signature-box.has-file {
  border-style: solid;
  border-color: #ccc;
}

.signature-preview {
  position: absolute;
  inset: 8px 10px;
  width: calc(100% - 20px);
  height: calc(100% - 16px);
  object-fit: contain;
  object-position: center center;
  display: block;
  background: #ffffff;
  z-index: 2;
}

.signature-caption {
  width: min(280px, 100%);
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

.profile-title {
  margin: 1rem 0 0.9rem;
  text-align: center;
  font-family: var(--font);
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.profile-fields {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: field;
}

.profile-fields > li {
  counter-increment: field;
  display: grid;
  grid-template-columns: 2.35rem 1fr;
  gap: 0.3rem 0.45rem;
  margin-bottom: 0.85rem;
  align-items: center;
}

.profile-fields > li.tall,
.profile-fields > li.spouse-item {
  align-items: start;
}

.profile-fields > li::before {
  content: counter(field, decimal-leading-zero) ".";
  font-weight: 700;
  font-size: 13px;
  line-height: 1.45;
  padding-top: 0.15rem;
}

.spouse-block {
  min-width: 0;
  width: 100%;
}

.inline-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  min-width: 0;
  width: 100%;
}

.lbl {
  flex: 0 1 auto;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.35;
  white-space: nowrap;
}

.inline-field input,
.inline-field select,
.inline-field textarea,
.line-field input {
  -webkit-appearance: none;
  appearance: none;
}

.inline-field input,
.inline-field select,
.inline-field textarea {
  flex: 1 1 160px;
  min-width: 120px;
  min-height: var(--tap);
  border: none;
  border-bottom: 1px solid #ccc;
  border-radius: 0;
  background: transparent;
  padding: 0.55rem 0.25rem;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--ink);
  outline: none;
}

.inline-field select {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
}

.inline-field textarea {
  min-height: 4.5rem;
  resize: vertical;
  line-height: 1.4;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
}

.inline-field input:focus,
.inline-field select:focus,
.inline-field textarea:focus,
.line-field input:focus {
  outline: none;
  background: #f7f9fc;
  border-color: #888;
}

.field-error {
  display: block;
  width: 100%;
  flex: 1 0 100%;
  margin: 0.2rem 0 0;
  padding: 0;
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: #d32f2f;
  line-height: 1.35;
  white-space: normal;
}

.inline-field.has-error {
  flex-wrap: wrap;
}

/* Keep inputs normal — only the message text is red */
.inline-field input.is-invalid,
.inline-field select.is-invalid,
.inline-field textarea.is-invalid,
.photo-box.is-invalid {
  box-shadow: none;
}

.photo-wrap .field-error {
  text-align: center;
  margin-top: 0.35rem;
}

.spouse-item .lbl {
  white-space: normal;
}

.spouse-item .inline-field select#spouse_employed {
  flex: 0 0 110px;
  max-width: 120px;
  min-width: 90px;
}

.spouse-details-wrap {
  display: none;
  width: 100%;
  margin-top: 0.55rem;
}

.spouse-details-wrap.is-open {
  display: block;
}

.spouse-details-field {
  width: 100%;
  flex-wrap: nowrap;
}

.spouse-details-field .lbl {
  flex: 0 0 auto;
  white-space: nowrap;
}

.spouse-details-field input {
  flex: 1 1 auto;
  min-width: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px dashed #999;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
  min-height: var(--tap);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  touch-action: manipulation;
}

.btn:hover { background: var(--accent-dark); }

.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn.is-loading {
  opacity: 0.72;
  cursor: wait;
  pointer-events: none;
}

.btn-ghost {
  background: #fff;
  color: #333;
  border: 1px solid #999;
}

.btn-ghost:hover { background: #f3f3f3; }

/* Thank-you popup */
body.thanks-lock { overflow: hidden; }

.thanks-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(20, 16, 16, 0.55);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.thanks-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.thanks-overlay[hidden] {
  display: none !important;
}

.thanks-overlay.is-open[hidden] {
  display: grid !important;
}

.thanks-card {
  position: relative;
  width: min(380px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 1.75rem 1.4rem 1.35rem;
  text-align: center;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
  transform: translateY(18px) scale(0.94);
  opacity: 0;
  overflow: hidden;
}

.thanks-overlay.is-open .thanks-card {
  animation: thanksPop 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes thanksPop {
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.thanks-burst {
  position: absolute;
  inset: -40% -20% auto;
  height: 140px;
  background: radial-gradient(circle at 50% 80%, rgba(139, 21, 21, 0.16), transparent 65%);
  pointer-events: none;
}

.thanks-check {
  display: grid;
  place-items: center;
  margin: 0 auto 0.85rem;
}

.thanks-circle {
  stroke: #1f8f4e;
  stroke-width: 2.5;
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
}

.thanks-tick {
  stroke: #1f8f4e;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
}

.thanks-overlay.is-open .thanks-circle {
  animation: thanksDraw 0.55s ease-out 0.15s forwards;
}

.thanks-overlay.is-open .thanks-tick {
  animation: thanksDraw 0.4s ease-out 0.45s forwards;
}

@keyframes thanksDraw {
  to { stroke-dashoffset: 0; }
}

.thanks-card h2 {
  margin: 0 0 0.45rem;
  font-size: 1.45rem;
  color: #1a1a1a;
}

.thanks-card p {
  margin: 0 0 1.25rem;
  color: #555;
  line-height: 1.45;
  font-size: 0.98rem;
}

.thanks-ok {
  min-width: 140px;
}

/* ---- Tablet / Mobile ---- */
@media (max-width: 768px) {
  body {
    background: #e8ebf0;
  }

  .page {
    padding: 0.65rem 0.55rem 2.5rem;
    width: 100%;
  }

  .alert {
    margin-bottom: 0.75rem;
    border-radius: 10px;
  }

  .form.sheet {
    padding: 0.85rem 0.75rem 1.35rem;
    border-radius: 14px;
    border: 1px solid #d5d9e0;
    box-shadow: 0 8px 24px rgba(20, 24, 40, 0.06);
  }

  .org-header {
    margin-bottom: 1rem;
    border-radius: 10px;
    overflow: hidden;
  }

  .meta-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
    padding: 0.85rem;
    background: #f7f8fb;
    border: 1px solid #e2e6ee;
    border-radius: 12px;
  }

  .meta-fields {
    max-width: none;
    width: 100%;
    gap: 0.75rem;
    padding-top: 0;
    order: 2;
  }

  .photo-wrap {
    order: 1;
    width: 100%;
    padding-bottom: 0.35rem;
    border-bottom: 1px dashed #cfd5e0;
    margin-bottom: 0.15rem;
    padding-bottom: 0.85rem;
  }

  .photo-hint {
    display: block;
  }

  .photo-box {
    width: min(132px, 40vw);
    height: min(156px, 48vw);
    border-radius: 10px;
    border-width: 1.5px;
    border-style: dashed;
  }

  .line-field {
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    min-height: 0;
    background: #fff;
    border: 1px solid #dde2ea;
    border-radius: 10px;
    padding: 0.55rem 0.7rem 0.45rem;
  }

  .line-lbl {
    font-size: 12px;
    color: #555;
    min-width: 0;
    letter-spacing: 0.02em;
  }

  .line-field input {
    border-bottom: none;
    min-height: 40px;
    padding: 0.25rem 0;
  }

  .lbl {
    white-space: normal;
  }

  .profile-title {
    margin: 1.15rem 0 0.85rem;
    font-size: 1.05rem;
    letter-spacing: 0.04em;
  }

  .profile-fields > li {
    display: block;
    position: relative;
    margin-bottom: 0.7rem;
    padding: 0.75rem 0.8rem 0.8rem 2.55rem;
    background: #fff;
    border: 1px solid #e2e6ee;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
  }

  .profile-fields > li::before {
    position: absolute;
    left: 0.7rem;
    top: 0.85rem;
    padding-top: 0;
    font-size: 12px;
    color: var(--accent);
    min-width: 1.5rem;
  }

  .inline-field {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .lbl {
    font-size: 12px;
    width: 100%;
    color: #444;
    line-height: 1.35;
  }

  .inline-field input,
  .inline-field select,
  .inline-field textarea {
    flex: none;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    font-size: 16px;
    border: 1px solid #d5dae3;
    border-radius: 9px;
    background: #fbfcfe;
    padding: 0.65rem 0.75rem;
  }

  .inline-field textarea {
    min-height: 5.25rem;
  }

  .inline-field input:focus,
  .inline-field select:focus,
  .inline-field textarea:focus,
  .line-field:focus-within {
    border-color: #b9c0cc;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(139, 21, 21, 0.08);
  }

  .line-field:focus-within {
    border-color: #b9c0cc;
  }

  .spouse-item .inline-field select#spouse_employed {
    flex: none;
    max-width: none;
    width: 100%;
  }

  .spouse-details-wrap {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px dashed #d7dbe3;
  }

  .spouse-details-field {
    flex-wrap: wrap;
  }

  .spouse-details-field .lbl,
  .spouse-details-field input {
    width: 100%;
    flex: none;
  }

  .signature-block {
    align-items: stretch;
    margin-top: 1rem;
    padding: 0.85rem;
    background: #f7f8fb;
    border: 1px solid #e2e6ee;
    border-radius: 12px;
  }

  .signature-box {
    width: 100%;
    height: 120px;
    border-radius: 10px;
    background: #fff;
  }

  .signature-caption {
    width: 100%;
    font-size: 13px;
    color: #555;
  }

  .actions {
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: none;
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent, #fff 28%);
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
    z-index: 5;
  }

  .btn {
    width: 100%;
    justify-content: center;
    border-radius: 11px;
    min-height: 50px;
    box-shadow: 0 6px 14px rgba(139, 21, 21, 0.22);
  }

  .btn-ghost {
    box-shadow: none;
  }

  .thanks-card {
    width: min(360px, calc(100% - 0.5rem));
    padding: 1.5rem 1.15rem 1.2rem;
  }
}

@media (max-width: 380px) {
  .form.sheet {
    padding: 0.7rem 0.55rem 1.15rem;
    border-radius: 12px;
  }

  .profile-fields > li {
    padding-left: 2.35rem;
  }

  .lbl {
    font-size: 11.5px;
  }
}
