* {
  box-sizing: border-box;
}

:root {
  --page-bg: color-mix(in srgb, var(--syntax-background, light-dark(#ffffff, #151515)) 97%, var(--page-fg));
  --page-fg: var(--syntax-foreground, light-dark(#1f1f1f, #ececec));
  --page-muted: light-dark(#646464, #a3a3a3);
  --page-border: light-dark(#d4d4d4, #383838);
  --page-section-border: color-mix(var(--syntax-string) 40%, transparent);
}

body {
  min-height: 100svh;
  margin: 0;
  background-color: var(--page-bg);
  background-image:
    linear-gradient(color-mix(in srgb, var(--syntax-comment) 12.5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--syntax-comment) 12.5%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--page-fg);
  font-family: "Cascadia Mono", monospace;
}

*:focus-visible {
  outline: 2px solid var(--syntax-function);
  outline-offset: 2px;
}

header,
main,
footer {
  width: min(100% - 2rem, 76rem);
  margin-inline: auto;
}

header {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding-block: clamp(3rem, 9vw, 7rem) 2rem;
  border-bottom: 2px solid var(--page-section-border);
}

.github-link {
  position: absolute;
  top: 1rem;
  right: 0;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  place-items: center;
  border: 1px solid var(--page-border);
  border-radius: 6px;
  background: var(--syntax-background);
  color: var(--syntax-foreground);
}

.github-link:hover {
  border-color: currentColor;
}

.github-link svg {
  width: 1.125rem;
  height: 1.125rem;
  stroke-width: 2;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.theme-controls {
  display: grid;
  grid-template-columns: 15rem auto;
  align-items: end;
  gap: 0.75rem;
}

.theme-actions {
  display: grid;
  grid-template-columns: 2.75rem auto;
  gap: 0.5rem;
}

.theme-control {
  display: grid;
  gap: 0.5rem;
  color: var(--page-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

button {
  display: inline-flex;
  align-items: center;
  background: var(--syntax-background);
  border-radius: 6px;
  border: 1px solid var(--page-border);
  color: var(--syntax-foreground);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  gap: 0.5rem;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem;
  padding-inline: 1rem;
  white-space: nowrap;
}

select {
  appearance: none;
  background: var(--syntax-background);
  border: 1px solid var(--page-border);
  color: var(--syntax-foreground);
  border-radius: 6px;

  font: inherit;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  text-transform: none;
}

@supports (appearance: base-select) {
  select,
  ::picker(select) {
    appearance: base-select;
    padding: 0;
    align-items: center;
    background: var(--syntax-background);
    min-height: 2.75rem;
    border-radius: 6px;
  }

  select {
    padding: 0;
    border: none;

    button {
      display: flex;
      width: 100%;
      justify-content: space-between;
      margin: 0;
    }

    &::picker-icon {
      display: none;
    }
  }

  ::picker(select) {
    padding: 0.5rem;
    width: max-content;
  }

  option {
    background: var(--syntax-background);
    color: var(--syntax-foreground);
    padding: 0.75rem;
  }
}

.color-scheme-toggle {
  width: 2.75rem;
  padding: 0;
}

.color-scheme-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
  stroke-width: 2;
}

:root[data-color-scheme="light"] .icon-moon,
:root[data-color-scheme="dark"] .icon-sun {
  display: none;
}

button:hover {
  border-color: currentColor;
}

dialog {
  width: min(100% - 2rem, 46rem);
  padding: 0;
  border: 1px solid var(--page-border);
  border-radius: 6px;
  background: var(--page-bg);
  color: var(--page-fg);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.65);
}

.dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--page-border);
}

dialog pre {
  min-height: 0;
  max-height: min(70svh, 42rem);
  border: 0;
  border-radius: 0;
  white-space: break-spaces;
}

main {
  padding-block: 1rem 4rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-block: 1rem;
  border-block: 2px solid var(--page-section-border);
}

.feature {
  display: grid;
  grid-template-rows: auto 6rem auto;
  min-width: 0;
  padding: 1.5rem;
}

.feature + .feature {
  border-inline-start: 2px solid var(--page-section-border);
}

.feature-index {
  display: block;
  margin-bottom: 1rem;
  color: var(--page-muted);
  font-size: 0.7rem;
}

.feature-specimen {
  min-width: 0;
  color: var(--page-fg);
}

.api-specimen {
  display: grid;
  align-content: center;
  gap: 0.45rem;
  font-size: clamp(0.7rem, 1vw, 0.8rem);
}

.api-old {
  color: var(--page-muted);
  text-decoration: line-through;
  text-decoration-color: var(--syntax-keyword);
  text-decoration-thickness: 2px;
}

.api-new {
  color: var(--syntax-function);
  font-weight: 700;
}

.size-specimen {
  display: flex;
  align-items: center;
  color: var(--syntax-function);
}

.size-value {
  font-size: clamp(2.75rem, 5vw, 4.25rem);
  font-weight: 300;
  line-height: 1;
}

.size-unit {
  color: var(--page-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.grammar-specimen {
  display: grid;
  align-content: center;
  gap: 0.55rem;
  font-size: 0.68rem;
}

.grammar {
  display: grid;
  grid-template-columns: 1fr 2.5rem;
  gap: 0.5rem;
  align-items: center;
}

.grammar::after {
  width: var(--load);
  height: 3px;
  justify-self: end;
  background: var(--syntax-function);
  content: "";
}

.grammar:nth-child(2)::after {
  background: var(--syntax-keyword);
}

.grammar:nth-child(3)::after {
  background: var(--syntax-string);
}

.swatch-specimen {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: center;
  gap: 0.4rem;
}

.swatch {
  aspect-ratio: 1.7;
  border: 1px solid var(--page-border);
  background: var(--swatch);
}

.feature h2 {
  max-width: 30ch;
  font-size: 0.9rem;
  line-height: 1.45;
  text-transform: none;
}

.install {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 1.5rem;
  padding-block: 2rem;
  border-bottom: 2px solid var(--page-section-border);
}

.install-label {
  padding-top: 1rem;
  color: var(--page-muted);
}

.install-steps {
  display: grid;
  gap: 1rem;
}

.install-steps p {
  max-width: 68ch;
  color: var(--page-muted);
  font-size: 0.85rem;
  line-height: 1.7;
}

.install-steps a {
  width: fit-content;
  color: var(--syntax-function);
  font-size: 0.85rem;
  font-weight: 700;
  text-underline-offset: 0.25em;
}

.install-steps pre {
  min-height: 0;
}

.samples-heading {
  display: grid;
  gap: 0.75rem;
  padding-block: 3rem 2rem;
  border-bottom: 2px solid var(--page-section-border);
}

.samples-heading h2 {
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1;
  text-transform: none;
}

.samples-heading p {
  color: var(--page-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.sample {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 1.5rem;
  padding-block: 2rem;
  border-bottom: 2px solid var(--page-section-border);
}

.sample-label {
  padding-top: 1rem;
  color: var(--page-muted);
}

.language-index {
  display: grid;
  gap: 1.25rem;
  padding-block: 2rem;
  border-bottom: 2px solid var(--page-section-border);
}

.language-index > p {
  max-width: 62ch;
  color: var(--page-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.language-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.5rem;
}

.language-group h3 {
  margin: 0 0 0.6rem;
  color: var(--page-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.language-group ul {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.language-group li::before {
  margin-inline-end: 0.5rem;
  color: var(--syntax-keyword);
  content: "\2022";
}

.playground-body {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.playground-control {
  display: grid;
  gap: 0.4rem;
  width: min(100%, 18rem);
  color: var(--page-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.playground-output pre {
  margin: 0;
}

pre {
  min-width: 0;
  min-height: 18rem;
  margin: 0;
  padding: clamp(1rem, 3vw, 2rem);
  overflow: auto;
  border: 1px solid var(--page-border);
  border-radius: 6px;
  background: var(--syntax-background);
  color: var(--syntax-foreground);
  font: 500 clamp(0.78rem, 1.5vw, 0.95rem) / 1.75 "Cascadia Mono", monospace;
  tab-size: 2;
  white-space: pre;
}

.page-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 2rem;
  padding-block: 2rem 4rem;
  border-top: 2px solid var(--page-section-border);
  color: var(--page-muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.footer-brand {
  display: grid;
  gap: 0.25rem;
}

.footer-brand strong {
  color: var(--page-fg);
  font-size: 0.9rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.75rem 1.25rem;
}

.page-footer a {
  color: var(--syntax-function);
  text-underline-offset: 0.25em;
}

@media (max-width: 52rem) {
  header {
    padding-top: 5rem;
    align-items: stretch;
    flex-direction: column;
  }

  .theme-controls {
    grid-template-columns: 1fr;
  }

  .theme-actions {
    grid-template-columns: 2.75rem 1fr;
  }

  .features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature:nth-child(3) {
    border-inline-start: 0;
  }

  .feature:nth-child(n + 3) {
    border-block-start: 2px solid var(--page-section-border);
  }

  .install,
  .sample {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .install-label,
  .sample-label {
    padding-top: 0;
  }

  pre {
    min-height: 14rem;
  }
}

@media (max-width: 30rem) {
  .page-footer {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .footer-nav {
    justify-content: start;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .feature + .feature {
    border-block-start: 2px solid var(--page-section-border);
    border-inline-start: 0;
  }

  .feature {
    grid-template-rows: auto 5.5rem auto;
  }

  .language-groups {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
