/* Stack Notebook — single stylesheet, no build step, no framework. */

:root {
  color-scheme: light dark;

  --paper:        #fbfaf7;
  --paper-raised: #ffffff;
  --ink:          #1e1c19;
  --ink-soft:     #4a4640;
  --ink-muted:    #736d64;
  --rule:         #e3ded4;
  --rule-strong:  #cfc8ba;
  --link:         #1a5c86;
  --link-hover:   #0f3f5e;
  --accent:       #a2572a;
  --note-bg:      #f4efe4;
  --code-bg:      #f1ede4;

  --measure: 43rem;
  --font-prose: Georgia, "Iowan Old Style", "Source Serif Pro", "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial,
             "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #16150f;
    --paper-raised: #1d1c15;
    --ink:          #ece7dc;
    --ink-soft:     #c8c2b5;
    --ink-muted:    #948d80;
    --rule:         #2e2c23;
    --rule-strong:  #423f33;
    --link:         #86bfe4;
    --link-hover:   #a9d4f1;
    --accent:       #d8925c;
    --note-bg:      #23211a;
    --code-bg:      #232119;
  }
}

:root[data-theme="dark"] {
  --paper:        #16150f;
  --paper-raised: #1d1c15;
  --ink:          #ece7dc;
  --ink-soft:     #c8c2b5;
  --ink-muted:    #948d80;
  --rule:         #2e2c23;
  --rule-strong:  #423f33;
  --link:         #86bfe4;
  --link-hover:   #a9d4f1;
  --accent:       #d8925c;
  --note-bg:      #23211a;
  --code-bg:      #232119;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-prose);
  font-size: 19px;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
}

@media (max-width: 640px) {
  body { font-size: 17.5px; line-height: 1.62; }
}

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

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

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}

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

.site-head {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.site-head .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.4rem;
  padding-bottom: 1.4rem;
}
.brand {
  font-family: var(--font-prose);
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand .dot { color: var(--accent); }

.site-nav {
  font-family: var(--font-ui);
  font-size: 0.87rem;
  display: flex;
  gap: 1.15rem;
}
.site-nav a { color: var(--ink-muted); text-decoration: none; }
.site-nav a:hover { color: var(--link); text-decoration: underline; }

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

.lede {
  font-size: 1.12rem;
  color: var(--ink-soft);
  margin: 2.6rem 0 0;
  max-width: 34rem;
}

.post-list { list-style: none; padding: 0; margin: 2.4rem 0 0; }
.post-list li { border-top: 1px solid var(--rule); }
.post-list li:last-child { border-bottom: 1px solid var(--rule); }
.post-list a.post-link {
  display: block;
  padding: 1.5rem 0;
  text-decoration: none;
  color: inherit;
}
.post-list a.post-link:hover .post-title { color: var(--link); text-decoration: underline; }
.post-title {
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
}
.post-dek { margin: 0; color: var(--ink-soft); font-size: 0.98rem; }
.post-meta {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0.55rem 0 0;
}

.empty-state {
  margin: 2.4rem 0 0;
  border: 1px dashed var(--rule-strong);
  border-radius: 10px;
  padding: 1.6rem 1.4rem;
  background: var(--note-bg);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.empty-state p { margin: 0; }

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

.article { margin-top: 2.6rem; }

.article-head { margin-bottom: 2rem; }
.article h1 {
  font-size: 2.15rem;
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin: 0 0 0.7rem;
}
@media (max-width: 640px) { .article h1 { font-size: 1.75rem; } }

.article-meta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0;
}

.disclosure {
  font-family: var(--font-ui);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink-soft);
  background: var(--note-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 0.85rem 1rem;
  margin: 1.6rem 0 0;
}
.disclosure p { margin: 0; }

.toc {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin: 2rem 0;
  background: var(--paper-raised);
}
.toc h2 {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 0.7rem;
  border: 0;
  padding: 0;
}
.toc ol { margin: 0; padding-left: 1.15rem; }
.toc li { margin: 0.32rem 0; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }

.prose h2 {
  font-size: 1.5rem;
  line-height: 1.26;
  letter-spacing: -0.015em;
  margin: 2.9rem 0 0.85rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}
.prose h3 {
  font-size: 1.16rem;
  line-height: 1.35;
  margin: 2rem 0 0.6rem;
}
.prose p { margin: 0 0 1.25rem; }
.prose ul, .prose ol { margin: 0 0 1.35rem; padding-left: 1.4rem; }
.prose li { margin: 0.4rem 0; }
.prose li > ul, .prose li > ol { margin-top: 0.4rem; margin-bottom: 0.4rem; }

.prose blockquote {
  margin: 1.6rem 0;
  padding: 0.2rem 0 0.2rem 1.15rem;
  border-left: 3px solid var(--rule-strong);
  color: var(--ink-soft);
  font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.6rem 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 4px;
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }

/* tables — the comparison table is the centrepiece, and it must not break mobile */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.8rem 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  min-width: 34rem;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0;
}
.table-scroll th, .table-scroll td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.table-scroll thead th {
  background: var(--note-bg);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--rule-strong);
}
.table-scroll tbody tr:last-child td { border-bottom: 0; }
.table-scroll tbody th { font-weight: 700; white-space: nowrap; }

/* ---------- static pages ---------- */

.page { margin-top: 2.6rem; }
.page h1 {
  font-size: 1.85rem;
  line-height: 1.22;
  letter-spacing: -0.02em;
  margin: 0 0 1.4rem;
}

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

.site-foot {
  margin-top: 4.5rem;
  border-top: 1px solid var(--rule);
  padding: 1.8rem 0 3rem;
  font-family: var(--font-ui);
  font-size: 0.84rem;
  color: var(--ink-muted);
}
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; justify-content: space-between; }
.foot-links { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; }
.site-foot a { color: var(--ink-muted); text-decoration: none; }
.site-foot a:hover { color: var(--link); text-decoration: underline; }

/* ---------- utility ---------- */

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 1rem; top: 1rem;
  position: fixed;
  z-index: 10;
  background: var(--paper-raised);
  color: var(--ink);
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

:target { scroll-margin-top: 1.5rem; }

@media print {
  .site-nav, .site-foot, .toc { display: none; }
  body { font-size: 12pt; background: #fff; color: #000; }
}
