/* ============================================================
   Lusitanos — Application Form
   Full-screen, one-question-per-view application engine.
   Shared by the Members Club form and future mastermind
   event pages. Depends on funnel.css for the brand tokens.
   ============================================================ */

:root {
  /* Monospace stack for the "QUESTION 3 OF 9" counter and the
     BACK / CONTINUE labels. System fonts only — no extra download. */
  --ap-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ap-line: rgba(241, 232, 212, 0.16);
  --ap-line-strong: rgba(241, 232, 212, 0.34);
}

/* ------------------------------------------------------------ */
/* Shell — locks the form to exactly one viewport, no page scroll */
/* ------------------------------------------------------------ */
html.ap-html,
body.ap-body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body.ap-body {
  background: var(--fn-oxblood);
  color: var(--fn-ink-on-dark);
  font-family: var(--fn-body);
  -webkit-font-smoothing: antialiased;
}

.ap-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh; /* small viewport height — avoids iOS toolbar clipping */
  position: relative;
}

/* ------------------------------------------------------------ */
/* Header — crest, question counter, dash progress               */
/* ------------------------------------------------------------ */
.ap-head {
  flex: 0 0 auto;
  padding: clamp(18px, 3.5vh, 34px) 24px 0;
  text-align: center;
}

.ap-head__crest {
  width: 30px;
  height: auto;
  margin: 0 auto clamp(12px, 2.4vh, 22px);
  opacity: 0.5;
}

.ap-counter {
  font-family: var(--ap-mono);
  font-size: 0.66rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(241, 232, 212, 0.4);
}
.ap-counter b {
  font-weight: 700;
  color: var(--fn-gold-bright);
}

/* Dash progress: one short rule per question. */
.ap-dashes {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}
.ap-dash {
  width: 38px;
  height: 2px;
  background: rgba(241, 232, 212, 0.11);
  transition: background 0.45s var(--fn-ease);
}
.ap-dash.is-done { background: var(--fn-gold); }
.ap-dash.is-current { background: rgba(241, 232, 212, 0.72); }

/* ------------------------------------------------------------ */
/* Stage — the question itself, vertically centred               */
/* ------------------------------------------------------------ */
.ap-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vh, 32px) clamp(20px, 5vw, 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ap-step {
  width: 100%;
  max-width: 780px;
  margin: auto;
  text-align: center;
}

/* Enter / exit transitions. Forward and back read differently so
   the direction of travel is legible. */
.ap-step {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.34s var(--fn-ease), transform 0.34s var(--fn-ease);
}
.ap-step.is-leaving-fwd { opacity: 0; transform: translateY(-16px); }
.ap-step.is-leaving-back { opacity: 0; transform: translateY(16px); }
.ap-step.is-entering-fwd { opacity: 0; transform: translateY(16px); }
.ap-step.is-entering-back { opacity: 0; transform: translateY(-16px); }

@media (prefers-reduced-motion: reduce) {
  .ap-step,
  .ap-step.is-leaving-fwd,
  .ap-step.is-leaving-back,
  .ap-step.is-entering-fwd,
  .ap-step.is-entering-back {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------ */
/* Question typography                                           */
/* ------------------------------------------------------------ */
.ap-q {
  font-family: var(--fn-serif);
  font-style: normal;
  font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: -0.005em;
  color: var(--fn-cream);
  text-wrap: balance;
}

.ap-qsub {
  font-family: var(--fn-body);
  font-size: clamp(0.86rem, 1.2vw, 0.95rem);
  line-height: 1.55;
  color: rgba(241, 232, 212, 0.45);
  max-width: 540px;
  margin: 0.9rem auto 0;
  text-wrap: pretty;
}

/* Live "(2/3 selected)" counter for multi-select questions. */
.ap-qcount {
  font-family: var(--fn-body);
  font-size: 0.82rem;
  color: rgba(241, 232, 212, 0.38);
  margin-top: 0.5rem;
}

.ap-field { margin-top: clamp(1.6rem, 4vh, 2.8rem); }

/* ------------------------------------------------------------ */
/* Text input — transparent, centred, thin bottom rule           */
/* ------------------------------------------------------------ */
.ap-input {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0.5rem 0.2rem 0.85rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ap-line-strong);
  border-radius: 0;
  color: var(--fn-cream);
  font-family: var(--fn-body);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.4;
  text-align: center;
  outline: none;
  transition: border-color 0.3s var(--fn-ease);
  -webkit-appearance: none;
  appearance: none;
}
.ap-input::placeholder { color: rgba(241, 232, 212, 0.3); }
.ap-input:focus { border-bottom-color: var(--fn-gold); }

/* ------------------------------------------------------------ */
/* Long text — full bordered box, left aligned                   */
/* ------------------------------------------------------------ */
.ap-textarea {
  display: block;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  min-height: clamp(120px, 20vh, 168px);
  padding: 1rem 1.1rem;
  background: transparent;
  border: 1px solid var(--ap-line-strong);
  border-radius: 0;
  color: var(--fn-cream);
  font-family: var(--fn-body);
  font-size: clamp(0.98rem, 1.5vw, 1.08rem);
  line-height: 1.6;
  text-align: left;
  resize: none;
  outline: none;
  transition: border-color 0.3s var(--fn-ease);
}
.ap-textarea::placeholder { color: rgba(241, 232, 212, 0.3); }
.ap-textarea:focus { border-color: var(--fn-gold); }

/* ------------------------------------------------------------ */
/* Phone — country code select + number on one rule              */
/* ------------------------------------------------------------ */
.ap-phone {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(14px, 3vw, 34px);
  max-width: 620px;
  margin: 0 auto;
}
.ap-phone__code { flex: 0 0 auto; text-align: left; }
.ap-phone__label {
  display: block;
  font-family: var(--ap-mono);
  font-size: 0.6rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(241, 232, 212, 0.38);
  margin-bottom: 0.45rem;
}
.ap-select {
  width: 88px;
  padding: 0.5rem 0.2rem 0.85rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ap-line-strong);
  border-radius: 0;
  color: var(--fn-cream);
  font-family: var(--fn-body);
  font-size: 1.05rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.3s var(--fn-ease);
  -webkit-appearance: none;
  appearance: none;
  /* Chevron, drawn inline so there's no extra asset request. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f1e8d4' stroke-opacity='.5' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px bottom 1.1rem;
  background-size: 11px;
}
.ap-select:focus { border-bottom-color: var(--fn-gold); }
/* The native dropdown list renders in OS chrome — force legible colours. */
.ap-select option { background: #2a0a0e; color: #f1e8d4; }
.ap-phone__number { flex: 1 1 auto; min-width: 0; }
.ap-phone .ap-input { max-width: none; }

/* ------------------------------------------------------------ */
/* Option cards — radio + multi-check                            */
/* ------------------------------------------------------------ */
.ap-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
  text-align: left;
}

.ap-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 0.95rem 1.15rem;
  background: transparent;
  border: 1px solid var(--ap-line);
  color: rgba(241, 232, 212, 0.62);
  font-family: var(--fn-body);
  font-size: clamp(0.9rem, 1.4vw, 1rem);
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.25s var(--fn-ease),
              color 0.25s var(--fn-ease),
              background-color 0.25s var(--fn-ease);
}
.ap-opt:hover {
  border-color: var(--ap-line-strong);
  color: var(--fn-cream);
}
.ap-opt:focus-visible {
  outline: 1px solid var(--fn-gold);
  outline-offset: 2px;
}
.ap-opt.is-selected {
  border-color: var(--fn-gold);
  color: var(--fn-cream);
  background: rgba(184, 146, 74, 0.09);
}

/* The hollow circle / check on the right of each card. */
.ap-opt__mark {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border: 1px solid rgba(241, 232, 212, 0.32);
  border-radius: 50%;
  position: relative;
  transition: border-color 0.25s var(--fn-ease);
}
.ap-opt--multi .ap-opt__mark { border-radius: 2px; }
.ap-opt.is-selected .ap-opt__mark { border-color: var(--fn-gold); }
.ap-opt.is-selected .ap-opt__mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--fn-gold);
  border-radius: inherit;
}

/* Multi-select cards grey out once the cap is reached. */
.ap-opt.is-blocked { opacity: 0.32; cursor: not-allowed; }

/* ------------------------------------------------------------ */
/* Footer — back / continue / progress line                      */
/* ------------------------------------------------------------ */
.ap-foot {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(14px, 2.4vh, 22px) clamp(20px, 5vw, 48px) clamp(18px, 3vh, 28px);
}

.ap-back,
.ap-next {
  font-family: var(--ap-mono);
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.28s var(--fn-ease);
  border: 0;
  background: none;
}

.ap-back {
  color: rgba(241, 232, 212, 0.38);
  padding: 0.6rem 0.2rem;
}
.ap-back:hover { color: var(--fn-cream); }
.ap-back[hidden] { visibility: hidden; display: block; } /* hold the layout slot */

.ap-next {
  padding: 0.95rem 1.9rem;
  background: rgba(241, 232, 212, 0.14);
  color: rgba(241, 232, 212, 0.55);
  border: 1px solid transparent;
}
.ap-next:not(:disabled):hover {
  background: var(--fn-gold);
  color: var(--fn-oxblood);
}
.ap-next:disabled { opacity: 0.4; cursor: not-allowed; }
.ap-next.is-ready {
  background: rgba(241, 232, 212, 0.9);
  color: var(--fn-oxblood);
}
.ap-next.is-ready:hover { background: var(--fn-gold); }

/* Hairline that fills left-to-right across the whole form. */
.ap-progressline {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1px;
  width: 100%;
  background: rgba(241, 232, 212, 0.08);
}
.ap-progressline__fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--fn-gold);
  transition: width 0.5s var(--fn-ease);
}

/* ------------------------------------------------------------ */
/* Validation message                                            */
/* ------------------------------------------------------------ */
.ap-error {
  font-family: var(--fn-body);
  font-size: 0.84rem;
  color: #d98b8b;
  margin-top: 0.9rem;
  min-height: 1.2em;
}

/* ------------------------------------------------------------ */
/* Submitting overlay                                            */
/* ------------------------------------------------------------ */
.ap-sending {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.2rem;
  background: var(--fn-oxblood);
}
.ap-sending.is-on { display: flex; }
.ap-sending__label {
  font-family: var(--ap-mono);
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(241, 232, 212, 0.5);
}
.ap-sending__bar {
  width: 160px;
  height: 1px;
  background: rgba(241, 232, 212, 0.14);
  overflow: hidden;
}
.ap-sending__bar span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--fn-gold);
  animation: apSweep 1.1s var(--fn-ease) infinite;
}
@keyframes apSweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ------------------------------------------------------------ */
/* Mobile                                                        */
/* ------------------------------------------------------------ */
@media (max-width: 620px) {
  .ap-dash { width: 22px; gap: 7px; }
  .ap-dashes { gap: 7px; }
  .ap-head__crest { width: 26px; }
  .ap-foot { padding-left: 20px; padding-right: 20px; }
  .ap-next { padding: 0.85rem 1.3rem; font-size: 0.62rem; letter-spacing: 0.18em; }
  .ap-back { font-size: 0.62rem; letter-spacing: 0.18em; }
  .ap-opt { padding: 0.85rem 1rem; }
  /* Options can outgrow one screen on mobile — let the stage scroll. */
  .ap-stage { align-items: flex-start; }
  .ap-step { margin-top: 0; }
}

@media (max-width: 380px) {
  .ap-dash { width: 16px; }
}
