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

*:not(dialog) {
  margin: 0;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
  hyphens: auto;
  hyphenate-limit-chars: 7
}

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

/* Vars */
:root {
  color-scheme: light dark;
  --white: #faf8f5;
  --black: #1c1b18;
  --colour: #7c3aed;
  --bg: light-dark(var(--white), var(--black));
  --fg: light-dark(var(--black), var(--white));
  --highlight: light-dark(
      var(--colour),
      oklch(from var(--colour) calc(l + 0.20) c h)
  );
  --dots: light-dark(
      oklch(from var(--highlight) calc(l + 0.36) 0.1 h),
      oklch(from var(--highlight) calc(l - 0.60) 0.1 h)
  );
  --links: light-dark(
      oklch(from var(--highlight) calc(l - 0.15) c h),
      oklch(from var(--highlight) calc(l + 0.15) c h)
  );
}

/* Styling */
html {
  color: var(--fg);
  background-color: var(--bg);
}

html::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--dots);
  mask-image: linear-gradient(135deg, white 0%, rgba(255, 255, 255, 0.2) 15%, rgba(255, 255, 255, 0.2) 85%, white 100%),
  url('/static/dots-c978f9f7.svg');
  mask-composite: intersect;
}

html:has(article)::before {
  mask-image: linear-gradient(135deg, white 0%, rgba(255, 255, 255, 0.0) 15%, rgba(255, 255, 255, 0.0) 85%, white 100%),
  url('/static/dots-c978f9f7.svg');
}

body {
  line-height: 1.5;
  display: grid;
  width: 100vw;
  height: 100vh;
}

h1 {
  color: var(--highlight);
}

a {
  color: var(--links);
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;

  p {
    padding-bottom: 1rem;
  }

  &:has(article) {
    padding-top: 2rem;

    ul {
      padding-bottom: 1rem;
    }

    nav {
      a {
        align-self: flex-start;
      }

      width: 70vw;
    }

    article {
      justify-self: flex-start;
      width: 70vw;
      padding-bottom: 2rem;
    }
  }

  &:not(:has(article)) {
    justify-content: center;

    ul {
      list-style: none;
      padding: 0;

      li {
        display: inline;

        &:not(:first-child)::before {
          content: " | "
        }
      }
    }
  }
}

nav[aria-label="breadcrumbs"] {
  font-size: 0.85rem;
  padding-bottom: 1rem;

  ol {
    list-style: none;
    padding-left: 0;

    li {
      display: inline-block;

      &:not(:last-child):after {
        content: "›";
        display: inline-block;
        padding: 0 .5ch;
        speak: never;
      }
    }
  }
}

main:has(nav[aria-label="subpages"]) nav[aria-label="breadcrumbs"] {
  padding-bottom: 0;
}

nav[aria-label="subpages"] {
  font-size: 0.85rem;
  padding-bottom: 1rem;

  ul {
    list-style: none;
    padding-left: 0;

    &::before {
      content: "→";
      padding-right: .5ch;
      speak: never;
    }

    li {
      display: inline-block;
      padding-right: 0;

      &:not(:first-child):before {
        content: "·";
        display: inline-block;
        padding: 0 .5ch;
        speak: never;
      }
    }
  }
}

a:not(
	[href^="#"],
	[href^="/"]
)::after {
  content: "↗";
  vertical-align: super;
  font-size: 0.5em;
  display: inline-block;
  bottom: 0.5em;
  padding-left: 1ch;
  position: relative;
}

pre {
  font: inherit;
  white-space: pre-line;
  text-wrap: pretty;
  overflow-wrap: break-word;
}

 /* Mobile adjustments */
 @media (max-width: 768px) {
   body {
     font-size: 1.1rem;
   }
   main:has(article) {
     padding-top: 3rem;

     nav, article {
       width: 90vw;
       max-width: 70ch;
     }
   }

   .card-grid {
      grid-template-columns: 1fr;

      .card {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;

        .card-left {
          padding-top: 0.5rem;
          padding-bottom: 0.25rem;

          h3 {
            margin-bottom: 0;
          }
        }

        .card-right {
          flex: 1;
        }
      }

      &.compact {
        .card {
          display: flex;
          flex-direction: column;
        }
      }
    }
 }

table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
  tr {
    border-bottom: 1px solid oklch(from var(--fg) calc(l - 0.50) c h);
    transition: border-color 0.5s ease, background-color 0.5s ease;

    &:hover {
      border-bottom-color: var(--highlight);
    }
  }
  th {
    text-align: left;
    width: 130px;
    padding: 0.5rem 0;
    color: var(--highlight);
    font-weight: normal;
  }
  td {
    padding: 0.5rem 0;
    font-size: 0.95rem;
  }
}

.uses {
  section {
    h2 {
      margin-bottom: 1rem;
      color: var(--highlight);
    }
  }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;

  .card {
    border: 1px solid oklch(from var(--fg) calc(l - 0.40) c h);
    border-radius: 0.5rem;
    padding: 0.25rem 1rem;
    transition: border-color 0.5s ease, box-shadow 0.5s ease;
    display: grid;
    grid-template-columns: minmax(110px, 130px) 1fr;
    gap: 1rem;
    align-items: flex-start;

    &:hover {
      border-color: var(--highlight);
      box-shadow: 0 4px 12px oklch(from var(--highlight) calc(l - 0.30) 0.1 h / 0.2);
    }

    .card-left {
      padding-top: 0.25rem;

      h3 {
        font-size: 1rem;
        margin: 0;
        color: var(--highlight);
        line-height: 1.3;
      }
    }

    .card-right {
      p {
        margin: 0;
        font-size: 0.95rem;
      }

      .note {
        display: block;
        margin-top: 0.5rem;
        font-size: 0.85em;
        opacity: 0.7;
        font-style: italic;
      }
    }
  }

  &.compact {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;

    .card {
      grid-template-columns: 120px 1fr;
    }
  }
}
