:root {
  color-scheme: dark;
  --bg: #111113;
  --fg: #f7f4e9;
  --muted: #a1a0a6;
  --border: #38383c;
  --button-bg: #f7f4e9;
  --button-fg: #19191b;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --fg: #202024;
  --muted: #696970;
  --border: #d4d4da;
  --button-bg: #242428;
  --button-fg: #f5f5f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(1080px, calc(100% - 64px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 80px 0 96px;
  text-align: center;
}

.wordmark {
  display: block;
  width: min(800px, 100%);
  height: auto;
}

.intro {
  max-width: 540px;
  margin-top: clamp(36px, 5vw, 64px);
}

h1 {
  margin: 0 0 15px;
  font-size: clamp(23px, 2.5vw, 28px);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -.65px;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: -.15px;
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 30px;
}

.meta {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: -.1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: var(--muted);
  background: #8888880c;
}

.btn.primary {
  border-color: var(--button-bg);
  background: var(--button-bg);
  color: var(--button-fg);
}

.btn.primary:hover {
  filter: brightness(.92);
}

.btn:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 5px;
}

@media (max-width: 540px) {
  .hero {
    width: calc(100% - 40px);
    padding: 64px 0 80px;
  }

  .intro {
    max-width: 340px;
    margin-top: 40px;
  }

  .tagline {
    font-size: 16px;
  }

  .btn {
    padding-inline: 21px;
  }
}

/* Chapters: a full-bleed screenshot, then a numbered heading and body in a
   left-aligned column. The screenshot is the section break. */
.feature {
  padding: clamp(56px, 7vw, 96px) 0;
}

/* Screenshots sit in mac-style windows tinted to their own chrome. */
:root {
  --window-bar: #1a1a1f;
  --window-bg: #1a1a1f;
  --window-edge: #ffffff14;
}

.window.haze {
  --window-bar: #35373a;
  --window-bg: #35373b;
}

.chapter .window {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: clamp(32px, 4vw, 56px) 0 0;
  container-type: inline-size;
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--window-edge), 0 30px 60px -20px #000000a6, 0 10px 20px -10px #00000080;
  overflow: hidden;
}

.window-bar {
  display: flex;
  align-items: center;
  gap: max(.66cqw, 4px);
  height: max(2.3cqw, 14px);
  padding: 0 max(1.05cqw, 7px);
  background: var(--window-bar);
}

.dot {
  flex: none;
  width: max(.98cqw, 6px);
  height: max(.98cqw, 6px);
  border-radius: 50%;
  box-shadow: inset 0 0 0 .5px #0005;
}

.dot.close { background: #ff5f57; }
.dot.min   { background: #febc2e; }
.dot.max   { background: #28c840; }

.window-title {
  margin-left: max(.7cqw, 4px);
  color: #dcdbe0;
  font-size: max(1.06cqw, 7px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: nowrap;
  pointer-events: none;
}

.window img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--window-bg);
}

.chapter .window {
  transition: transform .25s ease, box-shadow .25s ease;
}

.chapter .window:has(.zoom:hover),
.chapter .window:has(.zoom:focus-visible) {
  transform: translateY(-2px);
}

.chapter {
  width: min(1180px, calc(100% - 64px));
  margin: 0 auto;
}

.chapter-head {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: start;
  column-gap: 12px;
}

.index {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 96px;
  margin-top: -4px;
  color: var(--muted);
}

.index canvas.glyph {
  display: block;
  width: 96px;
  height: 96px;
}

.index-num {
  margin-top: 2px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .08em;
}

/* Without WebGL the number stands in for the glyph at glyph size. */
.index:not(.has-glyph) .index-num {
  height: 96px;
  line-height: 96px;
  font-size: 16px;
}

.chapter-head h2 {
  margin: 0;
  font-size: clamp(40px, 5.6vw, 76px);
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.chapter-body {
  max-width: 1180px;
  margin-top: clamp(24px, 3vw, 36px);
}

.chapter .window + .chapter-body {
  margin-top: clamp(32px, 4vw, 56px);
}

.caption {
  max-width: 900px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.2vw, 16px);
  line-height: 1.5;
  letter-spacing: -.005em;
  text-wrap: pretty;
}

.caption em {
  color: var(--fg);
  font-style: normal;
  font-weight: 500;
}

.chapter-body p {
  margin: 0 0 1.1em;
  font-size: clamp(18px, 1.7vw, 24px);
  line-height: 1.4;
  letter-spacing: -.012em;
  text-wrap: pretty;
}

.chapter-body p:last-child {
  margin-bottom: 0;
}

.chapter-body code {
  padding: .08em .35em;
  border-radius: 4px;
  background: #8888881f;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: .88em;
}

.chapter-body em {
  font-style: normal;
  font-weight: 600;
}

/* Clickable screenshots */
.zoom {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}

.zoom:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
}

/* Pixel-reveal overlay drawn by landing.js. */
.zoom canvas.pixelate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Full-bleed band: a chapter on its own brighter ground. The screenshot sits
   at its top edge, so the colour starts where the image ends. */
.band {
  --fg: #1c1d21;
  --muted: #55575f;
  --window-edge: #00000022;
  background: var(--band-bg, #d5d8de);
  color: var(--fg);
}

.band .chapter .window {
  box-shadow: 0 0 0 1px var(--window-edge), 0 30px 60px -20px #00000073, 0 10px 20px -10px #00000059;
}

.band-generative {
  --band-bg: #d5d8de;
}

.band .chapter-body code {
  background: #00000014;
}

/* Code card: the Lisp behind a feature, ray.so-style. */
:root {
  --code-bg: #16161a;
  --code-fg: #e6e3d8;
  --code-comment: #7d7c84;
  --code-string: #a8d08d;
  --code-keyword: #c792ea;
  --code-form: #c792ea;
  --code-name: #ffd479;
  --code-call: #82aaff;
  --code-number: #f78c6c;
  --code-paren: #8d8c94;
}

.code-card {
  width: 100%;
  max-width: 860px;
  margin: clamp(28px, 3.5vw, 44px) 0 0;
}

.code-frame {
  border-radius: 10px;
  background: var(--code-bg);
  box-shadow: 0 0 0 1px #ffffff14, 0 30px 60px -20px #000000b3, 0 10px 20px -10px #00000080;
  overflow: hidden;
}

.code-bar {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  background: #1c1c21;
  color: #8d8c94;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 500;
}

.code {
  margin: 0;
  padding: 22px 26px 26px;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--code-fg);
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 2;
}

.code .c  { color: var(--code-comment); font-style: italic; }
.code .s  { color: var(--code-string); }
.code .k  { color: var(--code-keyword); }
.code .f  { color: var(--code-form); font-weight: 600; }
.code .d  { color: var(--code-name); }
.code .fn { color: var(--code-call); }
.code .n  { color: var(--code-number); }
.code .p  { color: var(--code-paren); }

/* Code card in the Haze editor theme (ui/themes/mac-osx-haze.lisp):
   buffer-bg ground, syn-* slots for the tokens, window chrome for the bar. */
.band .code-frame {
  --code-bg: #3c3e42;
  --code-fg: #e6ebf0;
  --code-comment: #858c94;
  --code-string: #57ad8a;
  --code-keyword: #9e85d6;
  --code-form: #4085db;
  --code-name: #e6ebf0;
  --code-call: #4085db;
  --code-number: #d19447;
  --code-paren: #7a828a;
  box-shadow: 0 0 0 1px #00000033, 0 30px 60px -20px #00000073, 0 10px 20px -10px #00000059;
}

.band .code-bar {
  background: #35373a;
  color: #a3abb3;
}

/* Lightbox: the screenshot alone, fitted to the viewport. */
.lightbox {
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.lightbox::backdrop {
  background: #0c0c0ec7;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.lightbox .window {
  --ar: 1.5;
  display: flex;
  flex-direction: column;
  width: min(92vw, 1500px, calc((100vh - 96px) / (1 / var(--ar) + .023)));
  container-type: inline-size;
  border-radius: 8px;
  box-shadow: 0 0 0 1px #ffffff1f, 0 50px 100px -20px #000000d9, 0 20px 40px -20px #000000b3;
  overflow: hidden;
}

.lightbox-image {
  cursor: default;
}

.lightbox[open] .window {
  animation: lightbox-in .22s cubic-bezier(.2, .8, .2, 1);
}

@keyframes lightbox-in {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: none; }
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #ffffff1f;
  border-radius: 50%;
  background: #1a1a1ecc;
  color: #f7f4e9;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-close:hover {
  background: #2a2a2f;
}

.lightbox-close:focus-visible {
  outline: 2px solid #f7f4e9;
  outline-offset: 3px;
}

@media (max-width: 760px) {
  .chapter {
    width: calc(100% - 40px);
  }

  .chapter-head {
    grid-template-columns: 1fr;
    row-gap: 14px;
  }

  .index {
    margin-top: 0;
  }

  .code {
    padding: 16px 18px 20px;
    font-size: 12px;
  }

  .code-bar {
    height: 32px;
    padding: 0 12px;
  }

  .lightbox .window {
    width: min(calc(100vw - 24px), calc((100vh - 96px) / (1 / var(--ar) + .023)));
  }

  .lightbox-close {
    top: 12px;
    right: 12px;
  }
}
