/* Route-specific layout: landing, quiz, result, gallery, detail.
 *
 * Structure here comes from whitespace, hairlines and type hierarchy rather
 * than from boxes. The pills are the only things allowed to look like objects;
 * everything else sits directly on the ground. Where a character needs to be
 * set apart, it gets a soft radial halo instead of a panel — no edges, so it
 * reads as light rather than as another container.
 */

.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* A soft pool of warmth behind a character. */
.halo {
  display: grid;
  place-items: center;
  background: radial-gradient(closest-side, var(--bg-tint) 0%, rgba(241, 238, 231, 0) 78%);
}

/* ============================================================
   LANDING
   ============================================================ */

.hero {
  padding: 78px 0 34px;
  display: grid;
  gap: 34px;
  justify-items: center;
  text-align: center;
}

.hero-copy { max-width: 620px; display: grid; gap: 18px; justify-items: center; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* A parade of pills walking across the hero. */
.parade {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(0px, 2vw, 26px);
  width: 100%;
  overflow: hidden;
  padding-bottom: 8px;
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.parade .character-svg { width: clamp(108px, 15vw, 168px); height: auto; }
.parade > * { flex: none; }

/* Slightly different gaits stop the row reading as one animation copied five
 * times. Prime-ish ratios keep them from re-syncing. */
.parade > *:nth-child(1) { --walk-duration: 0.93s; }
.parade > *:nth-child(2) { --walk-duration: 1.11s; }
.parade > *:nth-child(3) { --walk-duration: 1.00s; }
.parade > *:nth-child(4) { --walk-duration: 0.83s; }
.parade > *:nth-child(5) { --walk-duration: 1.23s; }

/* Three columns divided by hairlines, not three boxes. */
.how {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}
.how-step {
  padding: 34px 34px 4px 0;
  display: grid;
  gap: 10px;
  align-content: start;
}
.how-step + .how-step { border-left: 1px solid var(--line); padding-left: 34px; }
.how-num {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-mute);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

/* ============================================================
   QUIZ
   ============================================================ */

.quiz {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 56px;
  align-items: start;
  padding: 48px 0 84px;
}

.progress { display: grid; gap: 10px; margin-bottom: 34px; }
.progress-track {
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--ink);
  transition: width .42s var(--ease);
}
.progress-meta { display: flex; justify-content: space-between; }

.question { margin-bottom: 28px; }

/* Options are hairline-separated rows, not a stack of cards. */
.options { display: grid; border-top: 1px solid var(--line); }

.option {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  padding: 19px 10px 19px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 16.5px;
  letter-spacing: -0.013em;
  color: var(--ink-body);
  transition: padding-left .18s var(--ease), color .18s var(--ease);
}
.option:hover { padding-left: 10px; color: var(--ink); }
.option.is-picked { color: var(--ink); }

.option-dot {
  width: 17px; height: 17px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  flex: none;
  transition: box-shadow .18s var(--ease), background .18s var(--ease);
}
.option:hover .option-dot { box-shadow: inset 0 0 0 1.5px var(--ink-mute); }
.option.is-picked .option-dot { background: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }

.quiz-nav { margin-top: 24px; display: flex; gap: 10px; align-items: center; }

/* The pill being sculpted while you answer. */
.quiz-aside {
  position: sticky;
  top: calc(var(--nav-h) + 30px);
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}
.quiz-aside .character-svg { width: 176px; height: auto; }
.quiz-preview { padding: 10px 24px; }

/* ============================================================
   RESULT
   ============================================================ */

.result { padding: 56px 0 84px; display: grid; gap: 60px; }

.result-hero {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 56px;
  align-items: center;
}
.result-stage { padding: 10px; }
.result-stage .character-svg { width: 260px; height: auto; }
.result-copy { display: grid; gap: 18px; align-content: center; max-width: 54ch; }

/* --- axis readout --- */

.axes { display: grid; gap: 20px; }
.axis { display: grid; gap: 8px; }
.axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-mute);
}
.axis-labels b { font-weight: 500; color: var(--ink); }
.axis-track {
  position: relative;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
}
.axis-track::before {
  content: '';
  position: absolute;
  left: 50%; top: -4px;
  width: 1px; height: 11px;
  background: var(--line-strong);
}
.axis-dot {
  position: absolute;
  top: 50%;
  width: 14px; height: 14px;
  border-radius: var(--r-pill);
  background: var(--ink);
  transform: translate(-50%, -50%);
  transition: left .6s var(--ease);
  box-shadow: 0 0 0 4px var(--bg);
}

/* --- relatives --- */

.relatives { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 44px; }
.relative {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  transition: gap .2s var(--ease);
}
.relative:hover { gap: 24px; }
.relative .character-svg { width: 88px; height: auto; flex: none; }
.relative:hover .character { animation-duration: calc(var(--walk-duration) * .62); }

/* ============================================================
   GALLERY
   ============================================================ */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 8px;
  row-gap: 30px;
}

/* No card. The pill stands on the page; a soft halo fades in under it on
   hover so there is feedback without a box appearing. */
.pill-card {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 14px 10px 18px;
  transition: transform .22s var(--ease);
}
.pill-card::before {
  content: '';
  position: absolute;
  inset: 0 4px 30px;
  z-index: -1;
  border-radius: var(--r-2xl);
  background: radial-gradient(closest-side, var(--bg-tint) 0%, rgba(241, 238, 231, 0) 80%);
  opacity: 0;
  transition: opacity .24s var(--ease);
}
.pill-card:hover { transform: translateY(-5px); }
.pill-card:hover::before { opacity: 1; }

.pill-card .character-svg { width: 152px; height: auto; }

/* Pills pick up the pace when you hover them. */
.pill-card:hover .character,
.pill-card:hover .leg-L, .pill-card:hover .leg-R,
.pill-card:hover .leg-L .knee, .pill-card:hover .leg-R .knee {
  animation-duration: calc(var(--walk-duration) * .62);
}

.pill-card .pill-name { font-size: 17px; }
.pill-card .pill-sub { font-size: 12.5px; color: var(--ink-mute); text-align: center; }

/* Twenty pills stepping in perfect unison looks like a machine, not a cabinet. */
.gallery-grid > *:nth-child(5n+1) { --walk-duration: 0.95s; }
.gallery-grid > *:nth-child(5n+2) { --walk-duration: 1.14s; }
.gallery-grid > *:nth-child(5n+3) { --walk-duration: 0.86s; }
.gallery-grid > *:nth-child(5n+4) { --walk-duration: 1.27s; }
.gallery-grid > *:nth-child(5n+5) { --walk-duration: 1.04s; }

/* ============================================================
   DETAIL
   ============================================================ */

.detail { padding: 34px 0 84px; display: grid; gap: 56px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--ink-mute);
  transition: color .16s var(--ease);
}
.back-link:hover { color: var(--ink); }

/* Prev / next sit either side of the character rather than at the foot of the
 * page, so moving through the set never means scrolling to the bottom first. */
.detail-flank {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 28px;
  align-items: center;
}

.flank-btn {
  position: relative;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink-mute);
  font-size: 19px;
  line-height: 1;
  transition: background .18s var(--ease), color .18s var(--ease),
              box-shadow .18s var(--ease), transform .18s var(--ease);
}
.flank-btn:hover {
  background: var(--surface-alt);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px transparent;
}
.flank-btn:first-child:hover { transform: translateX(-3px); }
.flank-btn:last-child:hover  { transform: translateX(3px); }

/* The destination's name appears under the arrow on hover, so the control is
 * still legible without a permanent label crowding the character. */
.flank-btn::after {
  content: attr(data-name);
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: -0.02em;
  color: var(--ink-mute);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s var(--ease);
}
.flank-btn:hover::after,
.flank-btn:focus-visible::after { opacity: 1; }

.detail-hero {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 60px;
  align-items: center;
}
.detail-stage { padding: 12px; }
.detail-stage .character-svg { width: 290px; height: auto; }
.detail-copy { display: grid; gap: 20px; align-content: center; max-width: 54ch; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 44px;
}
.panel {
  display: grid;
  gap: 20px;
  align-content: start;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1000px) {
  .quiz { grid-template-columns: 1fr; gap: 28px; }
  .quiz-aside { position: static; order: -1; }
  .quiz-aside .character-svg { width: 138px; }
  .result-hero, .detail-hero { grid-template-columns: 1fr; gap: 28px; justify-items: center; text-align: center; }
  .detail-flank { gap: 16px; }
  .flank-btn { width: 44px; height: 44px; font-size: 17px; }
  .result-copy, .detail-copy { justify-items: center; }
  .result-copy .chip-row, .detail-copy .chip-row { justify-content: center; }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .how { grid-template-columns: 1fr; }
  .how-step { padding: 26px 0 4px; border-top: 1px solid var(--line); }
  .how-step:first-child { border-top: 0; }
  .how-step + .how-step { border-left: 0; padding-left: 0; }
  .detail-grid { gap: 32px; }
}

@media (max-width: 680px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); row-gap: 20px; }
  .pill-card { padding: 10px 4px 14px; }
  .pill-card .character-svg { width: 100%; max-width: 148px; }
  .relatives, .detail-grid { grid-template-columns: 1fr; gap: 0; }
  .detail-stage .character-svg, .result-stage .character-svg { width: 210px; }
  .option { padding: 17px 4px; font-size: 15.5px; }
  .hero { padding: 46px 0 22px; }
  .result, .detail { gap: 40px; }

  /* Too narrow to flank: the arrows drop to a row under the character. */
  .detail-flank {
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 24px 10px;
  }
  .detail-hero { grid-area: 1 / 1 / 2 / 3; }
  .detail-flank > .flank-btn:first-child { grid-area: 2 / 1 / 3 / 2; }
  .detail-flank > .flank-btn:last-child  { grid-area: 2 / 2 / 3 / 3; }

  /* There is no hover on touch, so the destination name stops being a reveal
   * and becomes a permanent label; the circle grows into a labelled button. */
  .flank-btn {
    width: auto;
    padding: 0 16px;
    grid-auto-flow: column;
    gap: 8px;
    max-width: 42vw;
  }
  .flank-btn::after {
    position: static;
    transform: none;
    opacity: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .flank-btn:first-child:hover, .flank-btn:last-child:hover { transform: none; }
}
