/* Pushword quiz — self-contained styles. Themeable via the CSS variables below.
   The accent follows the host theme's --primary token; the purple is only the
   fallback when a site hasn't defined one. */
.pw-quiz {
  --pw-quiz-radius: 14px;
  --pw-quiz-card: #ffffff;
  --pw-quiz-border: #e5e7eb;
  --pw-quiz-accent: var(--primary, #6d28d9);
  --pw-quiz-correct: #16a34a;
  --pw-quiz-correct-bg: #dcfce7;
  --pw-quiz-wrong: #e11d48;
  --pw-quiz-wrong-bg: #ffe4e6;
  --pw-quiz-muted: #6b7280;
  display: block;
  margin: 2rem 0;
}

.pw-quiz * {
  box-sizing: border-box;
}

/* ---- header ---- */
.pw-quiz-head {
  margin-bottom: 1.25rem;
}
.pw-quiz-title {
  margin: 0 0 0.25rem;
}
.pw-quiz-meta {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  color: var(--pw-quiz-muted);
  font-size: 0.9rem;
  margin: 0;
}
.pw-quiz-diff {
  background: var(--pw-quiz-accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
}

/* ---- questions ---- */
.pw-quiz-questions {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.pw-quiz-q {
  position: relative;
  background: var(--pw-quiz-card);
  border: 1px solid var(--pw-quiz-border);
  border-radius: var(--pw-quiz-radius);
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.pw-quiz-q-num {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--pw-quiz-accent);
  margin-bottom: 0.5rem;
}
.pw-quiz-media {
  margin: 0 0 0.75rem;
}
/* Centered and capped at half the viewport so a portrait image never pushes the
   question and its answers off-screen. Scoped to the question image only — the
   video poster keeps its own full-bleed sizing. */
.pw-quiz-media-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 50vh;
  margin-inline: auto;
  border-radius: 10px;
}
.pw-quiz-question {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

/* ---- answers ---- */
.pw-quiz-answers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}
/* Let each answer button fill its grid cell so side-by-side boxes match the
   tallest one in their row. */
.pw-quiz-answers > li {
  display: flex;
}
@media (min-width: 540px) {
  .pw-quiz-answers {
    grid-template-columns: 1fr 1fr;
    /* Equal-height rows: every box in the two-column layout matches the tallest
       answer, so a long answer no longer leaves its neighbours shorter. */
    grid-auto-rows: 1fr;
  }
}
.pw-quiz-a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  font: inherit;
  background: #f9fafb;
  border: 1px solid var(--pw-quiz-border);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  cursor: default;
  transition: background 0.15s, border-color 0.15s;
}
.pw-quiz-a-prefix {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: color-mix(in oklch, var(--pw-quiz-accent) 14%, #fff);
  color: var(--pw-quiz-accent);
  font-weight: 700;
  font-size: 0.85rem;
}
.pw-quiz-a-img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}
.pw-quiz-a-text {
  flex: 1 1 auto;
}
.pw-quiz-a-mark {
  flex: 0 0 auto;
  width: 1.25rem;
  text-align: center;
  font-weight: 700;
}

/* ---- explanation ---- */
.pw-quiz-explanation {
  margin: 0.9rem 0 0;
  padding: 0.75rem 1rem;
  background: #f3f4f6;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #374151;
}
.pw-quiz-explanation-label {
  font-weight: 700;
}

/* ===========================================================================
   No-JS / crawler view (default): everything is visible and the correct
   answers are flagged with a ✓ so the page reads as a Q&A article.
   =========================================================================== */
.pw-quiz:not(.pw-quiz--js) .pw-quiz-a[data-correct] {
  border-color: var(--pw-quiz-correct);
  background: var(--pw-quiz-correct-bg);
}
.pw-quiz:not(.pw-quiz--js) .pw-quiz-a[data-correct] .pw-quiz-a-mark::after {
  content: "\2713"; /* ✓ */
  color: var(--pw-quiz-correct);
}

/* ===========================================================================
   Interactive view (JS on).
   =========================================================================== */
.pw-quiz--js .pw-quiz-q[data-locked] {
  display: none;
}
.pw-quiz--js .pw-quiz-a:not([disabled]) {
  cursor: pointer;
}
.pw-quiz--js .pw-quiz-a:not([disabled]):hover {
  border-color: var(--pw-quiz-accent);
  background: color-mix(in oklch, var(--pw-quiz-accent) 6%, #fff);
}
/* Hide the explanation until its question has been answered. */
.pw-quiz--js .pw-quiz-q:not(.pw-quiz-q--answered) .pw-quiz-explanation {
  display: none;
}

/* Reveal correctness only after answering. ✓/✗ glyphs back up the colours
   (WCAG 1.4.1 — never signal by colour alone). */
.pw-quiz--js .pw-quiz-a--correct {
  border-color: var(--pw-quiz-correct);
  background: var(--pw-quiz-correct-bg);
}
.pw-quiz--js .pw-quiz-a--correct .pw-quiz-a-mark::after {
  content: "\2713"; /* ✓ */
  color: var(--pw-quiz-correct);
}
.pw-quiz--js .pw-quiz-a--chosen-wrong {
  border-color: var(--pw-quiz-wrong);
  background: var(--pw-quiz-wrong-bg);
}
.pw-quiz--js .pw-quiz-a--chosen-wrong .pw-quiz-a-mark::after {
  content: "\2717"; /* ✗ */
  color: var(--pw-quiz-wrong);
}
/* Personality mode: an answer is a preference, not right or wrong — just mark
   the chosen one and drop the ✓/✗ affordance. */
.pw-quiz--profile .pw-quiz-a-mark {
  display: none;
}
.pw-quiz--js.pw-quiz--profile .pw-quiz-a--chosen {
  border-color: var(--pw-quiz-accent);
  background: color-mix(in oklch, var(--pw-quiz-accent) 10%, #fff);
}

/* ---- result ---- */
.pw-quiz-result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--pw-quiz-card);
  border: 1px solid var(--pw-quiz-border);
  border-radius: var(--pw-quiz-radius);
}
.pw-quiz-donut {
  display: block;
  width: 130px;
  height: 130px;
  margin: 0 auto 0.75rem;
}
.pw-quiz-donut-bg {
  stroke: var(--pw-quiz-border);
}
.pw-quiz-donut-fg {
  stroke: var(--pw-quiz-accent);
  transition: stroke-dasharray 0.7s cubic-bezier(0.22, 1, 0.36, 1); /* ease-out-quint */
}
.pw-quiz-donut-text {
  font-size: 1.8rem;
  font-weight: 700;
  fill: #111827;
}
.pw-quiz-band {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.25rem 0;
}
.pw-quiz-correct {
  color: var(--pw-quiz-muted);
  margin: 0.25rem 0;
}
.pw-quiz-percentile {
  color: var(--pw-quiz-accent);
  font-weight: 600;
  margin: 0.25rem 0;
}
.pw-quiz-cta {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--pw-quiz-border);
}
/* "Restart" — shown on a finished quiz (also when a completed attempt is replayed
   on return); resets it in place. Secondary/ghost styling so it never competes
   with the primary "next level" action. */
.pw-quiz-restart {
  display: block;
  font: inherit;
  font-weight: 600;
  color: var(--pw-quiz-accent);
  background: transparent;
  border: 1px solid var(--pw-quiz-accent);
  border-radius: 999px;
  padding: 0.55rem 1.3rem;
  margin: 1.25rem auto 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pw-quiz-restart:hover {
  background: var(--pw-quiz-accent);
  color: #fff;
}
.pw-quiz-restart:focus-visible {
  outline: 2px solid var(--pw-quiz-accent);
  outline-offset: 2px;
}
.pw-quiz-cta-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

/* ---- personality result card ---- */
.pw-quiz-profile-intro {
  color: var(--pw-quiz-muted);
  margin: 0 0 0.5rem;
  text-align: center;
}
.pw-quiz-profile-title {
  font-size: 1.4rem;
  margin: 0 0 0.75rem;
  color: var(--pw-quiz-accent);
  text-align: center;
}
.pw-quiz-profile-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 0.75rem;
  border-radius: var(--pw-quiz-radius);
}
.pw-quiz-profile-msg {
  margin: 0.25rem auto 0;
  max-width: 42rem;
  line-height: 1.6;
}
/* Both message boxes now hold rendered Markdown (a wrapping <p>, maybe more):
   collapse the block's outer margins so the container's own spacing wins. */
.pw-quiz-band > :first-child,
.pw-quiz-profile-msg > :first-child {
  margin-top: 0;
}
.pw-quiz-band > :last-child,
.pw-quiz-profile-msg > :last-child {
  margin-bottom: 0;
}
.pw-quiz-share {
  color: var(--pw-quiz-accent);
  font-weight: 600;
  margin: 0.75rem 0 0;
}

/* ===========================================================================
   Difficulty levels: an accessible tab selector (role=tablist) over one leaf
   quiz per panel. Without JS the panels stay visible and stack as a readable
   Q&A; quiz.js turns them into tabs.
   =========================================================================== */
.pw-quiz-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.pw-quiz-tab {
  font: inherit;
  font-weight: 600;
  color: var(--pw-quiz-accent);
  background: color-mix(in oklch, var(--pw-quiz-accent) 8%, #fff);
  border: 1px solid var(--pw-quiz-border);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pw-quiz-tab:hover {
  border-color: var(--pw-quiz-accent);
}
.pw-quiz-tab[aria-selected="true"] {
  background: var(--pw-quiz-accent);
  border-color: var(--pw-quiz-accent);
  color: #fff;
}
.pw-quiz-tab:focus-visible {
  outline: 2px solid var(--pw-quiz-accent);
  outline-offset: 2px;
}
/* Each level keeps its own meta line (questions count + difficulty badge). */
.pw-quiz-level > .pw-quiz-meta {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  color: var(--pw-quiz-muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}
/* "Next level →" nudge, shown once a level is passed. */
.pw-quiz-next {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--pw-quiz-accent);
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  margin-top: 1rem;
  cursor: pointer;
  transition: filter 0.15s;
}
.pw-quiz-next:hover {
  filter: brightness(1.08);
}
.pw-quiz-next:focus-visible {
  outline: 2px solid var(--pw-quiz-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .pw-quiz-donut-fg,
  .pw-quiz-a {
    transition: none;
  }
}
