/* Base of the new public pages: the element reset, and the page-level classes
 * every public page uses (layout, type, links).
 *
 * The reset sits in the `base` layer, the lowest, so any class wins over it.
 * Everything a page must look like is set on a .ui- class, unlayered: from M2
 * Bootstrap's own reset sits in the `legacy` layer on the pages that still
 * need the old modals, and it outranks anything in `base`.
 */

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

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--ui-header-height) + var(--ui-space-4));
  }

  body {
    margin: 0;
  }

  h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote {
    margin: 0;
  }

  ul[class],
  ol[class] {
    padding: 0;
    list-style: none;
  }

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

  a {
    color: inherit;
    text-decoration: none;
  }

  button, input, select, textarea {
    font: inherit;
    color: inherit;
  }

  :focus-visible {
    outline: 2px solid var(--ui-color-focus);
    outline-offset: 2px;
  }
}

/* The one !important of the new front end. A component's display rule would
 * otherwise beat the browser's own [hidden] rule, and an element hidden by
 * attribute would stay on screen. */
[hidden] {
  display: none !important;
}

/* Page */

.ui-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ui-color-page);
  color: var(--ui-color-ink);
  font-family: var(--ui-font-body);
  font-size: var(--ui-text-base);
  line-height: var(--ui-leading-normal);
  -webkit-font-smoothing: antialiased;
}

.ui-main {
  flex: 1 0 auto;
}

.ui-main:focus {
  outline: none;
}

.ui-container {
  width: 100%;
  max-width: var(--ui-container);
  margin-inline: auto;
  padding-inline: var(--ui-gutter);
}

.ui-stack {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
}

.ui-stack--tight {
  gap: var(--ui-space-2);
}

.ui-stack--loose {
  gap: var(--ui-space-6);
}

.ui-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-3);
}

.ui-grid {
  display: grid;
  gap: var(--ui-space-5);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 600px) {
  .ui-grid--2,
  .ui-grid--3,
  .ui-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .ui-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ui-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Type. Headings are chosen by class, never by element, so that an h2 can
 * look like an h3 where the outline needs it. */

.ui-h1,
.ui-h2,
.ui-h3 {
  margin: 0;
  font-family: var(--ui-font-heading);
  font-weight: var(--ui-weight-semibold);
  color: inherit;
  text-wrap: balance;
}

.ui-h1 {
  font-size: var(--ui-text-h1);
  line-height: var(--ui-leading-tight);
  letter-spacing: var(--ui-tracking-tight);
}

.ui-h2 {
  font-size: var(--ui-text-h2);
  line-height: 1.15;
  letter-spacing: -0.005em;
}

.ui-h3 {
  font-size: var(--ui-text-h3);
  line-height: var(--ui-leading-snug);
}

.ui-eyebrow {
  margin: 0;
  font-family: var(--ui-font-heading);
  font-size: var(--ui-text-2xs);
  font-weight: var(--ui-weight-medium);
  letter-spacing: var(--ui-tracking-eyebrow);
  text-transform: uppercase;
  color: var(--ui-color-ink-muted);
}

.ui-lead {
  margin: 0;
  font-size: var(--ui-text-lg);
  line-height: 1.6;
  max-width: 60ch;
  text-wrap: pretty;
}

.ui-text {
  margin: 0;
  font-size: var(--ui-text-base);
  line-height: var(--ui-leading-relaxed);
  max-width: 62ch;
  text-wrap: pretty;
}

.ui-text--soft {
  color: var(--ui-color-ink-soft);
}

.ui-small {
  margin: 0;
  font-size: var(--ui-text-sm);
  line-height: var(--ui-leading-normal);
  color: var(--ui-color-ink-soft);
}

.ui-link {
  color: var(--ui-color-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--ui-duration);
}

.ui-link:hover {
  color: var(--ui-color-ink-strong);
}

/* "Read more"-style link: no underline, a drawn arrow instead (the fonts have
 * no arrow glyph). */
.ui-link--arrow {
  font-weight: var(--ui-weight-semibold);
  text-decoration: none;
}

.ui-link--arrow::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-left: 0.4em;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateY(-0.1em) rotate(45deg);
}

/* Text from the editor or the CMS, as core/richtext.py writes it: p, h3, ul,
 * ol, li, strong, em, a. The only place where bare elements are styled, and
 * unlayered on purpose: Bootstrap's reset would beat it in `base`. */

.ui-richtext {
  line-height: var(--ui-leading-relaxed);
}

/* Bootstrap's reboot gives paragraphs, lists and headings margins from the
 * `legacy` layer, which outranks the reset above. They are zeroed first, and
 * each block is then spaced from the one before it. */
.ui-richtext > *,
.ui-richtext li > * {
  margin: 0;
}

.ui-richtext > * + * {
  margin-top: 1em;
}

/* A heading opens a part of the text: room above it, little below. */
.ui-richtext > * + h3 {
  margin-top: 1.5em;
}

.ui-richtext > h3 + * {
  margin-top: 0.25em;
}

.ui-richtext h3 {
  font-size: inherit;
  font-weight: var(--ui-weight-semibold);
  line-height: inherit;
}

.ui-richtext ul,
.ui-richtext ol {
  padding-left: 1.25em;
}

.ui-richtext li + li {
  margin-top: 0.25em;
}

.ui-richtext a {
  color: var(--ui-color-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ui-richtext strong {
  font-weight: var(--ui-weight-semibold);
}

/* Accessibility */

.ui-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ui-skip-link {
  text-decoration: none;
  position: absolute;
  top: var(--ui-space-2);
  left: var(--ui-space-2);
  z-index: calc(var(--ui-z-bar) + 1);
  padding: var(--ui-space-3) var(--ui-space-5);
  border-radius: var(--ui-radius-pill);
  background: var(--ui-color-band);
  color: var(--ui-color-on-band);
  font-weight: var(--ui-weight-semibold);
  transform: translateY(-200%);
}

.ui-skip-link:focus-visible {
  transform: none;
  outline-color: var(--ui-color-focus-on-band);
}
