/*
 * Onboarding ("meeting your companion") plus the avatar and voice pickers it
 * shares with Settings. settings.html links this file for the pickers section;
 * every onboarding-only rule is under .ob-*, so nothing leaks into Settings.
 */

/* ═════════════ shared pickers (onboarding + settings) ═════════════ */

/* Avatar gallery: round head thumbnails, native radios underneath. */
.av-grid, .ob-avatars {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: var(--s-4) var(--s-3);
}
.av-skel { width: 64px; height: 64px; border-radius: 50%; justify-self: center; }
.av-opt {
  position: relative; display: grid; justify-items: center; gap: 6px;
  cursor: pointer; text-align: center;
}
.av-opt__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.av-opt__img {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  background: var(--lav); box-shadow: 0 0 0 0 var(--ink);
  transition: box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.av-opt__img img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.av-opt:hover .av-opt__img { transform: translateY(-2px); }
.av-opt:has(input:checked) .av-opt__img { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
.av-opt:has(input:focus-visible) .av-opt__img { outline: 2px solid var(--focus); outline-offset: 6px; }
.av-opt__name { font-size: 12px; line-height: 1.25; color: var(--ink-2); max-width: 11ch; }
.av-opt:has(input:checked) .av-opt__name { color: var(--ink); font-weight: 600; }
.av-opt__current {
  /* A small tag on the circle's upper-right shoulder, clear of the face. */
  position: absolute; top: -6px; left: calc(50% + 12px);
  padding: 1px 7px; border-radius: var(--r-pill); background: var(--coral); color: #2A0E06;
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
}

/* Voice list: one row per voice, the radio label and its Preview button. */
.vc-list, .ob-voices { display: grid; gap: var(--s-2); }
@media (min-width: 900px) { .ob-voices { grid-template-columns: 1fr 1fr; } }
.vc-skel { height: 68px; border-radius: var(--r-m); }
.vc-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 6px 8px 6px 6px; border-radius: var(--r-m);
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.vc-row:has(input:checked) { border-color: var(--ink); background: #FFFDF9; box-shadow: var(--shadow-1); }
.vc-row:has(input:disabled) { opacity: .55; }
.vc-opt {
  flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: var(--s-3);
  padding: 10px 6px 10px 10px; border-radius: var(--r-s); cursor: pointer;
}
.vc-opt:has(input:disabled) { cursor: not-allowed; }
.vc-opt__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.vc-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.vc-opt__mark {
  flex: none; width: 20px; height: 20px; margin-top: 2px; border-radius: 50%;
  border: 1.5px solid rgba(36,21,43,.3); background: var(--surface);
  transition: border-width var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.vc-opt:has(input:checked) .vc-opt__mark { border: 6px solid var(--ink); }
.vc-opt__text { display: grid; gap: 2px; min-width: 0; }
.vc-opt__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.vc-opt__name { font-weight: 600; }
.vc-opt__tagline { color: var(--ink-2); font-size: 14px; }
.vc-opt__current { align-self: center; background: var(--coral); color: #2A0E06; }
.vc-opt__meta { font-size: 13px; color: var(--muted); text-transform: capitalize; }
.vc-play { flex: none; }
.vc-play svg { width: 14px; height: 14px; fill: currentColor; }
.vc-play.is-playing { --btn-bg: var(--coral-soft); --btn-bd: var(--coral); --btn-fg: var(--coral-ink); }
.vc-play.is-playing svg { animation: ob-beat 1s var(--ease) infinite; }
@keyframes ob-beat { 50% { transform: scale(.78); } }

@media (max-width: 480px) {
  .vc-play span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .vc-play { width: 44px; padding: 0; }
  .vc-opt__meta { font-size: 12px; }
}

/* ═════════════ onboarding ═════════════ */

.ob-body {
  min-height: 100dvh; display: grid; grid-template-rows: auto 1fr;
  overflow-x: hidden;
}

/* Two soft shapes drift to a new place on every step. */
.ob-shapes { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.ob-shape {
  position: absolute; display: block; border-radius: 58% 42% 55% 45% / 48% 60% 40% 52%;
  transition: transform 1200ms var(--ease), opacity 1200ms var(--ease);
}
.ob-shape--a { width: 58vmax; height: 58vmax; right: -22vmax; top: -24vmax; background: var(--lav); opacity: .7; }
.ob-shape--b { width: 30vmax; height: 30vmax; left: -12vmax; bottom: -14vmax; background: var(--coral-soft); opacity: .6; border-radius: 40% 60% 38% 62% / 58% 38% 62% 42%; }
body[data-step="2"] .ob-shape--a { transform: translate(-6vmax, 8vmax) rotate(24deg); }
body[data-step="2"] .ob-shape--b { transform: translate(4vmax, -2vmax) rotate(-12deg); }
body[data-step="3"] .ob-shape--a { transform: translate(-2vmax, 30vmax) rotate(60deg) scale(.8); }
body[data-step="3"] .ob-shape--b { transform: translate(10vmax, -20vmax) rotate(20deg); opacity: .4; }
body[data-step="4"] .ob-shape--a { transform: translate(-40vmax, 10vmax) rotate(110deg) scale(.7); }
body[data-step="4"] .ob-shape--b { transform: translate(60vmax, 0) rotate(40deg); }
body[data-step="5"] .ob-shape--a { transform: translate(-10vmax, 46vmax) rotate(150deg) scale(.9); opacity: .55; }
body[data-step="5"] .ob-shape--b { transform: translate(20vmax, -40vmax) rotate(80deg) scale(.8); }
body[data-step="6"] .ob-shape--a { transform: translate(-4vmax, 4vmax) rotate(200deg) scale(1.1); }
body[data-step="6"] .ob-shape--b { transform: translate(8vmax, -6vmax) rotate(120deg) scale(1.3); opacity: .8; }

.ob-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  width: min(1040px, 100% - 2 * var(--s-4)); margin-inline: auto; padding-block: var(--s-4);
}
.ob-logo {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font-family: var(--font-display); font-size: 22px; letter-spacing: -0.02em;
}
.ob-logo__dot { width: 14px; height: 14px; border-radius: 58% 42% 55% 45% / 48% 60% 40% 52%; background: var(--coral); }
.ob-progress { display: flex; align-items: center; gap: var(--s-3); }
.ob-progress__dots { display: flex; gap: 6px; }
.ob-progress__dots li {
  width: 8px; height: 8px; border-radius: var(--r-pill); background: rgba(36,21,43,.16);
  transition: width var(--dur-3) var(--ease), background-color var(--dur-3) var(--ease);
}
.ob-progress__dots li.is-done { background: var(--ink); }
.ob-progress__dots li.is-current { width: 26px; background: var(--coral); }
.ob-progress__count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4ch; }

.ob {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  width: min(1040px, 100% - 2 * var(--s-4)); margin-inline: auto;
}
.ob-step { flex: 1; display: flex; align-items: center; padding-block: clamp(16px, 5vh, 56px); }
.ob-step__inner { width: 100%; display: grid; gap: var(--s-5); align-content: center; }
.ob-step [tabindex="-1"]:focus { outline: none; }

.ob-headline { max-width: 13ch; }
.ob-step--intro .ob-headline { font-size: clamp(48px, 9vw, 120px); }
.ob-title { max-width: 18ch; }
.ob-lead { max-width: 52ch; }
.ob-field { max-width: 420px; }
.ob-field label { font-size: 15px; }
.ob-step--intro .ob-field { margin-top: var(--s-3); }

.ob-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--s-3); }
.ob-legend { padding: 0; font-size: 14px; font-weight: 600; margin-bottom: var(--s-3); }
.ob-error { color: var(--err); font-weight: 500; font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

/* Step 2 and 6: portrait beside the content. */
.ob-split { grid-template-columns: 1fr; }
.ob-split__side { display: grid; gap: var(--s-5); align-content: center; min-width: 0; }
@media (min-width: 820px) {
  .ob-split { grid-template-columns: minmax(260px, 5fr) 7fr; gap: clamp(32px, 6vw, 80px); align-items: center; }
}
.ob-portrait { position: relative; display: grid; justify-items: center; gap: var(--s-3); }
.ob-portrait::before { /* a coral blob peeking out behind the arch */
  content: ""; position: absolute; width: 46%; aspect-ratio: 1; right: 2%; bottom: 10%;
  background: var(--coral-soft); border-radius: 58% 42% 55% 45% / 48% 60% 40% 52%; z-index: 0;
}
.ob-arch {
  position: relative; z-index: 1; width: min(340px, 72vw); aspect-ratio: 3 / 4; overflow: hidden;
  border-radius: 999px 999px var(--r-l) var(--r-l); background: var(--lav);
}
.ob-arch__img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; opacity: 0; transform: scale(1.04); transition: opacity var(--dur-3) var(--ease), transform 900ms var(--ease); }
.ob-arch__img.is-in { opacity: 1; transform: none; }
.ob-arch__empty { position: absolute; inset: 0; border-radius: 0; }
.ob-portrait__name { position: relative; z-index: 1; font-family: var(--font-display); font-style: italic; color: var(--ink-2); min-height: 1.5em; }
.ob-portrait--small .ob-arch { width: min(280px, 56vw); }
@media (max-width: 819.98px) {
  .ob-step--meet .ob-arch { width: min(200px, 52vw); }
  .ob-portrait--small .ob-arch { width: min(180px, 48vw); }
  .ob-portrait::before { width: 34%; right: 18%; }
}

.ob-show-all { justify-self: start; }

/* Step 4: either/or cards. */
.ob-questions { display: grid; gap: var(--s-6); max-width: 760px; margin-top: var(--s-3); }
.ob-q { position: relative; border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--s-3); }
.ob-q__text { padding: 0 72px 0 0; margin-bottom: var(--s-3); font-family: var(--font-display); font-size: clamp(20px, 2.2vw, 26px); letter-spacing: -0.01em; line-height: 1.2; }
.ob-q__choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
@media (max-width: 520px) { .ob-q__choices { grid-template-columns: 1fr; } }
.ob-choice { position: relative; display: flex; cursor: pointer; }
.ob-choice__input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ob-choice__label {
  flex: 1; display: flex; align-items: center; min-height: 64px; padding: 14px 20px;
  border-radius: var(--r-l); border: 1px solid var(--line); background: var(--surface);
  font-weight: 500; transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.ob-choice:hover .ob-choice__label { border-color: rgba(36,21,43,.3); transform: translateY(-1px); }
.ob-choice__input:checked + .ob-choice__label { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.ob-choice__input:focus-visible + .ob-choice__label { outline: 2px solid var(--focus); outline-offset: 3px; }
/* Out of the flow, so its appearing never shifts the cards under the pointer. */
.ob-q__skip { position: absolute; top: -2px; right: 0; min-height: 30px; }

/* Step 5: plain-language permission notes. */
.ob-perms { display: grid; gap: var(--s-2); max-width: 720px; }
.ob-perm {
  display: flex; gap: var(--s-4); align-items: flex-start; padding: var(--s-4) var(--s-5) var(--s-4) var(--s-4);
  border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line);
}
.ob-perm .h3 { font-family: var(--font-ui); font-size: 17px; font-weight: 600; letter-spacing: 0; display: flex; align-items: center; gap: var(--s-2); }
.ob-perm .badge { background: var(--lav); color: var(--ink); font-weight: 500; }
.ob-perm p { margin-top: 2px; }
.ob-perm--quiet { background: transparent; border-style: dashed; }
.ob-perm__icon {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--lav);
}
.ob-perm--quiet .ob-perm__icon { background: var(--bg-2); }
.ob-perm__icon svg, .ob-body .icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Step 6 */
.ob-step--ready .ob-headline { font-size: clamp(44px, 6.4vw, 88px); max-width: 12ch; }
.ob-summary { display: grid; gap: 0; max-width: 520px; border-top: 1px solid var(--line); }
.ob-summary__row { display: grid; grid-template-columns: 7.5em 1fr; gap: var(--s-3); padding: 12px 0; border-bottom: 1px solid var(--line); }
.ob-summary dt { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.ob-summary dd { color: var(--ink); }

/* Bottom navigation: always reachable, quiet. */
.ob-nav {
  position: sticky; bottom: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-3);
  padding: var(--s-4) 0 calc(var(--s-4) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(251,246,238,0));
}
.ob-nav .ob-next { margin-left: auto; min-width: 160px; }
body[data-step="1"] .ob-nav { justify-content: flex-start; }
body[data-step="1"] .ob-nav .ob-next { margin-left: 0; }

@media (max-width: 600px) {
  .ob-skip { display: none; }
  .ob-step { align-items: flex-start; }
  .ob-perm { padding: var(--s-3); gap: var(--s-3); }
  .ob-summary__row { grid-template-columns: 1fr; gap: 2px; }
  .ob-nav .ob-next { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ob-shape, .ob-arch__img, .ob-progress__dots li, .ob-choice__label, .av-opt__img { transition: none !important; }
  .ob-arch__img { opacity: 1; transform: none; }
  .vc-play.is-playing svg { animation: none; }
}
