/* /quiz/ hub (site/quiz-hub.mjs): hero with the turning body and its session card, the 3 exercise demos (video + quiz UI timed by
   public/learn/ui/demos.js through data-state), regions with a 3D still, medals and ranks, FAQ. Tokens: learn.css. */

.qh-hero .qh-hero__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 480px); gap: 48px; align-items: center; padding-top: 40px; padding-bottom: 56px; }
.qh-hero__copy h1 { max-width: 13ch; }
.qh-hero .dek { font-size: 19px; max-width: 34ch; }
.qh-hero__cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; }
.qh-hero__cta .lx-btn { min-height: 54px; padding: 0 26px; font-size: 17px; }
.qh-hero__note { margin: 14px 0 0; font-size: 14px; color: #98A2B3; }
.qh-link { font-weight: 800; color: inherit; text-underline-offset: 4px; display: inline-flex; align-items: center; gap: 6px; }
.qh-hero .qh-link { color: #FFFFFF; }
.qh-hero__media { position: relative; aspect-ratio: 1; border-radius: 28px; background: #F2F4F7; box-shadow: 0 30px 70px rgba(0, 0, 0, .45); }
.qh-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* Hero session card (site/quiz-hub.mjs heroSteps): a satellite over the media's left edge telling one short session
   with the video: found1, ask2, found2 … found4, medal, out (it leaves before the loop so its numbers reset unseen).
   --n = structures found so far. Travel and arrivals on two curves; nothing pops. */
.qh-hero__media { --n: 1; }
.qh-hero__media:is([data-state="found2"], [data-state="ask3"]) { --n: 2; }
.qh-hero__media:is([data-state="found3"], [data-state="ask4"]) { --n: 3; }
.qh-hero__media:is([data-state="found4"], [data-state="medal"], [data-state="out"]) { --n: 4; }
.qh-session { position: absolute; left: -44px; bottom: 32px; z-index: 2; width: 300px; box-sizing: border-box; padding: 16px 18px 18px; border-radius: 20px; background: #FFFFFF; color: var(--lx-ink); box-shadow: 0 24px 48px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 10px; transition: opacity .35s var(--lx-out), transform .45s var(--lx-out); }
.qh-session__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--lx-muted); }
.qh-session__segs { display: flex; gap: 4px; }
.qh-session__segs i { width: 22px; height: 5px; border-radius: 999px; background: #EAECF0; transition: background .3s; }
.qh-session__segs i:nth-child(1),
:is([data-state="found2"], [data-state="ask3"], [data-state="found3"], [data-state="ask4"], [data-state="found4"], [data-state="medal"], [data-state="out"]) .qh-session__segs i:nth-child(2),
:is([data-state="found3"], [data-state="ask4"], [data-state="found4"], [data-state="medal"], [data-state="out"]) .qh-session__segs i:nth-child(3),
:is([data-state="found4"], [data-state="medal"], [data-state="out"]) .qh-session__segs i:nth-child(4) { background: var(--lx-green); }
/* The prompt: the new words rise into place as the old ones sink and fade (demos.js swapLabel) */
.qh-session__ask { display: grid; font-size: 20px; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; overflow: hidden; }
.qh-session__ask > span { grid-area: 1 / 1; white-space: nowrap; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .45s var(--lx-out); }
.qh-session__ask > .is-on { opacity: 1; transform: none; transition: opacity .35s .1s, transform .45s var(--lx-out) .1s; }
.qh-session__status { display: grid; font-size: 14px; font-weight: 800; }
.qh-session__status > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 8px; opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .35s var(--lx-out); }
.qh-session__ok { color: var(--lx-green-ink); }
.qh-session__ok i { width: 20px; height: 20px; border-radius: 999px; background: var(--lx-green); color: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.qh-session__ok svg { width: 12px; height: 12px; }
.qh-session__hint { color: var(--lx-muted); font-weight: 700; }
.qh-session__won { color: #8A5A00; }
:is([data-state^="found"]) .qh-session__ok,
:is([data-state^="ask"]) .qh-session__hint,
:is([data-state="medal"], [data-state="out"]) .qh-session__won { opacity: 1; transform: none; }
.qh-session__foot { display: flex; align-items: center; gap: 12px; }
.qh-session__bar { flex: 1; height: 8px; border-radius: 999px; background: #EAECF0; overflow: hidden; }
.qh-session__bar b { display: block; height: 100%; width: calc(var(--n) * 25%); border-radius: inherit; background: var(--lx-blue); transition: width .7s var(--lx-out), background .2s; }
:is([data-state="medal"], [data-state="out"]) .qh-session__bar b { background: var(--lx-gold); }
.qh-session__count { flex: none; font-size: 13px; font-weight: 800; color: var(--lx-ink-2); line-height: 1.3; font-variant-numeric: tabular-nums; }
/* The count rolls to the next digit (a column of 0 to 4 in a one-line window) */
.qh-session__digit { display: inline-block; height: 1.3em; overflow: hidden; vertical-align: top; }
.qh-session__roll { display: flex; flex-direction: column; transform: translateY(calc(var(--n) * -1.3em)); transition: transform .5s var(--lx-out) .15s; }
.qh-session__roll > span { height: 1.3em; text-align: center; }
/* The medal lands on the card's top-right corner, half outside, with one turn and a soft landing */
.qh-session__medal { position: absolute; top: -30px; right: -18px; filter: drop-shadow(0 10px 14px rgba(16, 24, 40, .25)); opacity: 0; transform: translateY(-36px) rotateY(-360deg) scale(.7); transition: opacity .3s, transform .9s cubic-bezier(.25, .8, .25, 1); }
.qh-session__medal svg { display: block; }
:is([data-state="medal"], [data-state="out"]) .qh-session__medal { opacity: 1; transform: none; }
/* The loop seam: the card leaves, its numbers snap back while it is away, and it comes back on the first find */
[data-state="out"] .qh-session { opacity: 0; transform: translateY(14px); }
[data-state="found1"] .qh-session { transition-delay: .2s; }
[data-state="found1"] .qh-session * { transition: none !important; }

.qh-section { padding: 56px 0; }
.qh-section h2 { margin: 0 0 24px; font-size: clamp(26px, 3vw, 34px); font-weight: 800; letter-spacing: -.02em; }
.qh-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; margin-bottom: 24px; }
.qh-head h2 { margin: 0; }
.qh-head .qh-link { color: var(--lx-ink-2); font-size: 15px; }

/* The three demos */
.qh-demos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.qh-demo h3 { margin: 16px 0 4px; font-size: 20px; font-weight: 800; }
.qh-demo p { margin: 0; color: var(--lx-ink-2); font-size: 16px; }
.qh-demo__media { position: relative; aspect-ratio: 1; border-radius: 24px; overflow: hidden; background: #F2F4F7; border: 1px solid var(--lx-line); }
.qh-prompt { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 9px 16px; border-radius: 999px; background: #FFFFFF; color: var(--lx-ink); font-size: 14px; font-weight: 800; white-space: nowrap; box-shadow: 0 6px 18px rgba(16, 24, 40, .12); }

.qh-options { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* Compact options (small type, tight lines) so the 2 × 2 answers stay low and the lit structure stays in view;
   names wrap rather than truncate: "Pectoralis…" would make the right answer ambiguous */
.qh-options li { position: relative; padding: 6px 9px; border-radius: 11px; border: 1.5px solid var(--lx-line); background: #FFFFFF; font-size: 12px; line-height: 1.25; font-weight: 700; color: var(--lx-ink); transition: background .25s, border-color .25s, color .25s, transform .2s; }
.qh-options .is-answer { padding-right: 28px; }
.qh-options i { position: absolute; right: 8px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 999px; background: var(--lx-green); color: #FFFFFF; display: none; align-items: center; justify-content: center; }
.qh-options svg { width: 11px; height: 11px; }
[data-state="tap"] .qh-options .is-answer { transform: scale(.96); border-color: var(--lx-ink-2); }
[data-state="right"] .qh-options .is-answer { background: var(--lx-green-soft); border-color: var(--lx-green); color: var(--lx-green-ink); animation: qh-pop .45s var(--lx-spring); }
[data-state="right"] .qh-options .is-answer i { display: inline-flex; }

/* A tap: a ring that shrinks onto the point. */
.qh-tap { position: absolute; left: var(--x); top: var(--y); width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 999px; border: 3px solid rgba(16, 24, 40, .55); background: rgba(255, 255, 255, .35); opacity: 0; pointer-events: none; }
[data-state="tap"] .qh-tap, [data-state="sel1"] .qh-tap--1, [data-state="sel2"] .qh-tap--2, [data-state="sel3"] .qh-tap--3 { animation: qh-tap .6s var(--lx-out) forwards; }
.qh-mark { position: absolute; left: var(--x); top: var(--y); width: 36px; height: 36px; margin: -52px 0 0 14px; border-radius: 999px; background: var(--lx-green); color: #FFFFFF; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 5px rgba(18, 183, 106, .2); opacity: 0; }
.qh-mark svg { width: 20px; height: 20px; }
[data-state="right"] .qh-mark { animation: qh-mark 1.6s var(--lx-out) forwards; }
/* A demo waiting for its turn (demos.js relay) keeps its result on screen, without replaying its animations */
[data-rest] .qh-mark { animation: none; opacity: 1; }
[data-rest] .qh-options .is-answer { animation: none; }

.qh-count { position: absolute; left: 12px; bottom: 12px; padding: 9px 14px; border-radius: 999px; background: #FFFFFF; font-size: 13px; font-weight: 800; color: var(--lx-ink); box-shadow: 0 4px 12px rgba(16, 24, 40, .08); }
.qh-count b { display: none; font-weight: 800; }
[data-state="ask"] .qh-count b[data-n="0"], [data-state="sel1"] .qh-count b[data-n="1"], [data-state="sel2"] .qh-count b[data-n="2"],
[data-state="sel3"] .qh-count b[data-n="3"], [data-state="check"] .qh-count b[data-n="3"], [data-state="right"] .qh-count b[data-n="3"] { display: inline; }
.qh-check { position: absolute; right: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 999px; background: #D0D5DD; color: #FFFFFF; font-size: 13px; font-weight: 800; transition: background .25s, transform .2s; }
.qh-check i { display: none; width: 14px; height: 14px; }
.qh-check svg { width: 14px; height: 14px; }
[data-state="sel1"] .qh-check, [data-state="sel2"] .qh-check, [data-state="sel3"] .qh-check { background: var(--lx-cta); }
[data-state="check"] .qh-check { background: var(--lx-cta-dark); transform: scale(.94); }
[data-state="right"] .qh-check { background: var(--lx-green-2); }
[data-state="right"] .qh-check i { display: inline-flex; }

/* Regions */
.qh-regions { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.qh-region { display: flex; flex-direction: column; border-radius: 20px; background: var(--lx-tile); color: var(--lx-ink); text-decoration: none; overflow: hidden; transition: transform .2s var(--lx-out), box-shadow .2s; }
.qh-region:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(16, 24, 40, .12); color: var(--lx-ink); }
.qh-region__img { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 12px; background: radial-gradient(90% 80% at 50% 40%, #FFFFFF 0%, #EEF1F5 100%); }
.qh-region__img img { width: 100%; height: 100%; object-fit: contain; transition: transform .35s var(--lx-out); }
.qh-region:hover .qh-region__img img { transform: scale(1.05); }
.qh-region__body { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 14px; }
.qh-region__body strong { font-size: 16px; font-weight: 800; }
.qh-region__meta { font-size: 13px; color: var(--lx-muted); }
.qh-region__medals { display: flex; gap: 4px; margin-top: 6px; }

/* Medals and ranks */
.qh-progress { background: var(--lx-tile); }
.qh-levels { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; counter-reset: lvl; }
.qh-levels li { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px; border-radius: 20px; background: #FFFFFF; text-align: center; }
.qh-levels__medal { position: relative; margin-bottom: 6px; }
.qh-levels__x { position: absolute; right: -14px; bottom: 4px; padding: 4px 9px; border-radius: 999px; background: var(--lx-ink); color: #FFE27A; font-size: 16px; font-weight: 800; line-height: 1; }
.qh-levels strong { font-size: 16px; font-weight: 800; }
.qh-levels li > span:last-child { font-size: 14px; color: var(--lx-ink-2); }
.qh-progress__rule { margin: 22px 0 18px; font-size: 17px; font-weight: 700; text-align: center; }
.qh-ranks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.qh-ranks li { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; font-weight: 800; color: var(--lx-ink-2); text-align: center; }
.qh-ranks small { margin-top: -6px; font-size: 12px; font-weight: 700; color: var(--lx-muted); }

/* FAQ + quick quiz */
.qh-more__grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
.qh-faq { border-bottom: 1px solid var(--lx-line); }
.qh-faq summary { padding: 16px 0; font-size: 17px; font-weight: 800; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.qh-faq summary::-webkit-details-marker { display: none; }
.qh-faq summary::after { content: '+'; font-size: 22px; line-height: 1; color: var(--lx-muted); }
.qh-faq[open] summary::after { content: '−'; }
.qh-faq p { margin: 0 0 18px; font-size: 16px; line-height: 1.6; color: var(--lx-ink-2); }
.qh-quick { display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: 22px; background: var(--lx-tile); color: var(--lx-ink); text-decoration: none; }
.qh-quick img { width: 120px; height: 120px; object-fit: contain; margin-bottom: 6px; }
.qh-quick strong { font-size: 18px; font-weight: 800; }
.qh-quick span { font-size: 15px; color: var(--lx-ink-2); }
.qh-quick .qh-link { margin-top: 8px; color: var(--lx-cta); }

@keyframes qh-pop { 40% { transform: scale(1.06); } }
@keyframes qh-tap { 0% { opacity: 0; transform: scale(1.6); } 35% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.7); } }
@keyframes qh-mark { 0% { opacity: 0; transform: scale(.6); } 15% { opacity: 1; transform: scale(1.05); } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 900px) {
  .qh-hero .qh-hero__grid { grid-template-columns: 1fr; gap: 28px; padding-top: 24px; padding-bottom: 40px; }
  .qh-hero__media { max-width: 440px; width: 100%; justify-self: center; margin-bottom: 44px; }
  /* The session card straddles the media's bottom edge instead of its left one */
  .qh-session { left: 16px; right: 16px; bottom: -44px; width: auto; }
  .qh-more__grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .qh-section { padding: 40px 0; }
  /* Demos: a swipeable row, the next card peeking. */
  .qh-demos { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 14px; margin: 0 -16px; padding: 0 16px 8px; scrollbar-width: none; }
  .qh-demos::-webkit-scrollbar { display: none; }
  .qh-demo { flex: 0 0 82%; scroll-snap-align: center; }
  .qh-options { left: 10px; right: 10px; bottom: 10px; gap: 6px; }
  .qh-options li { padding: 6px 9px; font-size: 12px; }
  .qh-prompt { font-size: 13px; padding: 8px 14px; }
  .qh-regions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .qh-levels { grid-template-columns: 1fr; gap: 10px; }
  .qh-levels li { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; row-gap: 2px; padding: 14px 16px; text-align: left; }
  .qh-levels__medal { margin: 0; grid-row: 1 / 3; }
  .qh-levels__medal svg { width: 58px; height: 72px; }
  .qh-levels__x { right: -10px; bottom: 0; padding: 3px 7px; font-size: 13px; }
  .qh-levels strong { align-self: end; }
  .qh-levels li > span:last-child { align-self: start; }
  .qh-ranks { display: flex; overflow-x: auto; gap: 14px; padding: 8px 0 6px; }
  .qh-ranks li { flex: 0 0 76px; }
  .qh-ranks svg { width: 64px; height: 70px; }
  .qh-hero__cta .lx-btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .qh-session, .qh-session *, .qh-tap, .qh-mark, .qh-options li, .qh-region, .qh-region__img img { animation: none !important; transition: none !important; }
}
.qh-head--systems { margin: 48px 0 6px; }
.qh-sub { margin: 0 0 20px; color: var(--lx-ink-2); font-size: 16px; }

/* Reload of /quiz/ by someone who has a dashboard: the static hub stays hidden until the dashboard replaces it
   (class set by the inline script of site/quiz-hub.mjs from the local hint, removed by public/learn/main.js). */
.lx-dash-pending main > :not(.lx-hub) { display: none; }
.lx-dash-pending .lx-hub { position: relative; min-height: 70vh; }
.lx-dash-pending .lx-hub > * { visibility: hidden; }
.lx-dash-pending .lx-hub::after { content: ""; position: absolute; left: 50%; top: 120px; width: 32px; height: 32px; margin-left: -16px; border-radius: 50%; border: 3px solid #E4E7EC; border-top-color: #2E7CF6; animation: qh-spin .8s linear infinite; }
@keyframes qh-spin { to { transform: rotate(360deg); } }
