/* Aether — shared styles (v2) */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #efe7d9;
  --bg-2: #e6ddcf;
  --bg-3: #d8cdbd;
  --fg: #151722;
  --fg-2: #343234;
  --muted: #7b746c;
  --muted-2: #aaa095;
  --rule: #d4c9b8;
  --accent: #8f564b;
  --accent-soft: rgb(143 86 75 / 0.14);
  --do: #8f564b;
  --do-soft: rgb(143 86 75 / 0.14);
  --blue: #5c7478;
  --blue-soft: rgb(92 116 120 / 0.14);

  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --sans: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;

  --pad: clamp(20px, 4vw, 56px);
  --col: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-weight: 400;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

/* ---------- top bar (v3) ---------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 20px var(--pad);
  gap: 24px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.topbar .brand {
  display: flex; align-items: center; gap: 12px;
}
.topbar .brand img {
  height: 22px;
  width: auto;
  display: block;
}
.topbar nav {
  display: flex; gap: 4px; justify-content: flex-end;
  align-items: center;
}
.topbar nav a {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--fg-2);
  padding: 8px 14px;
  border-radius: 999px;
  transition: background 140ms, color 140ms;
}
.topbar nav a:hover { color: var(--fg); background: var(--bg-2); }
.topbar nav a.active {
  background: var(--fg);
  color: var(--bg);
}
.topbar .end {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar .end .dot {
  width: 6px; height: 6px; border-radius: 999px; background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.topbar .end .contact-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--fg); color: var(--bg);
  padding: 8px 14px; border-radius: 999px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  letter-spacing: 0; text-transform: none;
  transition: opacity 140ms;
}
.topbar .end .contact-pill:hover { opacity: 0.85; color: var(--bg); }

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .topbar .brand img {
    height: 18px;
  }
  .topbar nav {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 2px;
  }
  .topbar nav a {
    font-size: 13px;
    padding: 7px 10px;
  }
}

/* ---------- generic ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--pad);
}
.prose {
  max-width: var(--col);
  margin: 0 auto;
}
.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3 { font-family: var(--sans); font-weight: 500; letter-spacing: -0.015em; }
h2 { font-size: clamp(28px, 3.2vw, 36px); line-height: 1.18; margin: 0 0 12px; }
h3 { font-size: 20px; line-height: 1.28; margin: 0 0 8px; }

p { margin: 0 0 18px; text-wrap: pretty; }
em { font-style: italic; }

hr.rule { border: 0; border-top: 1px solid var(--rule); margin: 64px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.btn:hover { background: var(--bg); color: var(--fg); }
.btn.ghost { background: transparent; color: var(--fg); }
.btn.ghost:hover { background: var(--fg); color: var(--bg); }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--rule);
  margin-top: 96px;
  padding: 32px var(--pad);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}
.footer .brand-mini {
  display: flex; align-items: center; gap: 8px;
}
.footer .brand-mini img { height: 16px; opacity: 0.7; }
.footer .links { display: flex; gap: 24px; flex-wrap: wrap; }
.footer .links a:hover { color: var(--fg); }

/* ============================================
   ARTICLE PAGE
   ============================================ */
.article-head {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) var(--pad) clamp(28px, 4vw, 48px);
}
.article-head .crumb {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 32px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.article-head .crumb a { color: var(--muted); }
.article-head .crumb a:hover { color: var(--fg); }
.article-head .crumb .sep { color: var(--rule); }
.article-head h1 {
  font-family: var(--sans);
  font-size: clamp(34px, 4.4vw, 54px);
  line-height: 1.08;
  letter-spacing: -0.018em;
  font-weight: 500;
  margin: 0 0 18px;
  max-width: none;
  text-wrap: pretty;
}
.article-head .lede {
  font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.45;
  color: var(--fg-2);
  margin: 0 0 28px;
  max-width: 76ch;
  text-wrap: pretty;
}
.article-head .meta-row {
  display: flex; gap: 24px; flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.article-head .meta-row .k { color: var(--muted-2); margin-right: 8px; }
.article-head .meta-row .v { color: var(--fg-2); }

.article-cover {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--pad);
}
.article-cover .panel {
  aspect-ratio: 21/10;
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
}
.article-cover .panel.fit-diagram {
  aspect-ratio: 1672/941;
}
.article-cover .panel svg { width: 100%; height: 100%; display: block; }
.article-cover .panel img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.article-cover .panel.fit-diagram > img {
  object-fit: contain;
}

.article-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 72px) var(--pad) clamp(48px, 8vw, 96px);
  display: grid;
  grid-template-columns: minmax(0, 720px);
  justify-content: center;
  gap: 48px;
}
@media (min-width: 1120px) {
  .article-shell {
    grid-template-columns: 220px minmax(0, 720px);
    justify-content: start;
    gap: 64px;
  }
}
.article-toc {
  display: none;
}
@media (min-width: 1120px) {
  .article-toc {
    display: block;
    position: sticky;
    top: 28px;
    align-self: start;
    max-height: calc(100vh - 56px);
    overflow: auto;
    padding-right: 8px;
  }
}
.article-toc .toc-title {
  display: block;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.article-toc a {
  display: block;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.45;
  text-transform: uppercase;
  color: var(--muted);
}
.article-toc a:hover { color: var(--fg); }
.article {
  font-size: 17.5px;
  line-height: 1.65;
  color: var(--fg);
}
.article h2 { scroll-margin-top: 28px; }
.article h2 {
  font-family: var(--sans);
  font-size: clamp(24px, 2.8vw, 32px);
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.2;
  margin: 56px 0 18px;
  text-wrap: balance;
}
.article h2:first-of-type { margin-top: 0; }
.article h2 .num {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-right: 14px;
  font-weight: 400;
  display: inline-block;
  transform: translateY(-3px);
}
.article h3 { scroll-margin-top: 28px; }
.article h3 {
  font-family: var(--sans);
  font-size: clamp(22px, 2.4vw, 26px);
  font-weight: 500;
  letter-spacing: -0.014em;
  line-height: 1.22;
  margin: 44px 0 14px;
  text-wrap: balance;
}
.article h4 { scroll-margin-top: 28px; }
.article h4 {
  font-family: var(--sans);
  font-size: clamp(18px, 1.9vw, 20px);
  font-weight: 500;
  letter-spacing: -0.008em;
  line-height: 1.3;
  margin: 30px 0 10px;
  color: var(--fg);
  text-wrap: balance;
}
.article p {
  margin: 0 0 20px;
  color: var(--fg);
  text-wrap: pretty;
}
.article ul {
  margin: 0 0 22px;
  padding-left: 1.25em;
  color: var(--fg);
}
.article li { margin-bottom: 8px; }
.article p.muted { color: var(--fg-2); }
.article em { font-style: italic; }
.article strong { font-weight: 600; }
.article figure {
  margin: 36px 0;
}
.article figure img {
  width: 100%;
  display: block;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg-2);
  box-shadow: 0 14px 40px rgb(21 23 34 / 0.06);
}
.article figcaption {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.article .math {
  margin: 24px 0;
  padding: 18px 20px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.34);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: normal;
}
.article .math mjx-container { margin: 0 !important; }
.article .pull {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(20px, 2.2vw, 26px);
  line-height: 1.3;
  letter-spacing: -0.012em;
  margin: 36px 0;
  border-left: 2px solid var(--fg);
  padding-left: 22px;
  color: var(--fg);
  text-wrap: balance;
}
.article .refs,
.article ol.refs {
  margin-top: 72px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
}
.article .refs h3 {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 18px;
  font-weight: 400;
}
.article .refs ol,
.article ol.refs {
  margin: 0; padding: 0;
  list-style: none;
  counter-reset: ref;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg-2);
}
.article .refs li,
.article ol.refs li {
  padding: 8px 0 8px 38px;
  position: relative;
  border-bottom: 1px solid var(--rule);
  counter-increment: ref;
}
.article .refs li:last-child,
.article ol.refs li:last-child { border-bottom: 0; }
.article .refs li::before,
.article ol.refs li::before {
  content: "[" counter(ref) "]";
  position: absolute;
  left: 0;
  top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* article footer with prev/next */
.article-nav {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--pad);
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  border-top: 1px solid var(--rule);
  padding-top: 32px;
  padding-bottom: 24px;
}
@media (min-width: 720px) {
  .article-nav { grid-template-columns: 1fr 1fr; gap: 20px; }
}
.article-nav .nav-card {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--rule);
  background: var(--bg-2);
  padding: 22px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms;
}
.article-nav .nav-card:hover { background: var(--bg); }
.article-nav .nav-card .dir {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.article-nav .nav-card .ttl {
  font-family: var(--sans); font-weight: 500; font-size: 18px; line-height: 1.3; letter-spacing: -0.015em;
}
.article-nav .nav-card.next { text-align: right; }
.article-nav .nav-card.disabled { opacity: 0.4; pointer-events: none; }
