/* Purupuru Systems site stylesheet. System fonts only; light and dark follow the reader's system setting. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1d2127;
  --muted: #5a6370;
  --line: #d8dde4;
  --link: #0b57d0;
  --surface: #f4f6f8;
  --banner-bg: #fff3c4;
  --banner-fg: #4d3b00;
  --hl-comment: #5f6b7a;
  --hl-keyword: #8a1fa8;
  --hl-string: #17703a;
  --hl-number: #a04a12;
  --hl-type: #0b5cad;
  --hl-function: #5b33b0;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --sans-ja: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --text-font: var(--sans);
  --text-leading: 1.7;
}

/* The text font follows the language. Only variables are set here, so that code keeps its own font. */
:lang(en) {
  --text-font: var(--sans);
  --text-leading: 1.7;
}

:lang(ja) {
  --text-font: var(--sans-ja);
  --text-leading: 1.9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --fg: #e4e6ea;
    --muted: #a0a8b3;
    --line: #2e333c;
    --link: #8ab4f8;
    --surface: #1d2026;
    --banner-bg: #4d3b00;
    --banner-fg: #fff3c4;
    --hl-comment: #8d97a5;
    --hl-keyword: #d7a3f5;
    --hl-string: #8fd4a1;
    --hl-number: #f2ab7c;
    --hl-type: #82b9f7;
    --hl-function: #c5aaff;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 46rem;
  padding: 0 1.25rem 3rem;
  background: var(--bg);
  color: var(--fg);
  font-size: 1.0625rem;
  overflow-wrap: break-word;
}

body,
[lang] {
  font-family: var(--text-font);
  line-height: var(--text-leading);
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:focus-visible,
pre:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -100rem;
}

.skip:focus {
  position: static;
}

.preview-banner {
  margin: 0 -1.25rem;
  padding: 0.4rem 1.25rem;
  background: var(--banner-bg);
  color: var(--banner-fg);
  font-size: 0.875rem;
  font-weight: 600;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--line);
}

.site-name {
  color: var(--fg);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.9375rem;
}

.site-header nav a {
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  text-decoration: underline;
}

main {
  padding-top: 2rem;
}

h1,
h2,
h3 {
  line-height: 1.3;
  text-wrap: balance;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.875rem;
}

h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.375rem;
}

h3 {
  margin: 2rem 0 0.5rem;
  font-size: 1.125rem;
}

p,
ul,
ol,
pre,
.table-wrap {
  margin: 0 0 1.25rem;
}

li + li {
  margin-top: 0.35rem;
}

.meta,
.tags,
.site-footer {
  color: var(--muted);
  font-size: 0.875rem;
}

.tagline {
  color: var(--muted);
  font-size: 1.125rem;
}

.post-list {
  padding: 0;
  list-style: none;
}

.post-list li {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.post-list h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1875rem;
}

.post-list p {
  margin: 0 0 0.35rem;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface);
}

pre {
  overflow-x: auto;
  padding: 1rem 1.125rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  line-height: 1.5;
  tab-size: 4;
}

pre code {
  font-size: 0.875rem;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  background: var(--surface);
}

.notes {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
}

.notes p {
  margin-bottom: 0.6rem;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* Code colours. The class names come from highlight.js; the colours are this site's own. */
.hljs-comment,
.hljs-quote,
.hljs-meta,
.hljs-doctag {
  color: var(--hl-comment);
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-name,
.hljs-tag {
  color: var(--hl-keyword);
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attr,
.hljs-attribute {
  color: var(--hl-string);
}

.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet,
.hljs-deletion,
.hljs-variable,
.hljs-template-variable {
  color: var(--hl-number);
}

.hljs-type,
.hljs-built_in,
.hljs-title.class_,
.hljs-title.class_.inherited__ {
  color: var(--hl-type);
}

.hljs-title,
.hljs-title.function_ {
  color: var(--hl-function);
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 700;
}

@media (max-width: 30rem) {
  body {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  pre {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
}

@media print {
  .site-header nav,
  .skip,
  .preview-banner {
    display: none;
  }

  pre {
    white-space: pre-wrap;
  }
}
