/* The site's styles, over Pico 2. A page's own <style> comes after this and wins. */

main {
  padding-top: 2rem;
}
h1,
h2,
h3 {
  margin-bottom: 0.2em;
}
/* The title carries the site's icon. */
h1:has(img) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
h1 img {
  width: 1.15em;
  height: 1.15em;
}
.lede {
  font-size: 1.1em;
}
.muted,
td small {
  color: var(--pico-muted-color);
}
.muted {
  font-size: 0.875em;
}
td small {
  display: block;
  font-size: 0.875em;
}

/* Every table sits flush with the text around it: Pico's cell padding stays
   between columns, never at the edges, and no cell paints the page background.
   A value's note sits under it, so cells top-align. */
th:first-child,
td:first-child {
  padding-left: 0;
}
th:last-child,
td:last-child {
  padding-right: 0;
}
th,
td {
  background-color: transparent;
  vertical-align: top;
}

/* Reference tables: a row per thing when wide; stacked, the thing above its
   details, when narrow. One breakpoint, 64rem. A cell with data-label shows
   its label when stacked, since the header row is hidden. */
table.ref code {
  overflow-wrap: anywhere;
}
@media (min-width: 64rem) {
  table.ref td:first-child {
    white-space: nowrap;
    padding-right: 1.25rem;
  }
}
@media (max-width: 63.99rem) {
  table.ref thead {
    display: none;
  }
  table.ref tr,
  table.ref td {
    display: block;
  }
  table.ref td {
    padding: 0;
    border: 0;
  }
  table.ref tr {
    padding: 0.6rem 0;
    border-bottom: var(--pico-border-width) solid var(--pico-table-border-color);
  }
  table.ref tr:last-child {
    border-bottom: 0;
  }
  table.ref td:first-child {
    margin-bottom: 0.2rem;
    font-weight: 600;
  }
  table.ref td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--pico-muted-color);
  }
}

footer.page {
  padding-top: var(--pico-spacing);
  font-size: 0.875em;
  border-top: var(--pico-border-width) solid var(--pico-muted-border-color);
}

/* The way home, above the title on every page but the home page. Each link is
   a 44px tap target; the negative margins keep it compact. */
nav.crumbs {
  justify-content: flex-start;
  align-items: center;
  font-size: 0.875rem;
  margin: -0.7rem 0 -0.45rem;
}
nav.crumbs a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 0;
  color: var(--pico-muted-color);
  text-decoration: none;
}
nav.crumbs a:hover,
nav.crumbs a:focus-visible {
  color: var(--pico-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
nav.crumbs img {
  width: 1.15rem;
  height: 1.15rem;
}
nav.crumbs + h1 {
  margin-top: 0;
}

/* An algorithm's page. Its field tables share one first-column width, so they
   line up down the page. The last row has no rule: the next heading draws one. */
.headline {
  font-size: 1.15em;
}
.fields table {
  table-layout: fixed;
}
.fields td:first-child,
.fields th:first-child {
  width: 14em;
}
.fields tr:last-child > * {
  border-bottom: 0;
}
.fields code {
  overflow-wrap: anywhere;
}
figure.diagram img {
  max-width: 40rem;
  width: 100%;
}
td.status {
  white-space: nowrap;
}
/* On a phone, a field table stacks: each row a block, its first cell the title,
   the rest under it. A small table marked compact stays a table. */
@media (max-width: 40rem) {
  .fields:not(.compact) thead {
    display: none;
  }
  .fields:not(.compact) tr,
  .fields:not(.compact) td {
    display: block;
    width: auto !important;
  }
  .fields:not(.compact) td {
    padding: 0;
    border: 0;
  }
  .fields:not(.compact) tr {
    padding: 0.6rem 0;
    border-bottom: var(--pico-border-width) solid var(--pico-table-border-color);
  }
  .fields:not(.compact) tr:last-child {
    border-bottom: 0;
  }
  .fields:not(.compact) td:first-child {
    margin-bottom: 0.2rem;
    font-weight: 600;
  }
  .fields.compact td:first-child,
  .fields.compact th:first-child {
    width: 45%;
  }
}

/* An alert, as GitHub draws one: a coloured rule and title, the text as usual.
   A page built from placeholder data opens with a warning. */
blockquote.alert {
  margin: 0 0 var(--pico-spacing);
  padding: 0.5rem 1rem;
  border-left: 0.25rem solid var(--alert-color);
  font-style: normal;
  color: inherit;
}
blockquote.alert p {
  margin: 0;
}
blockquote.alert p + p {
  margin-top: 0.25rem;
}
blockquote.alert .alert-title {
  color: var(--alert-color);
  font-weight: 600;
}
blockquote.alert .alert-title::before {
  content: "\26A0\FE0E";
  margin-right: 0.5rem;
}
blockquote.warning {
  --alert-color: #9a6700;
}
@media (prefers-color-scheme: dark) {
  blockquote.warning {
    --alert-color: #d29922;
  }
}
.cases .arrow {
  color: var(--pico-muted-color);
}

/* A status: a dot in its level's colour, ringed in ink so it holds on any
   background, then the word. The levels are on /styles/. */
.dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px #0b0b0b;
  margin-right: 0.45rem;
  vertical-align: -0.05rem;
}
.dot.ok {
  background: #1baf7a;
}
.dot.caution {
  background: #e0a526;
}
.dot.avoid {
  background: #d64545;
}
.dot.unknown {
  background: #9aa5b1;
}
.swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.45em;
  vertical-align: -0.1em;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px #0b0b0b;
}
