/* staticms default theme — system fonts, no webfont round-trip, dark-mode aware */
:root {
  --fg: #1a1a1a; --muted: #666; --bg: #fff; --card: #fff;
  --line: #e5e5e5; --accent: #0b5fff; --radius: 10px;
  --wrap: 62rem;
}
@media (prefers-color-scheme: dark) {
  :root { --fg:#e8e8e8; --muted:#9a9a9a; --bg:#121212; --card:#1b1b1b; --line:#2c2c2c; --accent:#6ea8ff; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.1rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* header */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; gap: 1rem; align-items: center; min-height: 60px; flex-wrap: nowrap; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--fg); white-space: nowrap; }
.nav { display: flex; gap: .9rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); font-size: .93rem; white-space: nowrap; padding: .35rem 0; }
.nav a:hover { color: var(--fg); }

/* secondary strip: keyword pages, scrolls sideways instead of wrapping */
.subnav { border-top: 1px solid var(--line); background: var(--bg); }
.subnav-track { display: flex; gap: 1.1rem; overflow-x: auto; scrollbar-width: none; padding-top: .55rem; padding-bottom: .55rem; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.subnav-track::-webkit-scrollbar { display: none; }
.subnav a { color: var(--muted); font-size: .86rem; white-space: nowrap; padding: .2rem 0; }
.subnav a:hover { color: var(--accent); }

.search input, .searchbox input {
  padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--fg); font: inherit; font-size: .93rem;
}
.search input { width: 11rem; }
.searchbox { margin: 1rem 0; }
.searchbox input { width: 100%; max-width: 30rem; }

/* main — .wrap already supplies the horizontal padding, so only set vertical
   here or the content gets 2.2rem of inset on each side. */
main { padding: 1.8rem 0 3rem; min-height: 60vh; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; margin: 2rem 0 .6rem; letter-spacing: -.01em; }
.page-head, .post-head { margin-bottom: 1.4rem; }
.lede { color: var(--muted); font-size: 1.08rem; margin: .3rem 0 0; }
.meta { color: var(--muted); font-size: .87rem; margin: .35rem 0; }
.empty { color: var(--muted); padding: 2rem 0; }

/* breadcrumb */
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 0 0 1rem; font-size: .85rem; color: var(--muted); }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; color: var(--line); }

/* cards */
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .thumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.card-body { padding: .85rem 1rem 1rem; }
.post-title { font-weight: 600; font-size: 1.02rem; color: var(--fg); display: block; }
.post-title:hover { color: var(--accent); }
.excerpt { color: var(--muted); font-size: .9rem; margin: .4rem 0 0; }

/* article body */
.post .hero img { border-radius: var(--radius); margin: 1rem 0; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.body { font-size: 1.04rem; }
.body > * + * { margin-top: 1.05rem; }
.body h2, .body h3 { letter-spacing: -.01em; }
.body img { border-radius: var(--radius); margin: 1.2rem 0; }
.body pre { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; overflow-x: auto; font-size: .88rem; }
.body code { background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: .1rem .35rem; font-size: .89em; }
.body pre code { border: 0; padding: 0; background: none; }
.body blockquote { margin: 1.2rem 0; padding: .2rem 0 .2rem 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.body table { border-collapse: collapse; width: 100%; font-size: .93rem; }
.body th, .body td { border: 1px solid var(--line); padding: .5rem .7rem; text-align: left; }

/* pagination */
.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 2.4rem 0 0; font-size: .93rem; }
.pagination .pos { color: var(--muted); }

.related { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1.4rem; }

/* keyword page -> newest posts of its linked category */
.page-feed { margin-top: 2.6rem; border-top: 1px solid var(--line); padding-top: 1.4rem; }
.page-feed h2 { font-size: 1.15rem; margin: 0 0 1rem; }
.feed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.feed-list li { border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.feed-list li a { font-weight: 600; }
.feed-list li time { display: block; color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.feed-list li p { margin: .45rem 0 0; color: var(--muted); font-size: .92rem; }
.feed-more { margin: 1.1rem 0 0; font-size: .93rem; }

.btn { display: inline-block; padding: .55rem .95rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* footer */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; padding: 1.6rem 0; }

/* Body content: the theme renders the title as the only <h1>, and the renderer
   demotes any <h1> pasted into the body to <h2>. Keep that first body heading
   from colliding with the page title. */
.body > h2:first-child { margin-top: 0; }

@media (max-width: 720px) {
  .bar { gap: .7rem; }
  .search input { width: 8.5rem; }
}

@media (max-width: 560px) {
  /* Row 1: brand + search. Row 2: categories. Row 3: keyword strip.
     The brand must be allowed to SHRINK (flex:1 made it grow to 270px at
     320px wide and shoved the search box onto its own row, giving a 184px
     tall sticky header). */
  .bar { flex-wrap: wrap; padding-top: .5rem; padding-bottom: .5rem; min-height: 0; row-gap: .45rem; }
  .brand {
    flex: 0 1 auto; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem;
  }
  .search { order: 2; flex: 0 1 auto; min-width: 0; margin-left: auto; }
  /* A percentage basis, not `flex:1 1 auto` — auto sizing let the input claim
     its full intrinsic width (270px at 320px viewport) and pushed itself onto
     a second row. Capped so brand + search always share row 1. */
  .search input { width: 42vw; max-width: 11rem; min-width: 6.5rem; padding: .42rem .6rem; font-size: .88rem; }
  .nav { order: 3; flex-basis: 100%; gap: 1rem; }
  .nav a { font-size: .89rem; }
  .subnav-track { gap: .95rem; padding-top: .45rem; padding-bottom: .45rem; }
  .subnav a { font-size: .82rem; }
  h2 { font-size: 1.2rem; }
}

@media (max-width: 360px) {
  /* iPhone SE class. At 320px the brand (132px) + input (134px) + gap no longer
     fit the 290px content box, so the search wrapped and the sticky header grew
     to 176px. Trim both until row 1 holds. */
  .bar { gap: .5rem; }
  .brand { font-size: .98rem; }
  .search input { width: 38vw; min-width: 5.5rem; font-size: .84rem; padding: .38rem .5rem; }
  .nav { gap: .85rem; }
  .nav a { font-size: .86rem; }
  .subnav a { font-size: .79rem; }
}
