:root {
  --brand: #0589f5;
  --brand-strong: #0470c9;
  --text: #24292f;
  --text-muted: #57606a;
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --border: #d8dee4;
  --header-height: 3.5rem;
  --sidebar-width: 16rem;
  color-scheme: light;
}

/* The theme plugin sets data-theme from the toggle, or the system setting
   when nothing has been chosen. Both blocks are needed so the page still
   follows the system setting without scripts. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #3aa3ff;
    --brand-strong: #6cbaff;
    --text: #e6edf3;
    --text-muted: #9198a1;
    --bg: #16191d;
    --bg-subtle: #20242a;
    --border: #30363d;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --brand: #3aa3ff;
  --brand-strong: #6cbaff;
  --text: #e6edf3;
  --text-muted: #9198a1;
  --bg: #16191d;
  --bg-subtle: #20242a;
  --border: #30363d;
  color-scheme: dark;
}

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

html {
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  font-family: "Cabin", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

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

a:hover {
  color: var(--brand-strong);
}

code,
pre {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--header-height);
  padding: 0 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header__logo {
  display: flex;
  margin-right: auto;
}

.site-header__links {
  display: flex;
  gap: 1.25rem;
}

.site-header__links a {
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
}

.site-header__links a:hover {
  color: var(--text);
}

.made-with,
.sidebar .made-with {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.site-header__links .made-with {
  font-weight: 400;
}

.made-with img {
  border-radius: 3px;
}

/* Only shown on phones, where the header has no room for it. */
.sidebar__made-with {
  display: none;
}

/* The dot sits left in light mode and right in dark mode. */
.theme-toggle {
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-subtle);
  cursor: pointer;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--brand);
  transform: translateY(-50%);
  transition: left 0.2s;
}

:root[data-theme="dark"] .theme-toggle::before {
  left: calc(100% - 1.2rem);
}

/* Layout */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.nav-toggle,
.nav-toggle__label {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Sidebar */

.sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem;
  border-right: 1px solid var(--border);
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar details ul {
  margin: 0.15rem 0 0.5rem 0.75rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}

.sidebar a,
.sidebar summary {
  display: block;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.sidebar summary {
  cursor: pointer;
  font-weight: 600;
}

.sidebar a:hover,
.sidebar summary:hover {
  background: var(--bg-subtle);
}

.sidebar a[aria-current="page"] {
  color: var(--brand);
  background: var(--bg-subtle);
  font-weight: 600;
}

.sidebar code {
  font-size: 0.85em;
}

/* Content */

.content {
  width: 100%;
  max-width: 48rem;
  padding: 2rem 2.5rem 4rem;
}

.content h1 {
  margin-top: 0;
  font-size: 2.25rem;
  font-stretch: 87.5%;
  line-height: 1.2;
}

.content h2 {
  margin-top: 2.25rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.5rem;
}

.content h3 {
  margin-top: 1.75rem;
  font-size: 1.2rem;
}

.content :not(pre) > code {
  padding: 0.15em 0.35em;
  border-radius: 4px;
  background: var(--bg-subtle);
}

/* The code highlighting theme sets each block's background and padding. */
.content pre {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  line-height: 1.5;
  border: 2px solid var(--border);
}

/* Added by the copy plugin. With a mouse it only shows while hovering over
   the block, so it doesn't cover the code. */
.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem;
  border: 0;
  background: none;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

@media (hover: hover) {
  .copy-button {
    opacity: 0;
  }

  pre:hover .copy-button,
  .copy-button:focus-visible {
    opacity: 1;
  }
}

.content table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

.content th,
.content td {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.content blockquote {
  margin: 1.25rem 0;
  padding: 0.5rem 1rem;
  border-left: 4px solid var(--brand);
  background: var(--bg-subtle);
}

/* Phones: the sidebar becomes a menu opened by the checkbox above it, so it
   works without any script. */

@media (max-width: 800px) {
  .layout {
    display: block;
  }

  .nav-toggle__label {
    display: block;
    padding: 0 0.25rem;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
  }

  .nav-toggle__label::before {
    content: "☰";
  }

  .sidebar {
    display: none;
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-toggle:checked ~ .sidebar {
    display: block;
  }

  .site-header__links .made-with {
    display: none;
  }

  .sidebar__made-with {
    display: block;
  }

  .sidebar__made-with .made-with {
    color: var(--text-muted);
  }

  .content {
    padding: 1.5rem 1.25rem 3rem;
  }

  .content h1 {
    font-size: 1.85rem;
  }
}
