/* ---------- Colours: light by default, dark when the visitor prefers it ---------- */
:root {
  color-scheme: light dark;
  --bg: #fffaf2;
  --surface: #ffffff;
  --surface-2: #f6efe4;
  --text: #1e1b2e;
  --muted: #5d5873;
  --line: #e7dfd2;

  /* Bright accents (also read by the drawing scripts) */
  --c-magenta: #d6246e;
  --c-teal: #0a9396;
  --c-sun: #f2a900;
  --c-coral: #f0603c;
  --c-violet: #6a4cd8;

  --accent: var(--c-magenta);
  --accent-2: var(--c-teal);
  --link: #b0175a;
  --focus: var(--c-violet);

  /* Drawing area colours */
  --canvas-bg: #ffffff;
  --canvas-ink: #1e1b2e;

  --radius: 18px;
  --shadow: 0 10px 30px rgba(30, 27, 46, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12101c;
    --surface: #1c1929;
    --surface-2: #262236;
    --text: #f5f1ea;
    --muted: #b5afc8;
    --line: #34304a;

    --c-magenta: #ff4f9a;
    --c-teal: #2ee6d6;
    --c-sun: #ffd23f;
    --c-coral: #ff8a5c;
    --c-violet: #a58bff;

    --link: #ff7ab3;
    --canvas-bg: #0d0b15;
    --canvas-ink: #f5f1ea;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
}
img, svg, canvas, video { display: block; max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(2.2rem, 5vw + 1rem, 3.8rem); }
h2 { font-size: clamp(1.6rem, 2.5vw + 1rem, 2.4rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
.lead { font-size: 1.25rem; color: var(--muted); max-width: 38em; }
code, kbd { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 6px; }

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.narrow { width: min(720px, 100% - 2.5rem); margin-inline: auto; }
.section { padding: clamp(3rem, 7vw, 6rem) 0; }
.section--tint { background: var(--surface-2); }

.skip-link { position: absolute; left: -10000px; top: 0; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 10; background: var(--surface); padding: 0.5rem 1rem; border-radius: 8px; }

/* Rainbow rule used as a small flourish */
.spectrum {
  height: 6px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--c-magenta), var(--c-coral), var(--c-sun), var(--c-teal), var(--c-violet));
}

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 0; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.brand__mark {
  width: 28px; height: 28px; border-radius: 50%;
  background: conic-gradient(var(--c-magenta), var(--c-coral), var(--c-sun), var(--c-teal), var(--c-violet), var(--c-magenta));
}
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.25rem; }
.site-nav a { display: block; padding: 0.45rem 0.85rem; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 600; }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] { background: var(--text); color: var(--bg); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 4rem; padding: 2.5rem 0; color: var(--muted); font-size: 0.95rem; }
.site-footer__inner { display: grid; gap: 0.5rem; }
.site-footer__name { font-family: var(--font-display); font-weight: 700; color: var(--text); margin: 0; }
.site-footer__note { margin: 0; max-width: 40em; }
.site-footer__links { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; gap: 1.25rem; }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.8rem 1.4rem; border-radius: 999px; border: 2px solid transparent;
  background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; cursor: pointer;
  font: inherit; font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.button--ghost { background: transparent; color: var(--text); border-color: var(--text); }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* ---------- Hero ---------- */
.hero { padding: clamp(3rem, 8vw, 7rem) 0 clamp(2rem, 5vw, 4rem); }
.hero__grid { display: grid; gap: 2.5rem; align-items: center; grid-template-columns: 1fr; }
@media (min-width: 860px) { .hero__grid { grid-template-columns: 1.1fr 1fr; } }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem; font-weight: 700; color: var(--accent-2); margin-bottom: 0.75rem; }

/* ---------- Gallery cards ---------- */
.card-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 2rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: var(--text);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card__media { aspect-ratio: 4 / 3; background: var(--canvas-bg); display: grid; place-items: center; }
.card__media img, .card__media canvas { width: 100%; height: 100%; object-fit: cover; }
.card__body { padding: 1.1rem 1.25rem 1.4rem; }
.card__body h3 { margin-bottom: 0.3rem; }
.card__body p { margin: 0; color: var(--muted); }
.card:nth-child(5n+1) { border-top: 5px solid var(--c-magenta); }
.card:nth-child(5n+2) { border-top: 5px solid var(--c-teal); }
.card:nth-child(5n+3) { border-top: 5px solid var(--c-sun); }
.card:nth-child(5n+4) { border-top: 5px solid var(--c-coral); }
.card:nth-child(5n+5) { border-top: 5px solid var(--c-violet); }

/* ---------- Interactive drawing areas ---------- */
.playground {
  display: grid; gap: 1.5rem; grid-template-columns: 1fr;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
@media (min-width: 900px) { .playground { grid-template-columns: 2fr 1fr; } }
.playground__stage { background: var(--canvas-bg); border-radius: calc(var(--radius) - 6px); overflow: hidden; aspect-ratio: 1 / 1; }
.playground__stage canvas { width: 100%; height: 100%; }
.playground__controls { display: grid; gap: 1rem; align-content: start; }
.control label { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 0.3rem; }
.control output { font-family: var(--font-mono); color: var(--accent); }
.control input[type="range"] { width: 100%; accent-color: var(--accent); }
.control textarea, .control input[type="text"], .control select {
  width: 100%; font: inherit; font-family: var(--font-mono); font-size: 0.95rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.75rem;
}
.control textarea { min-height: 9rem; resize: vertical; }

/* Step-by-step figures */
.steps { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin: 2rem 0; }
.steps figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0.75rem; }
.steps figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 0.5rem; text-align: center; }

/* Callout for a term or a surprise */
.note { border-left: 5px solid var(--c-sun); background: var(--surface); padding: 1rem 1.25rem; border-radius: 0 12px 12px 0; margin: 1.5rem 0; }
.note strong { color: var(--text); }

blockquote { margin: 2rem 0; padding: 0 0 0 1.25rem; border-left: 5px solid var(--c-violet); font-size: 1.25rem; font-family: var(--font-display); }
blockquote footer { font-size: 0.95rem; color: var(--muted); font-family: var(--font); margin-top: 0.5rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}