/* Dot's little planet on the home scene. The planet replaces the hill:
   no trees and no grass in the hero any more, Dot stands on the Earth. */
.page-home .scene .trees, .page-home .scene .ground { display: none; }

.scene-inner {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  row-gap: 8px;
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 48px var(--gutter) 40px;
}
.scene .scene-copy { padding: 0; flex: none; }
@media (min-width: 900px) {
  .scene-inner { grid-template-columns: minmax(0, 1fr) auto; column-gap: 32px; }
}
/* Narrow screens: room above the title for Dot to stand on its first line. */
@media (max-width: 899px) { .scene-inner { padding-top: 88px; } }

/* The planet block: room above for Dot, then the canvas. */
.planet {
  --planet: 448px;
  --canvas: 560px;               /* set by planet.js: planet + 14 px of sky */
  --above: 40px;                 /* Dot's head rises above the canvas */
  position: relative;
  margin: 0;
  width: 100%;
  min-width: 0;
  padding-top: var(--above);
  touch-action: pan-y;           /* vertical swipes still scroll the page */
  outline: none;
}
@media (min-width: 900px) { .planet { width: var(--canvas); } }
@media (max-width: 599px) { .planet { --planet: 320px; } }
.planet:focus-visible .planet-canvas { outline: 3px solid var(--focus); outline-offset: -40px; }

.planet-stage {
  position: relative;
  height: var(--canvas);
}
.planet-canvas, .planet-hits {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--canvas);
  height: var(--canvas);
  margin-left: calc(var(--canvas) / -2);
}
.planet-canvas {
  display: block;
  image-rendering: pixelated;
  cursor: grab;
  visibility: hidden;
}
.planet.ready .planet-canvas { visibility: visible; }

/* Until the planet is drawn, its pixel silhouette breathes in its place and
   Dot (and any costume) waits off stage, so she never floats in empty sky. */
.planet:not(.ready) .planet-stage::before {
  content: "";
  position: absolute;
  top: calc(14 * var(--u));
  left: 50%;
  width: var(--planet);
  height: var(--planet);
  margin-left: calc(var(--planet) / -2);
  background: var(--bg-raised);
  -webkit-mask: url("../img/planet-disc.svg") 0 0 / 100% 100% no-repeat;
  mask: url("../img/planet-disc.svg") 0 0 / 100% 100% no-repeat;
  animation: planet-wait 1.2s steps(2, jump-none) infinite alternate;
}
.planet:not(.ready) .planet-dot,
.planet:not(.ready) .hw-costume { visibility: hidden; }
@keyframes planet-wait { from { opacity: 0.35; } to { opacity: 0.8; } }
.planet.turning .planet-canvas { cursor: grabbing; }

/* Tap targets: real buttons, 32 px, centred on the pixel they stand for. */
.planet-hit {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.planet-hit[hidden] { display: none; }

/* Dot stands on the top of the planet. Her feet (row 92 of the sprite)
   sink one pixel into the ground at the canvas's 14 px margin. */
.planet-dot {
  position: absolute;
  top: calc(var(--above) + 14 * var(--u) - 92px + var(--u));
  left: calc(50% - var(--dot-size) / 2);
  width: var(--dot-size);
  height: var(--dot-size);
  padding: 0;
  border: 0;
  background: transparent 0 0 / auto no-repeat;
  image-rendering: pixelated;
  cursor: pointer;
  z-index: 2;
}

/* Her speech: the site's bubble, centred over her head. */
.planet-say {
  position: absolute;
  /* its bottom sits 12 px into the sprite's empty top rows (body starts at row 24) */
  top: calc(var(--above) + 14 * var(--u) - 92px + var(--u) + 12px);
  left: 50%;
  z-index: 3;
  width: max-content;
  max-width: min(300px, calc(100vw - 2 * var(--gutter)));
  margin: 0;
  transform: translate(-50%, calc(-100% - 12px));
  --tail: calc(50% - 4px);
}
.planet-say[hidden] { display: none; }
/* Beside her (left), when there is no room above: the two dots trail right. */
.planet-say.side {
  top: calc(var(--above) + 14 * var(--u) - 92px + var(--u) + 40px);
  left: calc(50% - var(--dot-size) / 2 + 12px);
  transform: translate(calc(-100% - 12px), -50%);
}
.planet-say.side:not(:empty)::after { left: calc(100% + 9px); top: calc(50% - 4px); }
/* Below her, over the planet, as a last resort: the dots trail up. */
.planet-say.below {
  top: calc(var(--above) + 14 * var(--u) + 24px);
  transform: translateX(-50%);
}
.planet-say.below:not(:empty)::after { top: auto; bottom: calc(100% + 9px); }
.planet-say small { font-size: 0.875rem; color: var(--night-4); }
.planet-say a { display: inline; }
/* Leafing through a pile of facts: ‹ 2 de 8 › under the fact. */
.say-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--night-4);
}
.say-pager button {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 0;
  background: var(--star);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink);
  font: 700 1rem/1 var(--font-dot);
  cursor: pointer;
}
.say-pager button:hover { background: var(--yellow); }
.say-pager button:active { transform: translate(2px, 2px); }


/* Facts that happened off the Earth live in the sky. */
.sky-fact {
  position: absolute;
  z-index: 1;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
/* The moon already in the sky carries Luna 3's flag. */
.moon-fact {
  top: 12vh;
  right: 14vw;
  width: 48px;
  height: 48px;
}
.moon-fact::before { /* pole */
  content: "";
  position: absolute;
  left: 30px;
  top: -24px;
  width: var(--u);
  height: 28px;
  background: var(--ink);
}
.moon-fact::after { /* cloth, history orange */
  content: "";
  position: absolute;
  left: 34px;
  top: -24px;
  width: 20px;
  height: 12px;
  background: var(--history);
  box-shadow: 0 0 0 var(--u) var(--ink);
}
/* By day the site's orb is the sun, so the moon shows up on its own:
   a small pale disc, like the daytime moon, still carrying the flag. */
.moon-fact-disc { display: none; }
html[data-sky="day"] .moon-fact { top: 7vh; right: 42vw; width: 32px; height: 32px; }
html[data-sky="day"] .moon-fact::before { left: 20px; top: -24px; }
html[data-sky="day"] .moon-fact::after { left: 24px; top: -24px; }
html[data-sky="day"] .moon-fact-disc {
  display: block;
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--stone-5) 0 0) 8px 12px / 4px 4px no-repeat,
    linear-gradient(var(--stone-5) 0 0) 16px 20px / 8px 4px no-repeat,
    var(--white);
  clip-path: polygon(25% 0, 75% 0, 75% 12.5%, 87.5% 12.5%, 87.5% 25%, 100% 25%, 100% 75%, 87.5% 75%, 87.5% 87.5%, 75% 87.5%, 75% 100%, 25% 100%, 25% 87.5%, 12.5% 87.5%, 12.5% 75%, 0 75%, 0 25%, 12.5% 25%, 12.5% 12.5%, 25% 12.5%);
}
@media (max-width: 899px) { html[data-sky="day"] .moon-fact { top: 3vh; right: 44vw; } }

/* A far fact is a star of its own: four arms, one pixel each way. */
.star-fact {
  width: 36px;
  height: 36px;
}
/* Up to four far facts, each on its own spot clear of the title and the planet. */
.star-fact[data-spot="0"] { top: 9vh; left: 52vw; }
.star-fact[data-spot="1"] { top: 4vh; left: 30vw; }
.star-fact[data-spot="2"] { top: 5vh; left: 68vw; }
.star-fact[data-spot="3"] { top: 15vh; left: 46vw; }
.star-fact::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 16px;
  width: var(--u);
  height: var(--u);
  background: var(--dot-pale);
  box-shadow: 4px 0 0 var(--dot-light), -4px 0 0 var(--dot-light), 0 4px 0 var(--dot-light), 0 -4px 0 var(--dot-light),
    8px 0 0 var(--dot), -8px 0 0 var(--dot), 0 8px 0 var(--dot), 0 -8px 0 var(--dot);
}
/* Old far facts dim like stones: no colour, no arms past the first. */
.star-fact.old::before {
  background: var(--night-6);
  box-shadow: 4px 0 0 var(--star-dim), -4px 0 0 var(--star-dim), 0 4px 0 var(--star-dim), 0 -4px 0 var(--star-dim);
}
@media (max-width: 899px) {
  .star-fact[data-spot] { left: auto; }
  .star-fact[data-spot="0"] { top: 4vh; right: 38vw; }
  .star-fact[data-spot="1"] { top: 2vh; right: 62vw; }
  .star-fact[data-spot="2"] { top: 7vh; right: 20vw; }
  .star-fact[data-spot="3"] { top: 2vh; right: 82vw; }
  .moon-fact { top: 5vh; right: 8vw; }
  .page-home .moon { top: 5vh; right: 8vw; }
}

@media (prefers-reduced-motion: reduce) {
  .planet-canvas { cursor: default; }
  .planet:not(.ready) .planet-stage::before { animation: none; opacity: 0.6; }
}

/* Her entrance: each word of the title is a span she can land on; the one
   under her sinks one pixel for two steps. */
.hop-word { display: inline-block; }
.hop-word.sunk { transform: translateY(var(--u)); }
