/* ============================================================
   EINIEX — Application flow (Typeform-style)
   Light, off-white, dot-grid. One question per screen.
   Builds on einiex.css for fonts + wordmark.
   ============================================================ */

:root {
  --ok:  oklch(0.58 0.13 152);   /* valid green */
  --bad: oklch(0.57 0.18 27);    /* invalid red */
  --ease-step: cubic-bezier(0.22, 1, 0.36, 1);
}

html, body { height: 100%; }
body {
  /* force the application flow to the light, off-white palette */
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ---------- dot-grid texture ---------- */
.ap-dots {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--text) 12%, transparent) 1.1px, transparent 1.1px);
  background-size: 26px 26px;
  background-position: -13px -13px;
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, #000 55%, transparent 100%);
  mask-image: radial-gradient(ellipse 90% 80% at 50% 45%, #000 55%, transparent 100%);
  opacity: 0.9;
}

/* ============================================================
   CHROME — logo, progress, counter, back
   ============================================================ */
.ap-app { position: fixed; inset: 0; z-index: 3; }

.ap-logo {
  position: fixed; top: clamp(1.25rem, 3.5vh, 2.25rem); left: clamp(1.25rem, 4vw, 2.75rem);
  z-index: 20; display: inline-flex; align-items: center;
}
.ap-logo .wordmark { font-size: 1.0625rem; letter-spacing: 0.3em; }

.ap-meter {
  position: fixed; top: clamp(1.4rem, 3.6vh, 2.4rem); right: clamp(1.25rem, 4vw, 2.75rem);
  z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: 0.55rem;
  width: clamp(8rem, 16vw, 12rem);
}
.ap-meter__track {
  width: 100%; height: 2px; border-radius: 2px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  overflow: hidden;
}
.ap-meter__fill {
  display: block; height: 100%; width: 0%;
  background: var(--text); border-radius: 2px;
  transition: width 0.5s var(--ease-step);
}
.ap-meter__count {
  font-family: var(--font-mono), monospace;
  font-size: 0.6875rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-2); font-variant-numeric: tabular-nums;
}

.ap-back {
  position: fixed; bottom: clamp(1.25rem, 4vh, 2.5rem); left: clamp(1.25rem, 4vw, 2.75rem);
  z-index: 20; display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 0.85rem 0.55rem 0.6rem; border-radius: 0.6rem;
  background: transparent; border: 1px solid var(--border);
  font-family: var(--font-mono), monospace; font-size: 0.6875rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-2); cursor: pointer;
  opacity: 0; visibility: hidden; transform: translateY(4px);
  transition: opacity 0.35s ease, transform 0.35s var(--ease-step), visibility 0.35s, border-color 0.25s ease, color 0.25s ease;
}
.ap-back.is-shown { opacity: 1; visibility: visible; transform: none; }
.ap-back:hover { border-color: var(--text); color: var(--text); }
.ap-back svg { width: 0.85rem; height: 0.85rem; }

/* ============================================================
   STEP STAGE
   ============================================================ */
.ap-stage { position: fixed; inset: 0; z-index: 5; }

.ap-step {
  position: absolute; inset: 0;
  display: flex; align-items: safe center; justify-content: flex-start;
  padding: 7rem clamp(1.5rem, 8vw, 9rem) 7rem;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  opacity: 0; visibility: hidden; pointer-events: none;
}
.ap-step::-webkit-scrollbar { width: 0; height: 0; }
.ap-step { scrollbar-width: none; }
.ap-step.is-active { opacity: 1; visibility: visible; pointer-events: auto; }

.ap-step__inner { width: 100%; max-width: 44rem; margin: 0 auto; }

/* entrance / exit animations (set via JS classes) */
@media (prefers-reduced-motion: no-preference) {
  .ap-step.anim-in-up   { animation: stepInUp   0.32s var(--ease-step) both; }
  .ap-step.anim-out-up  { animation: stepOutUp  0.30s var(--ease-step) both; }
  .ap-step.anim-in-down { animation: stepInDown 0.32s var(--ease-step) both; }
  .ap-step.anim-out-down{ animation: stepOutDown 0.30s var(--ease-step) both; }
}
@keyframes stepInUp   { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes stepOutUp  { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-40px); } }
@keyframes stepInDown { from { opacity: 0; transform: translateY(-40px); } to { opacity: 1; transform: none; } }
@keyframes stepOutDown{ from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(40px); } }

/* ---------- question typography ---------- */
.ap-kicker {
  display: inline-flex; align-items: center; gap: 0.55em;
  font-family: var(--font-mono), monospace; font-size: 0.6875rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-2);
  margin-bottom: 1.35rem;
}
.ap-kicker__no { color: var(--text); }
.ap-kicker__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text); display: inline-block; }

.ap-q {
  font-family: var(--font-display), sans-serif; font-weight: 500;
  font-size: clamp(2rem, 5.2vw, 3.5rem); line-height: 1.04;
  letter-spacing: -0.03em; color: var(--text); max-width: 18ch;
  text-wrap: balance;
}
.ap-q em { font-family: var(--font-serif), serif; font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.ap-sub {
  margin-top: 0.95rem; font-size: clamp(0.95rem, 1.6vw, 1.0625rem);
  line-height: 1.55; color: var(--text-2); max-width: 48ch;
}

/* ---------- floating inputs (no box, single bottom line) ---------- */
.ap-field { position: relative; margin-top: 2.5rem; }
.ap-input, .ap-textarea {
  width: 100%; border: 0; background: transparent; outline: none;
  font-family: var(--font-display), sans-serif; color: var(--text);
  font-size: clamp(1.5rem, 3.2vw, 2.25rem); font-weight: 400; letter-spacing: -0.02em;
  padding: 0.35em 0 0.4em; line-height: 1.2;
}
.ap-input::placeholder, .ap-textarea::placeholder { color: color-mix(in srgb, var(--text) 26%, transparent); }
.ap-input:-webkit-autofill { -webkit-text-fill-color: var(--text); transition: background-color 9999s; }

/* resting hairline + animated focus line */
.ap-line { position: relative; height: 1px; background: var(--border); margin-top: 0.1rem; }
.ap-line::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 100%; height: 2px;
  background: var(--text); transform: scaleX(0); transform-origin: left;
  transition: transform 0.5s var(--ease-step), background-color 0.25s ease;
}
.ap-field.is-focus .ap-line::after { transform: scaleX(1); }
.ap-field.is-valid   .ap-line::after { background: var(--ok); transform: scaleX(1); }
.ap-field.is-invalid .ap-line::after { background: var(--bad); transform: scaleX(1); }

/* validation glyph (email / url) */
.ap-vmark {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%) scale(0.6);
  width: 1.6rem; height: 1.6rem; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.35s var(--ease-step);
}
.ap-vmark svg { width: 100%; height: 100%; }
.ap-field.is-valid .ap-vmark.ok { opacity: 1; transform: translateY(-50%) scale(1); color: var(--ok); }
.ap-field.is-invalid .ap-vmark.bad { opacity: 1; transform: translateY(-50%) scale(1); color: var(--bad); }

.ap-error {
  margin-top: 0.85rem; font-family: var(--font-mono), monospace;
  font-size: 0.75rem; letter-spacing: 0.04em; color: var(--bad);
  opacity: 0; transform: translateY(-3px); transition: opacity 0.25s ease, transform 0.25s ease;
}
.ap-field.is-invalid + .ap-error { opacity: 1; transform: none; }

/* ---------- two-field (city / country) ---------- */
.ap-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; margin-top: 2.5rem; }
.ap-duo .ap-field { margin-top: 0; }
.ap-fieldlabel {
  font-family: var(--font-mono), monospace; font-size: 0.65rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-2); display: block; margin-bottom: 0.35rem;
}

/* ---------- textarea ---------- */
.ap-textarea {
  resize: none; overflow: hidden; min-height: 1.6em; font-size: clamp(1.25rem, 2.6vw, 1.75rem);
}
.ap-count {
  margin-top: 0.85rem; display: flex; justify-content: flex-end;
  font-family: var(--font-mono), monospace; font-size: 0.72rem; letter-spacing: 0.08em;
  color: var(--text-2); font-variant-numeric: tabular-nums;
}
.ap-count b { color: var(--text); font-weight: 400; }
.ap-count.is-met b { color: var(--ok); }

/* ---------- "Other" reveal input (sector / role / intent) ---------- */
.ap-otherwrap { overflow: hidden; max-height: 0; opacity: 0; margin-top: 0;
  transition: max-height 0.4s var(--ease-step), opacity 0.35s ease, margin-top 0.4s var(--ease-step); }
.ap-otherwrap.is-open { max-height: 7rem; opacity: 1; margin-top: 1.75rem; }
.ap-otherwrap .ap-field { margin-top: 0; max-width: 30rem; }
.ap-input--sm { font-size: clamp(1.15rem, 2.4vw, 1.6rem); }

/* ---------- pills ---------- */
.ap-pills { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 2.4rem; max-width: 40rem; }
.ap-pill {
  appearance: none; cursor: pointer;
  font-family: var(--font-display), sans-serif; font-size: 1.0625rem; font-weight: 400;
  letter-spacing: -0.01em; color: var(--text);
  padding: 0.7em 1.25em; border-radius: 100px;
  background: transparent; border: 1px solid var(--border);
  transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease, transform 0.18s var(--ease-step);
  display: inline-flex; align-items: center; gap: 0.5em;
}
.ap-pill:hover { border-color: var(--text); }
.ap-pill:active { transform: scale(0.96); }
.ap-pill.is-on {
  background: var(--text); color: var(--bg); border-color: var(--text);
}
.ap-pill__tick { width: 0; height: 0.95em; overflow: hidden; opacity: 0; transition: width 0.25s var(--ease-step), opacity 0.2s ease; }
.ap-pill.is-on .ap-pill__tick { width: 0.95em; opacity: 1; }
.ap-pill__tick svg { width: 0.95em; height: 0.95em; display: block; }

/* ---------- large referral buttons ---------- */
.ap-bigpills { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.6rem; max-width: 40rem; }
.ap-bigpill {
  cursor: pointer; text-align: left;
  font-family: var(--font-display), sans-serif; font-size: 1.1875rem; font-weight: 500;
  letter-spacing: -0.01em; color: var(--text);
  padding: 1.6rem 1.6rem; border-radius: 1rem;
  background: transparent; border: 1px solid var(--border);
  transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease, transform 0.18s var(--ease-step);
  display: flex; flex-direction: column; gap: 0.5rem; min-height: 6.5rem; justify-content: space-between;
}
.ap-bigpill:hover { border-color: var(--text); }
.ap-bigpill.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }
.ap-bigpill__k { font-family: var(--font-mono), monospace; font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-2); }
.ap-bigpill.is-on .ap-bigpill__k { color: color-mix(in srgb, var(--bg) 70%, transparent); }

/* conditional referral-name field (height animates) */
.ap-reveal { overflow: hidden; max-height: 0; opacity: 0; margin-top: 0;
  transition: max-height 0.45s var(--ease-step), opacity 0.4s ease, margin-top 0.45s var(--ease-step); }
.ap-reveal.is-open { max-height: 11rem; opacity: 1; margin-top: 2rem; }
.ap-reveal__clip { min-height: 0; }

/* ============================================================
   ACTIONS — OK button / enter hint / skip
   ============================================================ */
.ap-actions { display: flex; align-items: center; gap: 1.5rem; margin-top: 2.4rem; min-height: 3rem; }

.ap-ok {
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.6em;
  font-family: var(--font-display), sans-serif; font-size: 1rem; font-weight: 500;
  color: var(--bg); background: var(--text); border: 0;
  padding: 0.85em 1.6em; border-radius: 100px;
  transition: transform 0.18s var(--ease-step), opacity 0.3s ease, background 0.25s ease;
  opacity: 0; transform: translateY(6px) scale(0.98); pointer-events: none;
}
.ap-ok.is-shown { opacity: 1; transform: none; pointer-events: auto; }
.ap-ok:hover { background: color-mix(in srgb, var(--text) 88%, var(--bg)); }
.ap-ok:active { transform: scale(0.96); }
.ap-ok svg { width: 0.9em; height: 0.9em; }

.ap-hint {
  display: inline-flex; align-items: center; gap: 0.55em;
  font-family: var(--font-mono), monospace; font-size: 0.72rem; letter-spacing: 0.08em;
  color: var(--text-2); opacity: 0; transition: opacity 0.45s ease; pointer-events: none;
}
.ap-hint.is-shown { opacity: 1; }
.ap-hint kbd {
  font-family: var(--font-mono), monospace; font-size: 0.7rem;
  border: 1px solid var(--border); border-radius: 0.35rem; padding: 0.15em 0.45em;
  color: var(--text); background: color-mix(in srgb, var(--text) 4%, transparent);
}

.ap-skip {
  font-family: var(--font-mono), monospace; font-size: 0.72rem; letter-spacing: 0.06em;
  color: var(--text-2); cursor: pointer; background: none; border: 0; padding: 0;
  margin-top: 1.6rem; display: inline-flex; align-items: center; gap: 0.4em;
  transition: color 0.2s ease;
}
.ap-skip:hover { color: var(--text); }

/* ============================================================
   REVIEW SCREEN
   ============================================================ */
.ap-review { width: 100%; max-width: 46rem; margin: 0 auto; }
.ap-review__head { margin-bottom: 2.75rem; }
.ap-review__h {
  font-family: var(--font-display), sans-serif; font-weight: 500;
  font-size: clamp(2rem, 4.6vw, 3.25rem); line-height: 1.04; letter-spacing: -0.03em;
}
.ap-review__sub { margin-top: 0.9rem; font-size: 1rem; line-height: 1.55; color: var(--text-2); max-width: 48ch; }

.ap-summary { border-top: 1px solid var(--border); margin-bottom: 2.5rem; }
.ap-srow {
  display: grid; grid-template-columns: 12rem 1fr auto; align-items: start; gap: 1.5rem;
  padding: 1.15rem 0.25rem; border-bottom: 1px solid var(--border); position: relative;
}
.ap-srow__k {
  font-family: var(--font-mono), monospace; font-size: 0.7rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-2); padding-top: 0.15rem;
}
.ap-srow__v { font-size: 1.0625rem; line-height: 1.45; color: var(--text); text-wrap: pretty; overflow-wrap: break-word; word-break: break-word; }
.ap-srow__v.is-empty { color: color-mix(in srgb, var(--text) 32%, transparent); }
.ap-srow__tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ap-srow__tag {
  font-family: var(--font-mono), monospace; font-size: 0.72rem; letter-spacing: 0.04em;
  border: 1px solid var(--border); border-radius: 100px; padding: 0.25em 0.7em; color: var(--text-2);
}
.ap-edit {
  opacity: 0; cursor: pointer; background: none; border: 0; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 0.35em; padding: 0.3rem 0.4rem; border-radius: 0.4rem;
  font-family: var(--font-mono), monospace; font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase;
  transition: opacity 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.ap-srow:hover .ap-edit { opacity: 1; }
.ap-edit:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.ap-edit svg { width: 0.8rem; height: 0.8rem; }

.ap-submit {
  width: 100%; cursor: pointer; border: 0; border-radius: 100px;
  font-family: var(--font-display), sans-serif; font-size: 1.0625rem; font-weight: 500;
  color: var(--bg); background: var(--text); padding: 1.15em 2em;
  transition: transform 0.18s var(--ease-step), background 0.25s ease;
}
.ap-submit:hover { background: color-mix(in srgb, var(--text) 88%, var(--bg)); }
.ap-submit:active { transform: scale(0.985); }
.ap-submit[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.ap-submit__spin { display: none; }
.ap-submit.is-loading .ap-submit__label { display: none; }
.ap-submit.is-loading .ap-submit__spin {
  display: inline-block; width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--bg) 40%, transparent); border-top-color: var(--bg);
  animation: apspin 0.7s linear infinite; vertical-align: -0.15em;
}
@keyframes apspin { to { transform: rotate(360deg); } }

.ap-submiterr {
  margin-top: 1.1rem; display: none; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 1.1rem; border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--border));
  border-radius: 0.7rem; background: color-mix(in srgb, var(--bad) 7%, transparent);
}
.ap-submiterr.is-shown { display: flex; }
.ap-submiterr p { font-size: 0.875rem; color: var(--text); }
.ap-retry {
  cursor: pointer; background: none; border: 1px solid var(--text); border-radius: 100px;
  font-family: var(--font-mono), monospace; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.5em 1.1em; color: var(--text); white-space: nowrap; transition: background 0.2s ease, color 0.2s ease;
}
.ap-retry:hover { background: var(--text); color: var(--bg); }

/* ============================================================
   CONFIRMATION
   ============================================================ */
.ap-done { width: 100%; max-width: 40rem; margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; }
.ap-done__mark {
  width: 3.25rem; height: 3.25rem; border-radius: 50%; border: 1px solid var(--text);
  display: grid; place-items: center; margin-bottom: 2rem; color: var(--text);
}
.ap-done__mark svg { width: 1.4rem; height: 1.4rem; }
.ap-done__h {
  font-family: var(--font-display), sans-serif; font-weight: 500;
  font-size: clamp(2.25rem, 5.4vw, 3.75rem); line-height: 1.02; letter-spacing: -0.03em;
}
.ap-done__sub { margin-top: 1.1rem; font-size: 1.0625rem; line-height: 1.6; color: var(--text-2); max-width: 44ch; }
.ap-done__sub em { font-family: var(--font-serif), serif; font-style: italic; font-weight: 400; color: var(--text); }
.ap-done__logo { margin-top: 3.5rem; }
.ap-done__logo .wordmark { font-size: 1.375rem; letter-spacing: 0.34em; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* iPad / tablet */
@media (max-width: 1024px) {
  .ap-step { padding-left: clamp(1.5rem, 6vw, 4rem); padding-right: clamp(1.5rem, 6vw, 4rem); padding-top: 6.5rem; }
  .ap-q { font-size: clamp(2rem, 5.4vw, 3rem); }
  .ap-pills, .ap-bigpills { max-width: 38rem; }
}

@media (max-width: 640px) {
  .ap-step { padding: 6rem 1.4rem 6.5rem; }
  .ap-input, .ap-textarea { font-size: 1.5rem; }            /* >=16px, no iOS zoom */
  .ap-input--sm { font-size: 1.25rem; }
  .ap-q { font-size: clamp(1.85rem, 8.5vw, 2.5rem); max-width: 100%; }
  .ap-sub { max-width: 100%; }
  .ap-duo { grid-template-columns: 1fr; gap: 1.75rem; }
  /* pills wrap to two columns on mobile */
  .ap-pills { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; max-width: 100%; }
  .ap-pill { font-size: 1rem; padding: 0.75em 0.9em; justify-content: center; text-align: center; }
  .ap-bigpills { grid-template-columns: 1fr; }
  .ap-otherwrap .ap-field { max-width: 100%; }
  .ap-actions { flex-wrap: wrap; gap: 1rem 1.25rem; }
  .ap-review__h, .ap-done__h { font-size: clamp(1.85rem, 8vw, 2.4rem); }
  .ap-srow { grid-template-columns: 1fr; gap: 0.35rem; }
  .ap-srow__k { padding-top: 0; }
  .ap-edit { position: absolute; top: 1.15rem; right: 0; opacity: 1; }
  .ap-meter { width: clamp(6rem, 30vw, 9rem); }
  .ap-submit { padding-bottom: calc(1.15em + env(safe-area-inset-bottom, 0px)); }
  .ap-back { bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 380px) {
  .ap-input, .ap-textarea { font-size: 16px; }
}
