/* Base: the reset, the page background and text colour, links, and the helpers every page uses (visually hidden,
   JS-only controls, `[hidden]`, icons). Mobile first throughout; see tokens.css for the values. */

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

html {
  background: var(--color-bg);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--gradient-page);
  background-attachment: fixed;
  color: var(--color-text);
  font-family: var(--font-text);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  /* Lets `.full` (layout.css) measure the window's width without the scrollbar (`cqi`), which 100vw includes. */
  container-type: inline-size;
}

a {
  color: var(--color-accent);
}

/* Browsers give form controls their own font (Arial on macOS) instead of the page's; use the site font. Only the
   family: each control's size stays as its own rule sets it. */
button,
input,
select,
textarea {
  font-family: inherit;
}

/* Keyboard focus, everywhere: a ring outside the element (the tokens). Only for the keyboard (`:focus-visible`), so a
   mouse click doesn't draw it. A component may move it (inset, its own colour) but never just remove it. */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Controls that only work with JS; `layout.tsx` adds the `js` class before the first paint. */
html:not(.js) .js-only {
  display: none !important;
}

/* Reveal on scroll: the children of a `[data-reveal]` container fade in one after another as they come into view
   (`reveal.js` adds `.revealed` and their place in the batch, --reveal-index): they rise a little, grow to full size
   and come into focus. Hidden only with JS; and should reveal.js never run (it marks the container
   `.reveal-active`), a fallback shows them after a few seconds, so they can't stay hidden. */
html.js [data-reveal] > :not(.revealed) {
  opacity: 0;
  animation: reveal-fallback 0s 3s forwards;
}

[data-reveal].reveal-active > :not(.revealed) {
  animation: none;
}

[data-reveal] > .revealed {
  animation: reveal-in var(--duration-reveal) var(--ease-out) backwards;
  animation-delay: calc(var(--reveal-index, 0) * var(--duration-reveal-step));
}

@keyframes reveal-in {
  from {
    opacity: 0;
    translate: 0 var(--space-2);
    scale: 0.96;
    filter: blur(4px);
  }
}

@keyframes reveal-fallback {
  to {
    opacity: 1;
  }
}

/* `hidden` wins over the display set by classes such as `.button`. */
[hidden] {
  display: none !important;
}

.icon {
  display: block;
  flex: none;
}

/* Readers who ask for less motion (a system setting) get none: transitions and animations end at once. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }
}
