:root {
  color-scheme: light;
  --paper: #f5f2ea;
  --paper-raised: #faf8f2;
  --paper-deep: #ece7dc;
  --ink: #151617;
  --ink-soft: #55585a;
  --muted: #777a7c;
  --line: rgba(21, 22, 23, 0.16);
  --accent: #b31f35;
  --display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  --page: 1600px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

::selection {
  color: var(--ink);
  background: rgba(179, 31, 53, 0.17);
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 9px 12px;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  font: 0.68rem var(--mono);
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Header */

.site-head {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 20;
  width: min(100%, var(--page));
  padding: 24px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transform: translateX(-50%);
}

.brand {
  display: inline-flex;
  text-decoration: none;
}

.brand-mark {
  width: auto;
  height: 42px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.auth {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-soft);
  font: 0.66rem var(--mono);
}

.auth > a:not(.auth-link) {
  color: var(--ink);
  text-underline-offset: 3px;
}

.auth-link {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: rgba(245, 242, 234, 0.62);
  border: 1px solid var(--line);
  border-radius: 50%;
  text-decoration: none;
  backdrop-filter: blur(10px);
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.auth-link img {
  width: 18px;
  height: 18px;
}

.auth-link:hover {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.auth-link:hover img {
  filter: invert(1);
}

/* The entire first screen is the gesture */

.hero {
  position: relative;
  height: clamp(610px, 82svh, 840px);
  min-height: 610px;
  overflow: hidden;
  background: radial-gradient(135% 120% at 50% 44%, #f9f6ef 0%, #f1ece0 52%, #e6dfd0 100%);
  border-bottom: 1px solid var(--line);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero::before {
  z-index: 0;
  opacity: 0.16;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hero::after {
  z-index: 0;
  background: radial-gradient(125% 110% at 50% 46%, transparent 62%, rgba(60, 44, 16, 0.075) 100%);
}

.hand-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.human-hand {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transform: translateX(0.35vw);
  animation: hand-enter 1120ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.human-hand img {
  position: absolute;
  top: 50%;
  left: calc(49% - min(52.8vw, 845px));
  width: min(61vw, 980px);
  max-width: none;
  transform: translateY(-58.3%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 6%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 6%, #000 100%);
}

@keyframes hand-enter {
  from {
    opacity: 0.18;
    transform: translateX(-9vw);
  }
  to {
    opacity: 1;
    transform: translateX(0.35vw);
  }
}

.contact-ripple {
  position: absolute;
  top: 50%;
  left: 49.55%;
  z-index: 3;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.contact-ripple::before,
.contact-ripple::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(21, 18, 10, 0.44);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.22);
  animation: contact-ripple 720ms cubic-bezier(0.16, 0.72, 0.22, 1) 1030ms both;
}

.contact-ripple::after {
  border-color: rgba(179, 31, 53, 0.34);
  animation-delay: 1120ms;
}

@keyframes contact-ripple {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.22);
  }
  18% {
    opacity: 0.58;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(3.15);
  }
}

.hand-stage canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: manipulation;
}

.hand-stage canvas:focus-visible {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Research contracts */

.contracts {
  padding: clamp(68px, 8vw, 132px) max(24px, calc((100vw - var(--page)) / 2)) clamp(82px, 9vw, 148px);
}

.contracts-head {
  padding: 0 0 clamp(46px, 6vw, 86px);
}

.contracts-head h1 {
  max-width: 1100px;
  font-family: var(--display);
  font-size: clamp(5.2rem, 10.5vw, 10.6rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.78;
}

.contract-field {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.problem {
  position: relative;
  min-width: 0;
  min-height: 430px;
  padding: clamp(24px, 2.3vw, 38px);
  display: flex;
  flex-direction: column;
  grid-column: span 4;
  color: var(--ink);
  background: var(--paper-raised);
  transition: background 180ms ease;
}

.problem:nth-child(5n + 1) {
  min-height: 520px;
  grid-column: span 7;
}

.problem:nth-child(5n + 2) {
  min-height: 520px;
  grid-column: span 5;
}

.problem:hover {
  background: #f0ece3;
}

.problem-index {
  min-height: 46px;
}

.problem-index .n {
  color: var(--accent);
  font-family: var(--display);
  font-size: 2rem;
  font-style: italic;
  line-height: 1;
}

.gap-glyph {
  display: none;
}

.problem-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.problem-body .field-tag {
  margin-top: clamp(42px, 5vw, 76px);
  color: var(--muted);
  font: 0.58rem var(--mono);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.problem-body h3 {
  max-width: 22ch;
  margin-top: 11px;
  font-family: var(--display);
  font-size: clamp(2rem, 2.7vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 0.98;
}

.problem:nth-child(5n + 1) .problem-body h3 {
  max-width: 19ch;
  font-size: clamp(2.8rem, 3.8vw, 4.5rem);
  line-height: 0.92;
}

.problem-body .statement {
  max-width: 64ch;
  margin-top: 23px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.72;
}

.problem-body details {
  margin-top: auto;
  padding-top: 28px;
}

.problem-body summary {
  width: fit-content;
  color: var(--ink);
  font: 0.58rem var(--mono);
  letter-spacing: 0.06em;
  list-style: none;
  cursor: pointer;
  text-transform: uppercase;
}

.problem-body summary::after {
  content: " +";
  color: var(--accent);
}

.problem-body details[open] summary::after {
  content: " −";
}

.problem-body summary::-webkit-details-marker {
  display: none;
}

.problem-body .verify-full {
  margin-top: 14px;
  padding: 16px 0 0;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font: 0.66rem/1.75 var(--mono);
  white-space: pre-wrap;
}

.problem-side {
  margin-top: 26px;
  padding-top: 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px 14px;
  border-top: 1px solid var(--line);
}

.reward {
  color: var(--ink);
  font: 0.68rem var(--mono);
}

.status {
  color: var(--muted);
  font: 0.55rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.status.claimed {
  color: #587968;
}

.claim-btn {
  min-height: 38px;
  margin-left: auto;
  padding: 8px 13px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  font: 0.59rem var(--mono);
  letter-spacing: 0.025em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 150ms ease, background 150ms ease;
}

.claim-btn:hover,
.claim-btn:focus-visible {
  color: var(--paper);
  background: var(--ink);
}

.claim-btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.mini-note {
  max-width: 22ch;
  color: var(--muted);
  font: 0.57rem var(--mono);
}

.mini-act {
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  font: 0.57rem var(--mono);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mini-act:hover {
  color: var(--accent);
}

/* Claimed-work controls */

.submit-panel {
  margin-top: 22px;
  padding: 20px 0 0;
  border-top: 2px solid var(--accent);
}

.submit-panel label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font: 0.59rem var(--mono);
}

.submit-panel textarea,
.submit-panel input {
  width: 100%;
  padding: 10px 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  font: 0.7rem var(--mono);
}

.submit-panel textarea {
  min-height: 92px;
  resize: vertical;
}

.submit-panel .row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.submit-panel .status-line {
  color: var(--muted);
  font: 0.61rem var(--mono);
}

.token-box {
  margin-top: 12px;
  padding: 12px;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px dashed var(--line);
  font: 0.61rem var(--mono);
  word-break: break-all;
}

.site-foot {
  padding: 30px max(24px, calc((100vw - var(--page)) / 2)) 46px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font: 0.59rem var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-foot span:last-child {
  display: flex;
  gap: 22px;
}

.site-foot a {
  text-underline-offset: 3px;
}

@media (max-width: 1100px) {
  .problem,
  .problem:nth-child(5n + 1),
  .problem:nth-child(5n + 2) {
    min-height: 440px;
    grid-column: span 6;
  }

  .problem:nth-child(5n + 1) .problem-body h3 {
    font-size: clamp(2.5rem, 5vw, 3.7rem);
  }
}

@media (max-width: 700px) {
  .site-head {
    padding: 18px 16px;
  }

  .brand-mark {
    height: 30px;
  }

  .auth-link {
    width: 38px;
    height: 38px;
  }

  .hero {
    height: 510px;
    min-height: 510px;
  }

  .human-hand img {
    left: calc(49% - 112vw);
    width: 128vw;
  }

  .contracts {
    padding: 66px 16px 82px;
  }

  .contracts-head {
    padding-bottom: 48px;
  }

  .contracts-head h1 {
    font-size: clamp(4.5rem, 22vw, 6.2rem);
    line-height: 0.82;
  }

  .problem,
  .problem:nth-child(5n + 1),
  .problem:nth-child(5n + 2) {
    min-height: 0;
    padding: 24px 20px 22px;
    grid-column: 1 / -1;
  }

  .problem-body .field-tag {
    margin-top: 38px;
  }

  .problem-body h3,
  .problem:nth-child(5n + 1) .problem-body h3 {
    max-width: 20ch;
    font-size: clamp(2.35rem, 11vw, 3.2rem);
  }

  .problem-body .statement {
    font-size: 0.8rem;
  }

  .problem-body details {
    margin-top: 32px;
  }

  .problem-side {
    align-items: flex-start;
  }

  .claim-btn {
    width: 100%;
    margin: 8px 0 0;
    text-align: center;
  }

  .submit-panel .row {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-foot {
    padding: 28px 16px 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .human-hand {
    animation: none;
  }

  .contact-ripple {
    display: none;
  }
}
