:root {
  color-scheme: light;
  --ground: #ece9f1;
  --ground-deep: #e2deea;
  --grid: #dad5e3;
  --ink: #1c1724;
  --muted: #5e5770;
  --line: #d4cfde;
  --night: #141119;
  --violet: #5b3fd4;
  --text: "Gabarito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gel: "Bagel Fat One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --gutter: clamp(16px, 4.4vw, 72px);
  --radius: clamp(18px, 2vw, 28px);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 18px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
em { font-style: normal; }
a { color: inherit; }
img { display: block; }

:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 4px;
  border-radius: 8px;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--ground);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 16px; }

/* Header: sits over the table, so the grid runs behind it. */
.site-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 76px;
  padding: 0 var(--gutter);
  font-size: 16px;
  font-weight: 600;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand svg { width: 30px; height: 24px; }
.site-header nav { display: flex; gap: clamp(18px, 2.6vw, 36px); }
.site-header nav a {
  text-decoration: none;
  color: var(--muted);
}
.site-header nav a:hover { color: var(--ink); }

/* Hero: a WebGL table fills the section; the stage marks where the letters stand. */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: min(100svh, 1100px);
  padding: 76px var(--gutter) clamp(36px, 6vh, 80px);
  background-color: var(--ground);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  isolation: isolate;
}
.hero.gel-on { background-image: none; }

.gel {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}
.gel.is-over-letter { cursor: grab; }
.gel.is-holding { cursor: grabbing; }

.stage {
  position: relative;
  flex: 1 0 auto;
  height: clamp(260px, 52svh, 620px);
  min-height: clamp(260px, 52svh, 620px);
  pointer-events: none;
}

/* Without WebGL the letters are type, standing on the same line. */
.gel-fallback {
  display: none;
  position: absolute;
  inset: auto 0 0;
  margin: 0;
  text-align: center;
  font: 400 clamp(96px, 21vw, 380px)/0.74 var(--gel);
  letter-spacing: 0.04em;
}
.gel-fallback span { display: inline-block; text-shadow: 0 0.04em 0 rgba(255, 255, 255, 0.45), 0.03em 0.06em 0.08em rgba(28, 23, 36, 0.18); }
.gel-fallback span:nth-child(1) { color: #f29f38; }
.gel-fallback span:nth-child(2) { color: #a68bf2; }
.gel-fallback span:nth-child(3) { color: #34c3a0; }
.gel-fallback span:nth-child(4) { color: #ec5b8b; }
.gel-fallback span:nth-child(5) { color: #f29f38; }
.hero.gel-off .gel-fallback { display: block; }
.hero.gel-off .hint { display: none; }

.hero-text {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(16px, 2.4vw, 40px);
  align-items: end;
  margin-top: clamp(28px, 5vh, 56px);
}
.hero-lead { grid-column: 1 / span 7; }
.hero-side { grid-column: 8 / span 5; display: grid; gap: 18px; }

.kicker {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 600;
}
.hero h1 {
  font-size: clamp(44px, 6vw, 92px);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.035em;
}
.intro {
  max-width: 34ch;
  color: var(--muted);
  font-size: clamp(18px, 1.5vw, 21px);
  line-height: 1.45;
}
.hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  font-weight: 600;
}
.jump {
  padding: 9px 16px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 600 16px/1 var(--text);
  cursor: pointer;
  transition: transform 0.6s var(--spring), background-color 0.2s ease;
}
.jump:hover { background: var(--ink); color: var(--ground); }
.jump:active, .sound:active { transform: scale(0.94, 0.88); transition-duration: 0.08s; }
/* A switch: filled while the letters can be heard. */
.sound {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 600 16px/1 var(--text);
  cursor: pointer;
  transition: transform 0.6s var(--spring), background-color 0.2s ease, color 0.2s ease;
}
.sound svg { width: 20px; height: 20px; }
.sound svg path:not(:first-child) { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sound .sound-on, .sound[aria-pressed="true"] .sound-off { display: none; }
.sound[aria-pressed="true"] .sound-on { display: inline; }
.sound:hover { background: rgba(28, 23, 36, 0.08); }
.sound[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.contents { color: var(--muted); }
.contents a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--tint);
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

/* The index */
.index {
  padding: clamp(72px, 11vw, 160px) var(--gutter) clamp(72px, 9vw, 140px);
}
.index-head {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(16px, 2.4vw, 40px);
  align-items: end;
  margin-bottom: clamp(48px, 7vw, 110px);
}
.index-head h2 {
  grid-column: 1 / span 6;
  font-size: clamp(36px, 4.2vw, 64px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.index-head p {
  grid-column: 8 / span 5;
  max-width: 40ch;
  color: var(--muted);
}

.group + .group { margin-top: clamp(80px, 11vw, 170px); }
.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px clamp(20px, 3vw, 48px);
  margin-bottom: clamp(24px, 3.4vw, 48px);
  padding-bottom: clamp(16px, 1.6vw, 22px);
  border-bottom: 2px solid var(--ink);
}
.group-title {
  display: flex;
  align-items: center;
  gap: 0.22em;
  font-size: clamp(48px, 7.4vw, 124px);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.045em;
}
/* A drop of the group's gel colour. */
.group-title::before {
  content: "";
  flex: none;
  width: 0.36em;
  height: 0.36em;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.9) 0 9%, transparent 26%),
    radial-gradient(circle at 60% 70%, color-mix(in srgb, var(--tint) 70%, #000) 0, var(--tint) 62%, color-mix(in srgb, var(--tint) 55%, #fff) 100%);
  box-shadow: 0.04em 0.07em 0.12em color-mix(in srgb, var(--tint) 45%, transparent);
  transform: translateY(0.04em);
}
.group-text { flex: 1 1 22ch; max-width: 34ch; color: var(--muted); }
.group-count { margin-left: auto; color: var(--muted); font-weight: 600; }

/* Picture tiles: a 12-column grid with uneven pairs and even threes. */
.tiles {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(40px, 5vw, 72px) clamp(16px, 2vw, 28px);
}
.work {
  grid-column: span var(--span);
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}
.work-window {
  position: relative;
  display: block;
  overflow: hidden;
  height: clamp(240px, 24vw, 380px);
  border-radius: var(--radius);
  background: var(--night);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 0 0 1px rgba(28, 23, 36, 0.06);
  transform-origin: 50% 100%;
  transition: transform 0.7s var(--spring);
}
.work--row2 .work-window { height: clamp(260px, 34vw, 540px); }
.work--row1 .work-window { height: clamp(260px, 42vw, 620px); }
.work-window img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Pressing a picture squashes it a little, like gel; it springs back on release. */
.work:active .work-window {
  transform: scale(0.985, 0.955);
  transition-duration: 0.09s;
  transition-timing-function: ease-out;
}
.work:hover .work-title,
.tool:hover .tool-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.work-window--card {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 28% 32%, rgba(140, 107, 234, 0.6), transparent 42%),
    radial-gradient(circle at 74% 70%, rgba(23, 168, 140, 0.5), transparent 44%),
    repeating-radial-gradient(circle at 50% 54%, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 15px),
    var(--night);
}
.work-window-title {
  color: #f4f1fb;
  font-size: clamp(28px, 3.4vw, 52px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  text-align: center;
  text-wrap: balance;
}
.work-caption { display: grid; gap: 4px; }
.work-kind { color: var(--muted); font-size: 15px; font-weight: 600; }
.work-title {
  font-size: clamp(24px, 2.1vw, 32px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.work-summary { max-width: 46ch; color: var(--muted); }

/* Tools are things to use, so they read as a list, not a gallery. */
.tools { margin: 0; padding: 0; list-style: none; }
.tools li + li { border-top: 1px solid var(--line); }
.tool {
  display: grid;
  grid-template-columns: clamp(120px, 15vw, 210px) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(16px, 2.6vw, 40px);
  padding: clamp(14px, 1.6vw, 20px) clamp(8px, 1vw, 16px);
  border-radius: 18px;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.6s var(--spring);
}
.tool:hover { background: var(--ground-deep); }
.tool:active { transform: scale(0.992, 0.97); transition-duration: 0.09s; }
.tool-shot {
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  background: var(--night);
  box-shadow: 0 0 0 1px rgba(28, 23, 36, 0.08);
}
.tool-shot img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.tool-text { display: grid; gap: 4px; }
.tool-name { font-size: clamp(24px, 2.4vw, 36px); font-weight: 700; line-height: 1.05; letter-spacing: -0.025em; }
.tool-summary { max-width: 52ch; color: var(--muted); }
.tool-open {
  padding: 9px 18px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--ground);
  font-size: 16px;
  font-weight: 600;
}

.index-error, .empty { max-width: 60ch; }
.empty { display: grid; gap: 16px; }
.empty h3 { font-size: clamp(32px, 4vw, 56px); line-height: 1; letter-spacing: -0.03em; }
.empty p { color: var(--muted); }
.empty a { font-weight: 600; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 32px;
  padding: 32px var(--gutter) 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 16px;
}
.site-footer a { color: var(--ink); font-weight: 600; text-decoration-thickness: 2px; text-underline-offset: 4px; }

@media (max-width: 860px) {
  .hero-lead, .hero-side { grid-column: 1 / -1; }
  .hero-side { margin-top: 28px; }
  .index-head h2, .index-head p { grid-column: 1 / -1; }
  .index-head p { margin-top: 18px; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .work { grid-column: 1 / -1; }
  .work-window, .work--row2 .work-window, .work--row1 .work-window { height: auto; aspect-ratio: 4 / 3; }
  .group-count { margin-left: 0; }
}

@media (max-width: 560px) {
  body { font-size: 17px; }
  .site-header { height: 64px; font-size: 15px; }
  .hero { padding-top: 64px; }
  .stage { height: clamp(280px, 44svh, 400px); min-height: clamp(280px, 44svh, 400px); }
  .tool { grid-template-columns: 96px minmax(0, 1fr); }
  .tool-open { display: none; }
  .tool-summary { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .work-window, .tool, .jump, .sound { transition: none; }
  .work:active .work-window, .tool:active, .jump:active, .sound:active { transform: none; }
}
