/*
 * plain — 日本語の長文を読みやすくするためのシンプルなスタイル
 *
 * 和文向けの主な調整:
 * - 和文フォントを優先したフォントスタック（欧文フォントを先頭に置くと
 *   約物や記号が欧文グリフで描画され、字面が不揃いになるため和文を優先）
 * - 欧文より広い行間（1.85）と、1 行 35〜40 字程度に収まる本文幅
 * - 和文にイタリックは存在しないため、em は太字で強調
 * - 禁則処理は strict、長い URL などは折り返し可能に
 * - 和欧間の自動スペース（text-autospace）と行頭約物の詰め（text-spacing-trim）
 * - 見出しは文節単位で改行（word-break: auto-phrase）し、プロポーショナル詰め（palt）
 */

:root {
  --fg: #24292f;
  --fg-muted: #636c76;
  --border: #d8dee4;
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --link: #0a58ca;
  --link-visited: #6f42c1;

  --font-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", YuGothic, Meiryo, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "BIZ UDGothic", "Noto Sans Mono CJK JP", monospace;

  --measure: 42rem;
}

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

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

body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.85;
  letter-spacing: 0.02em;
  font-kerning: normal;
  line-break: strict;
  overflow-wrap: anywhere;
  text-autospace: normal;
  text-spacing-trim: normal;
  -webkit-font-smoothing: antialiased;
}

/* ---------- レイアウト ---------- */

.site-header,
.site-main,
.site-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  padding-top: 2rem;
  padding-bottom: 1.5rem;
}

.site-title {
  color: var(--fg);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.site-main {
  min-height: 60vh;
}

.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
}

/* ---------- リンク ---------- */

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:visited {
  color: var(--link-visited);
}

a:hover {
  text-decoration-thickness: 2px;
}

/* ---------- 記事一覧 ---------- */

.list-title {
  font-size: 1.375rem;
  margin: 0 0 1.5rem;
}

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

.post-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}

.post-list a {
  flex: 1 1 20rem;
  font-weight: 600;
  text-decoration: none;
  word-break: auto-phrase;
}

.post-list a:hover {
  text-decoration: underline;
}

.post-list time,
.post-list .count {
  flex: none;
  color: var(--fg-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* ---------- 記事 ---------- */

.post-header {
  margin-bottom: 2.5rem;
}

.post-header h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  line-height: 1.45;
  letter-spacing: 0.03em;
}

.post-meta {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.post-meta time + time {
  margin-left: 1em;
}

.terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.terms a {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
  text-decoration: none;
}

.terms a:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
}

.back {
  margin-top: 3rem;
  font-size: 0.875rem;
}

/* ---------- 本文 ---------- */

.post-body > :first-child {
  margin-top: 0;
}

.post-body p,
.post-body ul,
.post-body ol,
.post-body dl,
.post-body blockquote,
.post-body table,
.post-body pre,
.post-body figure,
.post-body .highlight {
  margin: 0 0 1.5em;
}

.post-body p {
  text-wrap: pretty;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-feature-settings: "palt";
  font-weight: 700;
  word-break: auto-phrase;
  text-wrap: pretty;
}

.post-body h2,
.post-body h3,
.post-body h4,
.post-body h5,
.post-body h6 {
  line-height: 1.5;
  margin: 2.5em 0 0.8em;
}

/* 和文の見出しはサイズ差より余白と罫線で階層を示す */
.post-body h2 {
  font-size: 1.375rem;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.post-body h3 {
  font-size: 1.1875rem;
}

.post-body h4 {
  font-size: 1.0625rem;
}

.post-body h5,
.post-body h6 {
  font-size: 1rem;
}

.post-body ul,
.post-body ol {
  padding-left: 1.5em;
}

.post-body li + li,
.post-body li > ul,
.post-body li > ol {
  margin-top: 0.25em;
}

.post-body li > ul,
.post-body li > ol {
  margin-bottom: 0;
}

.post-body dt {
  font-weight: 700;
}

.post-body dd {
  margin-left: 1.5em;
}

/* 和文にはイタリック体がないため、斜体ではなく太字で強調する */
em {
  font-style: normal;
  font-weight: 700;
}

strong {
  font-weight: 700;
}

/* 欧文のみの箇所は斜体を許可する */
:lang(en) em,
em:lang(en) {
  font-style: italic;
  font-weight: inherit;
}

blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 0.25em 1em;
  border-left: 4px solid var(--border);
  color: var(--fg-muted);
}

blockquote > :last-child {
  margin-bottom: 0;
}

hr {
  height: 0;
  margin: 3em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

.post-body img {
  display: block;
  margin: 0 auto;
}

figure {
  margin-left: 0;
  margin-right: 0;
}

figcaption {
  margin-top: 0.5em;
  color: var(--fg-muted);
  font-size: 0.875rem;
  text-align: center;
}

ruby rt {
  font-size: 0.5em;
  letter-spacing: 0;
}

/* ---------- 表 ---------- */

table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.6;
}

th,
td {
  padding: 0.4em 0.8em;
  border: 1px solid var(--border);
}

th {
  background: var(--bg-subtle);
  font-weight: 700;
}

/* ---------- コード ---------- */

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
  letter-spacing: 0;
  /* 等幅部分では和欧間スペースや約物詰めを無効にする */
  text-autospace: no-autospace;
  text-spacing-trim: space-all;
}

:not(pre) > code {
  padding: 0.15em 0.35em;
  margin: 0 0.1em;
  border-radius: 4px;
  background: var(--bg-subtle);
  overflow-wrap: anywhere;
}

pre {
  padding: 1em 1.1em;
  overflow-x: auto;
  border-radius: 6px;
  background: var(--bg-subtle);
  line-height: 1.6;
  overflow-wrap: normal;
  word-break: normal;
  tab-size: 4;
}

pre code {
  font-size: inherit;
  white-space: pre;
}

.highlight pre {
  margin: 0;
}

kbd {
  padding: 0.1em 0.4em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-subtle);
}

/* ---------- 数式 ---------- */

.MathJax_Display {
  overflow-x: auto;
  overflow-y: hidden;
}

/* ---------- 小さい画面 ---------- */

@media (max-width: 600px) {
  body {
    font-size: 0.9375rem;
    line-height: 1.8;
  }

  .site-header {
    padding-top: 1.25rem;
    padding-bottom: 1rem;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }

  .post-body h2 {
    font-size: 1.25rem;
  }

  .post-body h3 {
    font-size: 1.125rem;
  }
}
