/* Ink on paper: the maps are the page. One typeface (Inter, self-hosted),
   one accent (the pin orange), and the dots take the text colour, so both
   themes come from the same SVG. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/inter-latin-600-normal.woff2') format('woff2');
}

:root {
  --paper: #f5f3ee;
  --ink: #1b1a17;
  --muted: #5b5850;
  --rule: #dcd8cf;
  --code: #ebe8e1;
  --accent: #c2410c;
  --measure: 40rem;
  --gutter: clamp(1rem, 4vw, 3rem);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101114;
    --ink: #e9e6df;
    --muted: #a5a197;
    --rule: #2a2b30;
    --code: #1a1b20;
    --accent: #ff7a3d;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    400 1.0625rem/1.6 'Inter',
    sans-serif;
  font-feature-settings: 'cv11', 'ss01';
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover,
.play button:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

code,
pre {
  font-family: 'Inter', monospace;
  font-feature-settings: 'zero';
  font-variant-ligatures: none;
}

.bar,
main,
.foot {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.mark {
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.bar nav {
  display: flex;
  gap: 1.25rem;
}

.hero {
  padding: clamp(2rem, 7vw, 5rem) 0 1.5rem;
  max-width: var(--measure);
}

h1 {
  font-size: clamp(2.4rem, 6.5vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 600;
  margin: 0 0 1.25rem;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-weight: 600;
  margin: 0 0 1rem;
}

.lede {
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  color: var(--muted);
  margin: 0 0 1.75rem;
}

.install code {
  display: inline-block;
  max-width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--code);
  overflow-wrap: anywhere;
}

.map {
  margin: 0;
}

/* The dots take the text colour, or a colour the page's CSS gives the map. */
.map svg {
  display: block;
  width: 100%;
  height: auto;
}

.map-hero {
  margin: 1.5rem 0 0;
}

figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

main > section:not(.hero) {
  border-top: 1px solid var(--rule);
  margin-top: clamp(3rem, 8vw, 5.5rem);
  padding-top: 2rem;
}

.quick p,
.play > p,
.next p {
  max-width: var(--measure);
}

pre {
  margin: 1.25rem 0 0;
  padding: 1.25rem 1.5rem;
  background: var(--code);
  border: 1px solid var(--rule);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: end;
}

.grid figcaption {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.grid figcaption strong {
  color: var(--ink);
  font-weight: 600;
}

.facts dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1.75rem clamp(1.5rem, 4vw, 3rem);
  margin: 0;
}

.facts dt {
  font-weight: 600;
}

.facts dd {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.faq dl {
  margin: 0;
  max-width: var(--measure);
}

.faq dt {
  font-weight: 600;
  margin-top: 1.5rem;
}

.faq dt:first-child {
  margin-top: 0;
}

.faq dd {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

/* Playground: the controls read like a map legend, each group under the call
   it feeds. On a phone the map stays in view above them; from 56rem it sits
   beside them, with its code. */
.play-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem clamp(1.5rem, 4vw, 3.5rem);
  font-variant-numeric: tabular-nums;
  accent-color: var(--accent);
}

.stage {
  display: contents;
}

.preview {
  order: -1;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.5rem 0;
  background: var(--paper);
}

.preview svg {
  max-height: 35vh;
}

.stale svg {
  opacity: 0.25;
}

.stale #status {
  color: var(--accent);
}

@media (min-width: 56rem) {
  .play-body {
    grid-template-columns: minmax(15rem, 19rem) minmax(0, 1fr);
    align-items: start;
  }

  .stage {
    display: block;
    position: sticky;
    top: 1rem;
  }

  .preview svg {
    max-height: 60vh;
  }
}

.controls fieldset,
.controls legend {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.controls > fieldset {
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

legend strong + code {
  color: var(--muted);
}

.controls label,
.controls fieldset fieldset {
  display: grid;
  gap: 0.3rem;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.controls .pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 0.75rem;
}

.controls .check,
.controls .seg,
.controls .seg label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.controls .seg label {
  margin: 0 1rem 0 0;
}

.controls .range {
  grid-template-columns: 1fr auto;
}

.range input {
  grid-column: 1 / -1;
  order: 1;
  width: 100%;
  margin: 0;
}

.controls :is(input:not([type]), input[type='number'], textarea) {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 1rem;
  color: inherit;
  background: var(--code);
  border: 0;
  border-bottom: 1px solid var(--muted);
  border-radius: 0;
  resize: vertical;
}

.controls :is(input, textarea)[aria-invalid='true'] {
  border-bottom: 2px solid var(--accent);
}

/* A field that focus scrolls to stays clear of the map pinned above it. */
.controls :is(input, textarea) {
  scroll-margin-top: calc(35vh + 4rem);
}

::placeholder {
  color: var(--muted);
  opacity: 1;
}

.play button {
  padding: 0.45rem 0.9rem;
  font:
    600 0.875rem 'Inter',
    sans-serif;
  color: inherit;
  background: none;
  border: 1px solid currentColor;
  cursor: pointer;
}

/* The presets read as a row of choices: a name, then what it is for. */
.presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
}

#presets-label {
  grid-column: 1 / -1;
  font-size: 0.875rem;
  color: var(--muted);
}

.play .presets button {
  display: grid;
  align-content: start;
  gap: 0.15rem;
  padding: 0.7rem 0.9rem;
  text-align: left;
  font-weight: 400;
  border-color: var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--code);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.guides ul {
  max-width: var(--measure);
  margin: 0;
  padding-left: 1.25rem;
}

.guides li + li {
  margin-top: 0.4rem;
}

/* A guide page: one question, its answer, then code and the map it draws. */
.guide {
  max-width: 52rem;
}

.crumbs {
  padding-top: clamp(1rem, 4vw, 2.5rem);
  font-size: 0.9rem;
  color: var(--muted);
}

.guide h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  margin-top: 1rem;
}

.guide h2 {
  margin-top: 3rem;
}

.guide p,
.guide > ul {
  max-width: var(--measure);
}

.guide .code {
  margin: 1.5rem 0 0;
}

.guide .code figcaption {
  margin: 0 0 0.4rem;
}

.guide .code pre {
  margin: 0;
}

.guide .map {
  margin: 1.5rem 0 0;
}

.guide .map svg {
  max-height: 32rem;
}

.table {
  overflow-x: auto;
  margin-top: 1.25rem;
}

.table table {
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  padding: 0.4rem 0.75rem 0.4rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.table .num {
  text-align: right;
}

.foot {
  margin-top: clamp(3rem, 8vw, 5.5rem);
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: no-preference) {
  a,
  .play button {
    transition: color 120ms ease;
  }

  .preview svg {
    transition: opacity 150ms ease;
  }
}
