/* StaticFlow 2 — public theme.
   Colours come from Appearance & settings as :root variables (see lib/theme.php).
   Everything else is derived, so any palette stays coherent. */

:root {
  --background: #f6f6f3; --surface: #fff; --header: #fff; --header-text: #14161a;
  --text: #1a1d23; --muted: #5e6470; --accent: #4338ca; --on-accent: #fff;
  --header-size: 22px; --content-width: 820px; --layout-width: max(var(--content-width), 1120px); --grid-columns: 3;
  --border: color-mix(in srgb, var(--text) 11%, transparent);
  --border-strong: color-mix(in srgb, var(--text) 18%, transparent);
  --tint: color-mix(in srgb, var(--text) 4%, var(--surface));
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --radius: 18px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(16 18 24 / .04), 0 8px 24px -12px rgb(16 18 24 / .12);
  --shadow-lg: 0 2px 4px rgb(16 18 24 / .04), 0 24px 48px -20px rgb(16 18 24 / .24);
  --font: "Inter var", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto } *, *::before, *::after { transition: none !important; animation: none !important } }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--background); color: var(--text);
  font: 400 17px/1.7 var(--font); letter-spacing: -.003em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
main { flex: 1 }
img { max-width: 100%; height: auto }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px }
a:hover { text-decoration-thickness: 2px }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent) }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none }

.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none }
.skip:focus { top: 12px }

/* ---------- header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--header);
  background: color-mix(in srgb, var(--header) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--header-text) 9%, transparent);
  color: var(--header-text);
}
.bar { max-width: var(--layout-width); margin: 0 auto; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0 }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 17px;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .18), 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.site-logo { max-width: 180px; max-height: 48px; width: auto; height: auto; object-fit: contain }
.brand-copy { display: flex; flex-direction: column; min-width: 0 }
.brand-title { font-size: var(--header-size); font-weight: 700; letter-spacing: -.02em; line-height: 1.15 }
.brand-sub { font-size: 12.5px; opacity: .62; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0 }

.nav-wrap { position: relative }
.nav-check { position: absolute; opacity: 0; pointer-events: none }
.nav-burger { display: none; cursor: pointer; width: 42px; height: 42px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--header-text) 14%, transparent); place-content: center; gap: 4px }
.nav-burger span { display: block; width: 17px; height: 1.5px; border-radius: 2px; background: currentColor; transition: transform .2s var(--ease), opacity .2s }
.nav-check:focus-visible + .nav-burger { outline: 2px solid var(--accent); outline-offset: 2px }
.nav-check:checked + .nav-burger span:nth-child(1) { transform: translateY(5.5px) rotate(45deg) }
.nav-check:checked + .nav-burger span:nth-child(2) { opacity: 0 }
.nav-check:checked + .nav-burger span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg) }
.nav { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end }
.nav a {
  color: inherit; opacity: .74; text-decoration: none; font-weight: 500;
  font-size: clamp(14px, calc(var(--header-size) * .66), 20px);
  padding: 7px 13px; border-radius: 999px; transition: background .15s, opacity .15s, color .15s;
}
.nav a:hover { opacity: 1; background: color-mix(in srgb, var(--header-text) 7%, transparent) }
.nav a.active { opacity: 1; color: var(--accent); background: var(--accent-soft) }

/* ---------- layout */
.wrap { max-width: var(--layout-width); margin: 0 auto; padding: 64px 28px 24px; width: 100% }
.wrap.narrow { max-width: var(--content-width) }
.eyebrow { margin: 0 0 12px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent) }
.eyebrow time { color: inherit }
.lede { margin: 12px 0 0; font-size: 19px; color: var(--muted); max-width: 60ch }
.section-head { margin-bottom: 40px }
.section-head h1, .doc-head h1, .empty-state h1 {
  margin: 0; font-size: clamp(34px, 5vw, 54px); line-height: 1.05; letter-spacing: -.035em; font-weight: 700; text-wrap: balance;
}
.doc-head { margin-bottom: 32px }
.back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 28px; color: var(--muted); font-size: 15px; font-weight: 500; text-decoration: none; transition: color .15s, gap .2s var(--ease) }
.back:hover { color: var(--accent); gap: 11px }

.doc-card, .post-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(24px, 4.5vw, 56px); overflow-wrap: anywhere;
}
.feed { display: grid; gap: 22px }
.post-card { padding: clamp(24px, 4vw, 40px); transition: box-shadow .25s var(--ease), border-color .25s }
.post-card:hover { box-shadow: var(--shadow-lg); border-color: var(--border-strong) }
.post-card h2 { margin: 0 0 18px; font-size: clamp(24px, 3vw, 32px); line-height: 1.18; letter-spacing: -.025em; text-wrap: balance }
.post-card h2 a { color: var(--text); text-decoration: none }
.post-card h2 a:hover { color: var(--accent) }
.more, .sf-card-link { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--accent); text-decoration: none; transition: gap .2s var(--ease) }
.more:hover, .sf-grid-card:hover .sf-card-link { gap: 11px }

.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 36px; color: var(--muted); font-size: 14px }
.pager a { color: var(--text); font-weight: 600; text-decoration: none; padding: 10px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); justify-self: start }
.pager a:last-child { justify-self: end }
.pager a:hover { border-color: var(--accent); color: var(--accent) }

.empty { background: var(--surface); border: 1px dashed var(--border-strong); padding: 48px 28px; border-radius: var(--radius); text-align: center; color: var(--muted) }
.empty-state { text-align: center; padding-top: 110px; padding-bottom: 80px }
.empty-state .eyebrow { font-size: 15px }
.empty-state .lede { margin: 16px auto 32px }
.button, .sf-buy {
  display: inline-flex; align-items: center; gap: 10px; background: var(--accent); color: var(--on-accent);
  font-weight: 600; font-size: 16px; text-decoration: none; padding: 14px 24px; border-radius: 12px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .18), 0 8px 20px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform .15s var(--ease), box-shadow .2s, filter .2s;
}
.button:hover, .sf-buy:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: inset 0 1px 0 rgb(255 255 255 / .18), 0 14px 28px -10px color-mix(in srgb, var(--accent) 75%, transparent) }
.button:active, .sf-buy:active { transform: translateY(0) }

/* ---------- rendered Markdown */
.md-content { font-size: 17.5px; line-height: 1.75 }
.md-content > :first-child { margin-top: 0 }
.md-content > :last-child { margin-bottom: 0 }
.md-content h1, .md-content h2, .md-content h3, .md-content h4 { line-height: 1.22; letter-spacing: -.022em; margin: 1.9em 0 .6em; text-wrap: balance }
.md-content h1 { font-size: 2em } .md-content h2 { font-size: 1.6em } .md-content h3 { font-size: 1.28em } .md-content h4 { font-size: 1.08em }
.md-content p { margin: 0 0 1.15em }
.md-content ul, .md-content ol { padding-left: 1.4em; margin: 0 0 1.2em }
.md-content li { margin: .35em 0; padding-left: .2em }
.md-content li::marker { color: var(--accent) }
.md-content li.task { list-style: none; margin-left: -1.3em }
.md-content input[type=checkbox] { accent-color: var(--accent); width: 1em; height: 1em; margin: 0 .55em 0 0; vertical-align: -.1em }
.md-content strong { font-weight: 650 }
.md-content blockquote {
  margin: 1.6em 0; padding: 1.1em 1.4em; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--text);
  font-family: var(--serif); font-size: 1.08em; font-style: italic;
}
.md-content blockquote p:last-child { margin: 0 }
.md-content code { font: .86em/1.6 var(--mono); background: var(--tint); border: 1px solid var(--border); border-radius: 6px; padding: .12em .4em }
.md-content pre { background: #111318; color: #e8eaf0; border-radius: var(--radius-sm); padding: 20px 22px; overflow: auto; margin: 1.5em 0; font-size: 14.5px; line-height: 1.65; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .06) }
.md-content pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit }
.md-content table { display: block; max-width: 100%; overflow: auto; border-collapse: separate; border-spacing: 0; margin: 1.6em 0; font-size: .92em; border: 1px solid var(--border); border-radius: var(--radius-sm) }
.md-content th, .md-content td { overflow-wrap: normal; min-width: 6em; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top }
.md-content th { background: var(--tint); font-weight: 600; font-size: .9em; letter-spacing: .01em }
.md-content tr:last-child td { border-bottom: 0 }
.md-content hr { border: 0; height: 1px; background: var(--border); margin: 2.4em 0 }
.md-content img { border-radius: var(--radius-sm); margin: 1.4em 0 }
.md-content a { font-weight: 500 }

/* ---------- grids catalog */
.sf-grid-list { display: grid; grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr)); gap: 26px }
.sf-grid-card {
  position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s;
}
.sf-grid-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong) }
.sf-card-image { display: grid; place-items: center; aspect-ratio: 16 / 10; background: var(--tint); overflow: hidden; color: var(--muted); font-size: 44px; font-weight: 700; text-decoration: none }
.sf-card-image img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; transition: transform .6s var(--ease) }
.sf-grid-card:hover .sf-card-image img { transform: scale(1.04) }
.sf-card-content { padding: 22px 24px 24px; display: flex; flex-direction: column; flex: 1 }
.sf-card-content h2 { font-size: 20px; line-height: 1.3; letter-spacing: -.015em; margin: 0 0 10px; overflow-wrap: anywhere }
.sf-card-content h2 a { color: var(--text); text-decoration: none }
.sf-card-content h2 a::after { content: ""; position: absolute; inset: 0 } /* whole card is clickable */
.sf-card-content p { color: var(--muted); font-size: 15px; line-height: 1.65; margin: 0 0 18px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden }
.sf-card-link { margin-top: auto; font-size: 14.5px }

/* ---------- posts page (card grid) */
.sf-posts-grid { grid-template-columns: repeat(var(--posts-columns), minmax(0, 1fr)) }
.sf-card-content p.sf-card-meta { display: block; margin: 0 0 8px; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); line-height: 1.4 }
.sf-posts-grid .sf-card-image span { font-size: 40px; opacity: .55 }
.post-hero { margin: 0 0 32px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--tint) }
.post-hero img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: cover }

.sf-grid-detail {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); box-shadow: var(--shadow-lg); overflow: hidden;
}
.sf-detail-media { position: sticky; top: 80px; padding: 28px; background: var(--tint); min-width: 0; align-self: stretch }
.sf-detail-image img { display: block; width: 100%; height: auto; max-height: 820px; object-fit: contain; border-radius: 14px; box-shadow: var(--shadow) }
.sf-no-image { min-height: 320px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: 14px }
.sf-detail-content { padding: clamp(28px, 4vw, 52px); min-width: 0; overflow-wrap: anywhere }
.sf-detail-content h1 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.08; letter-spacing: -.035em; margin: 0 0 24px; text-wrap: balance }
.sf-buy-row { margin: 0 0 32px; padding-bottom: 32px; border-bottom: 1px solid var(--border) }
.sf-buy svg { font-size: 17px }

/* ---------- footer */
.site-footer { margin-top: 72px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px }
.site-footer .bar { padding-top: 28px; padding-bottom: 36px }
.footer-links { display: flex; gap: 20px }
.footer-links a { color: var(--muted); text-decoration: none }
.footer-links a:hover { color: var(--accent) }

/* ---------- responsive */
.sf-posts-grid { --grid-columns: var(--posts-columns) }
@media (max-width: 1000px) { .sf-grid-list { grid-template-columns: repeat(min(var(--grid-columns), 3), minmax(0, 1fr)); gap: 20px } }
@media (max-width: 860px) {
  .sf-grid-detail { grid-template-columns: 1fr }
  .sf-detail-media { position: static; padding: 18px }
  .sf-detail-image img { max-height: 520px }
}
@media (max-width: 760px) {
  body { font-size: 16px }
  .bar { padding: 12px 18px }
  .wrap { padding: 40px 18px 16px }
  .brand-sub { display: none }
  .nav-burger { display: grid }
  .nav-wrap > .nav { display: none }
  .nav-check:checked ~ .nav {
    display: flex; flex-direction: column; position: absolute; right: 0; top: calc(100% + 10px); min-width: 220px; padding: 8px;
    background: var(--header); color: var(--header-text); border: 1px solid color-mix(in srgb, var(--header-text) 12%, transparent);
    border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .18s var(--ease);
  }
  .nav-check:checked ~ .nav a { font-size: 16px; padding: 11px 14px; border-radius: 10px }
  .sf-grid-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px }
  .md-content { font-size: 16.5px }
  .lede { font-size: 17px }
  .section-head { margin-bottom: 28px }
}
@media (max-width: 520px) { .sf-grid-list { grid-template-columns: 1fr } .site-footer .bar { flex-direction: column; align-items: flex-start; gap: 10px } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98) } }
@media print { .site-header, .site-footer, .back, .skip { display: none } .doc-card, .post-card { box-shadow: none; border: 0; padding: 0 } }

/* "Hide title" option: heading stays for screen readers and SEO, but isn't shown */
.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.doc-head.title-hidden{margin:0;padding:0}
