:root {
  --bg: #fff; --fg: #111; --muted: rgba(0,0,0,.6); --line: rgba(0,0,0,.12);
  --card: rgba(0,0,0,.03); --glass: rgba(255,255,255,.75); --glow: rgba(0,0,0,.18);
  --crest: rgba(0,0,0,.3);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000; --fg: #f5f5f5; --muted: rgba(255,255,255,.62); --line: rgba(255,255,255,.2);
  --card: rgba(255,255,255,.05); --glass: rgba(0,0,0,.55); --glow: rgba(255,255,255,.22);
  --crest: rgba(255,255,255,.8);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 1.0625rem/1.65 "Atkinson Hyperlegible", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; transition: background .3s, color .3s;
}
a { color: inherit; }
.wrap { max-width: 56rem; margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--muted); }

/* Sky (stars in dark, drifting particles in light) */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.sky canvas { width: 100%; height: 100%; display: block; }

/* Header */
header {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  border-bottom: 1px solid transparent; transition: all .3s ease;
}
header.scrolled { background: var(--glass); border-color: var(--line); backdrop-filter: blur(8px) saturate(2); }
.bar { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; }
.brand { font-weight: 700; text-decoration: none; white-space: nowrap; }
nav { display: flex; align-items: center; gap: 1.1rem; }
nav a { text-decoration: none; color: var(--muted); font-size: .95rem; transition: color .2s; }
nav a:hover { color: var(--fg); }
#theme {
  display: grid; place-items: center; width: 2.1rem; height: 2.1rem; cursor: pointer;
  color: var(--fg); background: transparent; border: 1px solid var(--line); border-radius: 50%;
}
#theme:hover { background: var(--card); }
:root[data-theme="dark"] .i-moon, :root:not([data-theme="dark"]) .i-sun { display: none; }

/* Hero */
main { position: relative; z-index: 1; }
.hero { position: relative; min-height: 100svh; display: grid; place-items: center; text-align: center; overflow: hidden; padding: 5rem 1.25rem 3rem; }
.horizon { position: absolute; inset: 38% 0 0; overflow: hidden; }
.planet {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  width: 250vw; aspect-ratio: 1; border-radius: 50%;
  background: var(--bg); border-top: 1px solid var(--crest);
  box-shadow: 0 -2px 60px -10px var(--glow), inset 0 24px 80px -40px var(--glow);
  animation: rise 1.6s cubic-bezier(.2,.7,.2,1) both;
}
.hero-text { position: relative; width: 100%; }
.eyebrow { margin: 0; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-size: .85rem; }
h1 { margin: .2rem 0 .6rem; font-size: clamp(1.25rem, 6.6vw, 4.5rem); line-height: 1.05; letter-spacing: -.02em; white-space: nowrap; }
.lede { font-size: 1.2rem; color: var(--muted); margin: 0 auto 1.6rem; max-width: 32rem; }
.cta { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: .6rem 1.2rem; border-radius: 999px; text-decoration: none; font-weight: 700;
  background: var(--fg); color: var(--bg); border: 1px solid var(--fg); transition: transform .2s, opacity .2s;
}
.btn:hover { transform: translateY(-2px); opacity: .88; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.scroll { position: absolute; bottom: 1.5rem; left: 50%; translate: -50% 0; text-decoration: none; color: var(--muted); animation: bob 2s ease-in-out infinite; }

/* Sections */
.content { background: var(--bg); position: relative; }
section.wrap { padding-top: 4rem; padding-bottom: 1rem; }
h2 { font-size: 1.9rem; margin: 0 0 1.2rem; letter-spacing: -.01em; }
h3 { margin: 0; font-size: 1.1rem; }
.subhead { margin: -.6rem 0 1rem; color: var(--muted); font-weight: 400; }
.prose p { margin: 0 0 1rem; color: var(--muted); max-width: 40rem; }
.stack { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 1.2rem 0 0; }
.stack li, .tags { font-size: .85rem; color: var(--muted); }
.stack li { border: 1px solid var(--line); border-radius: 999px; padding: .2rem .8rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; padding: 1.1rem 0; }
.timeline p { margin: .15rem 0 0; }
.when { color: var(--muted); font-size: .9rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.card { display: block; text-decoration: none; padding: 1.2rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--card); transition: transform .2s, border-color .2s; }
.card:hover { transform: translateY(-3px); border-color: var(--fg); }
.card p { margin: .4rem 0 0; color: var(--muted); }
.card .tags { font-size: .8rem; margin-top: .8rem; }
.arrow { display: inline-block; transition: transform .2s; }
.card:hover .arrow, .posts a:hover .arrow { transform: translateX(4px); }

.posts { list-style: none; margin: 0; padding: 0; }
.posts a { display: grid; grid-template-columns: 6rem 1fr auto; gap: 1rem; padding: .9rem 0; border-top: 1px solid var(--line); text-decoration: none; }
.posts a:hover .title { text-decoration: underline; }
.journal { display: block; color: var(--muted); font-size: .9rem; font-style: italic; }
.date { color: var(--muted); font-size: .9rem; }

.socials { display: flex; gap: 1.2rem; }
.socials a { color: var(--muted); }
.socials a:hover { color: var(--fg); }
footer { position: relative; z-index: 1; background: var(--bg); margin-top: 4rem; padding: 2rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* Entrance animation */
.animate { opacity: 0; transform: translateY(14px); transition: opacity .7s ease, transform .7s ease; }
.animate.in { opacity: 1; transform: none; }
@keyframes rise { from { transform: translate(-50%, 30%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes bob { 50% { transform: translateY(6px); } }

@media (max-width: 640px) {
  nav a { display: none; }
  .timeline li { grid-template-columns: 1fr; gap: .2rem; }
  .posts a { grid-template-columns: 1fr auto; }
  .date { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .animate { opacity: 1; transform: none; transition: none; }
  .planet, .scroll { animation: none; }
}
