@layer reset, tokens, foundation, composition, components, states, utilities;

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

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

  body {
    min-block-size: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  img,
  picture,
  video {
    display: block;
    max-inline-size: 100%;
    block-size: auto;
  }

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

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

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

  ul,
  ol {
    list-style: none;
  }

  table {
    border-collapse: collapse;
    inline-size: 100%;
  }

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

  @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;
      scroll-behavior: auto !important;
    }
  }
}

@layer tokens {
  :root {
    --paper: #f1ecdf;
    --paper-light: #faf7ef;
    --ink: #171717;
    --ink-soft: #4c4a45;
    --signal: #f34a34;
    --electric: #74bff2;
    --marker: #f2dc35;
    --violet: #9c62c7;
    --line: #c8c0b3;
    --white: #ffffff;
    --success: #22785b;

    --display: "Anton", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
    --body: "Archivo", Helvetica, Arial, "Helvetica Neue", sans-serif;

    --s-3xs: 6px;
    --s-2xs: 10px;
    --s-xs: 16px;
    --s-sm: 26px;
    --s-md: 42px;
    --s-lg: 68px;
    --s-xl: 110px;

    --radius: 8px;
    --radius-sm: 4px;
    --shell: 1320px;
    --measure: 68ch;

    --cut: 14px;
  }
}

@layer foundation {
  html {
    background-color: var(--paper);
  }

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

  body {
    font-family: var(--body);
    background-color: var(--paper);
    color: var(--ink);
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
    overflow-x: hidden;
  }

  h1,
  h2,
  h3,
  h4 {
    font-family: var(--display);
    font-weight: 700;
    line-height: 1.02;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    text-wrap: balance;
  }

  h1 {
    font-size: clamp(2.6rem, 1.9rem + 3.4vw, 5.4rem);
  }

  h2 {
    font-size: clamp(2rem, 1.5rem + 2.2vw, 3.4rem);
  }

  h3 {
    font-size: clamp(1.4rem, 1.2rem + 1vw, 2rem);
  }

  h4 {
    font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
  }

  p {
    max-inline-size: var(--measure);
    text-wrap: pretty;
  }

  strong {
    font-weight: 700;
  }

  main :is(h2, h3) + p {
    margin-block-start: var(--s-2xs);
  }

  main p + p {
    margin-block-start: var(--s-xs);
  }

  :target {
    scroll-margin-block-start: 120px;
  }

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

@layer composition {
  .shell {
    inline-size: min(100% - (var(--s-sm) * 2), var(--shell));
    margin-inline: auto;
  }

  .shell-wide {
    inline-size: min(100% - (var(--s-xs) * 2), 1600px);
    margin-inline: auto;
  }

  .stack > * + * {
    margin-block-start: var(--flow, var(--s-xs));
  }

  .region {
    padding-block: clamp(var(--s-md), 5vw, var(--s-xl));
  }

  .region-tight {
    padding-block: clamp(var(--s-sm), 3vw, var(--s-lg));
  }

  .cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-xs);
    align-items: center;
  }

  .grid-auto {
    display: grid;
    gap: var(--s-sm);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
}

@layer utilities {
  .visually-hidden {
    position: absolute !important;
    inline-size: 1px;
    block-size: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: absolute;
    inset-block-start: -200px;
    inset-inline-start: var(--s-xs);
    z-index: 999;
    background: var(--ink);
    color: var(--paper-light);
    padding: var(--s-2xs) var(--s-xs);
    border-radius: var(--radius-sm);
    font-family: var(--display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .skip-link:focus {
    inset-block-start: var(--s-2xs);
  }

  .marker-underline {
    background-image: linear-gradient(var(--marker), var(--marker));
    background-repeat: no-repeat;
    background-position: 0 88%;
    background-size: 100% 0.32em;
  }

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

  .lede {
    font-size: clamp(1.1rem, 1rem + 0.7vw, 1.45rem);
    line-height: 1.5;
    color: var(--ink-soft);
  }

  .center-text {
    text-align: center;
  }

  .no-wrap {
    white-space: nowrap;
  }

  [hidden] {
    display: none !important;
  }
}
