/* きゅぶろぐ — blog.kyubuns.dev
 * Colors follow the previous Hatena Blog design (white, #333 text, black heading bars)
 * so returning readers still recognize the blog. */

:root {
  --text: #333333;
  --text-soft: #535350;
  --muted: #8a8a85;
  --line: #e6e6e3;
  --bg: #ffffff;
  --surface: #f6f6f4;
  --surface-strong: #ececea;
  --code-bg: #f7f7f5;
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Helvetica Neue", Arial, Meiryo, sans-serif;
  --mono: Monaco, ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  --radius: 12px;
  --gutter: clamp(16px, 4vw, 40px);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* long identifiers (UnityEngine.Rendering.Universal...) must wrap instead of overflowing */
.prose, .post-row-title, .article-title, .card-title, .pager-link, .category-list a { overflow-wrap: anywhere; min-width: 0; }

::selection { background: #ffe7ac; }

a { color: inherit; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------ header/footer */

.site-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px var(--gutter) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}


/* ----------------------------------------------------------------- elements */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 0.12s ease;
}

.button:hover { background: #e0e0dd; }

.button span {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
}


.cats { display: flex; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; font-size: 0.75rem; line-height: 1.8; }
.cats li + li::before { content: "/"; margin: 0 0.5em; color: #c8c8c4; }
.cats a { color: var(--muted); text-decoration: none; }
.cats a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

time { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); letter-spacing: 0.02em; }



.eyebrow {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow a { text-decoration: none; }

/* --------------------------------------------------------------------- home */

.home-layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px var(--gutter) 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 48px;
  padding-bottom: 40px;
  align-items: start;
}

.search input {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid #d5d5d0;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.search input:focus { outline: none; border-color: var(--text); }

.search-status { margin: 0 0 12px; font-size: 0.875rem; color: var(--text-soft); }

.home-main .post-list > .post-row:first-child { padding-top: 0; }

.list-pager { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; font-size: 0.875rem; font-weight: 700; }
.list-pager a { padding: 8px 4px; text-decoration: none; }
.list-pager a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ------------------------------------------------------------------ sidebar */

.sidebar { display: grid; gap: 24px; }

.profile { display: grid; gap: 4px; }
.profile img { margin-bottom: 8px; }
.profile img { display: block; }
.profile p { margin: 0; }
.profile-name { font-weight: 700; font-size: 1.05rem; line-height: 1.4; }
.profile-name span { display: block; font-size: 0.8125rem; font-weight: 400; color: var(--muted); }

.profile-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px !important; }

.profile-links { gap: 16px; }
.profile-links a { font-size: 0.8125rem; color: var(--text-soft); text-underline-offset: 3px; }
.profile-links a:hover { color: var(--text); }
.profile-email { grid-column: 1 / -1; margin-top: 0 !important; font-size: 0.8125rem; }
.profile-email a { color: var(--text-soft); text-underline-offset: 3px; }
.profile-email a:hover { color: var(--text); }

.side-title { margin: 0 0 8px; font-size: 0.9375rem; font-weight: 700; }

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

.category-list a {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 0.875rem;
  text-decoration: none;
}

.category-list a:hover { background: var(--surface); color: var(--text); }
.category-list span { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }

.more-categories summary { margin-top: 6px; font-size: 0.8125rem; font-weight: 700; color: var(--text-soft); cursor: pointer; }
.more-categories summary:hover { color: var(--text); }
.more-categories[open] summary { margin-bottom: 4px; }

/* ----------------------------------------------------------- archive lists */


.list-header { margin-bottom: 20px; }

.list-header h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 1.75rem); font-weight: 700; line-height: 1.3; }
.list-header h1 small { font-family: var(--mono); font-size: 0.9rem; font-weight: 400; color: var(--muted); vertical-align: middle; }

.year { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 20px; padding: 16px 0; border-top: 1px solid var(--line); }

.year-label { margin: 0; align-self: start; position: sticky; top: 20px; font-family: var(--mono); font-size: 1.3rem; font-weight: 700; line-height: 1; }
.year-label small { display: block; margin-top: 8px; font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.year-label small::after { content: " posts"; }

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

.post-row { padding: 12px 0; }
/* a list row looks exactly like the header of the article it opens (.article-meta / .article-title) */
.post-row time { display: block; margin: 0 0 1px; }
.post-row-title { display: block; text-decoration: none; }
.post-row-title:hover { text-decoration: underline; text-underline-offset: 4px; }
[data-search-results] mark { padding: 0 1px; border-radius: 2px; background: #ffe7ac; color: inherit; }
.post-row-snippet { margin: 4px 0 0; font-size: 0.8125rem; color: var(--text-soft); line-height: 1.7; }

/* ------------------------------------------------------------------ article */


.article-header { margin-bottom: 24px; }

.article-meta { margin: 0 0 1px; display: flex; gap: 10px; align-items: center; }
.article-meta time, .post-row time { line-height: 20px; }

.draft-badge { padding: 1px 10px; border-radius: 999px; background: #c72260; color: #fff; font-size: 0.75rem; font-weight: 700; }

.article-title, .post-row-title { margin: 0 0 2px; color: var(--text); font-size: clamp(1.2rem, 2.2vw, 1.375rem); font-weight: 500; line-height: 1.45; }

/* --- prose --- */

.prose { font-size: 0.9375rem; line-height: 1.65; }
.prose > :first-child { margin-top: 0; }

.prose p, .prose ul, .prose ol, .prose blockquote, .prose .table, .prose .code, .prose .card, .prose .embed-video { margin: 0 0 1em; }

/* Headings get weaker step by step so sections read as nested, not as separate dividers:
 * h1 = filled block, h2 = tinted band + 8px bar, h3 = 4px bar, h4 = small marker. */
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--text); font-weight: 700; line-height: 1.45; scroll-margin-top: 24px; }

.prose h1 {
  margin: 2em 0 0.9em;
  padding: 0.4em 0.75em;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: 1.25rem;
}

.prose h2 {
  margin: 1.8em 0 0.8em;
  padding: 0.3em 0.65em;
  border-left: 8px solid var(--text);
  border-radius: 0 6px 6px 0;
  background: var(--surface);
  font-size: 1.125rem;
}

.prose h3 { margin: 1.5em 0 0.6em; padding-left: 0.6em; border-left: 4px solid var(--text); font-size: 1.0625rem; }

.prose h4 { display: flex; align-items: baseline; gap: 0.5em; margin: 1.3em 0 0.5em; font-size: 1rem; }
.prose h4::before { content: ""; flex: none; width: 0.45em; height: 0.45em; background: var(--text); transform: translateY(-0.15em); }

.prose h1 + h2, .prose h2 + h3, .prose h3 + h4 { margin-top: 0.8em; }

.prose a { color: var(--text); text-decoration: underline; text-decoration-color: #b5b5b0; text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--text); }

.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: 0.2em 0; }
.prose li > ul, .prose li > ol { margin: 0.2em 0 0; }

.prose blockquote { padding: 14px 20px; border-left: 4px solid #d5d5d0; border-radius: 0 8px 8px 0; background: var(--surface); color: var(--text-soft); }
.prose blockquote > :last-child { margin-bottom: 0; }

.prose hr { height: 1px; margin: 2em 0; border: 0; background: var(--line); }

.prose img { border-radius: 6px; vertical-align: middle; }

.prose :not(pre) > code { padding: 0.12em 0.4em; border-radius: 4px; background: #f0f0ee; font-family: var(--mono); font-size: 0.86em; letter-spacing: 0; }

.prose .table { overflow-x: auto; }
.prose table { border-collapse: collapse; font-size: 0.9375rem; line-height: 1.7; min-width: 60%; }
.prose th, .prose td { padding: 8px 14px; border: 1px solid #dcdcd8; text-align: left; }
.prose th { background: var(--surface); }

/* --- code: GitHub's look (light theme). ```lang:file adds a gist-like file header and line numbers --- */

.code pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: #f6f8fa;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  letter-spacing: 0;
  tab-size: 4;
  color: #1f2328;
}

.code code { font-family: inherit; white-space: pre; }

.code-file { border: 1px solid #d1d9e0; border-radius: 6px; overflow: hidden; }
.code-filename { padding: 8px 16px; border-bottom: 1px solid #d1d9e0; background: #f6f8fa; font-family: var(--mono); font-size: 0.75rem; font-weight: 600; color: #1f2328; }
.code-file pre { display: flex; padding: 8px 0; background: #fff; border-radius: 0; }
.code-file code { padding: 0 16px 0 0; }
.code-lines { flex: none; padding: 0 16px; color: #59636e; text-align: right; user-select: none; -webkit-user-select: none; }

/* copy button: top right of the code, shown on hover (always shown where there is no hover) */
.code-body { position: relative; }
.code-copy {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid #d1d9e0;
  border-radius: 6px;
  background: #f6f8fa;
  color: #59636e;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background-color 0.12s ease;
}
.code-body:hover .code-copy, .code-copy:focus-visible, .code-copy.copied { opacity: 1; }
.code-copy:hover { background: #eaeef2; color: #1f2328; }
.code-copy .icon-check { display: none; }
.code-copy.copied { color: #1a7f37; border-color: #1a7f37; }
.code-copy.copied .icon-copy { display: none; }
.code-copy.copied .icon-check { display: block; }
.code-copy.copied::after {
  content: attr(data-copied);
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 8px;
  border-radius: 6px;
  background: #1f2328;
  color: #fff;
  font-family: var(--font);
  font-size: 0.75rem;
  white-space: nowrap;
}
@media (hover: none) { .code-copy { opacity: 1; } }

.token.comment, .token.prolog, .token.doctype, .token.cdata, .token.shebang { color: #59636e; }
.token.keyword, .token.important, .token.atrule { color: #cf222e; }
.token.string, .token.char, .token.regex, .token.attr-value, .token.template-string { color: #0a3069; }
.token.number, .token.boolean, .token.constant, .token.property, .token.tag, .token.attr-name, .token.selector { color: #0550ae; }
.token.function, .token.class-name, .token.namespace { color: #6639ba; }
.token.variable, .token.parameter { color: #953800; }
.token.punctuation, .token.operator { color: #1f2328; }

/* --- embeds --- */

.card { display: grid; gap: 2px; padding: 14px 18px; border: 1px solid #dcdcd8; border-radius: 10px; text-decoration: none !important; transition: border-color 0.12s ease; }
.card:hover { border-color: var(--text); }
.card-label { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.card-title { font-size: 0.9375rem; font-weight: 700; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.embed-video { aspect-ratio: 16 / 9; }
.embed-video iframe, .prose iframe { display: block; max-width: 100%; border: 0; border-radius: 8px; }
.embed-video iframe { width: 100%; height: 100%; }

.prose blockquote.twitter-tweet { max-width: 550px; border-left: 0; border-radius: 10px; font-size: 0.9375rem; }
.prose .twitter-tweet-rendered { margin: 0 0 1em !important; }

.prose .gist { font-size: 13px; line-height: 1.6; letter-spacing: 0; margin-bottom: 1em; }
.prose .gist .blob-code-inner, .prose .gist .blob-num { font-family: var(--mono) !important; }

/* --- article footer --- */

.article-footer { margin-top: 32px; }

.reactions { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 0 0 24px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }

.share {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text);
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.share:hover { background: var(--text); color: #fff; }
.share-hatena span { font-family: Verdana, Arial, sans-serif; font-size: 0.875rem; font-weight: 700; letter-spacing: -0.02em; }

.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.pager-link {
  display: grid;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid #dcdcd8;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.55;
  text-decoration: none;
  transition: border-color 0.12s ease;
}

.pager-link:hover { border-color: var(--text); }
.pager-link span { font-family: var(--mono); font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.pager-newer span::before { content: "← "; }
.pager-older { grid-column: 2; text-align: right; }
.pager-older span::after { content: " →"; }


/* ------------------------------------------------------------------ 404 */

.notfound { max-width: 640px; margin: 0 auto; padding: 96px var(--gutter) 0; text-align: center; }
.notfound-code { margin: 0; font-family: var(--mono); font-size: 5rem; font-weight: 700; line-height: 1; color: #d5d5d0; }
.notfound h1 { margin: 16px 0 8px; font-size: 1.5rem; }
.notfound p { color: var(--text-soft); }
.notfound .button { margin-top: 8px; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 960px) {
  .home-layout { grid-template-columns: minmax(0, 1fr); }
  /* the sidebar drops below the list; keep its search box above the list, where results appear */
  /* list pages: the search box goes above the list, where its results appear; elsewhere the whole sidebar follows the content */
  .is-list .sidebar { display: contents; }
  .is-list { row-gap: 32px; }
  .is-list .search { order: -1; margin-bottom: -20px; }
  .sidebar { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; margin-top: 24px; }
}

@media (max-width: 640px) {
  .site-header-inner { padding-top: 20px; }
  .brand { font-size: 1.4rem; }
  .home-layout { padding-top: 16px; }
  .year { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .year-label { position: static; display: flex; align-items: baseline; gap: 10px; }
  .year-label small { margin: 0; }
  .post-row { padding: 9px 0; }
  .prose h1 { font-size: 1.125rem; }
  .prose h2 { font-size: 1.0625rem; }
  .prose h3 { font-size: 1rem; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager-older { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
