/* projects.spacecan.club — engineering-notebook style. Light by default, dark on request. */
:root {
  color-scheme: light;
  --page: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1f0eb;
  --ink: #15171b;
  --ink-2: #4a4c52;
  --muted: #74767c;
  --line: #e2e0d8;
  --line-strong: #cfccc2;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e6effb;
  --good: #0a7a0a;
  --bad: #b3261e;
  --code-bg: #f1f0eb;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 8px 28px rgba(20, 20, 20, .06);
  --radius: 14px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e1116; --surface: #151a21; --surface-2: #1b2129;
    --ink: #eef0f3; --ink-2: #b8bec8; --muted: #8b939f;
    --line: #262d37; --line-strong: #343c48;
    --accent: #5b9ef0; --accent-ink: #86b6ef; --accent-soft: rgba(91, 158, 240, .14);
    --good: #3cc23c; --bad: #f2827a; --code-bg: #1b2129;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1116; --surface: #151a21; --surface-2: #1b2129;
  --ink: #eef0f3; --ink-2: #b8bec8; --muted: #8b939f;
  --line: #262d37; --line-strong: #343c48;
  --accent: #5b9ef0; --accent-ink: #86b6ef; --accent-soft: rgba(91, 158, 240, .14);
  --good: #3cc23c; --bad: #f2827a; --code-bg: #1b2129;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 16.5px/1.65 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
img { max-width: 100%; height: auto; display: block; }
code, kbd, pre { font-family: var(--mono); font-size: .88em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .38em; border-radius: 5px; border: 1px solid var(--line); overflow-wrap: anywhere; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; line-height: 1.5; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- header / footer ---------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 82%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head .in { max-width: 1160px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; letter-spacing: -.01em; }
.brand svg { width: 26px; height: 26px; }
.site-head nav { display: flex; gap: 4px; margin-left: auto; }
.site-head nav a { color: var(--ink-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14.5px; }
.site-head nav a:hover, .site-head nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.theme-btn { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; }
.theme-btn svg { width: 17px; height: 17px; }
.site-foot { border-top: 1px solid var(--line); margin-top: 72px; }
.site-foot .in { max-width: 1160px; margin: 0 auto; padding: 28px 24px 40px; display: flex; flex-wrap: wrap; gap: 8px 24px; color: var(--muted); font-size: 14px; }
.site-foot b { color: var(--ink-2); font-weight: 600; }

/* ---------- landing ---------- */
.hero { max-width: 1160px; margin: 0 auto; padding: 72px 24px 36px; position: relative; }
.hero .eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 14px; }
.hero h1 { font-size: clamp(42px, 7vw, 72px); line-height: 1.02; letter-spacing: -.035em; margin: 0 0 18px; font-weight: 750; }
.hero p.lede { font-size: clamp(18px, 2.2vw, 21px); color: var(--ink-2); max-width: 680px; margin: 0; line-height: 1.55; }
.hero-art { position: absolute; right: 24px; top: 40px; width: 300px; opacity: .9; pointer-events: none; }
.hero-art .orbit { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.hero-art .orbit.hi { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 7; }
.hero-art .body { fill: var(--ink); }
.hero-art .ship { fill: var(--accent); }
.hero-art .node { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.4; }
.hero-art .edge { stroke: var(--line-strong); stroke-width: 1; }
@media (max-width: 980px) { .hero-art { display: none; } }

.projects { max-width: 1160px; margin: 0 auto; padding: 8px 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.project {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.project:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.project .shot { background: #fff; border-bottom: 1px solid var(--line); aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; }
.project .shot img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.project .body { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.project .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.project h2 { margin: 0; font-size: 27px; letter-spacing: -.02em; line-height: 1.15; }
.project h2 a { color: var(--ink); text-decoration: none; }
.project h2 a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
.project { position: relative; }
.project .actions a, .project .actions { position: relative; z-index: 1; }
.project p { margin: 0; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 2px 0; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; line-height: 1.15; }
.stat span { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: block; margin-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--mono); font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); }
.chip { font-size: 12.5px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 10px; font-size: 14.5px; font-weight: 600;
  text-decoration: none; border: 1px solid var(--line-strong); color: var(--ink); background: var(--surface);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); color: #fff; }
.about { max-width: 1160px; margin: 40px auto 0; padding: 0 24px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.about div { border-top: 2px solid var(--ink); padding-top: 14px; }
.about h3 { margin: 0 0 6px; font-size: 15px; }
.about p { margin: 0; color: var(--ink-2); font-size: 15px; }
@media (max-width: 880px) { .projects, .about { grid-template-columns: 1fr; } }

/* ---------- write-up pages ---------- */
.doc-head { max-width: 1160px; margin: 0 auto; padding: 56px 24px 28px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
.doc-head h1 { font-size: clamp(34px, 5.5vw, 54px); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 14px; }
.doc-head .lede { font-size: 19px; color: var(--ink-2); max-width: 760px; margin: 0 0 20px; }
.doc-head .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.doc-head .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 900px; margin-top: 26px; }
@media (max-width: 700px) { .doc-head .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.layout { max-width: 1160px; margin: 0 auto; padding: 0 24px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 48px; }
.toc { position: sticky; top: 84px; align-self: start; font-size: 14px; max-height: calc(100vh - 100px); overflow-y: auto; }
.toc p { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 8px 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--ink); }
.toc a.on { border-left-color: var(--accent); color: var(--ink); font-weight: 600; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } .toc { display: none; } }

article { min-width: 0; max-width: 780px; }
article h2 { font-size: 28px; letter-spacing: -.02em; line-height: 1.2; margin: 64px 0 14px; padding-top: 8px; }
article h2:first-child { margin-top: 8px; }
article h3 { font-size: 20px; letter-spacing: -.01em; margin: 36px 0 10px; }
article p, article li { color: var(--ink-2); }
article p strong, article li strong { color: var(--ink); }
article ul, article ol { padding-left: 22px; }
article li { margin: 6px 0; }
article li::marker { color: var(--muted); }
.callout { border: 1px solid var(--line); background: var(--surface); border-left: 3px solid var(--accent); border-radius: 10px; padding: 14px 18px; margin: 22px 0; }
.callout p { margin: 0; }
.callout.warn { border-left-color: #c98500; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.kpis .stat b { font-size: 26px; }
@media (max-width: 640px) { .kpis { grid-template-columns: 1fr; } }

figure { margin: 28px 0; }
figure .frame { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
figure.dark .frame { background: #1b1b1b; }
figure.wide { margin-left: -40px; margin-right: -40px; }
figure.narrow .frame { max-width: 520px; margin: 0 auto; }
figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
figcaption b { color: var(--ink-2); font-weight: 600; }
.fig-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 28px 0; }
.fig-pair figure { margin: 0; }
@media (max-width: 1100px) { figure.wide { margin-left: 0; margin-right: 0; } }
@media (max-width: 640px) { .fig-pair { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; margin: 22px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td code { font-size: .82em; }
td.ok { color: var(--good); font-weight: 600; }
td.fail { color: var(--bad); font-weight: 600; }
caption { caption-side: bottom; text-align: left; padding: 10px 14px; font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.two-col > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; }
.two-col h4 { margin: 0 0 4px; font-size: 15px; }
.two-col p { margin: 0; font-size: 15px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

.eq { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin: 16px 0; overflow-x: auto; }
.eq code.tex { display: block; white-space: pre-wrap; background: none; border: 0; padding: 0; }
.eq .katex-display { margin: 0; }
.katex { font-size: 1.08em; color: var(--ink); }

.repo-card { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin: 48px 0 0; box-shadow: var(--shadow); }
.repo-card div { min-width: 0; }
.repo-card b { display: block; font-family: var(--mono); font-size: 15px; }
.repo-card span { color: var(--muted); font-size: 14px; }
.next-proj { margin-top: 18px; font-size: 15px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .site-head .in, .hero, .projects, .about, .doc-head, .layout, .site-foot .in { padding-left: 16px; padding-right: 16px; }
  .site-head nav a.long { display: none; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat b { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .site-head, .toc, .theme-btn { display: none; } .layout { grid-template-columns: 1fr; } }

/* fixes */
.nb { white-space: nowrap; }
.project .shot { position: relative; }
.project .shot img { position: absolute; inset: 0; }
figure.dark .frame { background: #000; border-color: var(--line-strong); }
