/* ==========================================================================
   Site stylesheet. Colors live in the variables below: change --accent to
   re-theme the whole site. Dark mode follows the visitor's OS setting.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --text: #1c2026;
  --text-muted: #5b6573;
  --border: #e3e6eb;
  --accent: #0b63ce;
  --accent-soft: #e8f1fc;
  --ok: #1a7f4b;
  --code-bg: #f6f8fa;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --width: 46rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --bg-soft: #171b21;
    --text: #e4e7eb;
    --text-muted: #9aa4b2;
    --border: #262c35;
    --accent: #6cb0ff;
    --accent-soft: #15263b;
    --ok: #4cc38a;
    --code-bg: #161b22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img, video, iframe { max-width: 100%; }
img { height: auto; border-radius: 6px; }

.icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; }

.container {
  width: 100%;
  max-width: calc(var(--width) + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.content { flex: 1; padding-top: 3rem; padding-bottom: 4rem; }

/* Phones: a little more room for the text column */
@media (max-width: 600px) {
  .container { padding: 0 1.1rem; }
  .content { padding-top: 2rem; padding-bottom: 3rem; }
  .post-card { padding: 1.15rem 1.1rem; }
  .hero { padding-top: 0; }
}

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--bg); padding: .5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);   /* solid fallback for older browsers (iOS < 16.2) */
  border-bottom: 1px solid var(--border);
}
@supports (background: color-mix(in srgb, red, blue)) {
  .site-header {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
  }
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 3.75rem;
  max-width: 64rem;
}
.brand {
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--accent); }

.site-nav { display: flex; gap: .25rem; }
.site-nav a {
  color: var(--text-muted);
  font-size: .92rem; font-weight: 500;
  padding: .4rem .7rem; border-radius: 8px;
}
.site-nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.site-nav a.active { color: var(--text); background: var(--bg-soft); }

.nav-toggle, .nav-toggle-label { display: none; }

@media (max-width: 860px) {
  .header-inner { flex-wrap: wrap; position: relative; }
  /* Invisible but focusable, so the menu opens with Tab + Space too */
  .nav-toggle {
    display: block; position: absolute; right: 0; top: .6rem;
    width: 2.5rem; height: 2.5rem; margin: 0; opacity: 0; cursor: pointer;
  }
  .nav-toggle-label {
    display: flex; align-items: center; justify-content: center;
    width: 2.5rem; height: 2.5rem; cursor: pointer; border-radius: 8px;
  }
  .nav-toggle-label span,
  .nav-toggle-label span::before,
  .nav-toggle-label span::after {
    display: block; width: 18px; height: 2px; background: var(--text);
    position: relative; border-radius: 2px; transition: transform .2s;
  }
  .nav-toggle-label span::before,
  .nav-toggle-label span::after { content: ""; position: absolute; }
  .nav-toggle-label span::before { top: -6px; }
  .nav-toggle-label span::after { top: 6px; }
  .nav-toggle:checked + .nav-toggle-label span { background: transparent; }
  .nav-toggle:checked + .nav-toggle-label span::before { transform: translateY(6px) rotate(45deg); }
  .nav-toggle:checked + .nav-toggle-label span::after { transform: translateY(-6px) rotate(-45deg); }
  .nav-toggle:focus-visible + .nav-toggle-label { outline: 2px solid var(--accent); outline-offset: 2px; }

  .site-nav {
    display: none; flex-basis: 100%; flex-direction: column;
    padding: .25rem 0 .75rem;
  }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  .site-nav a { padding: .6rem .7rem; font-size: 1rem; }
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .88rem;
}
.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; padding-top: 1.5rem; padding-bottom: 1.5rem;
}
.footer-inner p { margin: 0; }

.social { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.social a {
  display: inline-flex; padding: .45rem; border-radius: 8px;
  color: var(--text-muted);
}
.social a:hover { color: var(--accent); background: var(--bg-soft); }
.social .icon { width: 1.2rem; height: 1.2rem; }

/* ---------- Home ---------- */

.hero { padding: 1rem 0 2.5rem; border-bottom: 1px solid var(--border); margin-bottom: 2.5rem; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.15;
  letter-spacing: -0.03em; margin: 0 0 .5rem;
}
.hero-intro { color: var(--text-muted); margin: 0 0 1.75rem; max-width: 38rem; }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.hero-actions .social { margin-left: .25rem; }

.button {
  display: inline-block; padding: .55rem 1.1rem; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: .92rem;
  border: 1px solid var(--accent);
}
.button:hover { text-decoration: none; filter: brightness(1.08); }
.button-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.button-ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
@media (prefers-color-scheme: dark) { .button:not(.button-ghost) { color: #0b1420; } }

.section-title {
  font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin: 0 0 1.25rem;
}

.post-list { display: flex; flex-direction: column; gap: 1rem; }
.post-card {
  position: relative;
  padding: 1.4rem 1.5rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.post-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: var(--shadow); }
.post-card-title { font-size: 1.3rem; line-height: 1.35; letter-spacing: -0.015em; margin: .2rem 0 .5rem; }
.post-card-title a { color: var(--text); }
.post-card-title a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
.post-card:hover .post-card-title a { color: var(--accent); text-decoration: none; }
.post-card-excerpt { color: var(--text-muted); margin: 0 0 .75rem; font-size: .96rem; }
.read-more { font-size: .9rem; font-weight: 600; }

.post-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .5rem;
  margin: 0; font-size: .85rem; color: var(--text-muted);
}
.post-meta .sep { opacity: .6; margin-right: .5rem; }
.post-meta .meta-item { white-space: nowrap; display: inline-flex; align-items: center; }
.tag {
  text-transform: capitalize; background: var(--accent-soft); color: var(--accent);
  padding: .05rem .55rem; border-radius: 999px; font-weight: 500; font-size: .8rem;
}

.pagination {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 2.5rem; font-size: .92rem;
}
.pagination-item {
  padding: .5rem 1rem; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.pagination-item:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination-item.disabled { color: var(--text-muted); opacity: .5; }
.pagination-status { color: var(--text-muted); }

/* ---------- Profile header (About page) ---------- */

.profile-header { position: relative; padding-left: 1.25rem; }
.profile-header::before {          /* accent bar that grows in */
  content: ""; position: absolute; left: 0; top: .35rem; bottom: .35rem; width: 4px;
  border-radius: 4px; background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 25%, transparent));
  transform-origin: top; animation: grow-bar .7s ease-out both;
}
.eyebrow {
  font-family: var(--mono); font-size: .85rem; letter-spacing: .06em;
  color: var(--accent); margin: 0 0 .35rem;
  animation: fade-up .5s ease-out both;
}
.profile-header .page-title {
  font-size: clamp(2.1rem, 6vw, 3rem); letter-spacing: -0.03em; margin-bottom: .5rem;
  animation: fade-up .5s .08s ease-out both;
}
.credentials {
  font-family: var(--mono); font-size: .9rem; color: var(--text-muted);
  letter-spacing: .02em; margin: 0; text-wrap: balance;
  animation: fade-up .5s .16s ease-out both;
}
.nowrap { white-space: nowrap; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes grow-bar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .profile-header *, .profile-header::before { animation: none !important; } }

/* ---------- Posts & pages ---------- */

.post-header, .page-header { margin-bottom: 2.25rem; }
.post-title, .page-title {
  font-size: clamp(1.8rem, 4.5vw, 2.5rem); line-height: 1.2;
  letter-spacing: -0.025em; margin: 0 0 .75rem;
}
.page-subtitle { color: var(--text-muted); font-size: 1.1rem; margin: 0; }
.back-link { display: inline-block; font-size: .9rem; margin-bottom: 1.25rem; }

.post-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--border);
}
.post-nav-item {
  display: flex; flex-direction: column; gap: .2rem;
  padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--radius);
}
.post-nav-item:hover { border-color: var(--accent); text-decoration: none; }
.post-nav-item .label { font-size: .8rem; color: var(--text-muted); }
.post-nav-item .title { color: var(--text); font-weight: 600; line-height: 1.4; }
.post-nav-item.newer { text-align: right; grid-column: 2; }
@media (max-width: 600px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-item.newer { grid-column: 1; }
}

.related { margin-top: 2.5rem; }
.related h2 {
  font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin: 0 0 .75rem;
}
.related ul { list-style: none; padding: 0; margin: 0; }
.related li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border);
}
.related time { color: var(--text-muted); font-size: .85rem; white-space: nowrap; }

/* ---------- Prose (Markdown content) ---------- */

.prose { overflow-wrap: break-word; overflow-wrap: anywhere; } /* long URLs wrap instead of widening the page */
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose dl, .prose table,
.prose blockquote, .prose pre, .prose figure, .prose div.highlighter-rouge { margin: 0 0 1.25rem; }

.prose h1, .prose h2, .prose h3, .prose h4 {
  line-height: 1.3; letter-spacing: -0.015em; margin: 2.5rem 0 1rem;
}
.prose h1 { font-size: 1.75rem; }
.prose h2 { font-size: 1.45rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.2rem; }
.prose h4 { font-size: 1.05rem; }

.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .3rem 0; }
.prose li > ul, .prose li > ol { margin: .3rem 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.prose strong { font-weight: 650; }

.prose blockquote {
  margin-left: 0; padding: .25rem 0 .25rem 1.25rem;
  border-left: 3px solid var(--border); color: var(--text-muted);
}

.prose table {
  display: block; overflow-x: auto; border-collapse: collapse; font-size: .92rem;
}
.prose th, .prose td { border: 1px solid var(--border); padding: .5rem .75rem; text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 600; }

/* Images: "![alt](img.jpg?style=centerme)" centers an image */
.prose img[src$="centerme"] { display: block; margin: 0 auto; }

.prose figure {
  margin-left: 0; margin-right: 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--bg-soft);
}
.prose figure img { display: block; margin: 0 auto; border-radius: 0; padding: 0; }
.prose figcaption { padding: .7rem 1rem; font-size: .88rem; color: var(--text-muted); border-top: 1px solid var(--border); }

img.emoji {
  display: inline-block; width: 1.15em; height: 1.15em;
  margin: 0; padding: 0; border-radius: 0; vertical-align: -0.2em;
}

/* Callout box: <div class="message">...</div> */
.message {
  margin: 0 0 1.25rem; padding: 1rem 1.25rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--text);
}
.message > :last-child { margin-bottom: 0; }

.lead { font-size: 1.2rem; color: var(--text-muted); }

/* Responsive embeds: <div class="video-container"><iframe ...></iframe></div> */
.video-container {
  position: relative; aspect-ratio: 16 / 9; max-width: 100%;
  margin: 0 0 1.25rem; border-radius: var(--radius); overflow: hidden; background: #000;
}
.video-container iframe, .video-container object, .video-container embed {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;
}
@supports not (aspect-ratio: 1) {   /* iOS 14 and older */
  .video-container { height: 0; padding-bottom: 56.25%; }
}

/* Task lists: "- [ ]" = active (dot), "- [x]" = done (check) */
.prose ul.task-list { list-style: none; padding-left: 0; }
.prose .task-list-item {
  position: relative; padding: .55rem 0 .55rem 1.9rem; margin: 0;
  border-bottom: 1px solid var(--border);
}
.prose .task-list-item:last-child { border-bottom: 0; }
.prose .task-list-item-checkbox {
  appearance: none; -webkit-appearance: none; margin: 0;
  position: absolute; left: .3rem; top: 1.15rem;
  width: .6rem; height: .6rem; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.prose .task-list-item-checkbox:checked {
  top: .95rem; width: 1.1rem; height: 1.1rem; left: .1rem; box-shadow: none; background: transparent;
}
.prose .task-list-item-checkbox:checked::before {
  content: "✓"; display: block; text-align: center; line-height: 1.1rem;
  font-size: .85rem; font-weight: 700; color: var(--text-muted);
}

/* ---------- Code ---------- */

code, pre, kbd { font-family: var(--mono); font-size: .86em; }
:not(pre) > code {
  background: var(--code-bg); border: 1px solid var(--border);
  padding: .1em .35em; border-radius: 5px; overflow-wrap: break-word;
}
pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.15rem; overflow-x: auto; line-height: 1.55; font-size: .84rem;
}
pre code { font-size: inherit; background: none; border: 0; padding: 0; }
div.highlighter-rouge pre.highlight, figure.highlight pre { margin: 0; }
.prose div.highlighter-rouge, .prose figure.highlight { border: 0; background: none; }

/* Syntax highlighting (Rouge), GitHub-like light/dark */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .ch, .highlight .cd { color: #6a737d; font-style: italic; }
.highlight .cp { color: #6a737d; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv, .highlight .ow { color: #d73a49; }
.highlight .kc, .highlight .kt, .highlight .no, .highlight .bp { color: #005cc5; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd,
.highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .ss, .highlight .sa { color: #032f62; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il { color: #005cc5; }
.highlight .nf, .highlight .fm, .highlight .nc, .highlight .ne { color: #6f42c1; }
.highlight .nb, .highlight .nv, .highlight .vi, .highlight .vg, .highlight .vc { color: #e36209; }
.highlight .nt { color: #22863a; }
.highlight .na, .highlight .nd { color: #6f42c1; }
.highlight .gd { color: #b31d28; background: #ffeef0; }
.highlight .gi { color: #22863a; background: #f0fff4; }
.highlight .err { color: inherit; }
@media (prefers-color-scheme: dark) {
  .highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .ch, .highlight .cd, .highlight .cp { color: #8b949e; }
  .highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv, .highlight .ow { color: #ff7b72; }
  .highlight .kc, .highlight .kt, .highlight .no, .highlight .bp,
  .highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il { color: #79c0ff; }
  .highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd,
  .highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .ss, .highlight .sa { color: #a5d6ff; }
  .highlight .nf, .highlight .fm, .highlight .nc, .highlight .ne, .highlight .na, .highlight .nd { color: #d2a8ff; }
  .highlight .nb, .highlight .nv, .highlight .vi, .highlight .vg, .highlight .vc { color: #ffa657; }
  .highlight .nt { color: #7ee787; }
  .highlight .gd { color: #ffdcd7; background: #67060c; }
  .highlight .gi { color: #aff5b4; background: #033a16; }
}

/* ---------- Topics ---------- */

a.tag:hover { text-decoration: none; background: var(--accent); color: var(--bg); }
.post-card .tag { position: relative; z-index: 1; } /* clickable above the whole-card link */

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1.25rem; }
.section-head .section-title { margin: 0; }
.section-link { font-size: .88rem; font-weight: 500; }

.related h2 a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.related h2 a:hover { color: var(--accent); }
.all-topics { margin: .9rem 0 0; font-size: .9rem; }

.topic-index { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 2.5rem; }
.topic-index .tag { font-size: .88rem; padding: .3rem .8rem; }
.topic-index .count { opacity: .65; margin-left: .2rem; font-variant-numeric: tabular-nums; }

.topic { scroll-margin-top: 5rem; margin-bottom: 2.25rem; }
.topic h2 { text-transform: capitalize; }
.topic:target h2 { color: var(--accent); border-bottom-color: var(--accent); }
.prose .topic-posts { list-style: none; padding: 0; margin: 0; }
.prose .topic-posts li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border); margin: 0;
}
.prose .topic-posts time { color: var(--text-muted); font-size: .85rem; white-space: nowrap; }

/* ---------- Tools & Apps cards ---------- */

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: .9rem; margin: 0 0 2rem;
}
.card {
  display: flex; flex-direction: column; gap: .3rem;
  padding: 1rem 1.15rem; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow); }
.card-title { font-weight: 600; line-height: 1.4; }
.card:hover .card-title { color: var(--accent); }
.card-text { font-size: .88rem; color: var(--text-muted); line-height: 1.5; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Blog archive (/blog/) ---------- */

.prose .archive { list-style: none; padding: 0; margin: 0 0 2rem; }
.prose .archive li {
  display: grid; grid-template-columns: 4.2rem 1fr auto; align-items: baseline; gap: .25rem 1rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border); margin: 0;
}
.archive time { color: var(--text-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.archive-title { line-height: 1.45; }
.archive .tag { justify-self: end; white-space: nowrap; }
@media (max-width: 600px) {
  .prose .archive li { grid-template-columns: 1fr auto; }
  .archive time { grid-column: 1; }
  .archive .tag { grid-column: 2; grid-row: 1; }
  .archive-title { grid-column: 1 / -1; }
}
