/* KANZ Hosting - interaction and motion layer (loads after style.css).
   Rules of this file:
   - one pixel unit everywhere: block faces are 16 x 16 texels drawn at 3, 4 or 6 px per texel; particles are 4 px squares
   - only transform / opacity / the individual translate + scale properties move (accordion-type panels are the one exception)
   - hover motion is gated to real pointers, and everything stops under prefers-reduced-motion
   Block face textures are the --tx-* variables in css/textures.css (generated by _source/build_site.py). */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}
html { color-scheme: dark; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.display, .h2 { text-wrap: balance; }
a, button, summary, input { touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; }

/* ============================================================ hero scene */
.hero { background: none; }
.hero { overflow: clip; }
/* the hollow gem sits on the edge of the page so only half of it shows (the edge is the art side: left in Arabic, right in English) */
.hero__gem { position: absolute; inset: 0; pointer-events: none; }
.hero__gem::before { content: ""; position: absolute; top: 50%; left: 0; height: min(94%, 620px); aspect-ratio: 17 / 13; translate: -50% -50%;
  background: url("../assets/gem-hollow.svg") center / contain no-repeat; }
html[lang="en"] .hero__gem::before { left: auto; right: 0; translate: 50% -50%; }
.hero__in { z-index: 2; }
/* hero -> plans: an ordered-dither edge in the colour the next section starts with */
.hero::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 24px; pointer-events: none;
  background: var(--tx-dither) 0 0 / 48px 24px repeat-x; image-rendering: pixelated; }
.hero__fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
.fx-burst { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; image-rendering: pixelated; }

.scene { position: relative; width: min(100%, 600px); margin-inline: auto; aspect-ratio: 900 / 708; }
.hero__art .scene img { width: 100%; margin: 0; }
.scene__l { position: absolute; left: var(--x); top: var(--y); width: var(--w); translate: -50% -50%; }
.scene__l--base { inset: 0; width: auto; translate: none; }
.scene__p { display: block; }                    /* the part the pointer moves (added by js/fx.js) */
.scene__l--vox { width: var(--s, 96px); --s: 96px; z-index: 3; }

/* the island in pieces: positions come from js/config.js (scene), offsets from the pointer */
.isle { position: relative; aspect-ratio: 900 / 708; }
.isle img { position: absolute; max-width: none; height: auto; pointer-events: none; -webkit-user-drag: none; user-select: none; }
.scene.is-live { cursor: pointer; touch-action: pan-y; }

.bob--a { animation: bob-a 4.2s steps(7) infinite alternate; }
.bob--b { animation: bob-b 5.4s steps(8) -1.2s infinite alternate; }
.bob--c { animation: bob-a 6.2s steps(8) -2.4s infinite alternate-reverse; }
@keyframes bob-a { from { transform: translateY(6%); } to { transform: translateY(-10%); } }
@keyframes bob-b { from { transform: translateY(-7%); } to { transform: translateY(7%); } }

/* entrance: plain CSS so it runs on the compositor while the page is still loading, and nothing waits for a script */
.hero__copy > * { animation: rise .5s var(--ease-out) backwards; }
.hero__copy > :nth-child(2) { animation-delay: .06s; }
.hero__copy > :nth-child(3) { animation-delay: .12s; }
.hero__copy > :nth-child(4) { animation-delay: .18s; }
.hero__copy > :nth-child(5) { animation-delay: .24s; }
.scene__l { animation: pop-in .45s var(--ease-out) var(--d, 0s) backwards; }
.scene__l--base { animation: rise-t .6s var(--ease-out) backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes rise-t { from { opacity: 0; translate: 0 18px; } }
@keyframes pop-in { from { opacity: 0; scale: .9; } }

/* ============================================================ voxel blocks
   A CSS 3D cube: six 16 x 16 faces. .vox__tilt follows the pointer, .vox__hit takes the knock, .vox__spin turns. */
.vox { --s: 96px; position: relative; display: block; width: var(--s); height: var(--s); perspective: 700px; background: none; border: 0; padding: 0; color: inherit; }
.vox--m { --s: 64px; } .vox--s { --s: 48px; }
.vox__tilt, .vox__hit, .vox__spin { position: absolute; inset: 0; display: block; transform-style: preserve-3d; }
.vox__tilt { transform: rotateX(-24deg); }
.vox__spin { transform: rotateY(-38deg); animation: vox-spin 18s linear infinite; }
.vox--rev .vox__spin { animation-direction: reverse; animation-duration: 26s; }
@keyframes vox-spin { from { transform: rotateY(-38deg); } to { transform: rotateY(322deg); } }
.vox i { position: absolute; inset: 0; background: var(--side) 0 0 / 100% 100%; image-rendering: pixelated; backface-visibility: hidden; }
.vox i::after { content: ""; position: absolute; inset: 0; background: var(--crack, none) 0 0 / 100% 100%; image-rendering: pixelated; }
.vox i:nth-child(1) { transform: translateZ(calc(var(--s) / 2)); }
.vox i:nth-child(2) { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.vox i:nth-child(3) { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); background-image: var(--side-d); }
.vox i:nth-child(4) { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); background-image: var(--side-d); }
.vox i:nth-child(5) { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); background-image: var(--top); }
.vox i:nth-child(6) { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); background-image: var(--bottom); }
.vox--ore { --side: var(--tx-ore); --side-d: var(--tx-ore-d); --top: var(--tx-ore); --bottom: var(--tx-ore-d); }
.vox--turf { --side: var(--tx-turf-side); --side-d: var(--tx-turf-side-d); --top: var(--tx-turf-top); --bottom: var(--tx-stone-d); }
.vox--srv { --side: var(--tx-rack); --side-d: var(--tx-rack-d); --top: var(--tx-plate); --bottom: var(--tx-rack-d); }
.vox--stone { --side: var(--tx-stone); --side-d: var(--tx-stone-d); --top: var(--tx-stone); --bottom: var(--tx-stone-d); }
.vox[data-stage="1"] { --crack: var(--tx-crack-1); }
.vox[data-stage="2"] { --crack: var(--tx-crack-2); }
.vox[data-stage="3"] { --crack: var(--tx-crack-3); }
.is-paused .vox__spin, .is-paused .bob--a, .is-paused .bob--b, .is-paused .bob--c, .is-paused .float { animation-play-state: paused; }

/* the block you can mine */
button.vox { cursor: url("../assets/art/cursor-pick.png") 26 4, pointer; }
.ore__n { position: absolute; top: calc(100% + 16px); left: 50%; translate: -50% 0; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px 10px 4px; font-size: 13px; font-weight: 700; color: var(--mint); background: var(--ink); border: 1px solid rgba(90, 234, 207, .4); border-radius: 3px; direction: ltr; }
.ore__n img { width: 18px !important; }
.ore__n span:empty { display: none; }
.ore__gem { position: absolute; left: 50%; top: 50%; width: 36px !important; margin: -14px 0 0 -18px !important; pointer-events: none; }

.cta__vox { position: absolute; top: 50%; margin-top: -32px; pointer-events: none; }
.cta__vox--1 { inset-inline-start: max(4%, calc(50% - 560px)); }
.cta__vox--2 { inset-inline-end: max(4%, calc(50% - 560px)); margin-top: 20px; }

/* ================================================================== nav */
.nav__menu a[aria-current="true"] { color: var(--mint); border-color: var(--mint); }
.snd { display: grid; place-items: center; padding: 0; }
.snd[aria-pressed="false"] .snd__on, .snd[aria-pressed="true"] .snd__off { display: none; }
.snd[aria-pressed="true"] { color: var(--mint); border-color: var(--mint); }
.nav__burger span { transition: transform .2s var(--ease-out), opacity .15s ease; }
.nav__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav__burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }
@media (max-width: 1080px) {
  .nav__menu { display: flex; visibility: hidden; opacity: 0; transform: translateY(-8px); transition: opacity .2s var(--ease-out), transform .2s var(--ease-out), visibility 0s .2s; }
  .nav__menu.is-open { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
  .nav__menu a[aria-current="true"] { border-color: var(--line); }
}

/* ================================================================ plans */
.plan { transition: border-color .15s ease; }
@media (hover: hover) and (pointer: fine) {
  .plan:not(.plan--best):hover { border-color: var(--blue-200); }
  .chest:not([aria-expanded="true"]):hover .chest__lid { transform: rotateX(12deg); }
  .wall span:hover { transform: translateY(-6px); border-color: var(--mint); }
}
@media (min-width: 921px) {
  .plan--best { translate: 0 -10px; }       /* the recommended plan stands a step above the other two */
}
@media not ((hover: hover) and (pointer: fine)) {
  .wall span:hover { transform: none; border-color: var(--line-2); }   /* a tap must not leave a tile stuck in its hover state */
}

/* waiting for the order page */
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after { content: ""; width: 18px; height: 4px; flex: none; animation: dots .75s steps(1) infinite;
  background: linear-gradient(currentColor, currentColor) 0 0 / 4px 4px no-repeat, linear-gradient(currentColor, currentColor) 7px 0 / 4px 4px no-repeat, linear-gradient(currentColor, currentColor) 14px 0 / 4px 4px no-repeat; }
@keyframes dots { 0% { clip-path: inset(0 14px 0 0); } 33% { clip-path: inset(0 7px 0 0); } 66% { clip-path: inset(0); } }

/* ================================================================= loot */
.loot { padding-block: 34px !important; }
.loot__in { display: flex; align-items: center; gap: clamp(18px, 4vw, 48px); padding: 18px 30px; border: 1px solid var(--line-2); border-radius: 4px;
  background: radial-gradient(120% 90% at 50% -10%, rgba(40, 157, 243, .16), transparent 62%), linear-gradient(180deg, rgba(3, 57, 95, .62), rgba(2, 42, 71, .62)); }
.loot__copy { flex: 1; min-width: 0; display: grid; }
.loot__ask, .loot__out { grid-area: 1 / 1; align-self: center; transition: opacity .25s var(--ease-out), transform .25s var(--ease-out), visibility 0s .25s; }
.loot__ask p { margin-top: 4px; }
.loot__out { opacity: 0; visibility: hidden; transform: translateY(10px); }
.loot.is-open .loot__out { opacity: 1; visibility: visible; transform: none; transition-delay: .2s, .2s, 0s; }
.loot.is-open .loot__ask { opacity: 0; visibility: hidden; transform: translateY(-10px); }
.loot__list { display: grid; grid-template-columns: repeat(3, minmax(0, max-content)); justify-content: start; gap: 8px 10px; margin-top: 12px; }
.loot__list li { display: flex; align-items: center; gap: 9px; padding: 4px 14px 7px 12px; border: 1px solid var(--line-2); border-radius: 3px; background: rgba(2, 26, 46, .5); color: var(--frost); font-weight: 700; font-size: 15px; line-height: 1.4; min-width: 0; }
.loot__list img { width: 24px; height: 24px; object-fit: contain; flex: none; }
.loot__go { margin-top: 14px; justify-self: start; }
.loot__out { display: grid; }

/* the chest: a 3D box of 16 x 16 block faces, the lid hinged on its back edge */
.chest { --u: 6px; position: relative; flex: none; width: calc(var(--u) * 26); height: calc(var(--u) * 25); padding: 0; background: none; border: 0; perspective: 900px; cursor: pointer; }
.chest__box { position: absolute; left: 50%; top: 66%; width: calc(var(--u) * 16); height: calc(var(--u) * 16); margin: calc(var(--u) * -8) 0 0 calc(var(--u) * -8);
  transform-style: preserve-3d; transform: rotateX(-22deg) rotateY(-32deg); transition: scale .14s var(--ease-out); animation: chest-hop 3.6s steps(1) 1.5s infinite; }
.chest:active .chest__box { scale: .96; }
.chest[aria-expanded="true"] .chest__box { animation: none; }
@keyframes chest-hop { 0%, 12%, 100% { translate: 0 0; } 4% { translate: 0 -6px; } 8% { translate: 0 -3px; } }
.cf, .cl { position: absolute; left: 0; width: calc(var(--u) * 16); height: calc(var(--u) * 11); background-repeat: no-repeat; background-size: calc(var(--u) * 16) calc(var(--u) * 16);
  image-rendering: pixelated; backface-visibility: hidden; }
.cf { top: calc(var(--u) * 5); background-position: 0 100%; background-image: var(--tx-chest-side-d); }
.cf--front { background-image: var(--tx-chest-front); transform: translateZ(calc(var(--u) * 8)); }
.cf--back { transform: rotateY(180deg) translateZ(calc(var(--u) * 8)); }
.cf--right { transform: rotateY(90deg) translateZ(calc(var(--u) * 8)); }
.cf--left { transform: rotateY(-90deg) translateZ(calc(var(--u) * 8)); }
.cf--in { top: calc(var(--u) * -3 + 2px); height: calc(var(--u) * 16); background-image: var(--tx-chest-in); transform: rotateX(90deg); }
.chest__lid { position: absolute; left: 0; top: 0; width: calc(var(--u) * 16); height: calc(var(--u) * 5); transform-style: preserve-3d;
  transform-origin: 50% 100% calc(var(--u) * -8); transition: transform .5s var(--ease-pop); }
.chest[aria-expanded="true"] .chest__lid { transform: rotateX(112deg); }
.cl { top: 0; height: calc(var(--u) * 5); background-position: 0 0; background-image: var(--tx-chest-side-d); }
.cl--front { background-image: var(--tx-chest-front); transform: translateZ(calc(var(--u) * 8)); }
.cl--back { transform: rotateY(180deg) translateZ(calc(var(--u) * 8)); }
.cl--right { transform: rotateY(90deg) translateZ(calc(var(--u) * 8)); }
.cl--left { transform: rotateY(-90deg) translateZ(calc(var(--u) * 8)); }
.cl--top { top: calc(var(--u) * -8); height: calc(var(--u) * 16); background-image: var(--tx-chest-top); transform: rotateX(90deg); }
.cl--under { top: calc(var(--u) * -3 - 2px); height: calc(var(--u) * 16); background: var(--navy-900); box-shadow: inset 0 0 0 var(--u) var(--navy-500); transform: rotateX(-90deg); }

/* ============================================================ small bits */
.ram__card > img { animation: swap-in .2s var(--ease-out); }
.panel__view { animation: view-in .22s var(--ease-out); }
@keyframes swap-in { from { opacity: .5; transform: scale(.94); } }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.steps__row { position: relative; }
.steps__row li.steps__bar { position: absolute; inset-inline: 0; top: 0; height: 4px; padding: 0; border: 0; background: var(--mint); transform: scaleX(0); transform-origin: 0 50%; pointer-events: none; }
html[dir="rtl"] .steps__row li.steps__bar { transform-origin: 100% 50%; }
.wall span { cursor: pointer; }
.faq details.is-moving p { overflow: hidden; }
.faq details.is-closing summary::after { transform: rotate(45deg); margin-top: -5px; }

/* ============================================================ responsive */
@media (max-width: 860px) {
  .hero__gem::before { top: 210px; height: 430px; }
  .loot__list { grid-template-columns: repeat(2, minmax(0, max-content)); }
  .scene { width: min(78%, 420px); }
  .hero__art .scene img { width: 100%; }
  .scene__l--vox { --s: 56px; }
  .scene__l--vox .vox { --s: 56px; }
  #oreSlot { --x: 90% !important; --y: 4% !important; }
  #swordSlot { --x: 97% !important; --y: 44% !important; }
  .cta__vox { display: none; }
}
@media (max-width: 700px) {
  .loot__in { flex-direction: column; text-align: center; padding: 14px 18px 22px; gap: 6px; }
  .loot__list { justify-content: center; }
  .loot__go { justify-self: center; }
  .chest { --u: 5px; }
}
@media (max-width: 560px) {
  .nav__in { gap: 12px; }
  .loot__list { grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; gap: 6px; }
  .loot__list li { white-space: normal; text-align: start; font-size: 13.5px; line-height: 1.35; padding: 6px 8px 7px; gap: 7px; }
  .loot__list img { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
