:root {
  color-scheme: light dark;
  --bg: #fcfcfb;
  --fg: #1a1a1a;
  --mute: #5c5c5a;
  --edge: #8a8a87; /* 3.4:1: link underlines, field borders */
  --line: #c9c9c6;
  --rule: #e6e6e3;
  --tint: #f3f3f1;
  --serif: ui-serif, Charter, "Iowan Old Style", "Source Serif 4", "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --fg: #e8e8e6;
    --mute: #a4a4a0;
    --edge: #6e6e6b;
    --line: #4a4a48;
    --rule: #2a2a29;
    --tint: #1c1c1b;
  }
}
@view-transition { navigation: auto; }

html { -webkit-text-size-adjust: 100%; }
body {
  max-width: 38rem;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.6 var(--sans);
}
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 2px; }

a {
  color: inherit;
  text-decoration-color: var(--edge);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; text-wrap: pretty; }
h1 { margin: 0 0 0.6rem; font-size: 2rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { margin: 2.5rem 0 0.75rem; font-size: 1.4rem; font-weight: 600; }
h3 { margin: 2rem 0 0.5rem; font-size: 1.15rem; font-weight: 600; }
p { margin: 0 0 1rem; }
.meta { margin: 0; color: var(--mute); font-size: 0.875rem; }

header { margin-bottom: 3.5rem; }
/* Back to the main page: an outlined pill, same family as the comment buttons. */
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.95rem 0.45rem 0.8rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  color: var(--fg);
  font: 600 0.875rem/1.3 var(--sans);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.back:hover { background: var(--tint); border-color: var(--mute); }
.back:focus-visible { outline-offset: 3px; border-radius: 999px; }

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
}
nav a { color: var(--mute); text-decoration: none; }
nav a:hover { color: var(--fg); text-decoration: underline; }

/* Home: the name, then one card per entry. */
h1.name { font-size: 1.6rem; }
.entries { list-style: none; display: grid; gap: 1rem; margin: 2.5rem 0 0; padding: 0; }
.entries a {
  display: block;
  padding: 1.1rem 1.25rem 1.2rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.entries a:hover { border-color: var(--line); background: var(--tint); }
.entries a:focus-visible { outline-offset: 2px; border-radius: 10px; }
.entries .title {
  display: block;
  font: 600 1.3rem/1.25 var(--serif);
  text-wrap: pretty;
}
.entries .meta { display: block; margin-top: 0.3rem; }
.entries .summary { display: block; margin-top: 0.5rem; font-family: var(--serif); font-size: 1.05rem; }

/* Entry text */
article > .meta { margin-bottom: 2.25rem; }
.body, .comment-text { font-family: var(--serif); text-wrap: pretty; }
.body { font-size: 1.1875rem; line-height: 1.7; }
.body p, .comment-text p { margin: 0 0 1.15rem; }
.body ul, .body ol { margin: 0 0 1.15rem; padding-left: 1.4rem; }
.body li { margin: 0.3rem 0; }
.body blockquote { margin: 1.5rem 0; padding-left: 1.1rem; border-left: 2px solid var(--line); color: var(--mute); }
.body hr { width: 4rem; margin: 2.5rem auto; border: 0; border-top: 1px solid var(--line); }
.body code { font: 0.85em var(--mono); padding: 0.1em 0.3em; background: var(--tint); border-radius: 4px; }
.body pre { overflow-x: auto; margin: 1.5rem 0; padding: 1rem 1.1rem; background: var(--tint); border-radius: 8px; }
.body pre code { padding: 0; font-size: 0.8rem; line-height: 1.55; background: none; }
.body img { max-width: 100%; height: auto; }
.body figure { margin: 2rem 0; }
.body figure img { display: block; border-radius: 6px; }
.body figcaption { margin-top: 0.6rem; color: var(--mute); font: 0.875rem/1.5 var(--sans); }

/* YouTube: a poster that opens into the player (no script; see markdown.ts). */
.video details > summary {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  cursor: pointer;
  list-style: none;
}
.video summary::-webkit-details-marker { display: none; }
.video summary img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.video .play {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 4rem;
  height: 4rem;
  translate: -50% -50%;
  color: rgb(0 0 0 / 0.6);
  transition: color 0.15s, scale 0.15s;
}
.video summary:hover .play, .video summary:focus-visible .play { color: rgb(0 0 0 / 0.85); scale: 1.08; }
.video details[open] > summary { display: none; }
.video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; }

/* GitHub: a card for a link on its own line, a mark for one inside text. */
.gh-mark { flex: none; }
a.gh .gh-mark { width: 0.85em; height: 0.85em; margin-right: 0.3em; vertical-align: -0.08em; }
.body .gh-card { margin: 1.5rem 0; }
.gh-card a {
  display: inline-grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.85rem;
  min-width: min(100%, 18rem);
  padding: 0.75rem 1.1rem 0.8rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  font: 1rem/1.35 var(--sans);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.gh-card a:hover { border-color: var(--line); background: var(--tint); }
.gh-card .gh-mark { grid-row: span 2; width: 1.6rem; height: 1.6rem; }
.gh-title { font-weight: 600; }
.gh-path { color: var(--mute); font-size: 0.85rem; overflow-wrap: anywhere; }

/* Tags at the foot of an entry */
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 2.5rem 0 0; padding: 0; list-style: none; }
.tags a {
  display: inline-block;
  padding: 0.2rem 0.75rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--mute);
  font: 0.85rem/1.4 var(--sans);
  text-decoration: none;
}
.tags a:hover { border-color: var(--mute); color: var(--fg); background: var(--tint); }

/* Comments */
#comments { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
#comments > h2 {
  margin: 0 0 1.25rem;
  color: var(--mute);
  font: 600 0.8rem/1.4 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#comment-list ol { list-style: none; margin: 0; padding: 0; }
#comment-list ol ol { margin: 0.5rem 0 0 0.35rem; padding-left: 1.1rem; border-left: 1px solid var(--rule); }
#comment-list li { margin: 0 0 1.5rem; }
#comment-list li li { margin-bottom: 1rem; }
#comment-list summary { cursor: pointer; color: var(--mute); font-size: 0.875rem; }
#comment-list .who { color: var(--fg); font-weight: 600; }
.comment-text { margin-top: 0.35rem; font-size: 1.0625rem; line-height: 1.6; overflow-wrap: anywhere; }
.comment-text p { margin-bottom: 0.6rem; }
.reply { color: var(--mute); font-size: 0.85rem; text-decoration: none; }
.reply:hover { color: var(--fg); text-decoration: underline; }
.add-comment { margin: 1.5rem 0 0; }
.add-comment a, button {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: 600 0.9rem/1.3 var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.add-comment a:hover, button:hover { background: var(--tint); border-color: var(--mute); }

/* Comment form (/comment/) */
h1.form-title { font-size: 1.5rem; }
form + .meta { margin-top: 1.25rem; }
form { display: grid; gap: 1.1rem; margin-top: 1.5rem; }
label { display: grid; gap: 0.35rem; color: var(--mute); font-size: 0.875rem; }
input, textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.5 var(--sans);
}
textarea { font-family: var(--serif); font-size: 1.0625rem; resize: vertical; }
input:focus-visible, textarea:focus-visible { outline-offset: 1px; border-color: var(--fg); }
button { justify-self: start; }
.quote { margin: 1rem 0 0; color: var(--mute); border-left: 2px solid var(--line); padding-left: 1rem; }

@media (max-width: 40rem) {
  body { padding: 2.25rem 1.25rem 2.5rem; }
  header { margin-bottom: 2.25rem; }
  h1 { font-size: 1.7rem; }
  .body { font-size: 1.0625rem; line-height: 1.65; hyphens: auto; }
  nav { margin-top: 3.5rem; }
  .video { margin-inline: -1.25rem; }
  .video details > summary, .video iframe { border-radius: 0; }
  .video figcaption { padding-inline: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  * { transition: none !important; }
}
