/* ============================================================
   chimp.land — full-viewport pastel canopy
   One 1440×900 core scene centered via xMidYMid meet inside a
   full-bleed zero-scroll viewport. All layers share the exact
   scene coordinate system (--u = scene scale, --ox/--oy = origin).
   ============================================================ */
@font-face {
  font-family: "Lexend Deca";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/lexend-deca.woff2") format("woff2");
}

:root {
  --paper: #f6f1e7;
  --paper-2: #fbf8f1;
  --ink: #2f2c29;
  --ink-soft: #5d5751;
  --muted: #746d65;
  --coral: #e58c78;
  --font: "Lexend Deca", ui-rounded, "Avenir Next", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; border: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--paper);
}
body {
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
::selection { background: rgba(245, 213, 101, .55); }
a { color: inherit; }

/* ---------- stage: full-viewport zero-scroll canvas ---------- */
.stage {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; height: 100dvh;
  overflow: hidden; isolation: isolate;
  background: var(--paper);
  --u: 1px; --ox: 0px; --oy: 0px;
}
.layer { position: absolute; inset: 0; pointer-events: none; will-change: transform; }
.layer > svg, .layer > canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; overflow: visible;
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- sky ---------- */
.cloud { position: absolute; left: 0; pointer-events: none; will-change: transform; animation: drift linear infinite; }
.cloud svg { display: block; width: 100%; height: auto; overflow: visible; }
.cloud-1 { top: max(20px, calc(var(--oy) + 63 * var(--u))); width: max(84px, calc(144 * var(--u))); animation-duration: 210s; animation-delay: -60s; }
.cloud-2 { top: max(62px, calc(var(--oy) + 135 * var(--u))); width: max(62px, calc(101 * var(--u))); animation-duration: 260s; animation-delay: -170s; opacity: .85; }
@keyframes drift { from { transform: translateX(-20vw); } to { transform: translateX(116vw); } }

/* ---------- water ---------- */
.streak { stroke: #fbf8f1; stroke-width: 1.4; stroke-linecap: round; fill: none; stroke-dasharray: 12 22; animation: fall 1.4s linear infinite; opacity: .8; }
.streak:nth-of-type(2) { animation-duration: 1.1s; stroke-dasharray: 9 20; }
.streak:nth-of-type(3) { animation-duration: 1.6s; stroke-dasharray: 16 26; opacity: .55; }
@keyframes fall { to { stroke-dashoffset: -68; } }
.glint { fill: none; stroke: #fbf8f1; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 10 34; opacity: .85; animation: flow 7s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -264; } }

/* ---------- perches ---------- */
.perch { cursor: pointer; outline: none; pointer-events: auto; }
.perch .hit { fill: transparent; pointer-events: all; }
.perch .halo { opacity: 0; transition: opacity .6s ease; }
.perch.is-lit .halo, .perch:focus-visible .halo { opacity: 1; }

/* ---------- title ---------- */
.title {
  position: absolute; left: 50%;
  top: calc(var(--oy) + 136 * var(--u));
  width: calc(576 * var(--u));
  transform: translateX(-50%);
  text-align: center; pointer-events: none; z-index: 4;
}
.title-inner { will-change: transform; }
.welcome { display: block; width: 62%; margin: 0 auto calc(-16.5 * var(--u)); overflow: visible; }
.welcome text { font-family: var(--font); font-weight: 400; font-size: 25px; letter-spacing: .2em; fill: var(--muted); }
.wordmark {
  position: relative; display: inline-block; margin: 0;
  font-weight: 400; font-size: calc(92 * var(--u)); line-height: 1.05; letter-spacing: -.03em; color: var(--ink);
  -webkit-text-stroke: .018em var(--ink);
}
.wordmark .swash { position: absolute; left: -5%; width: 110%; top: 46%; height: 56%; z-index: -1; overflow: visible; }
.wordmark .ch { display: inline-block; pointer-events: auto; }
.wordmark .ch.dot { color: var(--coral); -webkit-text-stroke-color: var(--coral); }
.wordmark .ch.wob { animation: wob .7s cubic-bezier(.3, 1.6, .4, 1); }
@keyframes wob { 30% { transform: translateY(-.08em) rotate(-6deg); } 65% { transform: translateY(.02em) rotate(3deg); } }

/* ---------- nav: bare text in the open sky ---------- */
.topbar {
  position: absolute;
  top: max(18px, env(safe-area-inset-top, 18px), calc(var(--oy) + 33 * var(--u)));
  right: max(20px, env(safe-area-inset-right, 20px), calc(var(--ox) + 52 * var(--u)));
  z-index: 20;
  display: flex; gap: clamp(16px, calc(27 * var(--u)), 30px);
  font-size: clamp(13px, calc(15 * var(--u)), 17px); letter-spacing: .03em; color: var(--ink-soft);
}
.topbar a {
  display: inline-block; text-decoration: underline wavy transparent;
  text-underline-offset: .4em; text-decoration-thickness: 1.2px;
  transition: text-decoration-color .3s, transform .3s, color .3s;
}
.topbar a:hover, .topbar a:focus-visible, .topbar a.is-lit {
  color: var(--ink); text-decoration-color: var(--coral); transform: rotate(-2deg); outline: none;
}

/* ---------- hover note ---------- */
.notes { position: absolute; inset: 0; pointer-events: none; z-index: 15; }
.note {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  padding: clamp(5px, calc(6.5 * var(--u)), 9px) clamp(11px, calc(13 * var(--u)), 18px) clamp(6px, calc(7.2 * var(--u)), 10px);
  line-height: 1.25;
  background: rgba(255, 253, 248, .92); border: 1px solid rgba(47, 44, 41, .12); border-radius: 999px;
  box-shadow: 0 4px 14px -8px rgba(61, 57, 53, .28);
  font-size: clamp(12px, calc(14.5 * var(--u)), 16px); color: var(--ink-soft);
  opacity: 0; transform: translate(-50%, -100%) translateY(6px);
  transition: opacity .3s ease, transform .4s cubic-bezier(.2, .8, .3, 1);
}
.note.is-on { opacity: 1; transform: translate(-50%, -100%); }
.note.below { transform: translate(-50%, 0) translateY(-6px); }
.note.below.is-on { transform: translate(-50%, 0); }
.note b { font-weight: 400; color: var(--ink); }
.note i { font-style: normal; color: var(--coral); margin-left: .35em; }

/* ---------- portrait mobile dock (hidden on desktop / landscape) ---------- */
.mobile-dock {
  display: none;
  position: absolute; left: 50%;
  bottom: max(26px, calc(env(safe-area-inset-bottom, 16px) + 18px));
  transform: translateX(-50%);
  width: min(88vw, 380px);
  z-index: 20;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mobile-dock a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 15px;
  border-radius: 999px;
  background: rgba(255, 253, 248, .86);
  border: 1px solid rgba(47, 44, 41, .11);
  box-shadow: 0 6px 18px -12px rgba(61, 57, 53, .32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-decoration: none;
  font-size: 13.5px; letter-spacing: .01em; color: var(--ink);
  transition: transform .2s ease, border-color .2s ease;
}
.mobile-dock a i { font-style: normal; color: var(--coral); margin-left: 6px; }
.mobile-dock a:active, .mobile-dock a:focus-visible { transform: scale(.97); border-color: rgba(47, 44, 41, .28); outline: none; }

@media (max-aspect-ratio: 4 / 5) {
  .topbar { display: none; }
  .mobile-dock { display: grid; }
  .title {
    top: max(68px, 10dvh);
    width: min(86vw, 420px);
  }
  .welcome { width: 58%; margin-bottom: -6px; }
  .wordmark { font-size: clamp(38px, 11.8vw, 56px); }
  .cloud-1 { top: max(22px, 4.5dvh); }
  .cloud-2 { top: max(54px, 8.5dvh); }
}

/* ---------- butterfly ---------- */
.butterfly {
  position: absolute; left: 0; top: 0;
  width: max(14px, calc(32 * var(--u))); aspect-ratio: 1.25;
  margin: calc(-13 * var(--u)) 0 0 calc(-16 * var(--u));
  pointer-events: none; will-change: transform; z-index: 6;
}
.butterfly svg { width: 100%; height: 100%; overflow: visible; display: block; }
.butterfly .wing { transform-box: fill-box; animation: flap .34s ease-in-out infinite alternate; }
.butterfly .wing-l { transform-origin: 100% 50%; }
.butterfly .wing-r { transform-origin: 0% 50%; }
@keyframes flap { from { transform: scaleX(1); } to { transform: scaleX(.3); } }

.grain {
  position: absolute; inset: 0; z-index: 30; pointer-events: none; mix-blend-mode: multiply; opacity: .28;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.40  0 0 0 0 0.33  0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
#paint { position: fixed; inset: 0; z-index: 50; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .cloud, .streak, .glint, .butterfly .wing { animation: none !important; }
}
.static .cloud, .static .streak, .static .glint { animation: none; }
