:root {
  color-scheme: light;
  --ink: #1d2a2f;
  --muted: #61717a;
  --paper: #fffdf8;
  --blue: #2f6f9f;
  --teal: #2a8f82;
  --gold: #d49b39;
  --coral: #c66f62;
  --cream: #f7efe2;
  --shadow: 0 22px 60px rgb(37 53 58 / 14%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgb(223 238 231 / 80%), transparent 30rem),
    radial-gradient(
      circle at 92% 6%,
      rgb(247 239 226 / 96%),
      transparent 32rem
    ),
    var(--paper);
  color: var(--ink);
  font:
    18px/1.58 ui-serif,
    "Iowan Old Style",
    "Palatino Linotype",
    Palatino,
    Georgia,
    serif;
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.site-home {
  color: var(--blue);
  display: inline-block;
  font:
    800 0.9rem/1.2 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  margin-top: 28px;
  text-decoration: none;
}

code {
  border: 1px solid rgb(47 111 159 / 18%);
  border-radius: 6px;
  background: rgb(47 111 159 / 8%);
  padding: 0.08rem 0.3rem;
  font:
    0.88em/1.35 ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
}

.hero {
  min-height: 92vh;
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(390px, 1.06fr);
  gap: 52px;
  align-items: center;
  padding: 54px 0 24px;
}

.hero-copy {
  max-width: 620px;
  min-width: 0;
}

.eyebrow {
  color: var(--teal);
  font:
    700 0.78rem/1.2 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  letter-spacing: 0.08em;
  margin: 0 0 18px;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3.4rem, 6.3vw, 6.4rem);
  line-height: 0.92;
  margin: 0;
}

h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
  margin: 0 0 24px;
}

h3 {
  font-size: 1.25rem;
  line-height: 1.1;
  margin: 0 0 14px;
}

.dek {
  color: var(--muted);
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  line-height: 1.44;
  margin: 32px 0 0;
}

.hero-figure,
.panel {
  margin: 0;
  min-width: 0;
}

.hero-figure img,
.image-panel img {
  display: block;
  width: 100%;
  height: auto;
}

.hero-figure img {
  border-radius: 24px;
  box-shadow: 0 18px 50px rgb(37 53 58 / 10%);
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  border-block: 1px solid rgb(30 42 47 / 10%);
  padding: 22px 0;
  margin-bottom: 76px;
}

.toc a {
  border: 1px solid rgb(42 143 130 / 22%);
  border-radius: 999px;
  color: var(--blue);
  font:
    700 0.9rem/1.2 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  padding: 0.7rem 1rem;
  text-decoration: none;
}

.intro,
.closing {
  width: min(800px, 100%);
  margin: 0 auto 92px;
  color: #314047;
  font-size: clamp(1.22rem, 2vw, 1.5rem);
}

.chapter {
  display: grid;
  grid-template-columns: 88px minmax(300px, 0.84fr) minmax(380px, 1.16fr);
  gap: 36px;
  align-items: center;
  margin: 0 0 112px;
}

.chapter.reverse {
  grid-template-columns: 88px minmax(380px, 1.16fr) minmax(300px, 0.84fr);
}

.chapter.reverse .chapter-copy {
  grid-column: 3;
}

.chapter.reverse .panel {
  grid-column: 2;
  grid-row: 1;
}

.chapter-number {
  align-self: start;
  color: var(--coral);
  font:
    800 1rem/1 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  letter-spacing: 0.12em;
  margin-top: 10px;
}

.chapter-copy {
  min-width: 0;
}

.chapter-copy p,
.closing p {
  color: #314047;
  margin: 0 0 18px;
}

.image-panel {
  border: 1px solid rgb(30 42 47 / 10%);
  border-radius: 24px;
  background: rgb(255 255 255 / 66%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.code-card {
  border: 1px solid rgb(30 42 47 / 10%);
  border-radius: 22px;
  background: rgb(255 255 255 / 72%);
  box-shadow: var(--shadow);
  padding: 28px;
}

.code-card ul {
  margin: 0;
  padding-left: 1.1rem;
}

.code-card li {
  color: #314047;
  margin: 0 0 12px;
}

.strip {
  border-block: 1px solid rgb(30 42 47 / 10%);
  margin: 0 0 112px;
  padding: 62px 0;
}

.strip h2 {
  max-width: 760px;
}

.loop {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.loop div {
  border: 1px solid rgb(30 42 47 / 10%);
  border-radius: 18px;
  background: rgb(255 255 255 / 68%);
  padding: 22px;
}

.loop span {
  color: var(--coral);
  display: block;
  font:
    800 0.8rem/1 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  margin-bottom: 18px;
}

.loop strong {
  display: block;
  font:
    800 1.15rem/1.2 ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    sans-serif;
  margin-bottom: 10px;
}

.loop p {
  color: var(--muted);
  font-size: 0.98rem;
  margin: 0;
}

.closing {
  padding-bottom: 110px;
}

@media (max-width: 900px) {
  .hero,
  .chapter,
  .chapter.reverse {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 0;
    padding-top: 42px;
  }

  .chapter,
  .chapter.reverse {
    gap: 20px;
    margin-bottom: 82px;
  }

  .chapter.reverse .chapter-copy,
  .chapter.reverse .panel {
    grid-column: auto;
    grid-row: auto;
  }

  .chapter-number {
    margin: 0;
  }

  .loop {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  main {
    width: min(100% - 28px, 720px);
  }

  h1 {
    font-size: clamp(3rem, 16vw, 4.7rem);
  }

  .toc {
    justify-content: flex-start;
  }

  .loop {
    grid-template-columns: 1fr;
  }
}

/* Shared dark step strip treatment. */
.strip {
  background:
    linear-gradient(135deg, rgb(16 33 63 / 96%), rgb(34 92 116 / 94%)),
    var(--ink);
  border-radius: 30px;
  color: white;
  margin: 78px 0;
  padding: 40px;
}

.strip h2 {
  color: white;
  max-width: 820px;
}

.loop {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 28px;
}

.loop div {
  background: rgb(255 255 255 / 10%);
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 20px;
  padding: 18px;
}

.loop span {
  align-items: center;
  background: var(--gold);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.86rem;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  margin-bottom: 16px;
  width: 28px;
}

.loop strong {
  color: white;
  display: block;
  font-size: 1.14rem;
  margin-bottom: 10px;
}

.loop p {
  color: rgb(255 255 255 / 78%);
  font-size: 0.96rem;
  margin: 0;
}

@media (max-width: 900px) {
  .loop {
    grid-template-columns: 1fr;
  }

  .strip {
    padding: 26px;
  }
}
