/* Docs layout of the pack site (Unisson « Démarrer » model): the calmer aurora and the grain behind the page, then
   the .docs grid of the model, its columns being the nav landmark, main and the outline rail. The rules are the
   model's own, colours read from the --pack-* tokens, physical properties made logical. The header above is 64 px
   high (--top-h of the model): the menu sticks 20 px under it, the rail 28 px. */
:host {
  --top-h: 64px;
  display: block;
  position: relative;
  color: var(--pack-ink);
  font:
    16px / 1.6 Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-feature-settings: normal;
  letter-spacing: normal;
  -webkit-font-smoothing: antialiased;
}
:host([hidden]) {
  display: none;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Aurora, calmer than the home for reading (opacity .7), and the dotted grain: fixed behind the whole page. */
.aurora,
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.aurora {
  overflow: hidden;
  opacity: 0.7;
}
.aurora i {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}
.aurora i:nth-child(1) {
  inline-size: 70vmax;
  block-size: 70vmax;
  inset-inline-start: -20vmax;
  inset-block-start: -30vmax;
  background: radial-gradient(closest-side, var(--pack-a1), transparent 70%);
}
.aurora i:nth-child(2) {
  inline-size: 80vmax;
  block-size: 80vmax;
  inset-inline-end: -30vmax;
  inset-block-start: -10vmax;
  background: radial-gradient(closest-side, var(--pack-a2), transparent 70%);
}
.aurora i:nth-child(3) {
  inline-size: 70vmax;
  block-size: 70vmax;
  inset-inline-start: 20vmax;
  inset-block-end: -45vmax;
  background: radial-gradient(closest-side, var(--pack-a3), transparent 70%);
}
@keyframes drift1 {
  to {
    transform: translate3d(8vmax, 6vmax, 0) scale(1.1);
  }
}
@keyframes drift2 {
  to {
    transform: translate3d(-9vmax, 8vmax, 0) scale(0.92);
  }
}
.grain {
  opacity: 0.5;
  background-image: radial-gradient(var(--pack-line) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 20%, var(--pack-ink), transparent 70%);
  mask-image: radial-gradient(ellipse at 50% 20%, var(--pack-ink), transparent 70%);
}

/* The three columns: menu, content, outline. */
.docs {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 220px;
  gap: 40px;
  align-items: start;
  inline-size: min(1408px, 100% - 32px);
  margin-inline: auto;
  padding: 32px 0 0;
}
[part="nav"] {
  grid-column: 1;
  position: sticky;
  inset-block-start: calc(var(--top-h) + 20px);
  min-inline-size: 0;
}
[part="content"] {
  display: block;
  grid-column: 2;
  min-inline-size: 0;
  max-inline-size: 780px;
  inline-size: 100%;
  justify-self: center;
}
.rail {
  grid-column: 3;
  position: sticky;
  inset-block-start: calc(var(--top-h) + 28px);
  min-inline-size: 0;
}

/* layout="wide": one column of the model's .container.wide (1408 px), the content full width. */
.docs.wide {
  display: block;
}
.wide [part="content"] {
  max-inline-size: none;
}

@media (max-width: 1285px) {
  .docs {
    grid-template-columns: 232px minmax(0, 1fr) 200px;
    gap: 32px;
  }
}
/* Under 1100 px the rail folds: the outline comes into the content column, right after the page head (the first
   element of the default slot), as the model's disclosure. */
@media (max-width: 1099px) {
  .docs {
    grid-template-columns: 232px minmax(0, 1fr);
  }
  .rail {
    display: none;
  }
  [part="content"] {
    display: flex;
    flex-direction: column;
  }
  slot:not([name])::slotted(*) {
    order: 2;
  }
  slot:not([name])::slotted(:nth-child(1 of :not([slot]))) {
    order: 0;
  }
  .inline {
    order: 1;
    margin-block-start: 22px;
  }
}
/* Under 900 px one column: the menu, folded behind its own button, then the content. */
@media (max-width: 899px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding-block-start: 20px;
  }
  .docs.wide {
    padding-block-start: 32px;
  }
  [part="nav"] {
    grid-column: auto;
    position: static;
  }
  [part="content"] {
    grid-column: auto;
    max-inline-size: none;
  }
}

@media (max-width: 700px) {
  .docs.wide {
    padding-block-start: 20px;
  }
}

/* Catalog layout (the model's .cat of catalogue.html): main is a grid of two columns. Each element of the default
   slot goes to the right column in reading order; bythium-pack-catalog-filters places itself in the left one, across
   the rows of the others (see its sheet). The content column has no width limit here. Two measures of that model
   differ from documentation.html and reach the slotted tags as inherited custom properties: the lead of
   bythium-pack-doc-head runs to 66ch, and the text of bythium-pack-callout sits right under its heading. */
.docs.catalog {
  display: block;
}
.catalog [part="content"] {
  --pack-lead-measure: 66ch;
  --pack-callout-text-gap: 0;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  column-gap: 40px;
  align-items: start;
  grid-column: auto;
  max-inline-size: none;
}
.catalog slot::slotted(*) {
  min-inline-size: 0;
}
.catalog slot::slotted(:not(bythium-pack-catalog-filters)) {
  grid-column: 2;
}
@media (max-width: 1285px) {
  .catalog [part="content"] {
    grid-template-columns: 232px minmax(0, 1fr);
    column-gap: 32px;
  }
}
@media (max-width: 1099px) {
  .catalog [part="content"] {
    grid-template-columns: 212px minmax(0, 1fr);
    column-gap: 24px;
  }
}
@media (max-width: 899px) {
  .catalog [part="content"] {
    grid-template-columns: minmax(0, 1fr);
  }
  .catalog slot::slotted(:not(bythium-pack-catalog-filters)) {
    grid-column: 1;
  }
}

/* Motion: the drifting aurora, only when allowed. */
@media (prefers-reduced-motion: no-preference) {
  .aurora i:nth-child(1) {
    animation: drift1 26s ease-in-out infinite alternate;
  }
  .aurora i:nth-child(2) {
    animation: drift2 32s ease-in-out infinite alternate;
  }
  .aurora i:nth-child(3) {
    animation: drift1 38s ease-in-out infinite alternate-reverse;
  }
}

/* Forced colours: no decorative light. */
@media (forced-colors: active) {
  .aurora,
  .grain {
    display: none;
  }
}
