@use "../01-utils/tokens" as *;

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  height: 100dvh;
  color-scheme: light dark;
}

body {
  display: flex;
  flex-direction: column;
  font-family: var(--font-family);
  @include text-body-s;
  background-color: light-dark(
    var(--color-background),
    var(--color-background-inverse)
  );
  color: light-dark(var(--color-foreground), var(--color-foreground-inverse));
  height: 100%;
}

::selection {
  --bg-color: light-dark(
    var(--color-background-strong-inverse),
    var(--color-background-strong)
  );
  --text-color: light-dark(
    var(--color-foreground-inverse),
    var(--color-foreground)
  );

  background-color: var(--bg-color);
  color: var(--text-color);
}

:focus {
  --outline-color: light-dark(
    var(--color-background-strong-inverse),
    var(--color-background-strong)
  );
  outline: var(--base-space-1) solid var(--outline-color);
}

a {
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  color: light-dark(
    var(--color-foreground-primary-strong),
    var(--color-foreground-primary-weak-inverse)
  );

  &:hover,
  &:focus {
    color: light-dark(
      var(--color-foreground-primary),
      var(--color-foreground-primary-inverse)
    );
  }

  &:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-decoration-color: currentColor;
    text-decoration-skip-ink: auto;
    text-underline-offset: 2px;
  }

  &:active {
    color: light-dark(
      var(--color-foreground-primary-strong),
      var(--color-foreground-primary-strong-inverse)
    );
  }
}

abbr {
  text-decoration: none;
}

p,
ol,
ul,
dl,
blockquote,
figure,
hr {
  margin-inline-start: 0;
  padding-inline-start: 0;
}

main,
iframe,
img,
svg {
  display: block;
}

iframe,
img,
svg {
  height: auto;
  vertical-align: middle;
  max-width: 100%;
}

main {
  flex: 1;
}

nav {
  ul {
    max-width: 100%;
    flex-wrap: wrap;
  }

  li {
    display: inline-flex;
    flex-shrink: 0;
    flex-wrap: wrap;
  }

  a {
    @include text-body-m;
  }
}

section:not(.hero) {
  padding: var(--base-space-12) var(--page-padding-x);
}

ul {
  margin-block: 0;
  margin-inline: 0;
}

main {
  section {
    & > :is(h1, h2, h3, h4, h5, h6, p, ul, ol) + * {
      margin-block-start: var(--base-space-6);
    }

    & > * + :is(h1, h2, h3, h4, h5, h6) {
      margin-block-start: var(--base-space-12);
    }

    & > :is(h1, h2, h3, h4, h5, h6, p) + :is(ul, ol) {
      padding-inline-start: var(--base-space-8);
    }

    & > p {
      max-width: 65ch;
    }
  }

  h1 {
    @include text-heading1;
  }

  h2 {
    @include text-heading2;
  }

  h3 {
    @include text-heading3;
  }

  h4 {
    @include text-heading4;
  }

  h5 {
    @include text-heading5;
  }

  h6 {
    @include text-heading6;
  }
}

pre {
  overflow-x: auto;
}

main table {
  border-collapse: collapse;
}

main th {
  border-bottom: 1px solid
    color-mix(
      in oklch,
      light-dark(var(--color-foreground), var(--color-foreground-inverse)),
      transparent 75%
    );
  font-weight: 700;
}

main :is(th, td) {
  padding: var(--base-space-2) var(--base-space-4);
}

main tr:nth-of-type(even) td {
  background-color: light-dark(
    var(--color-background-weak),
    var(--color-background-weak-inverse)
  );
}

.link-button {
  display: inline-flex;
  padding-block: var(--base-space-3);
}

.astro-code {
  background-color: var(--color-background-strong-inverse) !important;
  padding-block: var(--base-space-4) !important;
  font-family: monospace !important;
  color: var(--color-foreground-inverse) !important;
}
