:root {
  --ratio: 1.4;
  --s-8: calc(var(--s-7) / var(--ratio));
  --s-7: calc(var(--s-6) / var(--ratio));
  --s-6: calc(var(--s-5) / var(--ratio));
  --s-5: calc(var(--s-4) / var(--ratio));
  --s-4: calc(var(--s-3) / var(--ratio));
  --s-3: calc(var(--s-2) / var(--ratio));
  --s-2: calc(var(--s-1) / var(--ratio));
  --s-1: calc(var(--s0) / var(--ratio));
  --s0: 1rem;
  --s1: calc(var(--s0) * var(--ratio));
  --s2: calc(var(--s1) * var(--ratio));
  --s3: calc(var(--s2) * var(--ratio));
  --s4: calc(var(--s3) * var(--ratio));
  --s5: calc(var(--s4) * var(--ratio));
  --max-width: 80ch;
}

* {
  box-sizing: border-box;
}

p{
  max-width: var(--max-width);
}


.box {
  padding: var(--s1);
  max-width: var(--max-width);
}

.stack {
  --space: var(--s1);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.stack > * {
  margin-top: 0;
  margin-bottom: 0;
}

.stack > * + * {
  margin-top: var(--space);
}

.cluster {
  --space: var(--s-4);
  /* ↓ Suppress horizontal scrolling caused by
  the negative margin in some circumstances */
  overflow: hidden;
}

.cluster > * {
  display: flex;
  flex-wrap: wrap;
  /* ↓ multiply by -1 to negate the halved value */
  margin: calc(var(--space) / 2 * -1);
}

.cluster > * > * {
  /* ↓ half the value, because of the 'doubling up' */
  margin: calc(var(--space) / 2);
}

.center {
  box-sizing: content-box;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--s-1);
  padding-right: var(--s-1);
}

.switcher {
  display: flex;
  flex-wrap: wrap;
}

.switcher > * {
  flex-grow: 1;
}

.switcher > :nth-last-child(n+ 4),
.switcher > :nth-last-child(n+ 4) ~ * {
  flex-basis: 100%;
}

.with-sidebar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.with-sidebar > :last-child {
  flex-grow: 1;
  min-width: 0;
  padding-left: 0;
}


.with-sidebar > :first-child {
  flex-basis: var(--max-width);
  flex-grow: 999;
  min-inline-size: 50%;
}

/* Custom */

body {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-5);
  align-items: flex-start;
}

header {
  flex-grow: 1;
  flex-basis: 32rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding-inline: var(--s-1);
  padding-block: var(--s-1);
  align-items: center;
}

main {
  flex-basis: 0;
  flex-grow: 999;
  min-inline-size: 50%;
  padding-inline: var(--s-1);
}

footer {
  flex-basis: 100%;
  margin-top: var(--s1);
  margin-bottom: var(--s1);
}

.subtitle {
  margin-top: 0;
}

fieldset legend {
  padding: 0 var(--s0) 0 var(--s0);
}

a.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 1em;
}

.table-scroll {
  overflow-x: auto;
}

.not-active {
  pointer-events: none;
  cursor: default;
}

.group, .doctest-block {
  overflow-x: scroll;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.article *{
  max-width: 100%;
}

.with-sidebar > .page {
  flex-grow: 999;
  flex-basis: auto;
}

.with-sidebar > .page-meta {
  flex-grow: 1;
  flex-basis: 30ch;
  min-width: 0;
}

.page > img {
  width: 100%;
  max-width: calc(100vw - 2*var(--s-3));
  height: auto;
}

.page-meta {
  overflow-y: scroll;
}


.icon, .large-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
}

.icon + .icon, .large-icon + .large-icon {
  margin-left: var(--s-4);
}

.icon-glyph {
  display: inline-block;
  vertical-align: middle;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  mask-size: contain;
  -webkit-mask-size: contain;
}

.icon .icon-glyph {
  width: 1em;
  height: 1em;
}

.large-icon .icon-glyph, #icon-preview .icon-glyph {
  width: 4em;
  height: 4em;
}

.subtitle-band {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Scoped to the header specifically — an unscoped svg[name="sinc"] selector
   here would also hijack the sinc SVGs embedded from Pelican's /resources
   fragments (same name="sinc" markup convention, reused deliberately), tearing
   them out of the article-card flow and blowing them up to header size. */
.subtitle-band svg[name="sinc"] {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30rem;
  height: auto;
  pointer-events: none;
}

/* The /resources article-card divider — same svg[name="sinc"] markup,
   scaled down to sit inline as a small rule rather than a header backdrop. */
.blurb-sinc svg[name="sinc"] {
  display: block;
  width: 8rem;
  height: auto;
  margin: var(--s-1) auto;
}

.subtitle-band .subtitle {
  position: relative;
  z-index: 1;
}

.tag-with-grandchildren {
  display: flex;
  align-items: stretch;
}

.tag + .tag-with-grandchildren, .tag-with-grandchildren + .tag {
  margin: var(--s-4);
}

.group-toggle {
  display: none;
}

.group:has(.group-toggle:checked) a.tag.empty {
  display: none;
}

.group:has(.group-toggle:checked) .tag-with-grandchildren:has(> a.tag.empty) {
  display: none;
}

.filter-scope-toggle {
  display: none;
}

.group:has(.filter-scope-toggle):not(:has(.filter-scope-toggle:checked)) a.tag.empty {
  display: none;
}

textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: calc(3 * 1.5em + 0.5em);
}

.tag-forest {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s0) var(--s2);
  align-items: flex-start;
}

.tag-forest--simple {
  gap: 0;
}


.tree-line {
  display: block;
  white-space: pre;
}
