/*
 * BJC book additions on top of the frozen Quarto/Bootstrap theme
 * (vendor/_static/bootstrap/*). The content-class styling (learn,
 * forYouToDo, …) lives in the frozen theme; this file styles only what the
 * XML build renders differently from the Quarto render: <details>-based
 * collapsibles (replacing the runtime-wrapped Bootstrap collapses), the
 * task lists (replacing Pandoc example lists), the builder's prev/next
 * buttons, and the search overlay.
 */

/* -- collapsible boxes (ifTime, takeItFurther, takeItTeased) + reveals ---- */

details.ifTime > summary,
details.takeItFurther > summary,
details.takeItTeased > summary,
details.reveal > summary {
  cursor: pointer;
  list-style: none;
  color: var(--bs-link-color);
  font-weight: bold;
}

details.ifTime > summary::-webkit-details-marker,
details.takeItFurther > summary::-webkit-details-marker,
details.takeItTeased > summary::-webkit-details-marker,
details.reveal > summary::-webkit-details-marker {
  display: none;
}

details.reveal > summary {
  font-weight: normal;
  color: inherit;
}

/* Only the toggle text itself reads as a link (the summary can carry an
   icon pill and lead-in text on the same line). */
details.reveal .reveal-label {
  color: var(--bs-link-color);
  text-decoration: underline;
}

details[open] > summary {
  margin-bottom: 0.5rem;
}

/* -- tasks (the numbered "for you to do" steps) --------------------------- */

/* Each task is its own one-item ol (numbered via @start); adjacent tasks
   read as one continuous list. */
ol.tasks {
  margin-bottom: 0;
}

ol.tasks > li {
  margin-bottom: 1rem;
}

/* -- images --------------------------------------------------------------- */

/* placement="indent" (the old ms-4 utility). */
img.indent {
  margin-left: 1.5rem;
}

/* -- prev/next (the builder's tree buttons) ------------------------------- */

.bjc-page-navigation {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bs-border-color, #dee2e6);
}

.bjc-page-navigation .up-button {
  display: none;
}

.bjc-page-navigation a.button {
  text-decoration: none;
}

.bjc-page-navigation .button .icon {
  display: none; /* material-symbols codepoints; we don't ship that font */
}

.bjc-page-navigation .button.disabled {
  visibility: hidden;
}

.bjc-page-navigation .next-button .name::after {
  content: " →";
}

.bjc-page-navigation .previous-button .name::before {
  content: "← ";
}

/* -- search overlay (search.js) ------------------------------------------- */

#bjc-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}

#bjc-search-overlay .bjc-search-box {
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
  border-radius: 0.5rem;
  width: min(40rem, 90vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.3);
}

#bjc-search-overlay input {
  border: none;
  outline: none;
  font-size: 1.2rem;
  padding: 1rem;
  background: transparent;
  color: inherit;
}

#bjc-search-overlay ol {
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0 0 0.5rem;
  border-top: 1px solid var(--bs-border-color, #dee2e6);
}

#bjc-search-overlay ol a {
  display: block;
  padding: 0.5rem 1rem;
  text-decoration: none;
}

#bjc-search-overlay ol a:hover,
#bjc-search-overlay ol li.selected a {
  background: var(--bs-tertiary-bg, #f8f9fa);
}

/* The builder's contents page emits a "Contents" heading; the old BJC root
   had none — the intro content leads directly. */
section.book > h1.ptx-toc-heading {
  display: none;
}

/* Unit/lab pages navigate via the sidebar, as the old site did — the
   builder's summary-links lists stay unrendered. */
#quarto-document-content nav.summary-links {
  display: none;
}

/* -- tables --------------------------------------------------------------- */

/* The old site's tables rendered with Bootstrap's .table (Quarto adds the
   class); the builder emits table.tabular, so give it the same basics. */
#quarto-document-content table.tabular {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
  caption-side: top;
  vertical-align: top;
  border-color: var(--bs-border-color, #dee2e6);
}

#quarto-document-content table.tabular > * > * > td,
#quarto-document-content table.tabular > * > * > th,
#quarto-document-content table.tabular > tr > td,
#quarto-document-content table.tabular > tr > th {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  vertical-align: top;
}

/* The emitter's per-cell alignment classes (halign c/r, valign m/b). */
#quarto-document-content table.tabular td.c,
#quarto-document-content table.tabular th.c {
  text-align: center;
}

#quarto-document-content table.tabular td.r,
#quarto-document-content table.tabular th.r {
  text-align: right;
}

#quarto-document-content table.tabular td.m,
#quarto-document-content table.tabular th.m {
  vertical-align: middle;
}

#quarto-document-content table.tabular td.b,
#quarto-document-content table.tabular th.b {
  vertical-align: bottom;
}

/* Inline code in table cells doesn't wrap mid-expression (the
   cheat-sheet's pseudocode column). */
#quarto-document-content table.tabular code {
  white-space: nowrap;
}

#quarto-document-content table.tabular > tr:first-child > th {
  border-bottom-width: 2px;
}

/* The builder's derived paragraphs (p-derived-*) wrap bare list-item runs
   that the old tight lists rendered without any <p>; keep them marginless
   so only authored paragraphs space out. */
#quarto-document-content p[id^="p-derived-"] {
  margin-top: 0;
  margin-bottom: 0;
}

/* -- video ---------------------------------------------------------------- */

/* The builder's <video> renders a .video-box whose height comes from a
   padding-top percentage (the 16:9 aspect box); the iframe is absolutely
   positioned to fill it. BHSawesome's theme carries these rules; BJC's
   frozen Quarto theme doesn't, so add them (without them the box has zero
   content height and the video collapses). */
#quarto-document-content .video-box {
  position: relative;
  height: 0;
  margin-bottom: 1rem;
}

#quarto-document-content .video-box > iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* -- docked sidebar sticky offset ----------------------------------------- */

/* Quarto's nav JS set the docked sidebar's `top` so position:sticky pins it
   to the viewport as you scroll (which is what keeps the sidebar/content
   divider line running the full length of the page). Our chrome replaces
   that JS, so set it in CSS. */
body.docked #quarto-sidebar {
  top: 0;
}

/* -- unsized images cap at the column ------------------------------------- */

/* Quarto stamped .img-fluid (max-width:100%; height:auto) on every
   markdown-authored image; the conversion's images carry no class. Give
   the same cap to any image without its own sizing (attributes or inline
   style), so full-resolution photos (the Difference Engine pair, the
   abacus) can't blow out the content column. Sized images are excluded so
   height/width attrs keep working (the art-gallery thumbnails). */
#quarto-document-content img:not([height]):not([width]):not([style]) {
  max-width: 100%;
  height: auto;
}

/* -- image-map hotspots: popups don't trap the mouse ---------------------- */

/* While a .hoverinfo popup is open, its layout box (the p's unshifted
   position:relative box, which sizes the invisible absolute div) sits over
   the image's other numbered regions — so moving directly from one number
   to the next kept the first popup open and never reached the second
   area. Make the popup machinery mouse-transparent: hover state comes
   only from the image-map areas themselves. */
.hoverinfo {
  pointer-events: none;
}

.hoverinfo area {
  pointer-events: auto;
}

/* PreTeXt border classes on tabular cells (the emitter's b/r/l/t levels
   from the tabular's border attrs) — the snap-cheat-sheet's fully-ruled
   reference tables (the old .bordered-table grid look). */
#quarto-document-content table.tabular > * > tr > td.t1,
#quarto-document-content table.tabular > * > tr > th.t1,
#quarto-document-content table.tabular > tr > td.t1,
#quarto-document-content table.tabular > tr > th.t1 {
  border-top: 1px solid var(--bs-border-color, #dee2e6);
}

#quarto-document-content table.tabular > * > tr > td.l1,
#quarto-document-content table.tabular > * > tr > th.l1,
#quarto-document-content table.tabular > tr > td.l1,
#quarto-document-content table.tabular > tr > th.l1 {
  border-left: 1px solid var(--bs-border-color, #dee2e6);
}

#quarto-document-content table.tabular > * > tr > td.r1,
#quarto-document-content table.tabular > * > tr > th.r1,
#quarto-document-content table.tabular > tr > td.r1,
#quarto-document-content table.tabular > tr > th.r1 {
  border-right: 1px solid var(--bs-border-color, #dee2e6);
}

/* -- saveAs boxes: the project name overlays the dialog screenshot -------- */

/* The old markup was <span class="text"> with these exact frozen-theme
   rules — the name composites into the save-this-as.png screenshot's
   blank filename field. The conversion carries the name as <var>. */
.saveAs var {
  position: absolute;
  margin-left: 182px;
  padding-top: 1.05em;
  z-index: 2;
  color: #333;
  font-style: normal;
}

/* -- the note aside (Quarto's simple callout-note) ------------------------ */

.note {
  padding: 0.4em 0.7em;
  margin-bottom: 1rem;
  border-left: 5px solid #2780e3;
  border-right: 1px solid #dee2e6;
  border-top: 1px solid #dee2e6;
  border-bottom: 1px solid #dee2e6;
  font-size: 0.9rem;
}
