/* Every Layout — Axioms and Layout Primitives */

/* === AXIOMS === */

* {
  box-sizing: border-box;
  max-inline-size: var(--measure);
}

html,
body,
div,
header,
nav,
main,
aside,
footer,
section,
details,
summary,
form,
fieldset,
table,
thead,
tbody,
tr,
th,
td {
  max-inline-size: none;
}

body {
  margin: 0;
}

/* === CUSTOM PROPERTIES === */

:root {
  --measure: 65ch;
  --space: 1rem;
  --s-5: calc(var(--space) / 5);
  --s-4: calc(var(--space) / 4);
  --s-3: calc(var(--space) / 3);
  --s-2: calc(var(--space) / 2);
  --s0: var(--space);
  --s1: calc(var(--space) * 1.5);
  --s2: calc(var(--space) * 2);
  --s3: calc(var(--space) * 3);
  --s4: calc(var(--space) * 4);
}

/* === STACK === */

.stack {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.stack > * {
  margin-block: 0;
}

.stack > * + * {
  margin-block-start: var(--space, 1rem);
}

.stack-sm > * + * {
  margin-block-start: var(--s-2);
}

.stack-lg > * + * {
  margin-block-start: var(--s2);
}

/* === BOX === */

.box {
  padding: var(--space, 1rem);
  border: 0 solid;
}

.box * {
  color: inherit;
}

/* === CENTER === */

.center {
  box-sizing: content-box;
  margin-inline: auto;
  max-inline-size: var(--measure);
  padding-inline-start: var(--space, 1rem);
  padding-inline-end: var(--space, 1rem);
}

/* === CLUSTER === */

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space, 1rem);
  justify-content: flex-start;
  align-items: center;
}

/* === SIDEBAR === */

.with-sidebar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space, 1rem);
}

.with-sidebar > :first-child {
  flex-basis: var(--sidebar-width, 18rem);
  flex-grow: 1;
}

.with-sidebar > :last-child {
  flex-basis: 0;
  flex-grow: 999;
  min-inline-size: var(--sidebar-threshold, 50%);
}

/* Sidebar on the right */
.with-sidebar-right {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space, 1rem);
}

.with-sidebar-right > :first-child {
  flex-basis: 0;
  flex-grow: 999;
  min-inline-size: var(--sidebar-threshold, 50%);
}

.with-sidebar-right > :last-child {
  flex-basis: var(--sidebar-width, 22rem);
  flex-grow: 1;
}

/* === COVER === */

.cover {
  display: flex;
  flex-direction: column;
  min-block-size: 100vh;
  padding: var(--space, 1rem);
}

.cover > * {
  margin-block: var(--space, 1rem);
}

.cover > :first-child:not(.cover-centered) {
  margin-block-start: 0;
}

.cover > :last-child:not(.cover-centered) {
  margin-block-end: 0;
}

.cover > .cover-centered {
  margin-block: auto;
}

/* === SWITCHER === */

.switcher {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space, 1rem);
}

.switcher > * {
  flex-grow: 1;
  flex-basis: calc((var(--switcher-threshold, 30rem) - 100%) * 999);
}
