/* ==========================================================================
   Base
   Reset, element defaults, accessibility helpers, the paper grain, and the
   reveal on scroll. Loaded on every page, straight after tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------- reset --- */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 300;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg, iframe { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

h1, h2, h3, h4, h5 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
  font-variation-settings: "SOFT" 30, "WONK" 1, "opsz" 90;
}

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }
a { color: inherit; }

dialog:not([open]) { display: none; }

:focus-visible {
  outline: 2px solid var(--ember-text);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--ember-pale); color: var(--ink); }

/* ------------------------------------------------------- accessibility --- */

.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -160%);
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.2rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform 0.25s var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); }

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

/* --------------------------------------------------------------- grain --- */

.grain {
  position: fixed;
  inset: -60%;
  z-index: 40;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: var(--grain);
  animation: grain-shift 7s steps(6) infinite;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -3%); }
  60%  { transform: translate(-2%, -2%); }
  80%  { transform: translate(3%, 1%); }
  100% { transform: translate(0, 0); }
}

/* ---------------------------------------------------- reveal on scroll --- */

/* An animation rather than a transition, so it does not replace the
   element's own transitions, and with no fill after it ends, so it does
   not pin transform and cancel hover lifts on revealed cards. */

.js [data-reveal] { opacity: 0; }

.js [data-reveal].is-in {
  opacity: 1;
  animation: reveal-in 0.8s var(--ease) var(--reveal-delay, 0ms) backwards;
}

@keyframes reveal-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------- reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .grain { animation: none; }
  .js [data-reveal],
  .js [data-reveal].is-in { opacity: 1; animation: none; }
}
