/*
 * Blog pages (/blog/): static HTML built from blog/posts/*.md, no JS. The shell copies the SPA's geometry —
 * the rail outside a 28 px-rounded mountain scene («昼夜» design spec) — and the content is variant C of the
 * reviewed prototype (apps/site/blog/prototype.html): a card stream for the index, a sticky side rail with the
 * table of contents beside the prose card for a post. Colours are tokens; day unless /blog-theme.js says night (the
 * account's theme, mirrored by the site).
 */
:root {
  --gutter: 18px;
  --ground: #eaf0f4;
  --card: #f7fafb;
  --raise: #ffffff;
  --ink: #162a44;
  --stone: #5c6b80;
  --hair: #d3dde5;
  --accent: #1f6782;
  --on-accent: #ffffff;
  --link: #1a5a73;
  --glass: rgba(247, 250, 251, 0.74);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --shadow: 0 18px 44px rgba(22, 42, 68, 0.12);
  --rail-shadow: 0 10px 30px -12px rgba(22, 42, 68, 0.25);
  --halo: 0 0 6px var(--ground), 0 0 2px var(--ground);
  --art: url("/assets/mountains-day.webp");
  --shade: linear-gradient(90deg, rgba(234, 240, 244, 0.62), rgba(234, 240, 244, 0.28) 50%, rgba(234, 240, 244, 0.16));
  --serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: "Noto Sans SC", "PingFang SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="night"] {
  --ground: #0f1d1f;
  --card: #172a2b;
  --raise: #1f3637;
  --ink: #eceee3;
  --stone: #97a79f;
  --hair: #2d4442;
  --accent: #e3b45f;
  --on-accent: #2b2210;
  --link: #e3b45f;
  --glass: rgba(15, 29, 31, 0.76);
  --glass-edge: rgba(227, 180, 95, 0.22);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
  --rail-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.5);
  --halo: 0 1px 2px rgba(0, 0, 0, 0.55);
  --art: url("/assets/mountains-night.webp");
  --shade: linear-gradient(90deg, rgba(15, 29, 31, 0.84), rgba(15, 29, 31, 0.56) 50%, rgba(15, 29, 31, 0.26));
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--ground); color: var(--ink); min-height: 100vh; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2 { font-family: var(--serif); font-weight: 600; text-wrap: balance; }
time { color: var(--stone); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 1px 8px; border: 1px solid var(--hair); border-radius: 999px; font-size: 12px; color: var(--stone); }

/* --- rail (same geometry as the SPA) ----------------------------------------------------------- */
.rail {
  position: fixed; z-index: 10; top: 50%; transform: translateY(-50%);
  inset-inline-start: calc(var(--gutter) + max(0px, (100% - 2 * var(--gutter) - 1530px) / 2));
  width: 72px; padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  border: 1px solid var(--glass-edge); border-radius: 36px; background: var(--glass);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); box-shadow: var(--rail-shadow);
}
.rail-mark { display: block; width: 44px; height: 44px; }
.rail-mark img { display: block; width: 44px; height: 44px; }
.rail nav { display: grid; gap: 4px; width: 100%; padding-top: 10px; border-top: 1px solid var(--hair); }
.rail nav a {
  display: grid; justify-items: center; gap: 2px; width: 58px; min-height: 52px; margin: 0 auto; padding: 6px 0;
  border-radius: 14px; color: var(--ink); font-size: 11px; line-height: 1.2;
}
.rail nav a:hover, .rail nav a[aria-current="page"] {
  color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); text-decoration: none;
}
.rail svg { width: 20px; height: 20px; }

/* --- the rounded mountain scene --------------------------------------------------------------- */
.scene {
  position: relative; min-height: calc(100vh - 48px); max-width: 1440px; margin-block: 24px;
  margin-inline-start: calc(var(--gutter) + max(0px, (100% - 2 * var(--gutter) - 1530px) / 2) + 90px);
  margin-inline-end: var(--gutter);
  background: var(--art) center / cover no-repeat;
  border-radius: 28px; overflow: clip; box-shadow: var(--shadow);
}
.scene::before { content: ""; position: absolute; inset: 0; background: var(--shade); pointer-events: none; }
.content { position: relative; z-index: 1; margin-inline-start: clamp(28px, 3.4vw, 52px); padding-block: 24px 32px; padding-inline-end: clamp(20px, 4vw, 56px); }
.brand-row { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.brand { display: grid; gap: 2px; text-shadow: var(--halo); color: var(--ink); }
.brand strong { font: 600 21px var(--serif); }
.brand small { font: 500 12px var(--serif); letter-spacing: 0.06em; }
.blog-crumb { margin-inline-start: auto; font-size: 13px; color: var(--ink); text-shadow: var(--halo); }

/* --- index: the card stream -------------------------------------------------------------------- */
.cards { margin-block: 24px 64px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; max-width: 980px; }
.card {
  display: block; overflow: hidden; border: 1px solid var(--glass-edge); border-radius: 18px;
  background: var(--glass); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: var(--shadow); color: var(--ink);
}
.card:hover { text-decoration: none; transform: translateY(-2px); transition: transform 0.18s; }
.card .thumb { height: 100px; background: var(--art) 14% 58% / 210% auto; border-bottom: 1px solid var(--glass-edge); }
.card:nth-child(3n + 2) .thumb { background-position: 60% 30%; }
.card:nth-child(3n) .thumb { background-position: 85% 80%; }
.card-body { padding: 16px 18px 18px; }
.card .post-title { font-size: 17px; margin: 6px 0 8px; }
.card .post-desc { color: var(--stone); font-size: 13.5px; line-height: 1.65; }

/* --- post: sticky side rail + prose card -------------------------------------------------------- */
.post-layout { margin-block: 24px 64px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; max-width: 1040px; align-items: start; }
.side {
  position: sticky; top: 24px; border: 1px solid var(--glass-edge); border-radius: 18px;
  background: var(--glass); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: var(--shadow); padding: 18px; font-size: 13.5px;
}
.side h2 { font-family: var(--sans); font-size: 12.5px; font-weight: 600; letter-spacing: 0.12em; color: var(--stone); margin: 14px 0 6px; }
.side ul { list-style: none; }
.side li { padding: 3px 0; line-height: 1.5; }
.article-card {
  border: 1px solid var(--glass-edge); border-radius: 18px;
  background: var(--glass); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: var(--shadow); padding: 36px 44px;
}
.meta-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.article-card .post-title-main { font-size: 30px; line-height: 1.4; }

/* --- prose -------------------------------------------------------------------------------------- */
.prose { margin-top: 24px; }
.prose h2 { font-size: 21px; margin: 32px 0 12px; }
.prose h3 { font-size: 17px; margin: 26px 0 10px; }
.prose p { line-height: 1.85; margin: 14px 0; font-size: 15.5px; }
.prose ul, .prose ol { padding-inline-start: 1.4em; line-height: 1.85; font-size: 15.5px; }
.prose li { margin: 5px 0; }
.prose blockquote { border-inline-start: 3px solid var(--accent); padding: 2px 0 2px 14px; color: var(--stone); margin: 16px 0; }
.prose code { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 4px; padding: 1px 5px; font-size: 0.92em; }
.prose pre { background: var(--card); border: 1px solid var(--hair); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 16px 0; }
.prose pre code { background: none; padding: 0; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose hr { border: 0; border-top: 1px solid var(--hair); margin: 28px 0; }

.foot { margin-top: 48px; padding-top: 14px; border-top: 1px solid var(--hair); color: var(--stone); font-size: 12.5px; line-height: 1.7; text-shadow: var(--halo); }

/* --- phones: the rail becomes the bottom tab bar, as on the SPA ---------------------------------- */
@media (max-width: 760px) {
  .rail {
    top: auto; bottom: 0; transform: none; inset-inline: 0; width: auto; flex-direction: row; justify-content: center;
    border-radius: 0; border-inline: none; border-bottom: none; padding: 6px 8px;
  }
  .rail-mark { display: none; }
  .rail nav { display: flex; border: 0; padding: 0; width: auto; }
  .rail nav a { width: 56px; min-height: 48px; }
  .scene { margin-inline: 0; margin-block: 0; min-height: 100vh; border-radius: 0; }
  .content { margin-inline-start: 0; padding-inline: 20px; padding-bottom: 96px; }
  .post-layout { grid-template-columns: 1fr; }
  .side { position: static; order: 2; }
}
@media (prefers-reduced-motion: reduce) {
  .card:hover { transform: none; transition: none; }
}
