:root {
  color-scheme: dark;
  --ground: #111;
  --white: #f4f4f2;
  --muted: #bcbcb9;
  --line: #414141;
  --edge: clamp(22px, 6vw, 76px);
  --apk-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  --apk-clearance: calc(64px + var(--apk-bottom));
  scroll-padding-bottom: var(--apk-clearance);
  font-family: system-ui, "Microsoft YaHei", sans-serif;
  background: var(--ground);
  color: var(--white);
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, figure { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
::selection { background: #ddd; color: #111; }
.wrap { width: min(100% - 2 * var(--edge), 1190px); margin-inline: auto; }
h1, h2 { font-weight: 750; letter-spacing: -.038em; line-height: 1.06; }
h1 { font-size: clamp(3rem, 10.5vw, 6rem); }
h2 { font-size: clamp(2.5rem, 9vw, 5.5rem); }
p { color: var(--muted); line-height: 1.65; }
.hero-copy p, .play-copy p { margin-top: 13px; }
.wide-only { display: none; }

.header {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
}
.wordmark { display: inline-flex; min-height: 44px; align-items: center; gap: 12px; font-size: .875rem; font-weight: 700; }
.wordmark span { width: 13px; height: 13px; border: 1px solid currentColor; transform: rotate(45deg); margin-left: 3px; }
nav { display: flex; gap: 10px; }
nav a { display: inline-flex; min-height: 44px; align-items: center; padding-inline: 7px; font-size: .875rem; }
nav a:hover { text-decoration: underline; text-underline-offset: 4px; }

.scene { position: relative; }
.frame { position: relative; min-height: 100vh; min-height: 100svh; display: grid; align-content: center; gap: 22px; padding-block: 54px var(--apk-clearance); }
.hero-frame { padding-top: 84px; }
.hero, .play, .burst { overflow: clip; }
.hero { background: #111; }
.play { background: #151515; }
.hero-copy, .play-copy { position: relative; z-index: 1; }
.scroll-link { width: fit-content; min-height: 44px; display: inline-flex; align-items: center; gap: 14px; padding-right: 10px; color: var(--white); font-size: .875rem; }
.scroll-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.arrow { position: relative; display: inline-block; width: 16px; height: 12px; flex: none; }
.arrow::before { content: ""; position: absolute; top: 5px; left: 1px; width: 13px; border-top: 1px solid currentColor; }
.arrow::after { content: ""; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-top: 1px solid; border-right: 1px solid; transform: rotate(45deg); }
.arrow-down { transform: rotate(90deg); }

.box-stage {
  --size: clamp(94px, min(31vw, 31svh), 214px);
  position: relative;
  isolation: isolate;
  height: clamp(168px, 41svh, 470px);
  display: grid;
  place-items: center;
  perspective: 760px;
}
.box-stage::before {
  content: "";
  position: absolute;
  inset: -17% -14%;
  z-index: -1;
  background: radial-gradient(ellipse at center, #343434, transparent 61%);
  transform: translateY(var(--back-y, 0px));
  pointer-events: none;
}
.orbit { display: none; position: absolute; aspect-ratio: 1; width: min(96%, 81svh); border: 1px solid #555; border-radius: 50%; opacity: .58; }
.orbit-inner { width: min(71%, 59svh); border-style: dashed; opacity: .42; }
.box-placeholder { width: 100%; height: 100%; background: url("assets/box-placeholder.svg") center / contain no-repeat; }
.cube { display: none; position: relative; width: var(--size); aspect-ratio: 1; transform-style: preserve-3d; }
.face {
  position: absolute;
  inset: 0;
  border: 1px solid #949494;
  background: linear-gradient(145deg, #4c4c4c, #212121);
  backface-visibility: hidden;
}
.face::after { content: ""; position: absolute; inset: 0 43%; background: #eee1; border-inline: 1px solid #fff2; }
.front { transform: translateZ(calc(var(--size) / 2)); }
.back { transform: rotateY(180deg) translateZ(calc(var(--size) / 2)); }
.right { transform: rotateY(90deg) translateZ(calc(var(--size) / 2)); background: #333; }
.left { transform: rotateY(-90deg) translateZ(calc(var(--size) / 2)); background: #2c2c2c; }
.upper { transform: rotateX(90deg) translateZ(calc(var(--size) / 2)); background: #696969; }
.lower { transform: rotateX(-90deg) translateZ(calc(var(--size) / 2)); background: #222; }

.play-progress { display: none; width: 110px; height: 2px; margin-top: 20px; background: #505050; }
.play-progress span { display: block; height: 100%; background: var(--white); transform: scaleX(var(--play-progress, 0)); transform-origin: left; }
.stack { position: relative; display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.stack li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 10px 13px;
  background: #242424;
  border: 1px solid #515151;
  border-radius: 12px;
}
.stack li:nth-child(2) { background: #2c2c2c; }
.stack li:nth-child(3) { background: #353535; }
.stack h3 { font-size: 1.1rem; }
.stack p { margin-top: 3px; font-size: .875rem; }
.step-number { align-self: start; padding-top: 4px; font-size: .8125rem; font-variant-numeric: tabular-nums; color: var(--muted); }

.burst { background: #151515; }
.frame.burst-frame { grid-template-columns: 1fr; justify-items: center; gap: 10px; padding-block: 35px var(--apk-clearance); }
/* Keep enough scroll range to settle the burst when mobile browser bars resize. */
main { padding-bottom: max(0px, calc(100lvh - 100svh)); background: #151515; }
.burst-copy { text-align: center; }
.burst-copy p { margin-top: 10px; }
.burst-stage {
  position: relative;
  --origin-x: 50%;
  --origin-y: 56%;
  width: min(100%, 720px);
  height: clamp(305px, 59svh, 560px);
  isolation: isolate;
  background:
    radial-gradient(circle at 29% 30%, #ddd 0 1px, transparent 2px),
    radial-gradient(circle at 75% 39%, #999 0 1px, transparent 2px),
    radial-gradient(circle at 68% 61%, #ddd 0 1px, transparent 2px),
    radial-gradient(circle at 31% 80%, #999 0 1px, transparent 2px),
    radial-gradient(ellipse at var(--origin-x) var(--origin-y), #393939 0%, #272727 29%, transparent 67%);
}
.burst-orbit {
  position: absolute;
  inset: 15% 14% 7%;
  border: 1px solid #8885;
  border-right-color: transparent;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-18deg);
}
.burst-core {
  position: absolute;
  left: var(--origin-x);
  top: var(--origin-y);
  width: clamp(54px, 15vw, 130px);
  aspect-ratio: 1;
  background: radial-gradient(circle, #dfdfdf, #9b9b9b55 24%, transparent 70%);
  transform: translate(-50%, -50%) scale(1.25);
  opacity: .3;
}
.burst-box {
  position: absolute;
  left: var(--x);
  top: var(--y);
  aspect-ratio: 1;
  background: url("assets/burst-box.svg") center / contain no-repeat;
  transform: translate(-50%, -50%) rotate(var(--angle));
}
.burst-box.far { width: clamp(32px, 10vw, 68px); filter: brightness(.74); }
.burst-box.mid { width: clamp(42px, 13vw, 89px); }
.burst-box.near { width: clamp(53px, 16vw, 115px); filter: brightness(1.15); }

.dock { position: fixed; z-index: 3; inset: auto 0 var(--apk-bottom); pointer-events: none; display: flex; justify-content: center; }
.apk-button {
  --apk-fill: var(--white);
  --apk-ink: #111;
  --apk-radius: 999px;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 12px;
  min-height: 48px;
  max-width: 100%;
  padding: 8px clamp(14px, 5vw, 26px);
  background: var(--apk-fill);
  color: var(--apk-ink);
  border-radius: var(--apk-radius);
  box-shadow: 0 8px 32px #0008;
  font-size: .875rem;
  font-weight: 650;
  text-align: center;
}
.apk-button[href]:hover { --apk-fill: #d9d9d9; }
.apk-button:focus-visible { outline-color: var(--white); }
.apk-status { color: #4a4a4a; font-size: .75rem; }

@media (max-width: 759px) {
  .hero-frame { row-gap: 12px; }
  .hero-frame .box-stage { height: clamp(130px, calc(100svh - 289px - var(--apk-clearance)), 47svh); }
}

@media (min-width: 760px) {
  .frame { grid-template-columns: .9fr 1.1fr; align-items: center; gap: 0 6%; }
  .hero-copy { grid-area: 1 / 1; }
  .box-stage { grid-area: 1 / 2 / 3; }
  .scroll-link { grid-area: 2 / 1; margin-top: 18px; }
  .wide-only { display: initial; }
  .stack li { min-height: 92px; padding-inline: 20px; }
}

/* Short viewports and reduced motion use the readable normal-flow layout. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: no-preference) {
  .motion .hero { min-height: 134svh; }
  .motion .play { min-height: 137svh; }
  .motion :is(.hero, .play) .pin { position: sticky; top: 0; }
  .motion .orbit { display: block; }
  .motion .play-progress { display: block; }
}
