/* hide later sections until exercises are complete */
/* Hide while there exists any pending exercise (wait cell without data-complete). */
body#progressive section:has(.cell.wait[data-check="true"]:not([data-complete="true"])) ~ *,
body#progressive section:has(ul.task-list input[type="checkbox"]:not(:checked)) ~ * {
  display: none !important;
}

/* Also hide content that follows a manual gate (unchecked task list)
   within the same section, not just subsequent sections. */
body#progressive ul.task-list:has(input[type="checkbox"]:not(:checked)) ~ * {
  display: none !important;
}
/* reveal later sections when exercises are complete: implicit when no pending remain */

/* general pill styling */
/* Only show the pill on the innermost section that still has a pending exercise. */
body#progressive section:has(.cell.wait[data-check="true"]:not([data-complete="true"])):not(:has(section .cell.wait[data-check="true"]:not([data-complete="true"])))::after, body#progressive ul.task-list:has(input[type="checkbox"]:not(:checked)) {
  display: inline-block;
  position: absolute;
  left: 0;
  right: 0;
  margin-inline: auto;
  border-radius: 0.25rem;
  padding: 0.5em;
  width: fit-content;
}

/* message pill to explain hidden sections */
body#progressive section:has(.cell.wait[data-check="true"]:not([data-complete="true"])):not(:has(section .cell.wait[data-check="true"]:not([data-complete="true"])))::after {
  content: "Complete (or skip) exercises to continue";
  color: #664d03;
  background-color: #fff3cd;
  border-color: #ffecb5;
}

/* remove message after completed sections */
section:not(:has(.cell.wait[data-check="true"]:not([data-complete="true"])))::after {
  content: "";
}

/* action pill for next sections and toc */
body#progressive ul.task-list:has(input[type="checkbox"]:not(:checked)) {
  color: #084298;
  background-color: #cfe2ff;
  border-color: #b6d4fe;
  cursor: pointer;
}

/* (hover) */
body#progressive ul.task-list:has(input[type="checkbox"]:not(:checked)):hover, ul.task-list:has(input[type="checkbox"]:not(:checked)) label:hover {
  color: #055160;
  background-color: #cff4fc;
  border-color: #b6effb;
  cursor: pointer;
}

/* remove action pill on click or displayall */
ul.task-list:has(input[type="checkbox"]:checked), ul.task-list input[type="checkbox"], body#displayall ul.task-list:has(input[type="checkbox"]:not(:checked)) {
  display: none;
}

/* hide toc until end */
body#progressive #quarto-content:has(.showtoc input[type="checkbox"]:not(:checked)) nav#TOC {
  visibility: hidden;
}

/* show toc at end */
#quarto-content:has(.showtoc input[type="checkbox"]::checked) nav#TOC {
  visibility: inherit;
}
