/* ── Puzzle set pages ─────────────────────────────────────────────────────────
   One problem per <section class="pz-problem">: the statement (a .latex-body
   block), figures, then dropdowns for the embedded app and the solution.
   ────────────────────────────────────────────────────────────────────────── */

.pz-page-wrap {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.pz-page-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pz-page-top h1 {
  margin: 0;
  font-size: 1.6rem;
}

.pz-page-links {
  font-size: 0.9rem;
}

.pz-toc {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
}

.pz-toc a {
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.pz-problem {
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  border-top: 2px solid var(--color-wood);
  scroll-margin-top: 1rem;
}

.pz-problem:first-of-type {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.pz-problem .math-env-problem {
  margin-top: 0;
}

/* ── Figures ── */

.pz-figrow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem 3rem;
  margin: 1rem 0 1.25rem;
}

/* The theme makes every <figure> a flex row, which collapses the container-sized box */
.pz-fig {
  display: block;
  flex: 1 1 220px;
  margin: 0 auto;
}

.pz-figrow > .pz-fig {
  margin: 0;
}

.pz-fig-box {
  position: relative;
  container-type: inline-size;
}

.pz-fig svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.pz-lab {
  position: absolute;
  white-space: nowrap;
  line-height: 1;
  font-style: normal;
  pointer-events: none;
}

/* \xc, \yc, \pc in math (see puzzles.js), matching the multiplication app */
.pz-x { color: #2E6CB5; }
.pz-y { color: #C2671B; }
.pz-p { color: #3C8031; }

/* Method rows inside a problem: prose on the left, worked example on the right */
.pz-method {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin: 1rem 0;
}

.pz-method-text {
  flex: 1 1 0;
  min-width: 0;
}

.pz-method > .pz-fig {
  flex: 0 1 auto;
  width: 34%;
}

/* ── Dropdowns (app and solution) ── */

.pz-drop {
  margin: 0.9rem 0;
  border: 1px solid var(--color-divider);
  border-radius: 6px;
  background: var(--color-cream);
  padding: 0 1.1rem;
}

.pz-drop > summary {
  padding: 0.65rem 0;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-slate);
}

.pz-drop > summary .pz-sum-kind {
  font-weight: bold;
  margin-right: 0.35rem;
}

.pz-drop[open] > summary {
  border-bottom: 1px solid var(--color-divider);
  margin-bottom: 1rem;
}

.pz-drop-body {
  padding-bottom: 1rem;
}

.pz-open-full {
  display: block;
  text-align: right;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

/* Same board-and-frame treatment as the widget layout */
.pz-embed {
  border: 2px solid var(--color-wood);
  outline: 4px ridge var(--color-wood-deep);
  margin: 4px;
}

.pz-embed iframe {
  display: block;
  width: 100%;
  border: none;
  transition: height 0.15s;
}

@media (max-width: 700px) {
  .pz-page-wrap { padding: 0 1rem; }
  .pz-method { flex-direction: column; align-items: stretch; }
  .pz-method > .pz-fig { width: 100%; max-width: 260px; margin: 0 auto; }
  .pz-drop { padding: 0 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pz-embed iframe { transition: none; }
}
