/* ur.foo-projects.org
   No web fonts, no external assets: the vhost ships a restrictive CSP and
   anything off-origin would be blocked. System font stacks only. */

:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --fg: #1a1a18;
  --muted: #6b6b66;
  --rule: #e2e2dd;
  --card: #ffffff;
  --link: #1b5e8a;
  --link-hover: #10405f;
  --code-bg: #f0f0ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 16px rgba(0, 0, 0, .04);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 38rem;   /* ~72 characters: the comfortable reading width */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --fg: #ececf0;
    --muted: #9a9aa4;
    --rule: #2c2c33;
    --card: #1d1d22;
    --link: #7fb8dd;
    --link-hover: #a8d2ee;
    --code-bg: #26262d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: .15em; }
a:hover { color: var(--link-hover); }

/* Visible keyboard focus. The default ring disappears against the dark
   palette, so it is redefined rather than removed. */
a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Announced to screen readers, not painted. Used for the index's <h1>, which
   would otherwise be a redundant "Posts" above a list that is obviously
   posts -- but the page still needs exactly one h1. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- site chrome ------------------------------------------------------ */

header.site {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3rem 0 1.75rem;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  display: inline-block;
  font-family: var(--mono);
  font-size: clamp(1.3rem, 4.5vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--fg);
  text-decoration: none;
}
.site-title:hover { color: var(--link); }

.site-tagline {
  margin: .4rem 0 0;
  color: var(--muted);
  font-size: .95rem;
}

/* Top-level nav. flex-wrap rather than a scroller: as links are added they
   should fall onto a second line on a phone, not slide out of sight. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.5rem;
  margin-top: 1.1rem;
  font-family: var(--mono);
  font-size: .85rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  /* Transparent underline reserved up front so the text does not shift down
     by a pixel when the real one appears on hover. */
  border-bottom: 1px solid transparent;
}

.site-nav a:hover {
  color: var(--fg);
  border-bottom-color: var(--rule);
}

.site-nav a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--link);
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding-top: 2.5rem;
}

footer.site {
  max-width: var(--measure);
  margin: 4rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: .85rem;
}
footer.site p { margin: 0; }

/* ---- index cards ------------------------------------------------------ */

.card {
  margin: 0 0 1.5rem;
  padding: 1.5rem 1.6rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease;
}

/* :focus-within so the hover affordance also appears for keyboard users
   tabbing onto the card's links. */
.card:hover, .card:focus-within {
  border-color: var(--link);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover, .card:focus-within { transform: none; }
}

.card-title { margin: 0; font-size: 1.35rem; line-height: 1.3; letter-spacing: -.01em; }
.card-title a { color: var(--fg); text-decoration: none; }
.card-title a:hover { color: var(--link); }

.card time,
.post-header time {
  display: block;
  margin-top: .35rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .02em;
}

.card-summary { margin: .9rem 0 0; color: var(--muted); }

.card-more { margin: 1rem 0 0; font-size: .9rem; }
.card-more a { text-decoration: none; font-weight: 600; }
.card-more a:hover { text-decoration: underline; }

/* ---- post ------------------------------------------------------------- */

.post-header {
  margin-bottom: 2.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.post-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 6vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -.02em;
  /* Long unbroken tokens (hostnames, flags like -fomg-optimize-harder) must
     not push a phone screen sideways. */
  overflow-wrap: anywhere;
}

.post h2 {
  margin: 2.75rem 0 .75rem;
  font-size: 1.3rem;
  line-height: 1.3;
  letter-spacing: -.01em;
}

.post h3 { margin: 2rem 0 .6rem; font-size: 1.1rem; }

.post p { margin: 0 0 1.25rem; }

.post ul, .post ol { margin: 0 0 1.25rem; padding-left: 1.4rem; }
.post li { margin-bottom: .4rem; }

.post blockquote {
  margin: 0 0 1.25rem;
  padding: .25rem 0 .25rem 1.15rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}
.post blockquote p:last-child { margin-bottom: 0; }

.post hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--rule); }

code {
  padding: .12em .35em;
  background: var(--code-bg);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .875em;
}

pre {
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  background: var(--code-bg);
  border-radius: 8px;
  /* Code is the one thing allowed to scroll sideways -- inside its own box,
     never the page. */
  overflow-x: auto;
}
pre code { padding: 0; background: none; font-size: .85rem; line-height: 1.55; }

.post-nav {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: .9rem;
}
.post-nav a { text-decoration: none; font-weight: 600; }
.post-nav a:hover { text-decoration: underline; }

/* ---- transient states ------------------------------------------------- */

.loading { color: var(--muted); }

.error {
  padding: 1rem 1.15rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 3px solid #c2534d;
  border-radius: 6px;
  color: var(--muted);
}
