/* The pixel night look, layered over site.css / play.css / atlas.css.

   Restraint is the point:
   - the pixel font (--font-display) is only for the wordmark, headings,
     buttons, big numbers and tier names; body text stays smooth;
   - glitches happen in exactly two places: an occasional idle glitch on the
     wordmark, and once on the tier reveal; never more than 3 flashes/second;
   - scanlines and the grid are static and faint;
   - everything moving stands down under prefers-reduced-motion. */

/* ------------------------------------------------------------ hard edges */

body *:not(svg *) { border-radius: 0 !important; }

body { -webkit-font-smoothing: antialiased; }
a, :root a { color: var(--teal); }

h1, h2, h3, .btn, .way-name, .mode-list-name, .reveal-tier, .reveal-leagues, .tally, .clock-label {
  letter-spacing: 0.02em;
}

/* Hard offset shadows read as pixels; a tiny step to the right too. */
.btn, .card, .way, .account form button { box-shadow: 4px 5px 0 var(--drop); }
.btn:hover:not(:disabled), .way:hover { box-shadow: 5px 7px 0 var(--drop); }
.btn:active:not(:disabled), .way:active { box-shadow: 1px 1px 0 var(--drop); }
.way:hover { transform: translateY(-3px); }

/* Answer text can hold any letter (Pączki, Erişte): keep it in the body font. */
.reveal-answer, .log, .answer-list, input, textarea { font-family: var(--font-body); }

/* -------------------------------------------------------------- backdrop */

.backdrop {
  background:
    linear-gradient(to bottom, var(--sky-top) 0%, var(--sky-low) 78%);
}

/* A faint pixel grid over the sky. */
.backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(120, 255, 160, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(120, 255, 160, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
}

.backdrop .moon {
  position: absolute;
  top: 9vh;
  right: 12vw;
  width: 48px;
  height: 48px;
  background: #d8e8c8;
  /* A stepped, pixel-cut disc with a bite out of it. */
  clip-path: polygon(25% 0, 75% 0, 75% 8%, 92% 8%, 92% 25%, 100% 25%, 100% 75%, 92% 75%, 92% 92%, 75% 92%, 75% 100%,
                     25% 100%, 25% 92%, 8% 92%, 8% 75%, 0 75%, 0 25%, 8% 25%, 8% 8%, 25% 8%);
  box-shadow: inset -14px -6px 0 rgba(10, 20, 14, 0.55);
  opacity: 0.85;
}

.backdrop .star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #cfe9d4;
  opacity: 0.7;
  animation: twinkle 4s steps(2, jump-none) infinite;
}
.backdrop .star:nth-of-type(1) { top: 8vh;  left: 9%;  animation-delay: -1s; }
.backdrop .star:nth-of-type(2) { top: 19vh; left: 23%; animation-delay: -3s; width: 2px; height: 2px; }
.backdrop .star:nth-of-type(3) { top: 5vh;  left: 38%; animation-delay: -2s; }
.backdrop .star:nth-of-type(4) { top: 24vh; left: 52%; animation-delay: -0.5s; width: 2px; height: 2px; }
.backdrop .star:nth-of-type(5) { top: 12vh; left: 64%; animation-delay: -2.5s; background: var(--teal-bright); }
.backdrop .star:nth-of-type(6) { top: 30vh; left: 79%; animation-delay: -1.5s; width: 2px; height: 2px; }
.backdrop .star:nth-of-type(7) { top: 16vh; left: 91%; animation-delay: -3.5s; }
.backdrop .star:nth-of-type(8) { top: 34vh; left: 6%;  animation-delay: -0.2s; width: 2px; height: 2px; background: var(--gold); }

.backdrop .hills { image-rendering: pixelated; }
.backdrop .hills path { animation: none; }

.backdrop .scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  opacity: 0.35;
  pointer-events: none;
}

/* ------------------------------------------------------- wordmark glitch */

.wordmark { font-size: 1.6rem; }
.wordmark-globe { image-rendering: pixelated; animation: none; }
.wordmark-text span { animation: none; }
.wordmark:hover .wordmark-text span { animation: none; }
.wordmark-text span:nth-child(odd), :root .wordmark-text span:nth-child(odd) { color: var(--teal); }

/* Idle: still for ~6.5 s, then a short split-and-slip lasting ~0.4 s
   (two jumps), then still again. */
.wordmark-text { position: relative; animation: idle-glitch 7s steps(1, end) 2s infinite; }
.wordmark:hover .wordmark-text { animation: idle-glitch 7s steps(1, end) -6.6s infinite; }

@keyframes idle-glitch {
  0%, 93%, 100% { transform: none; text-shadow: none; clip-path: none; }
  94%  { transform: translate(-2px, 0); text-shadow: 2px 0 var(--glitch-a), -2px 0 var(--glitch-b); clip-path: inset(10% 0 45% 0); }
  96%  { transform: translate(2px, 1px); text-shadow: -2px 0 var(--glitch-a), 2px 0 var(--glitch-b); clip-path: inset(50% 0 5% 0); }
  98%  { transform: none; text-shadow: 1px 0 var(--glitch-a), -1px 0 var(--glitch-b); clip-path: none; }
}

/* ----------------------------------------------------- tier reveal glitch */

/* The tier name lands, splits once, and settles. Plays once per reveal. */
.reveal-tier { animation: pop 460ms cubic-bezier(.2, 1.6, .4, 1) 160ms both, reveal-glitch 420ms steps(1, end) 520ms 1 both; }
.reveal-card .crest-lg svg { image-rendering: pixelated; }

@keyframes reveal-glitch {
  0%   { text-shadow: 3px 0 var(--glitch-a), -3px 0 var(--glitch-b); transform: translateX(-3px) skewX(-6deg); }
  35%  { text-shadow: -2px 0 var(--glitch-a), 2px 0 var(--glitch-b); transform: translateX(2px); }
  70%  { text-shadow: 1px 0 var(--glitch-a), -1px 0 var(--glitch-b); transform: none; }
  100% { text-shadow: none; transform: none; }
}

/* ------------------------------------------------------ bits, bars, misc */

/* Bursts are square pixels now, not leaves. */
.fx-bit, .fx-bit.spark { border-radius: 0 !important; }

/* The timer: stepped stripes instead of candy stripes. */
.clock-fill { background-image: repeating-linear-gradient(90deg, transparent 0 10px, rgba(0, 0, 0, 0.22) 10px 12px); animation-timing-function: steps(4, end); }

::selection { background: var(--teal); color: #000; }

:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; }

@keyframes twinkle {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark-text, .wordmark:hover .wordmark-text, .backdrop .star { animation: none; }
  .reveal-tier { animation: none; }
}

/* ------------------------------------------------- the hero's pixel planet */

.hero-earth .earth-spin { transform-origin: 0 0; animation: pixel-spin 24s steps(20, end) infinite; }
.hero-earth .orbit { transform-origin: 10px 10px; animation: spin 12s steps(24, end) infinite; }

@keyframes pixel-spin { from { transform: translateX(0); } to { transform: translateX(-20px); } }

/* Readable text on the bright main button (site.css's dark-scheme link
   colour would otherwise win). */
:root a.btn.primary, :root .btn.primary { color: #04140a; }

@media (prefers-reduced-motion: reduce) {
  .hero-earth .earth-spin, .hero-earth .orbit { animation: none; }
}

.wordmark-globe .globe-land { animation: none; }
