@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Special+Elite&display=swap');
@import url('https://unpkg.com/normalize.css') layer(normalize);
/* @import 'normalize.css' layer(normalize); */

@layer normalize, base, demo, blurring, debug;

@layer blurring {
  :root {
    --layers: 5;
    --blur-max: 40;
    --mask-stop: 25;
  }
  .blur {
    div {
      --blur: calc(
        sin(((var(--layers) - var(--i)) / var(--layers)) * 90deg) *
          var(--blur-max)
      );
      --stop: calc(
        sin(((var(--i)) / var(--layers)) * 90deg) * var(--mask-stop)
      );
      /* inverted */
      /* --stop: calc(
        var(--mask-stop) - sin(((var(--i) - 1) / var(--layers)) * 90deg) *
          var(--mask-stop)
      ); */
      position: absolute;
      inset: 0;

      &::after {
        content: '';
        position: absolute;
        inset: 0 -250%;
        -webkit-backdrop-filter: blur(calc(var(--blur) * 1px));
                backdrop-filter: blur(calc(var(--blur) * 1px));
        -webkit-mask: linear-gradient(
          180deg,
          #0000 0 calc((100 - var(--stop)) * 1%),
          #000 100%
        );
                mask: linear-gradient(
          180deg,
          #0000 0 calc((100 - var(--stop)) * 1%),
          #000 100%
        );
      }

      &::before {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--stop) * 1%);
        z-index: 20000;
      }
    }
  }
}

@layer debug {
  .blur::after {
    content: '';
    position: absolute;
    inset: 0;
  }

  .label {
    grid-area: 1 / 2;
    position: sticky;
    top: 0;
    height: 100vh;
    opacity: 0;
    transition: opacity 0.26s ease-out;
  }

  .label::after {
    content: 'blur overlay';
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 0.25rem;
    background: hsl(0 90% 50%);
    font-family: 'Special Elite', system-ui;
    text-shadow: 0 1px #111;
    position: absolute;
    top: 50%;
    left: 0;
    transform: rotate(-90deg) translateX(100%);
    transform-origin: 0 100%;
    z-index: 2;
  }

  .label::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.5;
    background: repeating-linear-gradient(
      45deg,
      #0000 0 8px,
      hsl(0 90% 50%) 8px 10px
    );
  }

  .blur::after,
  .blur div::before {
    outline: 4px dashed #0000;
    transition: outline-color 0.26s ease-out;
  }

  [data-debug='true'] .blur::after,
  [data-debug='true'] .blur div::before {
    outline-color: hsl(0 90% 50%);
  }

  [data-debug='true'] .label {
    opacity: 1;
  }

  [data-debug='true'] header div:first-of-type {
    opacity: 0.25;
  }

  .blur div::before {
    -webkit-clip-path: inset(-100% 0 -100% 0);
            clip-path: inset(-100% 0 -100% 0);
  }
}

@layer demo {
  :root {
    --img-size: clamp(120px, 40vmin, 380px);
    scrollbar-color: hsl(0 90% 50%) #0000;
  }

  .clear {
    padding: 0.5rem 0.75rem;
    display: inline-block;
    border: 2px solid canvasText;
    margin-top: 0.5rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    text-decoration: none;
    color: inherit;
    width: -webkit-fit-content;
    width: -moz-fit-content;
    width: fit-content;

    &:is(:focus-visible, :hover) {
      color: canvas;
      background-color: canvasText;
    }
  }

  .content {
    width: 1200px;
    max-width: calc(100vw - 2rem);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
  }

  header {
    min-height: 100vh;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
  }

  header > div:first-of-type {
    position: sticky;
    top: 0;
    height: -webkit-fit-content;
    height: -moz-fit-content;
    height: fit-content;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    grid-area: 1 / 1;
    width: -webkit-fit-content;
    width: -moz-fit-content;
    width: fit-content;
    max-width: 280px;
    text-wrap: balance;
    z-index: 2000;
    transition: opacity 0.26s ease-out;

    h1 {
      font-size: 0.875rem !important;
      margin: 0;
      background: hsl(0 90% 50%);
      text-shadow: 0 1px #111;
      translate: -10% 10%;
      rotate: -6deg;
      z-index: -1;
      padding: 0.25rem;
      font-family: 'Special Elite', system-ui;
      text-transform: uppercase;
      display: inline-grid;
      width: -webkit-fit-content;
      width: -moz-fit-content;
      width: fit-content;
      place-items: center;
    }
    p {
      font-weight: 300;
      margin: 0;
      line-height: 1.5;
      margin-block: 1rem;
    }
    p:first-of-type {
      line-height: 1;
      font-size: 2rem;
      font-weight: 600;
      margin: 0;
    }
  }

  .blur {
    grid-area: 1 / 2;
    position: sticky;
    top: 0;
    height: 100vh;
    width: 100%;
    justify-self: center;
  }

  header > ul {
    grid-area: 1 / 2;
    padding: 0;
    padding-block: calc((var(--padding) * 1vh) - (var(--img-size) * 0.5));
    list-style-type: none;
    gap: 6rem;
    display: flex;
    flex-direction: column;
    margin: 0;

    li {
      width: var(--img-size);
      aspect-ratio: 1;

      img {
        width: 100%;
        height: 100%;
        -o-object-fit: cover;
           object-fit: cover;
        border-radius: 6px;
        filter: contrast(1.1) saturate(var(--saturate, 0.1));
      }
    }
  }

  footer {
    opacity: 0.7;
    font-size: 0.875rem;
    padding: 2rem;
  }

  body {
    display: block;
    overflow-x: hidden;
  }
}

@layer base {
  :root {
    --font-size-min: 16;
    --font-size-max: 20;
    --font-ratio-min: 1.2;
    --font-ratio-max: 1.33;
    --font-width-min: 375;
    --font-width-max: 1500;
  }

  html {
    color-scheme: light dark;
  }

  [data-theme='light'] {
    color-scheme: light only;
  }

  [data-theme='dark'] {
    color-scheme: dark only;
  }

  :where(.fluid) {
    --fluid-min: calc(
      var(--font-size-min) * pow(var(--font-ratio-min), var(--font-level, 0))
    );
    --fluid-max: calc(
      var(--font-size-max) * pow(var(--font-ratio-max), var(--font-level, 0))
    );
    --fluid-preferred: calc(
      (var(--fluid-max) - var(--fluid-min)) /
        (var(--font-width-max) - var(--font-width-min))
    );
    --fluid-type: clamp(
      (var(--fluid-min) / 16) * 1rem,
      ((var(--fluid-min) / 16) * 1rem) -
        (((var(--fluid-preferred) * var(--font-width-min)) / 16) * 1rem) +
        (var(--fluid-preferred) * var(--variable-unit, 100vi)),
      (var(--fluid-max) / 16) * 1rem
    );
    font-size: var(--fluid-type);
  }

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

  body {
    background: light-dark(#fff, #000);
    display: grid;
    place-items: center;
    min-height: 100vh;
    font-family: 'Inter', 'SF Pro Text', 'SF Pro Icons', 'AOS Icons',
      'Helvetica Neue', Helvetica, Arial, sans-serif, system-ui;
  }

  body::before {
    --size: 45px;
    --line: color-mix(in hsl, canvasText, transparent 80%);
    content: '';
    height: 100vh;
    width: 100vw;
    position: fixed;
    background: linear-gradient(
          90deg,
          var(--line) 1px,
          transparent 1px var(--size)
        )
        calc(var(--size) * 0.36) 50% / var(--size) var(--size),
      linear-gradient(var(--line) 1px, transparent 1px var(--size)) 0%
        calc(var(--size) * 0.32) / var(--size) var(--size);
    -webkit-mask: linear-gradient(-20deg, transparent 50%, white);
            mask: linear-gradient(-20deg, transparent 50%, white);
    top: 0;
    transform-style: flat;
    pointer-events: none;
    z-index: -1;
  }

  .bear-link {
    color: canvasText;
    position: fixed;
    top: 1rem;
    left: 1rem;
    width: 48px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    opacity: 0.8;
  }

  :where(.x-link, .bear-link):is(:hover, :focus-visible) {
    opacity: 1;
  }

  .bear-link svg {
    width: 75%;
  }

  /* Utilities */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }
}

div.tp-dfwv {
  position: fixed;
}