/*
  Sumi documentation.
  Sumi's own colours come from its icon: washi paper, bands of sumi ink and one
  stroke of vermilion. The page sits on NekoLab's dot-grid notebook paper, with
  the studio's display face for headings and its sign-off at the foot of a page.
*/

@font-face {
  /* SIL Open Font License 1.1, see bricolage-grotesque-OFL.txt. */
  font-family: "Bricolage Grotesque";
  src: url("bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f1ede6;
  --dots: #ddd6c9;
  --card: #fbf9f5;
  --ink: #1f1e1b;
  --copy: #45423c;
  --muted: #7d786f;
  --line: rgba(31, 30, 27, 0.14);
  --hover: rgba(31, 30, 27, 0.06);
  --vermilion: #c8462c;
  --vermilion-soft: rgba(200, 70, 44, 0.14);
  --stripe-light: #a49f96;
  --stripe-dark: #5a564f;
  --note: rgba(31, 30, 27, 0.05);
  --tip-line: rgba(61, 122, 90, 0.38);
  --tip: rgba(61, 122, 90, 0.08);
  --warning-line: rgba(176, 111, 20, 0.4);
  --warning: rgba(214, 154, 40, 0.13);
  --syntax-comment: #8a857c;
  --syntax-keyword: #9a5214;
  --syntax-string: #3d7a5a;
  --syntax-number: #a0602a;
  --syntax-property: #3a5f9a;
  --syntax-tag: #b8432a;
  --syntax-template: #74519c;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #191816;
    --dots: #2b2926;
    --card: #22211e;
    --ink: #ece8e0;
    --copy: #c6c1b8;
    --muted: #8f8a81;
    --line: rgba(236, 232, 224, 0.14);
    --hover: rgba(236, 232, 224, 0.07);
    --vermilion: #e4694d;
    --vermilion-soft: rgba(228, 105, 77, 0.2);
    --stripe-light: #e2ded5;
    --stripe-dark: #a19c94;
    --note: rgba(236, 232, 224, 0.06);
    --tip-line: rgba(120, 190, 150, 0.35);
    --tip: rgba(120, 190, 150, 0.08);
    --warning-line: rgba(230, 170, 70, 0.38);
    --warning: rgba(230, 170, 70, 0.1);
    --syntax-comment: #8f8a81;
    --syntax-keyword: #e3a15f;
    --syntax-string: #8cc7a4;
    --syntax-number: #e0a46e;
    --syntax-property: #94b4e8;
    --syntax-tag: #ef8a70;
    --syntax-template: #c3a2e6;
  }
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  overflow-x: clip;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(var(--dots) 1.1px, transparent 1.3px) 0 0 / 22px 22px,
    var(--paper);
  font-family: var(--body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
}

/* ---------- Top bar ---------- */

.docs-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 72px;
  padding: 0 48px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--paper) 86%, transparent);
  backdrop-filter: blur(18px);
}

.docs-top-brand,
.docs-top-nav {
  display: inline-flex;
  align-items: center;
}

.docs-top-brand {
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.docs-top-brand .brand-logo,
.docs-top-brand .brand-logo img {
  width: 36px;
  height: 36px;
}

.docs-top-brand .brand-logo img {
  border-radius: 9px;
}

.docs-top-brand strong {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.docs-top-nav {
  gap: 24px;
  margin-left: auto;
  font-size: 0.94rem;
  font-weight: 650;
}

.docs-top-nav a {
  text-decoration: none;
  white-space: nowrap;
}

.docs-top-nav a:hover {
  color: var(--vermilion);
}

/* ---------- Layout ---------- */

.docs-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 760px) minmax(0, 210px);
  justify-content: start;
  gap: 56px;
  align-items: start;
  min-height: calc(100vh - 72px);
}

.docs-sidebar {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  padding: 28px 30px 30px;
  border-right: 1px solid var(--line);
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  backdrop-filter: blur(18px);
}

.mobile-nav-toggle {
  display: none;
}

/* ---------- Version picker and search ---------- */

.docs-version-picker select {
  padding: 6px 30px 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1.5 6 6.5 11 1.5" fill="none" stroke="%237d786f" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>')
    no-repeat right 11px center,
    var(--card);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.docs-version-picker select:hover,
.docs-version-picker select:focus-visible,
.docs-search input:focus {
  border-color: var(--vermilion);
  outline: none;
}

.docs-search {
  margin: 0 0 14px;
}

.docs-search input {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--card);
  font: inherit;
  font-size: 0.9rem;
  appearance: none;
  -webkit-appearance: none;
}

.docs-search input::placeholder {
  color: var(--muted);
}

.docs-search[hidden],
.docs-search-results[hidden] {
  display: none;
}

.docs-search-results {
  flex: 1;
  min-height: 0;
  margin-right: -16px;
  padding-right: 16px;
  overflow-y: auto;
}

.docs-search-results a {
  display: block;
  margin: 0 0 4px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.docs-search-results a:hover {
  background: var(--hover);
}

.docs-search-results a strong {
  display: block;
  font-size: 0.92rem;
}

.docs-search-results a span {
  display: block;
  color: var(--copy);
  font-size: 0.84rem;
}

.docs-search-results a p {
  margin: 4px 0 0;
  color: var(--copy);
  font-size: 0.82rem;
  line-height: 1.45;
}

.docs-search-results mark {
  border-radius: 3px;
  color: inherit;
  background: var(--vermilion-soft);
}

.docs-search-results .search-empty {
  margin: 6px 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Sidebar navigation ---------- */

.docs-nav {
  flex: 1;
  min-height: 0;
  margin-right: -16px;
  padding-right: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nav-group {
  margin: 0 0 24px;
}

.nav-group p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-nav a {
  position: relative;
  display: block;
  margin: 1px 0;
  padding: 5px 10px 5px 14px;
  border-radius: 7px;
  color: var(--copy);
  text-decoration: none;
}

.docs-nav a:hover,
.docs-nav a:focus-visible {
  color: var(--ink);
  background: var(--hover);
  outline: none;
}

.docs-nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--hover);
  font-weight: 700;
}

.docs-nav a[aria-current="page"]::before,
.docs-toc a[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 99px;
  background: var(--vermilion);
}

/* ---------- Content ---------- */

.docs-main {
  width: 100%;
  padding: 52px 0 72px;
}

.docs-content::before {
  content: attr(data-section);
  display: block;
  margin: 0 0 12px;
  color: var(--vermilion);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-family: var(--display);
  line-height: 1.12;
  letter-spacing: -0.01em;
}

h1 {
  margin: 0 0 16px;
  font-size: clamp(2.4rem, 4.4vw, 3.6rem);
  font-weight: 800;
}

h2 {
  margin: 44px 0 10px;
  font-size: 1.5rem;
  font-weight: 700;
}

h3 {
  margin: 30px 0 8px;
  font-size: 1.14rem;
  font-weight: 700;
}

h4 {
  margin: 24px 0 6px;
  font-size: 1rem;
  font-weight: 700;
}

h1[id],
h2[id],
h3[id],
h4[id] {
  scroll-margin-top: 92px;
}

p,
li {
  color: var(--copy);
}

p {
  margin: 0 0 16px;
}

ul,
ol {
  padding-left: 1.2rem;
}

.docs-content a,
.made-by a,
.not-found a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--vermilion);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.docs-content a:hover,
.made-by a:hover,
.not-found a:hover {
  color: var(--vermilion);
}

code {
  font: 0.92em var(--mono);
}

:not(pre) > code {
  padding: 0.1em 0.34em;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: var(--card);
}

.docs-content img {
  max-width: 100%;
  height: auto;
  margin: 30px 0;
}

blockquote {
  margin: 25px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--line);
  color: var(--copy);
}

/* ---------- Code blocks ---------- */

.code-block,
pre {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

pre {
  overflow-x: auto;
  margin: 0;
  padding: 16px 17px;
}

.code-block {
  margin: 24px 0;
}

.code-block figcaption {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font: 0.74rem var(--mono);
}

.code-block pre {
  border: 0;
  border-radius: 0;
}

.code-block code {
  color: var(--ink);
}

/* The terminal's window dots are the icon's three bands: two inks and the vermilion stroke. */
.window-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.window-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.window-dots span:nth-child(1) { background: var(--stripe-light); }
.window-dots span:nth-child(2) { background: var(--stripe-dark); }
.window-dots span:nth-child(3) { background: var(--vermilion); }

.terminal-block figcaption > span:last-child {
  margin-left: auto;
}

.terminal-line {
  display: grid;
  grid-template-columns: 1.4em minmax(0, 1fr);
  gap: 0.6em;
  min-width: max-content;
}

.terminal-prompt {
  color: var(--vermilion);
  user-select: none;
}

.syntax-comment { color: var(--syntax-comment); }
.syntax-keyword { color: var(--syntax-keyword); }
.syntax-string { color: var(--syntax-string); }
.syntax-number { color: var(--syntax-number); }
.syntax-property { color: var(--syntax-property); }
.syntax-tag { color: var(--syntax-tag); }
.syntax-template { color: var(--syntax-template); }

/* ---------- Callouts and tables ---------- */

.callout {
  margin: 24px 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--note);
}

.callout p {
  margin: 0;
}

.callout p > strong:first-child {
  color: var(--ink);
}

.callout-tip {
  border-color: var(--tip-line);
  background: var(--tip);
}

.callout-warning {
  border-color: var(--warning-line);
  background: var(--warning);
}

.table-wrap {
  overflow-x: auto;
  margin: 18px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 9px 14px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--hover);
  font-weight: 650;
}

td {
  background: color-mix(in oklab, var(--card) 60%, transparent);
}

/* ---------- On this page ---------- */

.docs-toc {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 140px);
  margin-top: 52px;
  padding-left: 24px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.docs-toc p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-toc a {
  position: relative;
  display: block;
  margin: 0 0 10px;
  color: var(--copy);
  font-size: 0.88rem;
  font-weight: 550;
  text-decoration: none;
}

.docs-toc a:hover,
.docs-toc a:focus-visible,
.docs-toc a[aria-current="true"] {
  color: var(--ink);
  outline: none;
}

.docs-toc a[aria-current="true"]::before {
  left: -25px;
  top: 1px;
  bottom: 1px;
}

.docs-toc a.toc-h3 {
  padding-left: 14px;
  font-size: 0.84rem;
}

.docs-toc code {
  padding: 0;
  border: 0;
  background: transparent;
}

/* ---------- Pager and sign-off ---------- */

.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
}

.docs-pager a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in oklab, var(--card) 70%, transparent);
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.docs-pager a:hover,
.docs-pager a:focus-visible {
  border-color: var(--vermilion);
  outline: none;
}

.pager-previous {
  grid-column: 1;
}

.pager-next {
  grid-column: 2;
  align-items: flex-end;
  text-align: right;
}

.docs-pager span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-pager strong {
  color: var(--ink);
  font-weight: 700;
}

/* NekoLab signing its work, as on the studio's product pages. */
.made-by {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 48px 0 0;
  padding-top: 24px;
  border-top: 2px dashed var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.made-by img {
  width: 40px;
  height: auto;
  flex: none;
  transform: rotate(-4deg);
}

.not-found {
  width: min(680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 72px 0;
}

/* ---------- Smaller screens ---------- */

@media (max-width: 1360px) {
  .docs-shell {
    grid-template-columns: 320px minmax(0, 760px);
  }

  .docs-toc {
    display: none;
  }
}

@media (max-width: 1120px) {
  .docs-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 32px;
    padding-right: 28px;
  }
}

@media (max-width: 840px) {
  .docs-topbar {
    position: static;
    height: auto;
    padding: 16px;
    gap: 14px;
  }

  .docs-shell {
    display: block;
    padding-right: 0;
  }

  .docs-sidebar {
    position: sticky;
    z-index: 10;
    top: 0;
    height: auto;
    max-height: 100dvh;
    overflow: hidden;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: var(--card);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-nav-toggle::after {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
  }

  .mobile-nav-toggle[aria-expanded="true"]::after {
    transform: rotate(225deg) translateY(-2px);
  }

  .docs-search {
    margin: 12px 0 0;
  }

  .docs-search-results,
  .docs-nav {
    margin: 12px 0 0;
    padding-right: 0;
    padding-bottom: 16px;
    max-height: min(58dvh, calc(100dvh - 136px));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .docs-nav[hidden] {
    display: none;
  }

  .docs-main {
    width: auto;
    padding: 36px 16px 48px;
  }
}

@media (max-width: 520px) {
  .docs-top-nav {
    gap: 14px;
  }

  .docs-pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    grid-column: 1;
  }
}
