/* =======================
   Base
   ======================= */
:root {
  --fg: #111;
  --muted: #444;
  --link: #111;
  --maxw: 960px;
  --line: #ddd;
}

html {
  box-sizing: border-box;
  font-size: 20px;
  background: #fff;
  color: var(--fg);
}
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  font: 20px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--link); text-decoration: underline; }
a:hover { text-decoration: none; }

img, video { max-width: 100%; height: auto; }

main { max-width: var(--maxw); margin: 48px auto 80px; padding: 0 16px; }
header, footer { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
footer { margin-top: 48px; color: var(--muted); font-size: 14px; }

/* Global headings baseline (applies to all unless overridden per page) */
h1 { font-size: 42px; line-height: 1.2; margin: 0 0 8px; font-weight: 700; }
h2 { font-size: 26px; margin: 0 0 12px; } /* Will be the same as home; chapter overrides below */

/* Utility */
.kicker { font-size: .6em; font-weight: 700; white-space: nowrap; }
.mb-50 { margin-bottom: 50px !important; }


/* =======================
   Home (index) page
   ======================= */
body.home main { max-width: var(--maxw); }
body.home h1 { /* keep previous homepage h1; using global 42px unless you had a different size */ }
body.home h2 { font-size: 26px; margin: 0 0 12px; } /* preserve inline look */
body.home .chapters { display: flex; gap: 40px; align-items: flex-start; }
body.home .chapters ol { flex: 1; padding-left: 22px; margin: 0; }
body.home .chapters li { margin: 6px 0; }

/* CTA section for homepage */
body.home .cta { text-align: center; padding: 24px 0 0; }
body.home .btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--fg);
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
  line-height: 1.5;
  font-weight: 600;
  background: transparent;
}
body.home .btn:hover { background: #f7f7f7; }
body.home .cta small { display: block; margin-top: 8px; color: var(--muted); }


/* =======================
   Chapter subpages
   ======================= */
body.chapter { --maxw: 1040px; }
body.chapter main { max-width: var(--maxw); margin: 40px auto 80px; padding: 0 16px; }
body.chapter header { 
  padding-left: 0;
  padding-right: 0;
  margin-bottom: 18px; }
body.chapter .crumbs { font-size: 20px; color: var(--muted); }
body.chapter .crumbs a { color: var(--muted); }
body.chapter h1 { font-size: 36px; line-height: 1.2; margin: 8px 0 10px; }
body.chapter .wrap {
  display: grid;
  grid-template-columns: 1fr 220px; /* same as before */
  gap: 0px;
  align-items: start;
}

/* Force the content column to span the full width of main, minus the sidebar */
body.chapter .content {
  padding-right: 40px; /* add space only on the right, before the sidebar
  padding-left: 0;    /* remove any padding */
  margin-left: 0;     /* remove any margin */
}



body.chapter .content p { margin: 0 0 14px; }
body.chapter .content hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

/* right side nav */
body.chapter aside { position: sticky; top: 20px; }
body.chapter .navbox { border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
body.chapter .navbox h2 { font-size: 14px; margin: 0 0 10px; color: var(--muted); letter-spacing: .02em; }
body.chapter .navgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
body.chapter .navgrid a { display: inline-block; text-align: center; padding: 6px 0; border: 1px solid var(--line); border-radius: 4px; text-decoration: none; color: var(--fg); font-variant-numeric: tabular-nums; }
body.chapter .navgrid a:hover { background: #f7f7f7; }
body.chapter .navgrid a.active { border-color: #aaa; background: #f2f2f2; font-weight: 600; }

/* footer + pager */
body.chapter footer { margin-top: 28px; color: var(--muted); font-size: 14px; }
body.chapter .pager { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
body.chapter .pager a { text-decoration: none; border: 1px solid var(--fg); border-radius: 4px; padding: 6px 10px; }
body.chapter .pager a:hover { background: #f7f7f7; }

/* CTA section for homepage */
body.chapter .cta { text-align: center; padding: 24px 0 0; }
body.chapter .btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--fg);
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
  line-height: 1.5;
  font-weight: 600;
  background: transparent;
}
body.chapter .btn:hover { background: #f7f7f7; }
body.chapter .cta small { display: block; margin-top: 8px; color: var(--muted); }


/* =======================
   Responsive
   ======================= */
@media (max-width: 768px) {
  body { font-size: 20px; }
  body.home .chapters { flex-direction: column; gap: 12px; }
  body.chapter .wrap { grid-template-columns: 1fr; }
  body.chapter aside { position: static; }
}

/* Site-wide fixed logo in the top-right corner */
.site-logo {
  position: fixed;
  top: 16px;
  right: 16px;
  display: block;
  z-index: 1000;
}

.site-logo img {
  /* Stop the global img { max-width:100% } from blowing it up on desktop */
  max-width: none;
  width: clamp(70px, 10vw, 120px);
  height: auto;
}

@media (max-width: 600px) {
  .site-logo { top: 12px; right: 12px; }
  .site-logo img { width: clamp(50px, 12vw, 80px); }
}
