@charset "UTF-8";

:root {
  color-scheme: light;
  --page: #fcfbf8;
  --surface: #f1efe9;
  --surface-raised: #fff;
  --text: #292824;
  --muted: #77746c;
  --border: #d9d5ca;
  --link: #145f91;
  --link-visited: #684c83;
  --code: #eeece6;
  --accent: #a44f32;
  --shadow: 0 12px 32px rgb(40 35 25 / 6%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #171918;
  --surface: #222624;
  --surface-raised: #1d211f;
  --text: #e5e4dd;
  --muted: #aaa99f;
  --border: #3b413d;
  --link: #8bc9ee;
  --link-visited: #c0a3df;
  --code: #242a27;
  --accent: #e69c7c;
  --shadow: 0 12px 32px rgb(0 0 0 / 18%);
}

html {
  background: var(--page);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.65;
  scroll-behavior: smooth;
}

body {
  margin: 0 auto 5rem;
  padding: 0 1.25rem;
  max-width: 1100px;
  background: var(--page);
  color: var(--text);
  line-height: inherit;
  transition: background-color 180ms ease, color 180ms ease;
}

nav:not(#TableOfContents) {
  max-width: 980px;
  margin: 1.5rem auto 3rem;
  display: grid;
  grid-template-rows: auto auto;
  grid-template-columns: 96px 1fr;
  grid-template-areas: "logo header" "logo nav";
  gap: 0 1.5rem;
  align-items: center;
}

nav:not(#TableOfContents) img {
  grid-area: logo;
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 50%;
}

nav:not(#TableOfContents) h1,
nav:not(#TableOfContents) h3 {
  grid-area: header;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 400;
  font-style: italic;
}

nav:not(#TableOfContents) ul {
  grid-area: nav;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.1rem;
  margin: 0.65rem 0 0;
  padding: 0;
  list-style: none;
}

nav:not(#TableOfContents) ul li { padding: 0; }

#theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

#theme-toggle:hover { border-color: var(--accent); }
#theme-toggle:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

main {
  max-width: 720px;
  margin: 0 auto;
  min-height: 55vh;
}

main > header { margin-bottom: 2rem; }
h1, h2, h3, h4 { line-height: 1.25; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }
h1.title { font-size: clamp(2rem, 5vw, 2.8rem); margin-bottom: 0.4rem; }
h2 { margin-top: 2.5rem; }
h2 small, h4 small {
  display: block;
  margin-top: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
  font-weight: normal;
}

a { color: var(--link); text-underline-offset: 0.18em; }
a:visited { color: var(--link-visited); }
a:hover { text-decoration-thickness: 2px; }
.tutorial-link { text-decoration: none; border-bottom: 1px solid var(--link); }
.tutorial-link:after { content: " ▶"; border-bottom: 1px solid var(--page); }
.tutorial-link:hover { border-bottom: 0; }

code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
code {
  padding: 0.1rem 0.32rem;
  border-radius: 3px;
  background: var(--code);
  font-size: 0.9em;
}
pre {
  box-sizing: border-box;
  overflow-x: auto;
  margin: 1.4rem -1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  line-height: 1.55;
  tab-size: 2;
}
pre code { padding: 0; background: transparent; font-size: 0.86rem; }
.hljs { color: var(--text); background: transparent; }
.hljs-comment, .hljs-quote, .hljs-doctag { color: var(--muted); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: #8654a0; }
:root[data-theme="dark"] .hljs-keyword,
:root[data-theme="dark"] .hljs-selector-tag,
:root[data-theme="dark"] .hljs-literal,
:root[data-theme="dark"] .hljs-type { color: #c9a0df; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #437a43; }
:root[data-theme="dark"] .hljs-string,
:root[data-theme="dark"] .hljs-regexp,
:root[data-theme="dark"] .hljs-addition { color: #a9d18c; }
.hljs-number, .hljs-built_in, .hljs-symbol, .hljs-bullet { color: #a44f32; }
:root[data-theme="dark"] .hljs-number,
:root[data-theme="dark"] .hljs-built_in,
:root[data-theme="dark"] .hljs-symbol,
:root[data-theme="dark"] .hljs-bullet { color: #e69c7c; }
.hljs-title, .hljs-function, .hljs-attr, .hljs-attribute { color: #145f91; }
:root[data-theme="dark"] .hljs-title,
:root[data-theme="dark"] .hljs-function,
:root[data-theme="dark"] .hljs-attr,
:root[data-theme="dark"] .hljs-attribute { color: #8bc9ee; }

main img { display: block; max-width: min(80%, 100%); height: auto; margin: 1rem auto; }
figure { margin: 1.5rem 0; }
figcaption { color: var(--muted); text-align: center; font-size: 0.9rem; }

table { width: 100%; border-collapse: collapse; }
table th { text-align: left; }
table td, table th { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); }
table .yes, table .todo { display: inline-block; width: 1rem; text-align: center; }
table .yes { color: #32804b; }
table .todo { color: #bc3d43; }

details { margin-top: 1rem; border-radius: 5px; background: var(--surface); }
details summary { padding: 0.6rem 0.9rem; cursor: pointer; }
details[open] { padding: 0 0.75rem 0.75rem; border-left: 3px solid var(--accent); background: var(--surface-raised); }
details[open] summary { margin: 0 -0.75rem 0.5rem; background: var(--surface); }

.alert { padding: 0.6rem 0.8rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: 4px; }
.alert > p { margin: 0; }
.alert-info { background: #dceef1; color: #0c5460; border-color: #bee5eb; }
.alert-danger { color: #721c24; background: #f8d7da; border-color: #f5c6cb; }
.alert-warning { color: #856404; background: #fff3cd; border-color: #ffeeba; }
.alert-success { color: #155724; background: #d4edda; border-color: #c3e6cb; }
:root[data-theme="dark"] .alert-info { background: #20383c; color: #b6e5eb; border-color: #31575e; }
:root[data-theme="dark"] .alert-danger { color: #f2b8be; background: #40282b; border-color: #63383d; }
:root[data-theme="dark"] .alert-warning { color: #f0d995; background: #403a26; border-color: #665c37; }
:root[data-theme="dark"] .alert-success { color: #b6dfbf; background: #273b2d; border-color: #3b5a43; }

blockquote { margin-left: 0; padding-left: 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
ol li { line-height: 1.5; }
ol li:not(:last-child) { margin-bottom: 0.35rem; }
#TableOfContents { padding-left: 1rem; border-left: 2px solid var(--border); }
details #TableOfContents { border-left: 0; }
#TableOfContents ol li { margin: auto; }

.stub h2 { margin-bottom: 0; }
.code-tutorial { max-width: 1200px; }
.code-tutorial .content { max-width: 1000px; margin: 0 auto 4rem; }
.code-tutorial section { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "header header" "details sample"; gap: 0 1rem; margin-bottom: 6rem; }
.code-tutorial section > * { grid-area: details; }
.code-tutorial section > h3 { grid-area: header; }
.code-tutorial section .highlight { grid-area: sample; }
.code-tutorial section .details { grid-area: details; }
.code-tutorial section .details p:first-child { margin-top: 0; }
.code-tutorial section .details .alert { margin: 0; }
.code-tutorial section pre { overflow-x: auto; }
.code-tutorial section .highlight pre { margin: 0; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; }
dl dt { grid-column: 1; font-weight: bold; }
dl dd { grid-column: 2; margin: 0; }
.htmlsample pre { margin-bottom: 1rem !important; }
iframe, video { display: block; max-width: 100%; margin: 0 auto; }
footer { text-align: center; color: var(--muted); font-size: 0.9rem; }
.image img { display: block; width: 50%; max-width: 80%; margin: 0.5rem auto; }
.image figure { margin: 0 20px; }
.image figcaption { width: 75%; margin: auto; text-align: center; font-size: 0.8rem; }
.image-center { display: block; margin: auto; }
.image-left { float: left; width: 50%; }
.image-right { float: right; width: 50%; }

@media (max-width: 1200px) {
  pre { margin: 1rem 0; }
  .code-tutorial section { display: block; }
}
@media (max-width: 768px) {
  body { padding: 0 1rem; }
  nav:not(#TableOfContents) { grid-template-columns: 64px 1fr; gap: 0 1rem; margin: 1rem auto 2rem; }
  nav:not(#TableOfContents) img { width: 64px; height: 64px; }
  nav:not(#TableOfContents) ul { gap: 0.35rem 0.8rem; }
  pre { padding: 0.8rem; }
  .image figcaption { width: 90%; }
  .image, .image-left, .image-right { float: none; display: block; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
