/* ==========================================================================
   Reset, document defaults, layout primitives and shared animations.
   ========================================================================== */

@layer reset, base, layout, motion;

/* Cross-document page transitions. Chromium honours this today; every other
   browser simply navigates as normal. */
@view-transition {
  navigation: auto;
}

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  img,
  picture,
  svg,
  video {
    display: block;
    max-width: 100%;
    /* Keep the intrinsic aspect ratio when CSS sets only one axis: without
       this an HTML `height` attribute survives as the used height and the
       image gets squashed to whatever ratio that implies. */
    height: auto;
  }

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

  button {
    background: none;
    border: 0;
    cursor: pointer;
  }

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

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

@layer base {
  html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
    -webkit-text-size-adjust: 100%;
    /* Decorative blobs and the marquee track are wider than the viewport by
       design; clip rather than let them create a sideways scroll. */
    overflow-x: clip;
  }

  body {
    background: var(--ink-900);
    color: var(--text-strong);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
  }

  h1,
  h2,
  h3 {
    font-family: var(--font-display);
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-wrap: balance;
  }

  p {
    text-wrap: pretty;
  }

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

  ::selection {
    background: color-mix(in srgb, var(--sand) 30%, transparent);
    color: #fff;
  }

  ::-webkit-scrollbar {
    width: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--ink-900);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--ink-500);
    border-radius: var(--radius-pill);
  }
  ::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--sand) 60%, transparent);
  }

  /* Keyboard users get a way past the nav. */
  .skip-link {
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 100;
    translate: -50% -150%;
    padding: 0.75rem 1.25rem;
    background: var(--paper);
    color: var(--ink-900);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-weight: 600;
    transition: translate var(--speed) var(--ease-out-expo);

    &:focus-visible {
      translate: -50% 0;
    }
  }
}

@layer layout {
  .shell {
    width: 100%;
    max-width: var(--shell);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }

  .section {
    padding-block: var(--section-gap);
    scroll-margin-top: 5rem;
  }

  /* Alternating band so adjacent sections read as separate surfaces. */
  .section--band {
    position: relative;
    background: var(--ink-800);
    border-block: 1px solid color-mix(in srgb, var(--paper) 5%, transparent);
    overflow: hidden;
    isolation: isolate;
  }

  .stack {
    display: flex;
    flex-direction: column;
  }

  /* Responsive grid with no media queries: columns collapse when the
     available width can no longer fit --col-min. */
  .auto-grid {
    display: grid;
    gap: var(--grid-gap, 1.25rem);
    grid-template-columns: repeat(
      auto-fit,
      minmax(min(var(--col-min, 20rem), 100%), 1fr)
    );
  }
}

@layer motion {
  /* Entrance directions, shared by the above-the-fold `.enter` class and by
     every scroll reveal. */
  @keyframes fade-up {
    from {
      opacity: 0;
      translate: 0 28px;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  @keyframes fade-left {
    from {
      opacity: 0;
      translate: -32px 0;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  @keyframes fade-right {
    from {
      opacity: 0;
      translate: 32px 0;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  @keyframes fade-scale {
    from {
      opacity: 0;
      scale: 0.94;
    }
    to {
      opacity: 1;
      scale: 1;
    }
  }

  @keyframes drift {
    0%,
    100% {
      translate: 0 0;
      scale: 1;
    }
    33% {
      translate: 4% -6%;
      scale: 1.08;
    }
    66% {
      translate: -5% 4%;
      scale: 0.95;
    }
  }

  @keyframes float {
    0%,
    100% {
      translate: 0 0;
    }
    50% {
      translate: 0 -12px;
    }
  }

  @keyframes marquee {
    to {
      translate: calc(-50% - var(--marquee-gap, 0.75rem) / 2) 0;
    }
  }

  @keyframes gradient-pan {
    0%,
    100% {
      background-position: 0% 50%;
    }
    50% {
      background-position: 100% 50%;
    }
  }

  @keyframes shimmer {
    from {
      translate: -120% 0;
    }
    to {
      translate: 320% 0;
    }
  }

  @keyframes scroll-cue {
    0% {
      opacity: 0;
      translate: 0 -6px;
    }
    40% {
      opacity: 1;
    }
    100% {
      opacity: 0;
      translate: 0 10px;
    }
  }

  @keyframes caret-blink {
    0%,
    45% {
      opacity: 1;
    }
    55%,
    100% {
      opacity: 0;
    }
  }

  @keyframes pulse-ring {
    from {
      opacity: 0.7;
      scale: 1;
    }
    to {
      opacity: 0;
      scale: 2.4;
    }
  }

  /* Entrance animation for above-the-fold content, which is visible before
     any scroll happens and so is not driven by <gv-reveal>.

     `both` means each element is held at opacity 0 through its delay, so the
     stagger is time the hero spends looking like an empty page. It is the
     first thing a visitor sees and it is the site's own content, not a
     decoration: keep the flourish, but make it brief. */
  .enter {
    animation: fade-up 0.5s var(--ease-out-expo) both;
    animation-delay: var(--delay, 0ms);
  }

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

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

    @view-transition {
      navigation: none;
    }
  }
}
