/* Visual language borrowed from rndr.studio: Space Grotesk + Space Mono,
   black ink on white/light grey, flat pastel panels, generous whitespace. */

:root {
  --ink: #111;
  --ink-soft: #555;
  --paper: #fff;
  --grey: #f0f0f0;
  --pink: #fdd0dd;
  --cream: #fffdd7;
  --sky: #addbf5;
  --mint: #96efaa;
  --lilac: #d7b3d6;
  --yellow: #fef136;
  --coral: #fc6470;
  --blue: #3f88c5;
  --green: #2fa866;
  --dark: #222;

  --sans: "Space Grotesk", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
  --pad: clamp(1.25rem, 5vw, 6rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 4rem; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { background: var(--yellow); }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.1; margin: 0 0 1rem; }
h1 { font-size: clamp(2.5rem, 7vw, 5.5rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(2rem, 4.5vw, 3.5rem); letter-spacing: -0.01em; }
h3 { font-size: 1.6rem; margin-top: 3rem; }
h4 { font-size: 1.2rem; margin-top: 1.5rem; }
p { margin: 0 0 1rem; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.9em; }

/* ---------- header / navigation ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem var(--pad);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--ink);
  font-family: var(--mono); font-size: 0.85rem;
}
.logo { text-decoration: none; font-weight: 700; }
.nav-toggle {
  font: inherit; background: var(--ink); color: var(--paper);
  border: 0; padding: 0.4rem 0.9rem; cursor: pointer;
}
.toc {
  display: none;
  position: absolute; right: var(--pad); top: 100%;
  background: var(--paper); border: 1px solid var(--ink);
  padding: 0.75rem 0; min-width: 18rem; max-height: 80vh; overflow: auto;
}
.toc.open { display: block; }
.toc a { display: block; padding: 0.3rem 1.25rem; text-decoration: none; }
.toc a .n { display: inline-block; width: 2.2rem; color: var(--ink-soft); }
.toc a.active { background: var(--pink); }

/* ---------- hero ---------- */

.hero {
  min-height: 85vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 4rem var(--pad);
  background: var(--dark); color: var(--paper);
}
.hero h1 { font-family: var(--mono); font-weight: 400; letter-spacing: -0.03em; }
.kicker { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; }
.lede { font-size: clamp(1.25rem, 2.2vw, 1.75rem); max-width: 40rem; }
.hint { font-family: var(--mono); font-size: 0.85rem; opacity: 0.7; }

/* ---------- chapters ---------- */

.chapter { padding: 6rem var(--pad); border-top: 1px solid var(--ink); }
.chapter[data-bg="white"] { background: var(--paper); }
.chapter[data-bg="grey"] { background: var(--grey); }
.chapter[data-bg="pink"] { background: var(--pink); }
.chapter[data-bg="cream"] { background: var(--cream); }
.chapter[data-bg="sky"] { background: var(--sky); }
.chapter[data-bg="mint"] { background: var(--mint); }
.chapter[data-bg="dark"] { background: var(--dark); color: var(--paper); }
.chapter[data-bg="dark"] .demo { color: var(--ink); }

.chapter-num {
  font-family: var(--mono); font-size: 0.9rem;
  display: inline-block; border: 1px solid currentColor;
  padding: 0.1rem 0.6rem; margin-bottom: 1.5rem;
}

/* readable text column; demos may be wider */
.prose { max-width: 44rem; }
.prose p, .prose li { font-size: 1.2rem; }
.big-quote {
  font-family: var(--mono); font-size: clamp(1.4rem, 3vw, 2.2rem);
  line-height: 1.3; margin: 2rem 0; max-width: 50rem;
}

.two-col { display: grid; gap: 2rem 4rem; grid-template-columns: 1fr; }
@media (min-width: 1000px) {
  .two-col { grid-template-columns: 1fr 1fr; align-items: start; }
}

/* ---------- interactive demo panels ---------- */

.demo {
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 1.25rem;
  margin: 2rem 0 2.5rem;
  max-width: 64rem;
}
.demo-title {
  font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.06em; margin: -1.25rem -1.25rem 1rem; padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--ink); background: var(--grey);
  display: flex; justify-content: space-between; gap: 1rem;
}
.demo canvas, .demo svg { display: block; max-width: 100%; touch-action: none; }
.demo canvas.clickable, .demo canvas.drawable { cursor: crosshair; }

.controls {
  display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; align-items: center;
  margin: 1rem 0 0; font-family: var(--mono); font-size: 0.85rem;
}
.controls label { display: inline-flex; align-items: center; gap: 0.5rem; }
.controls output, .readout { font-family: var(--mono); font-weight: 700; }

.btn {
  font-family: var(--mono); font-size: 0.85rem;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); padding: 0.45rem 0.9rem; cursor: pointer;
}
.btn:hover { background: var(--pink); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--yellow); }
.btn.active { background: var(--yellow); color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; }

input[type="range"] { accent-color: var(--ink); width: 9rem; }
input[type="text"], textarea, select {
  font-family: var(--mono); font-size: 1rem;
  border: 1px solid var(--ink); padding: 0.5rem 0.7rem; background: var(--paper);
  width: 100%;
}
textarea { min-height: 8rem; resize: vertical; line-height: 1.4; }

/* "try this" instructions inside demos */
.try {
  background: var(--cream); border-left: 4px solid var(--ink);
  padding: 0.6rem 0.9rem; margin: 0 0 1rem; font-size: 1rem;
}
.try::before { content: "Try this: "; font-family: var(--mono); font-weight: 700; }

/* optional deeper explanation */
details.curious {
  border: 1px dashed currentColor; padding: 0.6rem 1rem; margin: 1.5rem 0; max-width: 44rem;
}
details.curious summary { cursor: pointer; font-family: var(--mono); font-size: 0.9rem; }
details.curious summary::before { content: "For the curious → "; }
details.curious[open] summary { margin-bottom: 0.75rem; }

.callout {
  border: 1px solid currentColor; padding: 1rem 1.25rem; margin: 2rem 0; max-width: 44rem;
  background: rgba(255, 255, 255, 0.5);
}

.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-family: var(--mono); font-size: 0.8rem; margin-top: 0.5rem; }
.legend span::before {
  content: ""; display: inline-block; width: 0.75rem; height: 0.75rem;
  margin-right: 0.35rem; vertical-align: -1px; background: var(--c, var(--ink)); border-radius: 50%;
}

.figure-caption { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.5rem; }

table.data { border-collapse: collapse; font-family: var(--mono); font-size: 0.85rem; }
table.data th, table.data td { border: 1px solid #ccc; padding: 0.25rem 0.6rem; text-align: left; }
table.data th { background: var(--grey); }

.pill {
  display: inline-block; font-family: var(--mono); font-size: 0.8rem;
  border: 1px solid var(--ink); padding: 0.05rem 0.5rem; margin: 0.15rem; background: var(--paper);
}

.site-footer {
  padding: 3rem var(--pad); background: var(--dark); color: var(--paper);
  font-family: var(--mono); font-size: 0.85rem;
}
