:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --surface-muted: #f4f4f1;
  --text: #171717;
  --text-muted: #64645f;
  --text-soft: #92928b;
  --border: #deded8;
  --border-strong: #c9c9c0;
  --accent: #a34824;
  --accent-muted: #f1e4dc;
  --code-bg: #f1f1ed;
  --code-text: #242421;
  --content-width: 64rem;
  --wide-width: 78rem;
  --font-mono:
    ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}
main {
  min-height: calc(100vh - 6.5rem);
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, var(--border-strong));
  text-underline-offset: 0.22em;
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    opacity 140ms ease;

  &:hover {
    text-decoration-color: currentColor;
  }
}

a:focus-visible,
button:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 30;
  transform: translateY(-150%);
  border: 1px solid var(--text);
  background: var(--bg);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  text-decoration: none;

  &:focus {
    transform: translateY(0);
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.site-header__inner,
.home-hero__content,
.section-block,
.site-footer__inner {
  margin: 0 auto;
  padding-inline: 1rem;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--wide-width);
  min-height: 3.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.brand__mark {
  display: inline-grid;
  width: 1.45rem;
  height: 1.45rem;
  place-items: center;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  font-size: 0.72rem;
  line-height: 1;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  overflow-x: auto;
}

.site-nav__link {
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 0.35rem 0.5rem;
  text-decoration: none;
  white-space: nowrap;

  &:hover,
  &.is-active {
    background: var(--accent-muted);
    color: var(--accent);
  }
}

.home-hero {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.home-hero__content {
  max-width: var(--content-width);
  padding-block: 5rem 4.25rem;

  h1 {
    max-width: 34rem;
    font-size: clamp(1.75rem, 5vw, 3.5rem);
    line-height: 0.96;
  }
}

.lead {
  max-width: 46rem;
  margin-top: 1.65rem;
  color: var(--text-muted);
  font-size: 0.86rem;

  p {
    margin: 0 0 0.85rem;
  }
  strong {
    color: var(--text);
    font-weight: 600;
  }
}

.section-block {
  max-width: var(--content-width);
  padding-block: 2.25rem 3.5rem;
}

.section-block__header h2,
.doc-list h2,
.docs-sidebar__label,
.page-toc__label {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-block__header h2 {
  margin: 0 0 0.9rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--border);
}

.project-card {
  display: grid;
  min-height: 8rem;
  align-content: space-between;
  gap: 1.5rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 1rem;
  text-decoration: none;

  &:first-child {
    border-left: 1px solid var(--border);
  }
  &:hover {
    background: var(--surface-muted);
  }
}

.project-card__name {
  font-size: 0.95rem;
  font-weight: 600;
}

.project-card__summary {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

.docs-layout {
  display: grid;
  grid-template-columns: minmax(10rem, 13rem) minmax(0, 42rem) minmax(9rem, 12rem);
  gap: 2.25rem;
  max-width: var(--wide-width);
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.docs-sidebar,
.page-toc {
  position: sticky;
  top: 4.25rem;
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow: auto;
}

.docs-sidebar {
  &__label {
    margin: 0 0 0.55rem;
  }

  &__group + &__group {
    margin-top: 1.35rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--border);
  }

  &__link {
    display: block;
    color: var(--text-muted);
    font-size: 0.76rem;
    line-height: 1.35;
    padding: 0.28rem 0;
    text-decoration: none;

    &:hover,
    &.is-active {
      color: var(--accent);
    }
    &.is-active::before {
      content: "→ ";
    }
  }
}

.docs-content {
  min-width: 0;
}

.page-header {
  margin-bottom: 1.8rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);

  h1 {
    font-size: clamp(1.45rem, 4vw, 2.5rem);
    line-height: 1;
  }

  p {
    max-width: 38rem;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.82rem;
  }
}

.prose {
  color: var(--text);

  > :first-child {
    margin-top: 0;
  }
  > :last-child {
    margin-bottom: 0;
  }

  h2 {
    margin: 2.15rem 0 0.65rem;
    font-size: 1.2rem;
    line-height: 1.25;
  }

  h3 {
    margin: 1.65rem 0 0.5rem;
    font-size: 0.98rem;
    line-height: 1.3;
  }

  h4 {
    margin: 1.35rem 0 0.45rem;
    font-size: 0.88rem;
  }

  p,
  ul,
  ol,
  pre,
  blockquote,
  table {
    margin: 0 0 1rem;
  }
  ul,
  ol {
    padding-left: 1.25rem;
  }
  li + li {
    margin-top: 0.2rem;
  }
  strong {
    font-weight: 600;
  }
  a {
    color: var(--accent);
  }

  code {
    border: 1px solid var(--border);
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.08rem 0.24rem;
  }

  pre {
    overflow-x: auto;
    border: 1px solid var(--border);
    background: var(--code-bg);
    padding: 0.85rem;

    code {
      border: 0;
      background: transparent;
      padding: 0;
    }
  }

  blockquote {
    border-left: 1px solid var(--text);
    color: var(--text-muted);
    padding: 0.15rem 0 0.15rem 0.85rem;
  }

  table {
    display: block;
    overflow-x: auto;
    width: 100%;
    border-collapse: collapse;
  }

  th,
  td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    text-align: left;
    vertical-align: top;
  }

  th {
    background: var(--surface-muted);
    font-size: 0.75rem;
    font-weight: 600;
  }
}

.heading-anchor {
  color: var(--text-soft);
  font-weight: 400;
  opacity: 0;
  padding-left: 0.35rem;
  text-decoration: none;

  h2:hover &,
  h3:hover &,
  h4:hover &,
  &:focus {
    opacity: 1;
  }
}

.doc-list {
  margin-top: 2.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);

  h2 {
    margin: 0 0 0.85rem;
  }

  &__items {
    display: grid;
    border-top: 1px solid var(--border);
  }

  &__item {
    display: grid;
    gap: 0.18rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem 0;
    text-decoration: none;

    &:hover {
      background: var(--surface-muted);
    }
    span {
      font-weight: 600;
    }
    small {
      color: var(--text-muted);
      font-size: 0.74rem;
    }
  }
}

.page-toc {
  color: var(--text-muted);
  font-size: 0.72rem;

  &__label {
    margin: 0 0 0.55rem;
  }

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

    ul {
      margin-top: 0.18rem;
      padding-left: 0.7rem;
    }
  }

  li {
    margin: 0.22rem 0;
  }

  a {
    color: var(--text-muted);
    text-decoration: none;

    &:hover {
      color: var(--accent);
    }
  }
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);

  &__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem 1.25rem;
    max-width: var(--wide-width);
    padding-block: 1.1rem;
    font-size: 0.72rem;
  }

  a {
    color: inherit;
  }
}

@media (max-width: 1024px) {
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .docs-sidebar,
  .page-toc {
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }

  .docs-sidebar__link {
    display: inline-flex;
    margin-right: 0.7rem;
  }

  .page-toc {
    order: 2;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 12px;
  }

  .site-header__inner {
    align-items: flex-start;
    flex-direction: column;
    padding-block: 0.75rem;
  }

  .site-nav {
    width: 100%;
  }
  .home-hero__content {
    padding-block: 3.5rem 3rem;
  }
  .section-block {
    padding-block: 2rem 3rem;
  }
  .project-grid {
    grid-template-columns: 1fr;
  }

  .project-card {
    border-inline: 0;

    &:first-child {
      border-left: 0;
    }
  }

  .docs-layout {
    padding: 1.25rem 1rem 3rem;
  }

  .site-footer__inner {
    align-items: flex-start;
    flex-direction: column;
  }
}
