/* Public pages. Colour tokens come from content.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: inherit; }
.wrap { width: 100%; max-width: 752px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 2.5rem; padding-bottom: 3rem; }

/* The header stays at the top while reading. On phones, where it takes two
   rows, site.js slides it away while scrolling down and back on the way up. */
.site-head { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: var(--bg); transition: transform .25s ease; }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .site-head { background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px); }
}
.site-head.away { transform: translateY(-100%); }
/* Headings reached from a table of contents stop below the header. */
.content [id] { scroll-margin-top: 96px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; min-height: 72px; padding-top: .75rem; padding-bottom: .75rem; }
.brand { font-weight: 700; font-size: 1.3rem; text-decoration: none; letter-spacing: -.01em; }
.brand .logo { display: block; max-height: 44px; width: auto; }
.nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.nav a { text-decoration: none; color: var(--muted); font-size: .95rem; }
.nav a:hover { color: var(--text); }
.head-right { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem 1.4rem; }
.langs { display: flex; gap: .15rem; font-size: .8rem; }
.langs a { text-decoration: none; color: var(--muted); padding: .15rem .4rem; border-radius: 6px; }
.langs a:hover { color: var(--text); }
.langs a.on { color: var(--text); font-weight: 600; background: var(--soft); }

.site-desc { color: var(--muted); font-size: 1.1rem; margin: 0 0 2.5rem; }
.list-head { font-size: 1.8rem; margin: 0 0 2rem; }
.list-head span { color: var(--muted); font-weight: 400; font-size: 1rem; display: block; }

/* The newest post spans the column; the rest sit in a grid of tiles. */
.card { margin: 0 0 3rem; }
.card-cover img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--soft); }
.card-title { font-size: 1.55rem; line-height: 1.25; margin: .9rem 0 .35rem; letter-spacing: -.01em; }
.card-title a { text-decoration: none; }
.card-title a:hover { color: var(--accent-ink); }
.card-excerpt { margin: .5rem 0 0; color: var(--text); opacity: .85; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 0 0 3rem; }
.tile { position: relative; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.tile:has(.tile-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; background: var(--soft); }
.tile-body { padding: .7rem .85rem .85rem; display: flex; flex-direction: column; gap: .35rem; }
.tile-title { font-size: 1rem; line-height: 1.3; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile-link { text-decoration: none; }
.tile-link:focus-visible { outline: none; }
/* The title's link covers the whole tile. */
.tile-link::after { content: ""; position: absolute; inset: 0; }
.tile:hover .tile-link { color: var(--accent-ink); }
.tile .meta { font-size: .8rem; }
.tile-excerpt { margin: 0; font-size: .88rem; line-height: 1.45; opacity: .85; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .tile:hover { transform: none; }
  .site-head, .to-top { transition: none; }
}
.meta { color: var(--muted); font-size: .9rem; margin: 0; }
.meta a { color: var(--muted); }

.pager { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.pager a { color: var(--accent-ink); text-decoration: none; }

.post-head h1 { font-size: 2.3rem; line-height: 1.15; margin: 0 0 .6rem; letter-spacing: -.02em; }
.post-head { margin-bottom: 1.75rem; }
.post-cover { margin: 0 0 2rem; }
.post-cover img { display: block; width: 100%; height: auto; border-radius: 8px; }
.notice { background: var(--soft); border-radius: 8px; padding: .6rem .9rem; font-size: .95rem; }
.notice a { color: var(--accent-ink); }
.empty, .message { color: var(--muted); }
.message a { color: var(--accent-ink); }

/* Older and newer posts under a post. */
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 3rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.post-nav-side { display: flex; flex-direction: column; gap: .5rem; }
.post-nav-side.newer { text-align: right; }
.post-nav-side .tile { text-align: left; }
.post-nav-label { color: var(--muted); font-size: .85rem; }

/* Back to top: shown by site.js once a screen has scrolled away. */
.top-sentinel { position: absolute; top: 0; left: 0; width: 1px; height: 100vh; pointer-events: none; }
.to-top { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 20; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); color: var(--text); background: color-mix(in srgb, var(--bg) 70%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 4px 16px rgb(0 0 0 / .15); font-size: 1.25rem; line-height: 1; cursor: pointer; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.to-top.shown { opacity: .85; transform: none; pointer-events: auto; }
.to-top.shown:hover { opacity: 1; }
.to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Where the text column reaches the button's corner, the footer's links
   keep clear of it. */
@media (max-width: 879px) { .foot-row { padding-right: 72px; } }

.site-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.foot-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; padding-top: 1.25rem; padding-bottom: 1.25rem; }

@media (max-width: 559px) {
  body { font-size: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tile-body { padding: .55rem .65rem .7rem; }
  .tile-title { font-size: .95rem; }
  .tile-excerpt { display: none; }
  .post-nav { gap: 12px; }
  .content [id] { scroll-margin-top: 1rem; }
  .post-head h1 { font-size: 1.8rem; }
  .card-title { font-size: 1.35rem; }
  .content { font-size: 1.05rem; }
}
