/* =========================================================
   ZB Digital · Check your market (apply.html)
   Builds on home.css (tokens, type, buttons, nav, focus).
   Motion: questions rise in fast (people answer by keyboard,
   so it stays short); the Market Check card tilts in 3D
   toward the pointer; reduced motion gets simple fades.
   ========================================================= */

.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;
}

/* ---------------------------------------------------------
   Nav: progress in the middle
   --------------------------------------------------------- */
.ap-page .nav-bar { gap: clamp(12px, 3vw, 32px); }
.ap-progress {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ap-segs {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
}
.ap-seg {
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(237, 240, 246, 0.1);
}
.ap-seg::after {
  content: "";
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 450ms var(--ease-out);
}
.ap-seg.is-done::after { transform: scaleX(1); }
.ap-seg.is-now::after { transform: scaleX(0.4); background: var(--accent-2); }
.ap-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ap-exit .i { transform: rotate(180deg); }
@media (max-width: 559px) {
  .ap-exit { width: 44px; padding: 0; }
  .ap-exit-label, .ap-label { display: none; }
}

/* ---------------------------------------------------------
   Background: soft glow + dot map, fixed
   --------------------------------------------------------- */
.ap-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.ap-glow {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 900px;
  background:
    radial-gradient(45% 45% at 20% 30%, rgba(61, 123, 255, 0.16), transparent 70%),
    radial-gradient(35% 35% at 85% 15%, rgba(61, 123, 255, 0.08), transparent 70%);
}
.ap-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(237, 240, 246, 0.1) 1px, transparent 1.4px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(70% 60% at 30% 40%, #000 10%, transparent 75%);
  mask-image: radial-gradient(70% 60% at 30% 40%, #000 10%, transparent 75%);
}

/* ---------------------------------------------------------
   Layout
   --------------------------------------------------------- */
.ap-main {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  padding: calc(var(--nav-h) + 12px + clamp(40px, 8vh, 96px)) 0 clamp(110px, 14vh, 160px);
}
.ap-grid { display: grid; gap: 48px; align-items: start; }
.ap-aside { display: none; }
@media (min-width: 1024px) {
  .ap-grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: clamp(56px, 7vw, 120px);
  }
  .ap-aside { display: block; position: sticky; top: calc(var(--nav-h) + 48px); }
}
.apply-stage { max-width: 720px; outline: none; }

/* ---------------------------------------------------------
   Market Check card (3D, fills in live)
   --------------------------------------------------------- */
.pass-wrap {
  perspective: 1400px;
  max-width: 440px;
}
.pass {
  --sx: 30%;
  position: relative;
  padding: 28px 28px 24px;
  border-radius: 24px;
  overflow: hidden;
  transform: rotateX(6deg) rotateY(-10deg);
  transform-style: preserve-3d;
  background: linear-gradient(160deg, #1B2437 0%, #131926 55%, #0E121B 100%);
  box-shadow:
    inset 0 0 0 1px var(--line-2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 60px 120px -50px rgba(0, 0, 0, 0.9),
    0 30px 60px -30px rgba(31, 95, 240, 0.35);
}
/* moving light across the card, driven by the tilt */
.pass::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg,
    transparent calc(var(--sx) - 22%),
    rgba(134, 172, 255, 0.14) var(--sx),
    transparent calc(var(--sx) + 22%));
}
.pass-top { display: flex; justify-content: space-between; align-items: center; }
.pass-top img { height: 20px; width: auto; }
.pass-status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-2);
  background: var(--accent-tint-2);
}
.pass-title { margin-top: 40px; font-size: 30px; font-weight: 600; line-height: 1.1; letter-spacing: -0.035em; }
.pass-sub { margin-top: 6px; font-size: 14px; color: var(--text-2); }
.pass-fields { margin-top: 26px; }
.pass-fields div,
.ap-summary div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.pass-fields dt,
.ap-summary dt { flex-shrink: 0; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.pass-fields dd,
.ap-summary dd {
  min-width: 0;
  font-size: 15.5px;
  font-weight: 500;
  text-align: right;
  overflow-wrap: anywhere;
  color: var(--text);
  transition: color 250ms ease;
}
.pass-fields dd.is-empty,
.ap-summary dd.is-empty { font-weight: 400; color: var(--text-3); }
.pass-foot {
  margin-top: 14px;
  padding-top: 18px;
  border-top: 1px dashed var(--line-2);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}
.pass-stamp {
  position: absolute;
  right: 24px;
  bottom: 76px;
  padding: 8px 14px;
  border: 2px solid var(--accent-2);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(14, 18, 27, 0.85);
  opacity: 0;
  transform: rotate(-10deg) scale(1.6);
  transition: transform 320ms var(--ease-out), opacity 200ms ease;
}
.pass.is-sent .pass-stamp { opacity: 1; transform: rotate(-10deg) scale(1); }

.ap-points { margin-top: 40px; display: grid; gap: 14px; max-width: 440px; }
.ap-points li { display: flex; align-items: flex-start; gap: 12px; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.ap-points .i { margin-top: 5px; font-size: 13px; color: var(--accent-2); }

@media (prefers-reduced-motion: no-preference) {
  .pass-wrap { animation: ap-pass-in 1100ms var(--ease-out) 150ms backwards; }
}
@keyframes ap-pass-in {
  from { opacity: 0; transform: translateY(40px) rotateX(24deg) rotateY(-20deg); }
}

/* ---------------------------------------------------------
   Questions
   --------------------------------------------------------- */
.apply-step { display: none; }
.apply-step.is-active { display: block; }
.apply-q-num {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent-2);
}
.apply-q-title {
  font-size: clamp(30px, 3.6vw, 52px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.04em;
  text-wrap: balance;
}
.apply-q-title.is-long { font-size: clamp(26px, 2.8vw, 40px); line-height: 1.12; }
.apply-q-help { margin-top: 14px; max-width: 52ch; font-size: 17px; color: var(--text-2); }

.apply-field { position: relative; margin-top: 36px; }
.apply-input {
  width: 100%;
  padding: 12px 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line-3);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.apply-input::placeholder { color: var(--text-3); font-weight: 400; }
.apply-input:focus { outline: none; }
/* focus indicator: the underline draws in from the left */
.apply-field::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 300ms var(--ease-out);
}
.apply-field:focus-within::after { transform: scaleX(1); }
.apply-input[aria-invalid="true"] { border-bottom-color: #FF8080; }
.apply-error { min-height: 1.5em; margin-top: 12px; font-size: 14px; color: #FF8080; }

.apply-options { margin-top: 32px; display: grid; gap: 12px; outline: none; }
.apply-option {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 64px;
  padding: 14px 20px 14px 16px;
  border-radius: 16px;
  text-align: left;
  font-size: clamp(16px, 1.5vw, 19px);
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-2);
  user-select: none;
  -webkit-user-select: none;
  transition: transform 160ms var(--ease-out), box-shadow 200ms ease, background-color 200ms ease;
}
/* selected fill sweeps in from the left */
.apply-option::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(31, 95, 240, 0.3), rgba(31, 95, 240, 0.12));
  clip-path: inset(0 100% 0 0);
  transition: clip-path 260ms var(--ease-out);
}
.apply-option.is-selected::before { clip-path: inset(0 0 0 0); }
.apply-option.is-selected { box-shadow: inset 0 0 0 1px var(--accent); }
.apply-option:active { transform: scale(0.985); }
.apply-option-key {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--line-3);
  transition: background-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}
.apply-option.is-selected .apply-option-key { background: var(--accent-fill); color: var(--on-accent); box-shadow: none; }
.apply-option-text { flex: 1; }
.apply-option-check {
  font-size: 16px;
  color: var(--accent-2);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.apply-option.is-selected .apply-option-check { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .apply-option:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-3); }
  .apply-option.is-selected:hover { box-shadow: inset 0 0 0 1px var(--accent); }
  .apply-option:hover .apply-option-key { color: var(--text); }
}

.apply-actions { margin-top: 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.apply-hint { font-size: 13px; color: var(--text-3); }
.apply-hint kbd {
  margin-left: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--line-3);
}
@media (max-width: 559px) {
  .apply-hint { display: none; }
  .apply-next, .ap-confirm { width: 100%; }
}

/* Final step */
.ap-call { margin-top: 20px; display: grid; gap: 10px; }
.ap-call li { display: flex; align-items: flex-start; gap: 12px; font-size: 16px; }
.ap-call .i { margin-top: 5px; font-size: 14px; color: var(--accent-2); }
.ap-summary {
  margin-top: 24px;
  padding: 6px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.ap-summary div:first-child { border-top: 0; }
@media (min-width: 1024px) { .ap-summary { display: none; } } /* the card shows it on desktop */
.ap-sched {
  margin-top: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-3);
  background: rgba(237, 240, 246, 0.02);
}
.ap-sched .i { flex-shrink: 0; font-size: 24px; color: var(--accent-2); }
.ap-sched-title { font-weight: 600; }
.ap-sched-note { margin-top: 4px; font-size: 14px; color: var(--text-2); }
.ap-confirm { margin-top: 28px; }
.ap-confirm[disabled] { opacity: 0.7; cursor: progress; }
.ap-assure { margin-top: 14px; font-size: 14px; color: var(--text-3); }

/* Back */
.apply-back {
  position: fixed;
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  background: rgba(12, 14, 19, 0.8);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: color 200ms ease, box-shadow 200ms ease, transform 160ms var(--ease-out);
}
.apply-back .i { font-size: 13px; transform: rotate(180deg); }
.apply-back:active { transform: scale(0.97); }
.apply-back[hidden] { display: none; }
@media (hover: hover) and (pointer: fine) {
  .apply-back:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-3); }
}

/* ---------------------------------------------------------
   Question entrance: children rise in a quick stagger.
   Direction flips when going back. "backwards" fill so press
   feedback on options still works after the entrance.
   --------------------------------------------------------- */
.apply-stage { --ap-from: 18px; }
.apply-stage[data-dir="back"] { --ap-from: -18px; }
@media (prefers-reduced-motion: no-preference) {
  .apply-step.is-active > * { animation: ap-rise 480ms var(--ease-out) backwards; }
  .apply-step.is-active > :nth-child(2) { animation-delay: 40ms; }
  .apply-step.is-active > :nth-child(3) { animation-delay: 80ms; }
  .apply-step.is-active > :nth-child(4) { animation-delay: 120ms; }
  .apply-step.is-active > :nth-child(5) { animation-delay: 160ms; }
  .apply-step.is-active > :nth-child(6) { animation-delay: 200ms; }
  .apply-step.is-active > :nth-child(7) { animation-delay: 240ms; }
  .apply-step.is-active > :nth-child(8) { animation-delay: 280ms; }
  .apply-step.is-active > .apply-options { animation: none; }
  .apply-step.is-active .apply-option { animation: ap-rise 460ms var(--ease-out) backwards; animation-delay: 140ms; }
  .apply-step.is-active .apply-option:nth-child(2) { animation-delay: 190ms; }
}
@media (prefers-reduced-motion: reduce) {
  .apply-step.is-active > * { animation: ap-fade 200ms ease backwards; }
}
@keyframes ap-rise {
  from { opacity: 0; transform: translateY(var(--ap-from)); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes ap-fade { from { opacity: 0; } to { opacity: 1; } }
