/* Moko website. Same palette and type as the game (src/ui/theme.ts): matte clay
   on a warm putty table, four colours that each mean one thing, light from the
   top left, lots of space. The board is the loud thing; the type stays light. */

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

:root {
  color-scheme: light;

  --bg: #e9e4dc;
  --surface: #f1ede6;
  --raised: #f7f4ef;
  --ink: #3c4250;
  --dim: #645e55; /* textDim from the app, darkened to reach 4.5:1 on --bg */
  --faint: #8d867b;
  --line: rgba(60, 66, 80, 0.12);
  --scrim: rgba(233, 228, 220, 0.9);

  --floor: #efe9df;
  --floor-top: #f9f6f0;
  --floor-side: #d8cdbb;
  --block: #d06c4a;
  --block-top: #e0805c;
  --block-side: #ad5737;
  --goal: #d9a441;
  --goal-top: #e6b55a;
  --goal-side: #a8792a;
  --ice: #e2e9ec;
  --ice-top: #f2f7f9;
  --ice-side: #bfccd2;
  --bridge: #c86e50;
  --pit-wall-top: #a8997f;
  --pit-wall: #6e6250;
  --pit-floor: #3b404c;
  --pit-floor-deep: #2a2e37;
  --player: #f7f2e9;
  --player-shade: #ddd4c5;
  --echo: #c9bfd8;
  --light: #b9cbb4;
  --portal-a: #8a9f8f;
  --portal-b: #a18aab;

  --font: 'Jost', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --gutter: clamp(16px, 5vw, 72px);
  --max: 1360px;
  --radius: 24px;
}

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

@view-transition {
  navigation: auto;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* Clay grain over everything, so flat CSS surfaces sit with the photographed art. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .3 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--goal-top);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--raised);
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip:focus {
  top: 16px;
}

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Type ---------- */

.label {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.label .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-radius: 2px;
  background: var(--block);
  vertical-align: 1px;
}

.display {
  margin: 0;
  font-weight: 300;
  font-size: clamp(3rem, 6.6vw, 7.5rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.h2 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(2.5rem, 5.4vw, 5.5rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.lead {
  margin: 0;
  font-size: clamp(1.1rem, 1.5vw, 1.375rem);
  line-height: 1.5;
  color: var(--dim);
  text-wrap: pretty;
}

.body {
  color: var(--dim);
  text-wrap: pretty;
}

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  transition: background-color 0.4s var(--ease), box-shadow 0.4s var(--ease), transform 0.5s var(--ease);
}

.nav.is-scrolled {
  background: rgba(233, 228, 220, 0.82);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 1px 0 var(--line);
}

.nav.is-hidden {
  transform: translateY(-100%);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 36px);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
}

.nav-links a {
  position: relative;
  text-decoration: none;
  color: var(--ink);
  padding-block: 6px;
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.45s var(--ease);
}

.nav-links a:hover::after,
.nav-links a[aria-current='page']::after {
  transform: scaleX(1);
  transform-origin: left;
}

@media (max-width: 640px) {
  .nav-links .hide-sm {
    display: none;
  }
}

/* The mark: Moko, small. Its eyes follow the pointer. */
.mark {
  --ex: 0px;
  --ey: 0px;
  position: relative;
  width: 30px;
  height: 29px;
  flex: none;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 34% 28%, #fffefb 0, var(--player) 40%, var(--player-shade) 100%);
  box-shadow: 0 4px 6px -2px rgba(60, 44, 30, 0.35), inset -2px -3px 5px rgba(150, 130, 100, 0.22);
}

.mark::before,
.mark::after {
  content: '';
  position: absolute;
  top: 11px;
  width: 3.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--ink);
  transform: translate(var(--ex), var(--ey));
  transition: transform 0.25s var(--ease);
  animation: blink 5.2s infinite;
}

.mark::before {
  left: 10px;
}

.mark::after {
  left: 17px;
}

@keyframes blink {
  0%, 94%, 100% { scale: 1 1; }
  96% { scale: 1 0.1; }
}

/* ---------- Buttons ---------- */

.btn {
  --h: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: var(--h);
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), background-color 0.3s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--ink);
  color: var(--raised);
  box-shadow: 0 5px 0 #272b35, 0 12px 24px -8px rgba(39, 43, 53, 0.55);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #272b35, 0 18px 30px -10px rgba(39, 43, 53, 0.5);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #272b35, 0 4px 10px -4px rgba(39, 43, 53, 0.5);
}

.btn-quiet {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px rgba(60, 66, 80, 0.3);
}

.btn-quiet:hover {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Round clay buttons, like the game's tool buttons. */
.tool {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffdf9, var(--raised) 55%, #ebe5da);
  box-shadow: 0 3px 0 var(--floor-side), 0 8px 14px -6px rgba(92, 70, 48, 0.35), inset 0 1px 0 #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.tool:hover {
  transform: translateY(-1px);
}

.tool:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--floor-side), 0 3px 6px -3px rgba(92, 70, 48, 0.35), inset 0 1px 0 #fff;
}

.tool svg {
  width: 20px;
  height: 20px;
}

.tool[aria-pressed='false'] .on,
.tool[aria-pressed='true'] .off {
  display: none;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  min-height: max(680px, 100svh);
  padding-block: 112px 88px;
}

.hero-art {
  position: relative;
  display: block;
  width: calc(100% + var(--gutter));
  max-width: 760px;
  margin-right: calc(-1 * var(--gutter));
  justify-self: end;
  aspect-ratio: 1;
  -webkit-mask-image: radial-gradient(closest-side, #000 76%, transparent);
  mask-image: radial-gradient(closest-side, #000 76%, transparent);
}

.hero-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translate3d(0, var(--parallax, 0px), 0);
  animation: hero-in 1.8s var(--ease-soft) both;
}

@keyframes hero-in {
  from {
    opacity: 0;
    scale: 1.06;
    filter: blur(6px);
  }
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.hero-copy .label {
  margin-bottom: 28px;
}

.hero-copy .display {
  margin-bottom: 32px;
}

.hero-copy .lead {
  max-width: 30em;
  margin-bottom: 40px;
}

.hero .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.hero .line > span {
  display: inline-block;
  animation: rise 1.1s var(--ease) both;
}

.hero .line:nth-child(2) > span {
  animation-delay: 0.08s;
}

.hero .line:nth-child(3) > span {
  animation-delay: 0.16s;
}

.hero .fade {
  animation: fade-up 1s var(--ease) 0.35s both;
}

.hero .fade + .fade {
  animation-delay: 0.45s;
}

.hero .fade + .fade + .fade {
  animation-delay: 0.55s;
}

@keyframes rise {
  from {
    transform: translateY(105%);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.soon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--dim);
}

.soon::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--goal);
  box-shadow: 0 0 0 0 rgba(217, 164, 65, 0.5);
  animation: pulse 2.4s var(--ease) infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 9px rgba(217, 164, 65, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 164, 65, 0); }
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 28px;
  translate: -50% 0;
  display: grid;
  justify-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  text-decoration: none;
  animation: fade-up 1s var(--ease) 0.9s both;
}

.scroll-cue i {
  width: 1px;
  height: 44px;
  background: linear-gradient(var(--ink), var(--ink)) 0 0 / 100% 40% no-repeat, var(--line);
  animation: cue 2.2s var(--ease) infinite;
}

@keyframes cue {
  0% { background-position: 0 -20px; }
  100% { background-position: 0 64px; }
}

/* Narrow screens: the island sits under the words instead of beside them. */
@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-block: 120px 24px;
    gap: 8px;
  }

  .hero-art {
    width: min(100%, 560px);
    margin-right: 0;
    justify-self: center;
  }

  .scroll-cue {
    display: none;
  }
}

/* ---------- Sections ---------- */

.section {
  padding-block: clamp(80px, 11vw, 168px);
}

.section-head {
  display: grid;
  gap: 28px;
  max-width: 880px;
  margin-bottom: clamp(56px, 7vw, 96px);
}

.section-head .lead {
  max-width: 34em;
}

/* Reveal on scroll. Only hidden once JavaScript is running to show it again. */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 1s var(--ease), transform 1.1s var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}

.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ---------- Demo ---------- */

.demo {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
}

.demo-copy {
  display: grid;
  gap: 28px;
  align-content: start;
}

.level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.level-tab {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
  color: var(--dim);
  font-size: 15px;
  line-height: 44px;
  cursor: pointer;
  transition: box-shadow 0.3s var(--ease), background-color 0.3s var(--ease), color 0.3s var(--ease);
}

.level-tab b {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.level-tab:hover {
  box-shadow: inset 0 0 0 1.5px rgba(60, 66, 80, 0.35);
}

.level-tab[aria-current='true'] {
  background: var(--raised);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--floor-side), 0 8px 16px -8px rgba(92, 70, 48, 0.4);
}

.level-tab .tick {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--goal);
  align-self: center;
  display: none;
}

.level-tab.is-solved .tick {
  display: block;
}

.keys {
  margin: 0;
  font-size: 14px;
  color: var(--dim);
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  margin-inline: 1px;
  border-radius: 7px;
  background: var(--raised);
  box-shadow: 0 2px 0 var(--floor-side);
  font: 500 12px/1 var(--font);
  color: var(--ink);
}

.tray {
  position: relative;
  border-radius: 36px;
  background: linear-gradient(180deg, #e4ded4, #e8e3da 40%);
  box-shadow: inset 0 2px 6px rgba(92, 70, 48, 0.14), inset 0 -1px 0 rgba(255, 255, 255, 0.6), 0 1px 0 rgba(255, 255, 255, 0.7);
  padding: clamp(18px, 3vw, 32px);
}

.hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
}

.hud-level {
  display: grid;
  gap: 2px;
}

.hud-level strong {
  font-weight: 400;
  font-size: 19px;
}

.hud-level span {
  font-size: 14px;
  color: var(--dim);
}

.hud-moves {
  text-align: right;
  font-size: 14px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hud-moves output {
  display: block;
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  color: var(--ink);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(220px, 26vw, 340px);
  margin-block: 12px 20px;
  outline: none;
  border-radius: 20px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.stage:active {
  cursor: grabbing;
}

.stage:focus-visible {
  box-shadow: 0 0 0 1.5px rgba(60, 66, 80, 0.28);
}

.tray-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tools {
  display: flex;
  gap: 12px;
}

.par-note {
  font-size: 14px;
  color: var(--dim);
  text-align: right;
}

/* The board: every cell is a clay slab with a lit top and a darker front face. */
.board {
  --c: 64px;
  position: relative;
  width: calc(var(--cols) * var(--c));
  height: calc(var(--rows) * var(--c) + var(--c) * 0.12);
  transition: opacity 0.4s var(--ease), transform 0.6s var(--ease);
}

.board::before {
  content: '';
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: calc(var(--c) * -0.55);
  height: calc(var(--c) * 0.7);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(92, 70, 48, 0.22), transparent);
  filter: blur(6px);
}

.board.is-entering {
  opacity: 0;
  transform: translateY(14px) scale(0.98);
}

.board > * {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--c);
  height: var(--c);
  transform: translate(calc(var(--x) * var(--c)), calc(var(--y) * var(--c)));
}

.tile::before {
  content: '';
  position: absolute;
  inset: calc(var(--c) * 0.035);
  border-radius: calc(var(--c) * 0.2);
  background: linear-gradient(155deg, var(--floor-top) 10%, var(--floor) 70%);
  box-shadow:
    0 calc(var(--c) * 0.085) 0 var(--floor-side),
    0 calc(var(--c) * 0.15) calc(var(--c) * 0.18) rgba(92, 70, 48, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -2px 5px rgba(120, 100, 70, 0.07);
}

.tile.ice::before {
  background: linear-gradient(155deg, #fbfdfe 0%, var(--ice-top) 30%, var(--ice) 75%, #d8e3e8 100%);
  box-shadow:
    0 calc(var(--c) * 0.085) 0 var(--ice-side),
    0 calc(var(--c) * 0.15) calc(var(--c) * 0.18) rgba(92, 70, 48, 0.16),
    inset 0 1px 0 #fff;
}

.tile.ice::after {
  content: '';
  position: absolute;
  inset: calc(var(--c) * 0.035);
  border-radius: calc(var(--c) * 0.2);
  background: linear-gradient(135deg, transparent 32%, rgba(255, 255, 255, 0.95) 33%, rgba(255, 255, 255, 0.95) 37%, transparent 38%, transparent 46%, rgba(255, 255, 255, 0.75) 47%, rgba(255, 255, 255, 0.75) 49%, transparent 50%);
}

.tile.goal::after {
  content: '';
  position: absolute;
  inset: 25%;
  border: max(2px, calc(var(--c) * 0.055)) solid var(--goal);
  border-radius: calc(var(--c) * 0.1);
  box-shadow: inset 0 1px 1px rgba(80, 50, 10, 0.25), 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* A hole is a missing slab: its lit far wall, then its dark floor. */
.tile.water::before {
  background: linear-gradient(180deg, var(--pit-wall-top) 0%, var(--pit-wall) 24%, var(--pit-floor) 24.5%, var(--pit-floor-deep) 100%);
  box-shadow: inset 0 0 0 calc(var(--c) * 0.02) rgba(42, 46, 55, 0.4), inset 0 calc(var(--c) * 0.06) calc(var(--c) * 0.08) rgba(0, 0, 0, 0.35);
}

.tile.water::after {
  content: '';
  position: absolute;
  inset: 32% 22% 14%;
  border: 1.5px dashed rgba(255, 255, 255, 0.14);
  border-radius: calc(var(--c) * 0.08);
}

.tile .fill {
  position: absolute;
  inset: calc(var(--c) * 0.035);
  z-index: 1;
  border-radius: calc(var(--c) * 0.2);
  background: linear-gradient(155deg, #d98466, var(--bridge) 70%);
  box-shadow: inset 0 calc(var(--c) * 0.03) calc(var(--c) * 0.06) rgba(60, 25, 10, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.15);
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.25s var(--ease), transform 0.4s var(--ease);
}

.tile.is-filled .fill {
  opacity: 1;
  transform: none;
}

.piece {
  transition: transform var(--t, 140ms) var(--move-ease, cubic-bezier(0.25, 0.8, 0.3, 1));
}

.block .face {
  position: absolute;
  inset: 9% 9% 11%;
  border-radius: 20%;
  transform: translateY(calc(var(--c) * -0.1));
  background: linear-gradient(155deg, var(--block-top) 10%, var(--block) 75%);
  box-shadow:
    0 calc(var(--c) * 0.12) 0 var(--block-side),
    0 calc(var(--c) * 0.2) calc(var(--c) * 0.2) rgba(60, 44, 30, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: box-shadow 0.3s var(--ease), transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

.block .face::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(155deg, #efc677 10%, var(--goal) 75%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.block.on-goal .face {
  box-shadow:
    0 calc(var(--c) * 0.12) 0 var(--goal-side),
    0 calc(var(--c) * 0.2) calc(var(--c) * 0.2) rgba(60, 44, 30, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  animation: settle 0.5s var(--ease);
}

.block.on-goal .face::after {
  opacity: 1;
}

@keyframes settle {
  40% { transform: translateY(calc(var(--c) * -0.16)) scale(1.06); }
}

.block.is-sunk .face {
  transform: translateY(calc(var(--c) * 0.02)) scale(0.84);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.2s 0.1s linear;
}

.hero-piece {
  --lx: 0px;
  --ly: 0px;
}

.hero-piece::before {
  content: '';
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 10%;
  height: 18%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(60, 44, 30, 0.38), transparent);
}

.hero-piece .feet {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 50%;
  height: 17%;
  translate: -50% 0;
  background:
    radial-gradient(closest-side, var(--player-shade) 92%, transparent) 0 0 / 40% 100% no-repeat,
    radial-gradient(closest-side, var(--player-shade) 92%, transparent) 100% 0 / 40% 100% no-repeat;
  transform: translate(calc(var(--lx) * 0.6), calc(var(--ly) * 0.4));
  transition: transform 0.14s var(--ease);
}

.hero-piece .body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70%;
  height: 67%;
  margin: -44% 0 0 -35%;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 34% 26%, #fffefa 0, #f5efe4 34%, #e6dccb 78%, #d3c6b1 100%);
  box-shadow:
    inset calc(var(--c) * -0.04) calc(var(--c) * -0.06) calc(var(--c) * 0.1) rgba(140, 115, 80, 0.28),
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    0 calc(var(--c) * 0.05) calc(var(--c) * 0.06) rgba(60, 44, 30, 0.22);
  transform-origin: 50% 90%;
}

.hero-piece .eye {
  position: absolute;
  top: 40%;
  width: 9.5%;
  height: 13%;
  border-radius: 50%;
  background: var(--ink);
  transform: translate(var(--lx), var(--ly));
  transition: transform 0.14s var(--ease);
  animation: blink 4.6s infinite;
}

.hero-piece .eye:first-child {
  left: 33%;
}

.hero-piece .eye:last-child {
  left: 57.5%;
}

.hero-piece[data-face='right'] { --lx: calc(var(--c) * 0.06); }
.hero-piece[data-face='left'] { --lx: calc(var(--c) * -0.06); }
.hero-piece[data-face='up'] { --ly: calc(var(--c) * -0.05); }
.hero-piece[data-face='down'] { --ly: calc(var(--c) * 0.04); }

.hero-piece.is-stepping .body {
  animation: squash 0.22s var(--ease);
}

@keyframes squash {
  0% { transform: scale(1.08, 0.9); }
  60% { transform: scale(0.97, 1.04); }
}

.hero-piece.is-bumping .body {
  animation: bump 0.26s var(--ease);
}

@keyframes bump {
  40% { transform: translate(var(--bx), var(--by)) scale(1.04, 0.96); }
}

/* "Swipe" hint over the first level until the first move, like the game's. */
.swipe-hint {
  pointer-events: none;
  z-index: 40;
}

.swipe-hint::before {
  content: '';
  position: absolute;
  left: 30%;
  top: 30%;
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 0 calc(var(--c) * 0.08) rgba(255, 255, 255, 0.3), 0 6px 16px rgba(60, 44, 30, 0.2);
  animation: swipe 2.2s var(--ease) infinite;
}

@keyframes swipe {
  0% { opacity: 0; transform: translateX(0) scale(0.8); }
  15% { opacity: 1; transform: translateX(0) scale(1); }
  65% { opacity: 1; transform: translateX(calc(var(--c) * 1.6)); }
  85%, 100% { opacity: 0; transform: translateX(calc(var(--c) * 1.8)) scale(0.9); }
}

/* Solved panel, like the game's completion sheet. */
.solved {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: inherit;
  background: radial-gradient(closest-side, rgba(233, 228, 220, 0.94), rgba(233, 228, 220, 0.7));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s var(--ease), visibility 0s 0.45s;
}

.solved.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s var(--ease) 0.35s, visibility 0s 0.35s;
}

.solved-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  max-width: 380px;
  text-align: center;
  transform: translateY(16px);
  transition: transform 0.7s var(--ease) 0.35s;
}

.solved.is-open .solved-card {
  transform: none;
}

.solved-card .h3 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.solved-card p {
  margin: 0;
  color: var(--dim);
}

.solved-card .row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.stars {
  display: flex;
  gap: 8px;
}

.stars i {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--goal);
  box-shadow: 0 3px 0 var(--goal-side);
  transform: scale(0);
  transition: transform 0.5s var(--ease);
}

.solved.is-open .stars i {
  transform: scale(1);
}

.solved.is-open .stars i {
  transition-delay: 0.5s;
}

.stars i.is-empty {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--goal);
}

@media (max-width: 900px) {
  .demo {
    grid-template-columns: 1fr;
  }
}

/* ---------- Materials ---------- */

.materials {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 28px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.material {
  display: grid;
  align-content: start;
  gap: 10px;
}

.material figure {
  position: relative;
  margin: 0 0 12px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
}

.material img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--ease);
  -webkit-mask-image: radial-gradient(closest-side, #000 80%, transparent);
  mask-image: radial-gradient(closest-side, #000 80%, transparent);
}

.material:hover img {
  transform: translateY(-8px) scale(1.04);
}

.material .swatch {
  display: flex;
  align-items: center;
  gap: 10px;
}

.material .swatch i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--c);
  box-shadow: 0 2px 0 var(--s);
}

.material h3 {
  margin: 0;
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.material p {
  margin: 0;
  font-size: 16px;
  color: var(--dim);
  max-width: 22em;
}

@media (max-width: 900px) {
  .materials {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 48px;
  }
}

/* ---------- Worlds ---------- */

.worlds {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.world {
  position: relative;
  display: grid;
  grid-template-columns: 7.5rem 64px minmax(0, 1fr) minmax(0, 1.25fr);
  align-items: center;
  gap: clamp(16px, 3vw, 48px);
  padding: 22px clamp(8px, 1.5vw, 20px);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.5s var(--ease);
}

.world::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 18px;
  background: var(--raised);
  box-shadow: 0 3px 0 var(--floor-side), 0 18px 32px -18px rgba(92, 70, 48, 0.4);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.4s var(--ease), transform 0.5s var(--ease);
}

.world:hover::before {
  opacity: 1;
  transform: none;
}

.world-range {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.world-glyph {
  width: 64px;
  height: 64px;
  transition: transform 0.6s var(--ease);
}

.world:hover .world-glyph {
  transform: translateY(-4px) rotate(-4deg);
}

.world h3 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(2rem, 3.6vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.025em;
  transition: transform 0.6s var(--ease);
}

.world:hover h3 {
  transform: translateX(8px);
}

.world p {
  margin: 0;
  font-size: 17px;
  color: var(--dim);
  text-wrap: pretty;
}

@media (max-width: 760px) {
  .world {
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas: 'glyph name' 'glyph idea' 'glyph range';
    row-gap: 6px;
    align-items: start;
  }

  .world-glyph {
    grid-area: glyph;
    width: 52px;
    height: 52px;
  }

  .world h3 {
    grid-area: name;
  }

  .world p {
    grid-area: idea;
    font-size: 16px;
  }

  .world-range {
    grid-area: range;
    font-size: 13px;
  }
}

/* Glyph motion on hover: each world's one idea, moving. */
.g-drop { transition: transform 0.6s var(--ease), opacity 0.4s var(--ease); }
.world:hover .g-drop { transform: translateY(10px) scale(0.85); opacity: 0; }
.g-slide { transition: transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1); }
.world:hover .g-slide { transform: translateX(16px); }
.g-spikes { transition: transform 0.5s var(--ease); transform-origin: 50% 100%; }
.world:hover .g-spikes { transform: scaleY(0.15); }
.g-turn { transform-box: fill-box; transform-origin: center; transition: transform 1.2s var(--ease); }
.world:hover .g-turn { transform: rotate(200deg); }
.g-belt { animation: belt 0.9s linear infinite paused; }
.world:hover .g-belt { animation-play-state: running; }
@keyframes belt { to { transform: translateX(10px); } }
.g-crack { stroke-dasharray: 60; stroke-dashoffset: 0; transition: stroke-dashoffset 0.8s var(--ease); }
.world:hover .g-crack { stroke-dashoffset: 60; animation: redraw 0.8s var(--ease) 0.1s forwards; }
@keyframes redraw { to { stroke-dashoffset: 0; } }
.g-left, .g-right { transition: transform 0.6s var(--ease); }
.world:hover .g-left { transform: translateX(-5px); }
.world:hover .g-right { transform: translateX(5px); }
.g-key { transform-box: fill-box; transform-origin: 30% 50%; transition: transform 0.6s var(--ease); }
.world:hover .g-key { transform: rotate(-90deg); }
.g-pop { transform-box: fill-box; transform-origin: center; transition: transform 0.6s var(--ease); }
.world:hover .g-pop { transform: translateY(-3px) scale(1.08); }

/* ---------- Principles ---------- */

.principles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(32px, 6vw, 96px);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: p;
}

.principle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 24px;
  padding-block: 36px;
  border-top: 1px solid var(--line);
  counter-increment: p;
}

.principle::before {
  content: '0' counter(p);
  grid-row: span 2;
  padding-top: 0.55em;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.principle h3 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(1.9rem, 3vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.principle p {
  margin: 0;
  color: var(--dim);
  max-width: 28em;
}

@media (max-width: 760px) {
  .principles {
    grid-template-columns: 1fr;
  }
}

/* ---------- Download ---------- */

.coming {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 5vw, 80px);
}

.coming figure {
  margin: 0;
}

.coming img {
  width: 100%;
  -webkit-mask-image: radial-gradient(closest-side, #000 70%, transparent);
  mask-image: radial-gradient(closest-side, #000 70%, transparent);
}

.coming-copy {
  display: grid;
  gap: 28px;
  justify-items: start;
}

.stores {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.store {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 22px 0 18px;
  border-radius: 18px;
  background: var(--raised);
  box-shadow: 0 3px 0 var(--floor-side), 0 12px 24px -14px rgba(92, 70, 48, 0.5);
}

.store svg {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--ink);
}

.store span {
  display: grid;
  line-height: 1.15;
}

.store small {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.store b {
  font-weight: 500;
  font-size: 18px;
}

@media (max-width: 760px) {
  .coming {
    grid-template-columns: 1fr;
  }

  .coming figure {
    width: min(100%, 420px);
    margin-inline: auto;
  }
}

/* ---------- Footer ---------- */

.footer {
  padding-block: 56px 40px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--dim);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer a {
  text-decoration: none;
  color: var(--ink);
}

.footer a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.footer .brand {
  font-size: 18px;
  color: var(--ink);
}

.footer .mark {
  transform: scale(0.8);
}

/* ---------- Document pages (support, privacy) ---------- */

.doc {
  padding-block: 152px clamp(96px, 12vw, 160px);
}

.doc-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 32px;
  padding-bottom: clamp(40px, 6vw, 72px);
  margin-bottom: clamp(40px, 6vw, 72px);
  border-bottom: 1px solid var(--line);
}

.doc-head .h2 {
  margin-top: 24px;
}

.doc-head .lead {
  margin-top: 24px;
  max-width: 32em;
}

.doc-head img {
  width: clamp(140px, 22vw, 280px);
  -webkit-mask-image: radial-gradient(closest-side, #000 70%, transparent);
  mask-image: radial-gradient(closest-side, #000 70%, transparent);
}

.doc-body {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 2.4fr);
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
}

.toc {
  position: sticky;
  top: 104px;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
}

.toc a {
  color: var(--dim);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.toc a:hover,
.toc a.is-active {
  color: var(--ink);
}

.prose {
  max-width: 44em;
}

.prose h2 {
  margin: 64px 0 18px;
  font-weight: 400;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose h3 {
  margin: 36px 0 8px;
  font-weight: 500;
  font-size: 19px;
}

.prose p,
.prose li {
  color: var(--dim);
}

.prose strong {
  color: var(--ink);
  font-weight: 500;
}

.prose a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.prose ul {
  padding-left: 1.1em;
}

.prose li + li {
  margin-top: 8px;
}

.prose li::marker {
  color: var(--block);
}

.faq {
  margin: 0;
  border-top: 1px solid var(--line);
}

.faq details {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0;
  font-size: 20px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

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

.faq summary::after {
  content: '';
  flex: none;
  width: 14px;
  height: 14px;
  background:
    linear-gradient(var(--ink), var(--ink)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) center / 1.5px 100% no-repeat;
  transition: transform 0.4s var(--ease);
}

.faq details[open] summary::after {
  transform: rotate(135deg);
}

.faq details > div {
  padding-bottom: 24px;
}

.faq details > div > :first-child {
  margin-top: 0;
}

.contact-card {
  display: grid;
  gap: 16px;
  justify-items: start;
  margin-top: 64px;
  padding: clamp(24px, 4vw, 40px);
  border-radius: 28px;
  background: var(--raised);
  box-shadow: 0 3px 0 var(--floor-side), 0 24px 40px -28px rgba(92, 70, 48, 0.5);
}

.contact-card h2 {
  margin: 0;
}

.contact-card p {
  margin: 0;
}

.meta {
  font-size: 14px;
  color: var(--dim);
}

@media (max-width: 860px) {
  .doc-head,
  .doc-body {
    grid-template-columns: 1fr;
  }

  .doc-head img {
    display: none;
  }

  .toc {
    display: none;
  }
}

/* ---------- 404 ---------- */

.lost {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 120px var(--gutter) 80px;
  text-align: center;
}

.lost-inner {
  display: grid;
  justify-items: center;
  gap: 24px;
}

.lost img {
  width: min(360px, 70vw);
  margin-bottom: -24px;
  -webkit-mask-image: radial-gradient(closest-side, #000 70%, transparent);
  mask-image: radial-gradient(closest-side, #000 70%, transparent);
}

/* ---------- Motion preferences ---------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }

  .hero-art img {
    transform: none;
  }
}
