:root {
  --bg: #0b0d12;
  --bg2: #10131a;
  --fg: #e9e7e1;
  --muted: #9a9890;
  --line: #23262e;
  --accent: #9ec1ff;
  --accent2: #f3c56b;
  --card: #141821;
  --max: 820px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f5f0;
  --bg2: #ffffff;
  --fg: #1a1a19;
  --muted: #6b6a66;
  --line: #e3e0d8;
  --accent: #1f4ed8;
  --accent2: #b4760a;
  --card: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  padding: 0 20px;
  transition: background 0.3s, color 0.3s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; }

/* ---- sky canvas behind the hero ---- */
body { position: relative; }
.skywrap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
#sky { width: 100%; height: 100%; display: block; }
.skywrap::after {
  /* fades the sky into the page background below the hero */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 45%, var(--bg) 100%);
}

.top {
  max-width: var(--max);
  margin: 0 auto;
  padding: 26px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.top .name { color: var(--fg); font-weight: 600; white-space: nowrap; }
.top nav { display: flex; gap: 18px; font-size: 15px; align-items: center; }
.top nav a { color: var(--fg); opacity: 0.75; }
.top nav a:hover { opacity: 1; text-decoration: none; }
#theme {
  background: transparent; border: 1px solid var(--line); color: var(--fg); opacity: 0.8;
  border-radius: 999px; width: 30px; height: 30px; cursor: pointer; line-height: 1;
}
#theme:hover { color: var(--fg); border-color: var(--muted); }

main { max-width: var(--max); margin: 0 auto; }
section { padding: 64px 0 8px; }
section + section { border-top: 1px solid var(--line); margin-top: 40px; }

h1, h3 {
  font-family: Newsreader, Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.12;
  margin: 0 0 18px;
}
h1 { font-size: 52px; max-width: 720px; text-wrap: balance; }
h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin: 0 0 28px;
}
h3 { font-size: 26px; margin-bottom: 6px; }
h3 .stack { display: block; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 6px; letter-spacing: 0; }

.hero { min-height: 78vh; display: flex; flex-direction: column; justify-content: center; padding-top: 40px; }
.eyebrow { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.lede { font-size: 19px; max-width: 640px; }
.links a { margin-right: 18px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 28px; }
p { margin: 0 0 14px; }
.intro { max-width: 680px; }

/* ---- scroll reveal ---- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---- work ---- */
.entry { display: grid; grid-template-columns: 210px 1fr; gap: 28px; padding: 22px 0 10px; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry .meta { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: var(--muted); }
.entry .org { color: var(--fg); font-weight: 600; font-size: 16px; }
.entry .body p { margin-bottom: 10px; }

/* ---- simulation ---- */
.sim {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 8px 0 24px;
}
.sim-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.pol {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px;
}
.pol:hover { color: var(--fg); }
.pol.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.load { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.load input { width: 120px; accent-color: var(--accent); }
.load output { font-family: "JetBrains Mono", ui-monospace, monospace; min-width: 52px; }
#simcanvas { width: 100%; height: auto; display: block; border-radius: 8px; background: var(--bg2); }
.sim-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.sim-stats div { display: flex; flex-direction: column; gap: 2px; }
.sim-stats .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sim-stats .v { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 20px; }
.sim-note { font-size: 14px; color: var(--muted); margin: 12px 0 0; }

/* ---- projects ---- */
.project { margin: 0 0 56px; }
.project .shot {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  margin-bottom: 18px;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.project .shot:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(0,0,0,0.35); }
.project .shot img { aspect-ratio: 16 / 9; object-fit: cover; }
.project .text p { max-width: 700px; }

#about p { max-width: 700px; }

footer {
  max-width: var(--max);
  margin: 48px auto 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 680px) {
  h1 { font-size: 34px; }
  .lede { font-size: 17px; }
  .hero { min-height: 70vh; }
  .entry { grid-template-columns: 1fr; gap: 8px; }
  .top nav { gap: 12px; font-size: 14px; }
  .top nav a:nth-child(2) { display: none; }
  .sim-stats { grid-template-columns: repeat(2, 1fr); }
  .load { margin-left: 0; width: 100%; }
  footer { flex-direction: column; }
  section { padding-top: 44px; }
}
