/* ============================================================
   APEX ISA — Onboarding wizard
   Sits on the shared Marble Drift tokens + living gradient.
   ============================================================ */

/* explicit display on .ob-done/.ob-pane would otherwise beat the UA
   [hidden] rule and leak the completion screen — enforce it */
[hidden] { display: none !important; }

.ob { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- top bar + progress rail ---------- */
.ob-top {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--paper) 80%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.ob-top__inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 70px;
}
.ob-sound {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: transparent; border: 1px solid var(--line);
  color: var(--ink-dim); cursor: pointer;
  font: 500 0.74rem/1 var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.55rem 0.85rem;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.ob-sound:hover { color: var(--ink); border-color: var(--ink-faint); }
.ob-sound__icon {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--clay);
  box-shadow: 0 0 0 0 var(--clay-haze);
  transition: background-color 0.2s var(--ease);
}
.ob-sound.is-off .ob-sound__icon { background: var(--ink-faint); }

.ob-rail { height: 3px; background: var(--line-soft); overflow: hidden; }
.ob-rail__fill {
  display: block; height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: left;
  background: var(--clay);
  transition: transform 0.6s var(--ease);
}
.ob-rail.is-complete .ob-rail__fill { background: var(--clay-deep); }

/* ---------- layout ---------- */
.ob-main {
  flex: 1; width: 100%;
  padding-block: clamp(2.5rem, 7vw, 5.5rem);
  display: flex; flex-direction: column;
  align-items: center;          /* centre the column on the page */
  justify-content: center;
  text-align: center;
}

/* ---------- intro ---------- */
.ob-intro { max-width: 40rem; margin-inline: auto; }
.js-anim .ob-intro > * { opacity: 0; animation: introUp 0.7s var(--ease) both; }
.js-anim .ob-intro > :nth-child(1) { animation-delay: 0.05s; }
.js-anim .ob-intro > :nth-child(2) { animation-delay: 0.14s; }
.js-anim .ob-intro > :nth-child(3) { animation-delay: 0.23s; }
.js-anim .ob-intro > :nth-child(4) { animation-delay: 0.34s; }
.js-anim .ob-intro > :nth-child(5) { animation-delay: 0.44s; }
@keyframes introUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
.ob-intro__h {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(2.2rem, 1.4rem + 4vw, 4rem);
  line-height: 1.08; letter-spacing: -0.02em;
  color: var(--ink); margin: var(--sp-3) 0 var(--sp-5);
  text-wrap: balance;
}
.ob-intro__h em {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  letter-spacing: -0.01em; color: var(--clay);
}
.ob-intro__sub {
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.22rem);
  line-height: 1.65; color: var(--ink-dim);
  max-width: 52ch; margin: 0 auto var(--sp-7);
  text-wrap: pretty;
}
.ob-intro__meta {
  margin-top: var(--sp-6);
  font: 500 0.72rem/1.5 var(--mono);
  letter-spacing: 0.06em; color: var(--ink-faint);
}
.ob-intro__resume {
  margin-top: var(--sp-5);
  font-size: 0.92rem; color: var(--clay);
}

/* ---------- wizard frame ---------- */
.ob-wizard { max-width: 50rem; width: 100%; margin-inline: auto; }
.ob-wizard__head {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: var(--sp-7);
}
.ob-step-count {
  font: 600 0.78rem/1 var(--mono);
  letter-spacing: 0.18em; color: var(--clay);
  display: inline-block;
}
.js-anim .ob-step-count.is-pop { animation: countPop 0.5s var(--ease); }
@keyframes countPop {
  0% { transform: scale(0.82); opacity: 0.4; }
  55% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.ob-step-name {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.25rem, 1rem + 1.4vw, 1.9rem);
  letter-spacing: -0.015em; color: var(--ink);
}

/* viewport holds one animated pane at a time */
.ob-viewport { position: relative; overflow: hidden; }
.ob-pane {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-6);
}
.ob-pane__blurb {
  color: var(--ink-dim); font-size: 1.02rem;
  line-height: 1.6; max-width: 58ch; margin-inline: auto;
  text-wrap: pretty;
}
.ob-secure {
  font-size: 0.88rem; color: var(--clay-deep);
  background: var(--clay-haze);
  padding: var(--sp-4) var(--sp-5);
  max-width: 60ch; margin-inline: auto;
}

/* staggered entrance for everything inside an arriving pane */
.js-anim .is-entering > *,
.js-anim .is-entering-back > * {
  opacity: 0;
  animation: fieldUp 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 65ms + 120ms);
}
@keyframes fieldUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- fields ---------- */
.ob-field {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-3);
  width: 100%; max-width: 42rem; margin-inline: auto;
}
.ob-field--big, .ob-field--grid, .ob-field--rank { max-width: 46rem; }
.ob-label {
  font: 600 0.92rem/1.4 var(--sans);
  color: var(--ink);
}
.ob-req {
  font: 500 0.62rem/1 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint); margin-left: 0.5rem;
}
.ob-input {
  font: 400 1rem/1.5 var(--sans);
  color: var(--ink);
  text-align: center;
  background: color-mix(in oklab, var(--paper) 70%, transparent);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  width: 100%;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.ob-input--area, .ob-input--sm { text-align: left; }
.ob-input::placeholder { color: var(--ink-faint); }
.ob-input:focus {
  outline: none;
  border-color: var(--clay);
  background: color-mix(in oklab, var(--paper) 90%, transparent);
  box-shadow: 0 0 0 3px var(--clay-haze);
}
/* keep browser autofill on-palette instead of the default blue/yellow wash */
.ob-input:-webkit-autofill,
.ob-input:-webkit-autofill:hover,
.ob-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  transition: background-color 9999s ease 0s;
  box-shadow: 0 0 0 100px color-mix(in oklab, var(--paper) 88%, transparent) inset;
}
.ob-input--area { resize: vertical; min-height: 3.5rem; }
.ob-input--sm { padding: 0.6rem 0.7rem; font-size: 0.92rem; }
.ob-field--big .ob-input--area { min-height: 11rem; }

/* radio / single-choice cards */
.ob-choices {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-3); width: 100%;
}
.ob-choice {
  text-align: left; cursor: pointer;
  width: 100%; max-width: 34rem;
  background: color-mix(in oklab, var(--paper) 64%, transparent);
  border: 1px solid var(--line);
  padding: 0.95rem 1.1rem;
  font: 500 0.98rem/1.45 var(--sans);
  color: var(--ink-dim);
  display: flex; align-items: center; gap: 0.85rem;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.15s var(--ease);
}
.ob-choice:active { transform: scale(0.985); }
.ob-choice::before {
  content: ""; flex: none;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.ob-choice:hover { color: var(--ink); border-color: var(--ink-faint); }
.ob-choice.is-on {
  color: var(--ink); border-color: var(--clay);
  background: color-mix(in oklab, var(--clay) 9%, transparent);
}
.ob-choice.is-on::before {
  border-color: var(--clay);
  box-shadow: inset 0 0 0 4px var(--clay);
}

/* rank pills */
.ob-field--rank { gap: var(--sp-5); width: 100%; }
.ob-rank {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-3); width: 100%;
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}
.ob-rank:last-child { border-bottom: 0; padding-bottom: 0; }
.ob-rank__label {
  font-size: 0.96rem; color: var(--ink);
  text-align: center; max-width: 44ch;
}
.ob-rank__pills { display: flex; gap: 0.5rem; justify-content: center; }
.ob-pill {
  width: 2.4rem; height: 2.4rem; cursor: pointer;
  background: color-mix(in oklab, var(--paper) 60%, transparent);
  border: 1px solid var(--line);
  font: 600 0.95rem/1 var(--mono);
  color: var(--ink-dim);
  transition: transform 0.14s var(--ease), background-color 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.ob-pill:hover { border-color: var(--clay); color: var(--ink); transform: translateY(-1px); }
.ob-pill:active { transform: scale(0.9); }
.ob-pill.is-on {
  background: var(--clay); border-color: var(--clay);
  color: var(--clay-on); transform: translateY(-2px);
}

/* grid rows (social / systems) */
.ob-field--grid { gap: var(--sp-5); width: 100%; }
.ob-gridrow {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-3); width: 100%; max-width: 34rem; margin-inline: auto;
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}
.ob-gridrow:last-child { border-bottom: 0; padding-bottom: 0; }
.ob-gridrow__name {
  font: 600 0.88rem/1.3 var(--sans); color: var(--ink);
  text-align: center;
}
.ob-gridrow__inputs { display: grid; gap: var(--sp-3); width: 100%; }

/* ---------- nav ---------- */
.ob-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-5);
  margin-top: var(--sp-8);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--line-soft);
}
.ob-nav__dots { display: flex; gap: 0.15rem; flex-wrap: wrap; justify-content: center; }
.ob-dot {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent;
  width: 22px; height: 22px; padding: 0; cursor: pointer;
  display: grid; place-items: center;
}
.ob-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--line);
  transition: background-color 0.3s var(--ease), transform 0.3s var(--ease);
}
.ob-dot:hover::before { background: var(--ink-faint); transform: scale(1.25); }
.ob-dot.is-done::before { background: var(--clay-deep); }
.ob-dot.is-on::before { background: var(--clay); transform: scale(1.7); }
.js-anim .ob-dot.is-on::before { animation: dotPulse 2.6s var(--ease) infinite; }
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--clay-haze); }
  55% { box-shadow: 0 0 0 6px transparent; }
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn--ghost::after { content: none; }
.btn--ghost:hover { border-color: var(--clay); color: var(--clay-deep); }
.btn--ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.is-busy { opacity: 0.8; cursor: progress; }

.ob-error {
  margin: var(--sp-5) auto 0;
  max-width: 42rem; width: 100%;
  font: 600 0.92rem/1.5 var(--sans);
  color: oklch(0.448 0.172 28);
  background: oklch(0.50 0.16 28 / 0.08);
  padding: var(--sp-4) var(--sp-5);
}

/* ---------- completion ---------- */
.ob-done {
  max-width: 38rem; text-align: center;
  margin-inline: auto;
  display: flex; flex-direction: column; align-items: center;
}
.js-anim .ob-done:not([hidden]) > :not(.ob-check) {
  opacity: 0; animation: introUp 0.7s var(--ease) both;
}
.js-anim .ob-done:not([hidden]) .ob-done__h { animation-delay: 0.7s; }
.js-anim .ob-done:not([hidden]) .ob-done__sub { animation-delay: 0.82s; }
.js-anim .ob-done:not([hidden]) .btn { animation-delay: 0.96s; }
.ob-check { width: 76px; height: 76px; margin-bottom: var(--sp-5); }
.ob-check__ring, .ob-check__tick {
  fill: none; stroke: var(--clay);
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}
.ob-check__ring { stroke-dasharray: 183; stroke-dashoffset: 183; }
.ob-check__tick { stroke-dasharray: 48; stroke-dashoffset: 48; }
.ob-done:not([hidden]) .ob-check__ring { animation: draw 0.7s var(--ease) forwards; }
.ob-done:not([hidden]) .ob-check__tick { animation: draw 0.4s var(--ease) 0.55s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.ob-done__h {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(2rem, 1.4rem + 3vw, 3.4rem);
  letter-spacing: -0.02em; color: var(--ink);
  margin-bottom: var(--sp-4);
}
.ob-done__h::after { content: none; }
.ob-done__sub {
  font-size: 1.1rem; line-height: 1.65; color: var(--ink-dim);
  max-width: 48ch; margin-bottom: var(--sp-7);
  text-wrap: pretty;
}

/* celebratory pulse of the living haze */
body.is-celebrate::before { animation: drift-a 38s ease-in-out infinite, glow 2.4s var(--ease); }
body.is-celebrate::after  { animation: drift-b 47s ease-in-out infinite, glow 2.4s var(--ease); }
@keyframes glow {
  0% { filter: saturate(118%) brightness(1); }
  35% { filter: saturate(165%) brightness(1.08); }
  100% { filter: saturate(118%) brightness(1); }
}

/* ---------- step transition keyframes ---------- */
.js-anim .is-entering { animation: paneIn 0.42s var(--ease) both; }
.js-anim .is-entering-back { animation: paneInBack 0.42s var(--ease) both; }
.js-anim .is-leaving {
  position: absolute; inset: 0;
  animation: paneOut 0.4s var(--ease) both;
}
.js-anim .is-leaving-back {
  position: absolute; inset: 0;
  animation: paneOutBack 0.4s var(--ease) both;
}
@keyframes paneIn  { from { opacity: 0; transform: translateX(38px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes paneOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(-30px) scale(0.985); } }
@keyframes paneInBack  { from { opacity: 0; transform: translateX(-38px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes paneOutBack { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(30px) scale(0.985); } }

.js-anim .is-shake { animation: shake 0.4s var(--ease); }
@keyframes shake {
  10%,90% { transform: translateX(-2px); }
  30%,70% { transform: translateX(4px); }
  50% { transform: translateX(-6px); }
}

@media (prefers-reduced-motion: reduce) {
  .ob-rail__fill { transition: none; }
  .ob-check__ring, .ob-check__tick { animation: none !important; stroke-dashoffset: 0 !important; }
}

@media (max-width: 640px) {
  .ob-gridrow { grid-template-columns: 1fr; gap: var(--sp-3); }
  .ob-rank { gap: var(--sp-3); }
  .ob-nav { flex-wrap: wrap; }
  .ob-nav__dots { order: 3; width: 100%; justify-content: center; }
}
