/*
 * BJC book — element defaults.
 *
 * The slice of Bootstrap's reboot the book actually relied on, plus the
 * Quarto and bjc.scss element rules (list spacing, code colors, heading
 * weights) that sat on top of it, merged into one place. Everything here is
 * a bare element selector or one of the handful of utility classes the
 * chrome and the quiz runtime's markup carry (the "utilities" section at
 * the bottom — keep it to classes that actually occur in the markup).
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  font-size: var(--bjc-root-font-size);
}

body {
  margin: 0;
  font-family: var(--bjc-font-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bjc-body-color);
  background-color: var(--bjc-body-bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

[hidden] {
  display: none !important;
}

hr {
  margin: 1rem 0;
  color: inherit;
  border: 0;
  border-top: 1px solid;
  opacity: 0.25;
}

/* -- headings -------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-weight: 400;
  line-height: 1.2;
  color: inherit;
}

/* Fluid below 1200px, fixed above — Bootstrap's responsive-font-size sizes. */
h1 {
  font-size: calc(1.325rem + 0.9vw);
}

h2 {
  font-size: calc(1.29rem + 0.48vw);
}

h3 {
  font-size: calc(1.27rem + 0.24vw);
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1.1rem;
}

h6 {
  font-size: 1rem;
}

@media (min-width: 1200px) {
  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.65rem;
  }

  h3 {
    font-size: 1.45rem;
  }
}

/* Quarto's article headings: semibold, a rule under h2s. */
h1,
h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

h2 {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bjc-border);
}

h3 {
  font-weight: 600;
}

h3,
h4 {
  margin-top: 1.5rem;
  opacity: 0.9;
}

h5,
h6 {
  opacity: 0.9;
}

/* -- text ------------------------------------------------------------------ */

p {
  margin-top: 8px; /* bjc.scss: paragraphs sit a little apart */
  margin-bottom: 1rem;
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
  text-decoration-skip-ink: none;
}

b,
strong {
  font-weight: bolder;
}

small {
  font-size: 0.875em;
}

mark {
  padding: 0;
  background-color: var(--bjc-mark-bg);
}

sub,
sup {
  position: relative;
  font-size: 0.75em;
  line-height: 0;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

blockquote {
  margin: 0 0 1rem;
  padding: 0.625rem 1.25rem;
  border-left: 0.25rem solid var(--bjc-blockquote-border);
}

blockquote > :last-child {
  margin-bottom: 0;
}

/* The builder's <blockquote class="blockquote"> (Unit 6's timeline quotes):
   Quarto's muted, inset pull-quote look. */
.blockquote {
  margin-bottom: 1rem;
  padding-left: 1rem;
  padding-right: 1.5rem;
  font-size: inherit;
  color: var(--bjc-caption-color);
}

.lead {
  font-size: 1.25rem;
  font-weight: 300;
}

/* -- links ----------------------------------------------------------------- */

a {
  color: var(--bjc-link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--bjc-link-hover);
}

/* An <a> with no href isn't a link (bjc-assignments.js strips the href from
   an unassigned assignment link). */
a:not([href]):not([class]),
a:not([href]):not([class]):hover {
  color: inherit;
  text-decoration: none;
}

/* -- lists ----------------------------------------------------------------- */

ol,
ul {
  margin-top: 0;
  margin-bottom: 0; /* bjc.scss: lists are tight; the li padding spaces items */
  padding-left: 2rem;
}

li {
  padding: 3px;
}

li > ul,
li > ol {
  margin: 5px auto;
}

li > ol {
  list-style-type: lower-alpha;
}

/* A sub-list under a bare item sits tight; a sub-item that is itself a
   paragraph gets room above (Quarto's list rhythm). */
ul > li:not(:has(> p)) > ul,
ol > li:not(:has(> p)) > ul,
ul > li:not(:has(> p)) > ol,
ol > li:not(:has(> p)) > ol {
  margin-bottom: 0;
}

ul > li:not(:has(> p)) > ul > li:has(> p),
ol > li:not(:has(> p)) > ul > li:has(> p),
ul > li:not(:has(> p)) > ol > li:has(> p),
ol > li:not(:has(> p)) > ol > li:has(> p) {
  margin-top: 1rem;
}

dt {
  font-weight: 700;
}

dd {
  margin-bottom: 0.5rem;
  margin-left: 0;
}

/* -- code ------------------------------------------------------------------ */

pre,
code,
kbd,
samp {
  font-family: var(--bjc-font-mono);
  font-size: 1em;
}

/* Inline code: purple on a pale pill, no padding (bjc.scss zeroed
   Bootstrap's), never wrapped inside — the Snap!-block names in prose. */
code {
  padding: 0;
  font-size: 0.875em;
  font-weight: 400;
  color: var(--bjc-code-color);
  background-color: var(--bjc-code-bg);
  border-radius: 0.25rem;
  white-space: pre;
  word-wrap: break-word;
}

a > code {
  color: inherit;
}

/* In running text (a paragraph, list item or table cell) the pill gets a
   little padding and wraps with the line; in the nav menus it is plain. */
p code,
li code,
td code,
dd code {
  padding: 0.2em;
  background-color: var(--bjc-inline-code-bg);
  white-space: pre-wrap;
}

nav p code,
nav li code,
nav td code {
  padding: 0;
  background-color: transparent;
}

code.break {
  word-wrap: break-word;
}

/* Code blocks: the Quarto theme stripped Bootstrap's box (no background,
   border or padding) and bjc.scss shrank them to their content. */
pre {
  display: block;
  width: min-content;
  margin: 0 0 1rem;
  padding: 2px;
  overflow: auto;
  font-size: 0.875em;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bjc-pre-color);
}

pre > code {
  display: block;
}

pre code,
p pre code,
li pre code {
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  background-color: transparent;
  white-space: pre;
  word-break: normal;
}

pre.inline {
  display: inline;
  margin: 0 0.25em;
}

/* <var>: an input/parameter name — orange, italic (the browser default). */
var {
  padding: 0;
  color: var(--bjc-var-color);
}

kbd {
  padding: 0.4rem;
  font-size: 0.875em;
  color: var(--bjc-kbd-color);
  background-color: var(--bjc-kbd-bg);
  border: 1px solid var(--bjc-border);
  border-radius: 5px;
}

kbd kbd {
  padding: 0;
  font-size: 1em;
}

@media print {
  code {
    white-space: pre-wrap;
  }
}

/* -- media ----------------------------------------------------------------- */

img,
svg {
  vertical-align: middle;
}

figure {
  margin: 0 0 1rem;
}

figure > p:first-child {
  margin-top: 0;
  margin-bottom: 0;
}

figure > p:empty {
  display: none;
}

iframe {
  margin-bottom: 1em;
  border: 0;
}

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

table {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  caption-side: bottom;
  border-collapse: collapse;
}

caption,
figcaption {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--bjc-caption-color);
  text-align: center;
}

th {
  text-align: inherit;
}

thead,
tbody,
tfoot,
tr,
td,
th {
  border-color: inherit;
  border-style: solid;
  border-width: 0;
}

/* -- forms ----------------------------------------------------------------- */

label {
  display: inline-block;
}

input,
button,
select,
optgroup,
textarea {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background-color: var(--bjc-control-bg);
}

button,
select {
  text-transform: none;
}

button {
  border-radius: 0;
}

button:focus:not(:focus-visible) {
  outline: 0;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
  -webkit-appearance: button;
}

button:not(:disabled),
[type="button"]:not(:disabled),
[role="button"] {
  cursor: pointer;
}

input[type="checkbox"] {
  margin-right: 0.5ch;
}

/* -- details --------------------------------------------------------------- */

details {
  margin-bottom: 1em;
}

summary {
  display: list-item;
  cursor: pointer;
}

details > summary {
  color: var(--bjc-muted);
}

details > summary > p:only-child {
  display: inline;
}

/* -- utilities the markup carries ------------------------------------------ */

/* Bootstrap utility classes still present in the chrome, the sidebar
   (config.ts), the builder's prev/next nav and the quiz runtime's cards.
   Each is the Bootstrap definition verbatim. */

.d-flex {
  display: flex !important;
}

.d-none {
  display: none !important;
}

@media (min-width: 992px) {
  .d-lg-block {
    display: block !important;
  }
}

.justify-content-between {
  justify-content: space-between !important;
}

.justify-content-center {
  justify-content: center !important;
}

.align-items-center {
  align-items: center !important;
}

.flex-grow-1 {
  flex-grow: 1 !important;
}

.float-start {
  float: left !important;
}

.float-end {
  float: right !important;
}

.clearfix::after {
  display: block;
  clear: both;
  content: "";
}

.list-unstyled {
  padding-left: 0;
  list-style: none;
}

.mt-1 {
  margin-top: 0.25rem !important;
}

.mb-3 {
  margin-bottom: 1rem !important;
}

.ms-2 {
  margin-left: 0.5rem !important;
}

.me-auto {
  margin-right: auto !important;
}

.mx-auto {
  margin-right: auto !important;
  margin-left: auto !important;
}

.px-1 {
  padding-right: 0.25rem !important;
  padding-left: 0.25rem !important;
}
