/* Night-shift theme: indigo night sky, one amber signal light. */
:root {
  --night: #0E1424;
  --night-deep: #090E1A;
  --panel: #151D31;
  --line: #24304B;
  --ink: #E3E9F5;
  --ink-soft: #B4C0D8;
  --steel: #7E93B8;
  --amber: #F2B84B;
  --amber-soft: rgba(242, 184, 75, .14);
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --measure: 72ch;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 400 17px/1.7 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* Starfield behind every page (Hubble eXtreme Deep Field), dimmed for reading */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(9, 14, 26, .55), rgba(9, 14, 26, .78)),
    url("../images/deep-field.jpg") center / cover no-repeat,
    var(--night-deep);
}
.is-post::before {
  background:
    linear-gradient(180deg, rgba(9, 14, 26, .82), rgba(9, 14, 26, .9)),
    url("../images/deep-field.jpg") center / cover no-repeat,
    var(--night-deep);
}
img { max-width: 100%; height: auto; }
a { color: var(--amber); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #FFD27E; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--amber); color: var(--night-deep); }

.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--amber); color: var(--night-deep); padding: 6px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(14, 20, 36, .82);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: 1120px; margin: 0 auto; padding: 10px var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 18px/1 var(--display); }
.brand img { width: 32px; height: 32px; object-fit: cover; border-radius: 50%; border: 1px solid var(--line); }
.brand:hover { color: var(--amber); }
.topnav { display: flex; gap: clamp(12px, 3vw, 28px); font-size: 15px; }
.topnav a { color: var(--ink-soft); text-decoration: none; }
.topnav a:hover { color: var(--amber); }

/* Hero: the one loud moment */
.hero {
  position: relative; overflow: hidden;
  min-height: min(88vh, 860px); display: flex; align-items: center;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(9, 14, 26, .82) 0%, rgba(9, 14, 26, .45) 45%, rgba(9, 14, 26, 0) 75%),
    linear-gradient(180deg, rgba(9, 14, 26, 0) 60%, rgba(9, 14, 26, .9) 100%),
    url("../images/cosmic-cliffs.jpg") center 30% / cover no-repeat,
    var(--night-deep);
}
.hero__graph { opacity: .55; }
.hero__graph { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero__inner {
  position: relative; width: 100%;
  max-width: 1120px; margin: 0 auto;
  padding: clamp(64px, 12vw, 140px) var(--gutter) clamp(56px, 9vw, 110px);
}
.hero__avatar { width: 88px; height: 88px; object-fit: cover; border-radius: 50%; border: 2px solid var(--amber); display: block; margin-bottom: 28px; }
.hero__title {
  margin: 0;
  font: 800 clamp(56px, 11vw, 136px)/.9 var(--display);
  letter-spacing: -.035em;
  color: var(--ink);
  text-shadow: 0 2px 30px rgba(9, 14, 26, .8);
}
.hero__lede { max-width: 46ch; margin: 24px 0 28px; font-size: clamp(17px, 2vw, 20px); color: var(--ink); text-shadow: 0 1px 12px rgba(9, 14, 26, .9); }

.social { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; }
.social a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); text-decoration: none; font-size: 14px;
  background: rgba(21, 29, 49, .7);
}
.social a:hover { border-color: var(--amber); color: var(--amber); }
.social svg { width: 15px; height: 15px; }

/* Sections */
.section-title { font: 700 26px/1.2 var(--display); letter-spacing: -.01em; margin: 0 0 28px; }
.projects, .timeline { max-width: 1120px; margin: 0 auto; padding: 72px var(--gutter) 0; }

.projects__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  border-top: 1px solid var(--line); border-left: 1px solid var(--line);
}
.projects__list a {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 16px 18px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.projects__list strong { font: 600 16px/1.3 var(--mono); }
.projects__list span { font-size: 14px; color: var(--steel); }
.projects__list a:hover { background: var(--amber-soft); }
.projects__list a:hover strong { color: var(--amber); }

/* Timeline of posts: dates are a real sequence, so the rail earns its place */
.timeline__list { list-style: none; margin: 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: 120px 1fr; gap: 0 36px;
  position: relative; padding-bottom: 44px;
}
.entry::before {
  content: ""; position: absolute; left: 120px; margin-left: 17px; top: 10px; bottom: 0;
  width: 1px; background: var(--line);
}
.entry::after {
  content: ""; position: absolute; left: 120px; margin-left: 13px; top: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--night); border: 1px solid var(--steel);
}
.timeline--first .entry:first-child::after { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 5px var(--amber-soft); }
.entry:last-child::before { display: none; }
.entry__date { text-align: right; padding-top: 2px; }
.entry__day { display: block; font: 600 15px/1.3 var(--mono); color: var(--ink-soft); }
.entry__year { display: block; font: 400 13px/1.3 var(--mono); color: var(--steel); }
.entry__body { max-width: var(--measure); min-width: 0; }
.entry__title { margin: 0 0 8px; font: 700 clamp(21px, 2.4vw, 25px)/1.25 var(--display); letter-spacing: -.01em; }
.entry__title a { color: var(--ink); text-decoration: none; }
.entry__title a:hover { color: var(--amber); }
.entry__excerpt { margin: 0 0 12px; color: var(--ink-soft); font-size: 16px; overflow-wrap: anywhere; }

.chip {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--steel);
  font: 500 13px/1.7 var(--mono); text-decoration: none;
}
a.chip:hover { color: var(--amber); border-color: var(--amber); }

.button {
  display: inline-block; padding: 9px 18px; border-radius: 8px;
  background: var(--amber); color: var(--night-deep);
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
}
.button:hover { background: #FFD27E; color: var(--night-deep); }
.button--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button--ghost:hover { background: transparent; color: var(--amber); border-color: var(--amber); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 0; }
.pager__count { color: var(--steel); font: 400 14px var(--mono); }

/* Post page */
.post { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 64px var(--gutter) 0; }
.post__header { margin-bottom: 40px; padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.post__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 18px; color: var(--steel); font: 400 14px var(--mono); }
.post__title, .post--own-title .prose > h1:first-child {
  margin: 0; font: 800 clamp(34px, 5.4vw, 54px)/1.06 var(--display); letter-spacing: -.025em;
}
.post__tags { margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 14px; color: var(--steel); font: 400 14px var(--mono); }
/* When the article brings its own H1, the header is just the meta line above it */
.post--own-title .post__header { margin-bottom: 12px; padding-bottom: 0; border-bottom: 0; }
.post--own-title .post__tags { display: none; }
.post--own-title .prose > h1:first-child { margin-bottom: 36px; padding-bottom: 32px; border-bottom: 1px solid var(--line); }

.prose { overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--display); line-height: 1.25; letter-spacing: -.01em; margin: 2.2em 0 .6em; scroll-margin-top: 72px; }
.prose h1 { font-size: 32px; }
.prose h2 { font-size: 27px; padding-top: .4em; }
.prose h3 { font-size: 21px; }
.prose h4 { font-size: 18px; color: var(--ink-soft); }
.prose p, .prose ul, .prose ol, .prose table, .prose blockquote { margin: 0 0 1.2em; }
.prose li { margin: .25em 0; }
.prose li > ul, .prose li > ol { margin: .25em 0; }
.prose strong { color: #fff; font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose img { display: block; margin: 1.6em auto; border-radius: 10px; border: 1px solid var(--line); }
.prose p > img:only-child { margin: 1.6em auto; }
.prose blockquote {
  padding: 4px 0 4px 20px; border-left: 3px solid var(--amber);
  color: var(--ink-soft);
}
.prose blockquote > :last-child { margin-bottom: 0; }

.prose code { font: 400 .86em/1.5 var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: .1em .4em; }
.prose pre, .prose .highlight { margin: 0 0 1.4em; }
.prose pre {
  background: var(--night-deep); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; overflow-x: auto; line-height: 1.6;
  font-size: 14px;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; color: #D7DEEC; }
.prose .highlighter-rouge { position: relative; }
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  padding: 3px 10px; border-radius: 6px; cursor: pointer;
  background: var(--panel); color: var(--steel); border: 1px solid var(--line);
  font: 500 12px/1.6 var(--body); opacity: 0; transition: opacity .15s;
}
.highlighter-rouge:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--amber); border-color: var(--amber); }
@media (hover: none) { .copy-btn { opacity: 1; } }

.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 15px; }
.prose th, .prose td { padding: 8px 14px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--panel); font-weight: 600; }
.prose tr:nth-child(even) td { background: rgba(21, 29, 49, .45); }

.repo-card {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  margin: 56px 0 0; padding: 22px 24px;
  border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 10px;
  background: var(--panel);
}
.repo-card strong { font-family: var(--mono); }
.repo-card span { display: block; color: var(--steel); font-size: 15px; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 40px 0 0; }
.post-nav__item {
  display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); text-decoration: none; font: 600 16px/1.35 var(--display);
}
.post-nav__item span { display: block; margin-bottom: 4px; color: var(--steel); font: 400 13px var(--mono); }
.post-nav__item:hover { border-color: var(--amber); color: var(--amber); }
.post-nav__item--next { text-align: right; }

/* Footer */
.footer { margin-top: 96px; border-top: 1px solid var(--line); background: rgba(9, 14, 26, .85); }
.footer__inner {
  max-width: 1120px; margin: 0 auto; padding: 28px var(--gutter);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  color: var(--steel); font-size: 14px;
}
.footer p { margin: 0; }
.footer a { color: var(--ink-soft); }

/* Rouge syntax colors, tuned to the palette */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cd { color: #6B7A99; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv { color: #C99CF0; }
.highlight .kt, .highlight .nc, .highlight .nn { color: #8FD3C9; }
.highlight .kc, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .il, .highlight .m { color: #F7A072; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx { color: #A9D98C; }
.highlight .na, .highlight .nt { color: #F2B84B; }
.highlight .nf, .highlight .fm { color: #82B1FF; }
.highlight .nd, .highlight .nb, .highlight .bp { color: #F2B84B; }
.highlight .o, .highlight .ow { color: #9FB0CF; }
.highlight .p { color: #B4C0D8; }
.highlight .nv, .highlight .vi, .highlight .vg { color: #F28C8C; }
.highlight .gd { color: #F28C8C; }
.highlight .gi { color: #A9D98C; }
.highlight .err { color: inherit; background: none; }

/* Small screens */
@media (max-width: 680px) {
  body { font-size: 16px; }
  .topnav a[href*="medium"] { display: none; }
  .hero { min-height: 0; background-position: 0 0, 0 0, 70% 30%, 0 0; }
  .hero::after { content: ""; position: absolute; inset: 0; background: rgba(9, 14, 26, .35); pointer-events: none; }
  .hero__inner { z-index: 1; }
  .entry { grid-template-columns: 1fr; padding-left: 26px; padding-bottom: 36px; }
  .entry::before, .entry::after { left: 0; }
  .entry::before { margin-left: 4px; }
  .entry::after { margin-left: 0; }
  .entry__date { text-align: left; display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
  .entry__day, .entry__year { display: inline; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav__item--next { text-align: left; }
  .prose pre { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); border-radius: 0; border-left: 0; border-right: 0; }
}

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