/* =========================================================
   Calm reading blog — styles
   The colour theme is chosen in the CMS (Settings → Site settings).
   ========================================================= */
:root, [data-theme="sky"] {
  --bg: #f6f9fc;
  --surface: #ffffff;
  --tint: #e8f2fb;         /* pastel sky */
  --tint-strong: #d3e7f7;
  --accent: #336fa0;       /* links & buttons (AA on white) */
  --accent-hover: #24567f;
  --ink: #1f2d3a;
  --muted: #5d6b79;
  --line: #e1e8ef;
}
[data-theme="sage"] {
  --bg: #f7faf8; --surface: #fff; --tint: #e8f2eb; --tint-strong: #d2e6d8;
  --accent: #3f7a57; --accent-hover: #2d5c40; --ink: #1f2d25; --muted: #5c6b62; --line: #e1e9e3;
}
[data-theme="lavender"] {
  --bg: #f9f8fd; --surface: #fff; --tint: #efecfa; --tint-strong: #ded8f4;
  --accent: #6750a4; --accent-hover: #4f3d82; --ink: #26223a; --muted: #625e74; --line: #e8e5f1;
}
[data-theme="sand"] {
  --bg: #fbf9f5; --surface: #fff; --tint: #f5eee2; --tint-strong: #ebdfc9;
  --accent: #86662f; --accent-hover: #6a5024; --ink: #2d271f; --muted: #6b6255; --line: #ece5d9;
}
:root {
  --sans: "Source Sans 3", -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --radius: 10px;
  --max: 1120px;
  --pad: clamp(16px, 4vw, 32px);
  --header-h: 64px;
  --shadow: 0 1px 2px rgba(31, 45, 58, .04), 0 2px 8px rgba(31, 45, 58, .04);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 20px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 17px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0; color: var(--ink); }
p, figure, dl, dd { margin: 0; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
::selection { background: var(--tint-strong); }
:focus-visible { outline: 3px solid var(--tint-strong); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 60; background: var(--surface); padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.container { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--pad); }
.narrow { max-width: 720px; }

/* ---------- small pieces ---------- */
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; transition: background .15s, color .15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--tint); color: var(--accent); border-color: var(--tint-strong); }
.btn-secondary:hover { background: var(--tint-strong); color: var(--accent-hover); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; line-height: 1.6; text-decoration: none; background: var(--tint); color: var(--accent); }
.tag:hover { background: var(--tint-strong); color: var(--accent-hover); }
.tag-sage { background: #e6f1e9; color: #3a6b4d; }
.tag-sage:hover { background: #d4e8da; color: #2d5c40; }
.tag-ink { background: #edf0f3; color: #4a5866; }
.tag-ink:hover { background: #e0e5ea; color: var(--ink); }
.tag-plain { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.draft { padding: 1px 8px; border-radius: 999px; background: #fdf1c7; color: #7a5b00; font-size: .78rem; font-weight: 600; }
.empty { padding: 32px 0; color: var(--muted); }
.crumbs { font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.section-title { font-size: 1.35rem; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--tint-strong); color: var(--accent); font-size: 1rem; }
.site-nav { display: flex; gap: 4px; margin-left: 8px; }
.site-nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; text-decoration: none; }
.site-nav a:hover { background: var(--tint); color: var(--ink); }
.site-nav a[aria-current] { background: var(--tint); color: var(--accent); }
.header-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-button { display: none; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; }
.icon-button:hover { background: var(--tint); color: var(--ink); }

/* search box (header, listing pages, 404) */
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; min-height: 42px; padding: 8px 12px 8px 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; font-size: 16px; color: var(--ink); -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: #8795a3; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint-strong); }
.header-search { width: 240px; }
.page-list .header-search { display: none; }

/* ---------- home ---------- */
.welcome { background: var(--tint); border-bottom: 1px solid var(--tint-strong); }
.welcome-inner { padding-block: clamp(28px, 5vw, 48px); }
.welcome-title { font-size: clamp(1.6rem, 3.2vw, 2.1rem); }
.welcome-text { margin-top: 10px; max-width: 62ch; color: var(--ink); font-size: 1.05rem; }
.welcome .text-link { display: inline-block; margin-top: 12px; }

.with-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(32px, 5vw, 56px); padding-top: clamp(28px, 4vw, 44px); align-items: start; }
.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.more { margin-top: 28px; }

/* post list */
.post { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.post.has-thumb { grid-template-columns: minmax(0, 1fr) 168px; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .88rem; color: var(--muted); }
.post-title { margin-top: 8px; font-size: clamp(1.2rem, 2vw, 1.35rem); line-height: 1.3; }
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.post-excerpt { margin-top: 6px; color: var(--muted); }
.post-thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }

/* sidebar widgets */
.sidebar { display: grid; gap: 20px; position: sticky; top: calc(var(--header-h) + 20px); }
.widget { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.widget-tint { background: var(--tint); border-color: var(--tint-strong); }
.widget-title { font-family: var(--sans); font-size: .95rem; font-weight: 600; margin-bottom: 10px; }
.widget p + p, .widget p + .btn, .widget p + .text-link { margin-top: 12px; }
.widget .btn { margin-top: 14px; }
.widget .text-link { display: inline-block; margin-top: 10px; }
.widget-photo { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin-bottom: 12px; }
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-list a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; margin-inline: -10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.topic-list a:hover { background: var(--tint); color: var(--ink); }
.topic-list a[aria-current] { background: var(--tint); color: var(--accent); font-weight: 600; }
.count { min-width: 26px; padding: 0 7px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: .82rem; text-align: center; line-height: 1.7; }

/* ---------- listing pages ---------- */
.page-top { padding-top: clamp(28px, 5vw, 48px); }
.page-header { max-width: 720px; }
.page-header .crumbs { margin-bottom: 8px; }
.page-title { font-size: clamp(1.8rem, 3.6vw, 2.4rem); }
.page-intro { margin-top: 10px; font-size: 1.08rem; color: var(--muted); }
.page-count { margin-top: 8px; font-size: .9rem; color: var(--muted); }
.list-tools { display: grid; gap: 14px; padding-bottom: 8px; }
.chips { display: none; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips a { flex-shrink: 0; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: .92rem; text-decoration: none; white-space: nowrap; }
.chips a:hover { border-color: var(--tint-strong); background: var(--tint); }
.chips a[aria-current] { border-color: var(--accent); background: var(--accent); color: #fff; }
.year-title { margin-top: 28px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-family: var(--sans); font-size: .95rem; font-weight: 600; color: var(--muted); }

/* ---------- article ---------- */
.progress { position: fixed; top: 0; left: 0; z-index: 50; height: 3px; width: 0; background: var(--accent); opacity: .6; }
.article-layout { display: grid; grid-template-columns: minmax(0, 720px) 220px; justify-content: center; gap: 56px; padding-top: clamp(24px, 4vw, 44px); }
.article-header .crumbs { margin-bottom: 14px; }
.article-title { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.2; }
.article-desc { margin-top: 12px; font-family: var(--serif); font-size: clamp(1.1rem, 1.8vw, 1.25rem); color: var(--muted); line-height: 1.5; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 18px; padding-bottom: 20px; border-bottom: 1px solid var(--line); font-size: .92rem; color: var(--muted); }
.article-cover { margin-top: 28px; }
.article-cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); }
.article-cover figcaption { margin-top: 8px; font-size: .88rem; color: var(--muted); }
.article-aside { padding-top: 120px; }
.toc { position: sticky; top: calc(var(--header-h) + 24px); }
.toc-title { font-size: .85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.toc ol { list-style: none; margin: 10px 0 0; padding: 0; border-left: 2px solid var(--line); }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); font-size: .92rem; line-height: 1.4; text-decoration: none; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-mobile { display: none; margin-top: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.toc-mobile summary { padding: 12px 16px; font-weight: 600; cursor: pointer; }
.toc-mobile .toc { position: static; padding: 0 16px 14px; }
.toc-mobile .toc-title { display: none; }
.toc-mobile .toc ol { margin-top: 0; }

.prose { margin-top: 28px; font-family: var(--serif); font-size: clamp(1.06rem, .3vw + 1rem, 1.15rem); line-height: 1.8; overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { margin-top: 1.9em; font-size: 1.5rem; line-height: 1.3; }
.prose h3 { margin-top: 1.6em; font-size: 1.2rem; }
.prose h2 + *, .prose h3 + * { margin-top: .6em; }
.prose a { text-decoration-color: var(--tint-strong); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--accent); }
.prose blockquote { margin: 1.6em 0; padding: 14px 20px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--tint); color: var(--ink); }
.prose blockquote p + p { margin-top: .6em; }
.prose img { margin-inline: auto; border-radius: 8px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose code { padding: 1px 5px; border-radius: 4px; background: var(--tint); font-size: .88em; }
.prose pre { overflow-x: auto; padding: 16px; border-radius: 8px; background: #1f2d3a; color: #eef3f8; font-size: .88em; }
.prose pre code { background: none; padding: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.prose table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: .95rem; }
.prose th, .prose td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--tint); font-weight: 600; }
.article-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 32px; font-size: .92rem; color: var(--muted); }
.end-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-top: 36px; padding: 20px 22px; border-radius: var(--radius); background: var(--tint); }
.end-note p { flex: 1 1 280px; }
.end-note .btn { background: var(--surface); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 32px; }
.pager-link { display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; }
.pager-link:hover { border-color: var(--tint-strong); background: var(--tint); }
.pager-next { text-align: right; grid-column: 2; }
.pager-label { font-size: .85rem; color: var(--muted); }
.pager-title { font-family: var(--serif); font-weight: 600; color: var(--ink); line-height: 1.35; }
.related { margin-top: 56px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 16px; margin-top: 16px; }
.related-item { display: grid; gap: 6px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; }
.related-item:hover { border-color: var(--tint-strong); background: var(--tint); }
.related-title { font-family: var(--serif); font-weight: 600; color: var(--ink); line-height: 1.35; }
.to-top { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--accent); text-decoration: none; opacity: 0; pointer-events: none; transition: opacity .2s; }
.to-top.show { opacity: 1; pointer-events: auto; }

/* ---------- about / contact ---------- */
.about-text { margin-top: 0; }
.about-text .lead { font-size: 1.2em; color: var(--ink); }
.topic-notes li + li { margin-top: .5em; }
.about-actions { margin-top: 1.6em; }
.about-photo { width: 100%; border-radius: var(--radius); }
.facts div { display: grid; grid-template-columns: 80px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; padding-top: 0; }
.facts dt { font-weight: 600; }
.facts dd { color: var(--muted); }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.check-list li { position: relative; padding-left: 26px; color: var(--muted); }
.check-list li::before { content: ""; position: absolute; left: 2px; top: .45em; width: 12px; height: 7px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }
.card { padding: clamp(20px, 3vw, 28px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.form { display: grid; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
.form input, .form select, .form textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font: inherit; font-weight: 400; font-size: 16px; color: var(--ink); }
.form textarea { resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--tint-strong); }
.form .btn { justify-self: start; }
.page-top.narrow .search { max-width: 420px; margin-top: 24px; }

/* ---------- footer ---------- */
.site-footer { margin-top: 72px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px 40px; padding-block: 32px 20px; }
.footer-name { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }
.footer-about p + p { margin-top: 4px; color: var(--muted); max-width: 46ch; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; }
.footer-links a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.footer-base { padding-block: 14px 26px; font-size: .85rem; color: var(--muted); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1080px) {
  .article-layout { grid-template-columns: minmax(0, 720px); }
  .article-aside { display: none; }
  .toc-mobile { display: block; }
}
@media (max-width: 920px) {
  .with-sidebar { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
  .sidebar-desktop { display: none; }
  .chips { display: flex; }
  .header-search { width: 200px; }
}
@media (max-width: 720px) {
  :root { --header-h: 58px; }
  .header-inner { gap: 8px; }
  .icon-button { display: grid; }
  .header-search { display: none; }
  .site-nav {
    position: absolute; top: 100%; left: 0; right: 0; margin: 0; flex-direction: column; gap: 2px;
    padding: 8px var(--pad) 14px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 8px 16px rgba(31, 45, 58, .06);
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; font-size: 1.05rem; }
  .post.has-thumb { grid-template-columns: minmax(0, 1fr) 96px; gap: 14px; }
  .post-thumb img { aspect-ratio: 1; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: auto; }
  .form-row { grid-template-columns: 1fr; }
  .form .btn { justify-self: stretch; }
  .footer-inner { flex-direction: column; }
}
@media (max-width: 420px) {
  .brand span:last-child { font-size: 1.05rem; }
  .post.has-thumb { grid-template-columns: minmax(0, 1fr); }
  .post-thumb { order: -1; }
  .post-thumb img { aspect-ratio: 16 / 9; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  .site-header, .site-footer, .article-aside, .toc-mobile, .end-note, .pager, .related, .to-top, .progress { display: none !important; }
  body { background: #fff; }
}
