/* The Bruh Media — reset, fonts, base typography, page atmosphere. */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg, video { display: block; max-inline-size: 100%; }
  button, input, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  a { color: inherit; }
}

@layer base {
  /* Fonts are local, variable, split by script. All three families are OFL-licensed. */
  @font-face {
    font-family: "Geologica";
    src: url("../fonts/geologica-latin.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "Geologica";
    src: url("../fonts/geologica-cyrillic.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
  }
  @font-face {
    font-family: "Onest";
    src: url("../fonts/onest-latin.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }
  @font-face {
    font-family: "Onest";
    src: url("../fonts/onest-cyrillic.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
  }
  @font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
    font-weight: 100 800;
    font-display: swap;
    unicode-range: U+0000-00FF, U+2000-206F, U+2212;
  }

  html {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-text);
    font-size: 100%;
    line-height: 1.55;
    scroll-behavior: smooth;
    scroll-padding-block-start: calc(var(--header-h) + 1rem);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* lets <details> and friends animate to height: auto */
    interpolate-size: allow-keywords;
  }

  body {
    min-block-size: 100svh;
    font-size: var(--fs-body);
    overflow-wrap: break-word;
    position: relative;
    isolation: isolate;
  }

  /* Signal: slow drifting light. Invisible on paper because the glow tokens are transparent there. */
  body::before {
    content: "";
    position: fixed;
    inset: -20vmax;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(42vmax 42vmax at 78% 18%, var(--glow-violet), transparent 70%),
      radial-gradient(36vmax 36vmax at 12% 78%, var(--glow-orange), transparent 70%),
      radial-gradient(30vmax 30vmax at 30% 8%, var(--glow-violet), transparent 72%);
    animation: drift 38s var(--ease-in-out) infinite alternate;
  }

  /* Grain: paper tooth in the light theme, dithering for the glows in the dark one. */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    opacity: var(--grain-opacity);
    /* no blend mode on purpose: blending a full-screen layer over the animated glow
       would force the whole page to re-composite every frame */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .14 0 0 0 0 .22 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  @keyframes drift {
    to { transform: translate3d(4vmax, -3vmax, 0) scale(1.08); }
  }

  h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--ink);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.025em;
    text-wrap: balance;
  }
  h2 { font-size: var(--fs-h2); }
  h3 { font-size: var(--fs-h3); font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; }

  p, li { text-wrap: pretty; }
  p { max-inline-size: 68ch; }

  a {
    color: var(--link);
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    text-decoration-color: color-mix(in oklch, currentColor 40%, transparent);
    transition: text-decoration-color var(--dur-1) var(--ease-out);
  }
  @media (hover: hover) {
    a:hover { text-decoration-color: var(--accent); }
  }

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

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

  hr {
    border: 0;
    border-block-start: 1px solid var(--line);
  }

  @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;
    }
    body::before { animation: none; }
  }

  @media (forced-colors: active) {
    body::before, body::after { display: none; }
  }
}

@layer utilities {
  .container {
    inline-size: min(100% - 2 * var(--gutter), var(--container));
    margin-inline: auto;
  }
  .visually-hidden {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .skip-link {
    position: absolute;
    inset-block-start: 0.5rem;
    inset-inline-start: 0.5rem;
    z-index: 200;
    padding: 0.6rem 1rem;
    background: var(--ink);
    color: var(--bg);
    border-radius: var(--r-sm);
    translate: 0 -200%;
  }
  .skip-link:focus-visible { translate: 0 0; }
}
