:root {
  color-scheme: dark;

  --ink: #0d0d12;
  --panel: #16161d;
  --line: #2b2b36;
  --text: #ecebf2;
  --muted: #a3a2b3;
  --accent: #c9a6ff;

  --sans: 'Bricolage Grotesque', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --gutter: clamp(16px, 4vw, 48px);
}

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--accent);
}

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

/* Gallery */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 30ch);
  gap: 24px 48px;
  align-items: end;
  padding: clamp(40px, 8vw, 96px) var(--gutter) clamp(32px, 5vw, 56px);
}

.intro h1 {
  margin: 0;
  font-size: clamp(2.75rem, 9vw, 7rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.015em;
}

.intro p {
  margin: 0;
  color: var(--muted);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 40px 20px;
  margin: 0;
  padding: 0 var(--gutter);
  list-style: none;
}

.card {
  display: grid;
  gap: 4px;
  text-decoration: none;
}

.card-media {
  position: relative;
  display: block;
  aspect-ratio: 1;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--panel);
  outline: 1px solid var(--line);
  outline-offset: -1px;
}

.card:hover .card-media {
  outline-color: var(--accent);
}

.card-media img,
.card-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-media video {
  opacity: 0;
  transition: opacity 200ms;
}

.card-media video.is-playing {
  opacity: 1;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.card-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-summary {
  color: var(--muted);
  font-size: 0.9375rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  justify-content: space-between;
  margin-top: clamp(56px, 8vw, 96px);
  padding: 24px var(--gutter);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
}

.site-footer p {
  margin: 0;
}

/* Sketch page */

.sketch-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.topbar a {
  text-decoration: none;
}

.topbar span {
  color: var(--muted);
}

#stage {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 24px var(--gutter);
}

#stage canvas {
  display: block;
  max-width: 100%;
  /* p5 sets a fixed inline size. This lets the canvas shrink on small screens. */
  height: auto !important;
}

#stage input[type='range'] {
  width: min(100%, 400px);
  accent-color: var(--accent);
}

.details {
  display: flex;
  flex-direction: column;
  padding: 32px var(--gutter) 24px 32px;
  border-left: 1px solid var(--line);
}

.details h1 {
  margin: 0 0 12px;
  font-size: 2.5rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.details p {
  margin: 0 0 16px;
  color: var(--muted);
}

.details .eyebrow {
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.details .hint {
  padding-left: 12px;
  border-left: 2px solid var(--accent);
  color: var(--text);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: auto;
  padding-top: 32px;
}

.pager a {
  text-decoration: none;
  font-weight: 500;
}

.pager a[rel='next'] {
  text-align: right;
}

.pager small {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
}

@media (min-width: 1200px) {
  /* Five columns divide the ten sketches evenly. */
  .gallery {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Not found page */

.not-found {
  padding: clamp(48px, 12vw, 120px) var(--gutter);
}

.not-found h1 {
  margin: 0 0 12px;
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

@media (max-width: 860px) {
  .intro {
    grid-template-columns: minmax(0, 1fr);
  }

  .sketch-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
  }

  .details {
    padding: 24px var(--gutter);
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}
