/* ============================================================
   GAME FEEL — pointer depth, keyboard demo and motion feedback.
   Static layout remains in styles.css; effects remain optional.
   ============================================================ */
.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  z-index: 60;
  pointer-events: none;
}

.reading-progress span {
  display: block;
  height: 100%;
  background: var(--yellow);
  transform: scaleX(0);
  transform-origin: left;
  box-shadow: 0 0 16px #ffcd1f88;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at var(--glow-x, 75%) var(--glow-y, 45%),
    #ffcd1f0d 0,
    transparent 56%
  );
}

.hero-scene {
  position: absolute;
  inset: 0;
  transform: perspective(1100px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg))
    translate3d(
      calc(var(--pointer-x, 0px) + var(--move-x, 0px)),
      calc(var(--pointer-y, 0px) + var(--move-y, 0px)),
      0
    );
  transition: transform 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hero-art.is-playing .hero-scene {
  transition-duration: 0.18s;
}

.hero-art.is-playing .hero-characters {
  animation-play-state: paused;
  filter: drop-shadow(0 20px 40px #ffcd1f26);
}

.hero .art-orbit::after {
  animation: orbit-turn 45s linear infinite;
}

.hero .art-orbit::before {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  top: 25%;
  right: 6%;
  background: var(--yellow);
  box-shadow: 0 0 26px #ffcd1faa;
}

.hero-art .control-pulse {
  position: absolute;
  width: 70%;
  aspect-ratio: 1;
  border: 2px solid #ffcd1f9c;
  border-radius: 50%;
  top: 17%;
  left: 20%;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

.hero .floating-keyboard {
  top: 24px;
  padding: 16px;
  border-color: #ffffff35;
  transform: rotate(-7deg);
  transition:
    border-color 0.25s,
    box-shadow 0.25s;
}

.hero .floating-keyboard:focus-within,
.hero .floating-keyboard:hover {
  border-color: #ffcd1f99;
  box-shadow:
    0 15px 55px #0007,
    0 0 28px #ffcd1f12;
}

.hero .key-label {
  font-size: 10px;
  letter-spacing: 1.3px;
  color: var(--yellow);
  text-align: center;
}

.demo-key {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #ffffff40;
  border-bottom: 4px solid #111;
  border-radius: 7px;
  color: #fff;
  background: #363739;
  font-size: 16px;
  font-weight: 800;
  padding: 0;
  box-shadow: 0 4px 0 #101112;
  transition:
    transform 0.12s,
    background 0.12s,
    color 0.12s,
    box-shadow 0.12s;
}

.demo-key:hover {
  background: #515254;
}

.demo-key.is-pressed,
.demo-key:active {
  color: var(--ink);
  background: var(--yellow);
  border-color: #d8a813;
  transform: translateY(4px);
  box-shadow:
    0 0 0 #101112,
    0 0 25px #ffcd1f55;
}

.keyboard-help {
  display: block;
  text-align: center;
  font-size: 10px;
  color: #bcbec1;
  margin-top: 13px;
}

.keyboard-feedback {
  display: block;
  min-height: 16px;
  text-align: center;
  font-size: 10px;
  color: var(--yellow);
  margin-top: 3px;
}

.motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid #ffffff26;
  border-radius: 6px;
  background: #ffffff07;
  color: #bcbec1;
  font-size: 12px;
  letter-spacing: 0;
}

.motion-toggle:hover {
  border-color: var(--yellow);
  color: var(--yellow);
}

.motion-toggle:disabled {
  cursor: default;
  opacity: 0.7;
}

.motion-toggle > span {
  color: var(--yellow);
}

.hero .hero-bottom {
  position: relative;
  z-index: 5;
}

/* The first viewport arrives in a readable sequence, once per page load. */
.motion-ready:not(.motion-paused) .hero-copy > * {
  animation: hero-arrive 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.motion-ready .hero-copy > :nth-child(2) {
  animation-delay: 0.08s;
}

.motion-ready .hero-copy > :nth-child(3) {
  animation-delay: 0.16s;
}

.motion-ready .hero-copy > :nth-child(4) {
  animation-delay: 0.24s;
}

.motion-ready .hero-copy > :nth-child(5) {
  animation-delay: 0.32s;
}

.motion-ready:not(.motion-paused) .hero-art {
  animation: art-arrive 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.motion-ready .reveal.is-ready {
  transform: translateY(34px) scale(0.985);
  transition:
    opacity 0.75s ease var(--reveal-delay, 0ms),
    transform 0.75s cubic-bezier(0.16, 1, 0.3, 1) var(--reveal-delay, 0ms);
}

.motion-ready .reveal.is-visible {
  transform: none;
}

.interactive-card {
  position: relative;
  isolation: isolate;
}

.interactive-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  background: radial-gradient(
    240px circle at var(--spot-x, 50%) var(--spot-y, 50%),
    #ffcd1f26,
    transparent 78%
  );
  transition: opacity 0.3s;
}

.interactive-card:hover::before,
.interactive-card:focus-within::before {
  opacity: 1;
}

.feature-icon {
  transition:
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.3s;
}

.feature-item:hover .feature-icon,
.feature-item:focus-within .feature-icon {
  transform: rotate(-9deg) scale(1.09);
  box-shadow: 7px 7px 0 #151617;
}

.review-card {
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}

.review-card:hover {
  border-color: #d3aa1b;
  box-shadow: 0 12px 34px #1516170c;
}

.button {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.button::after {
  content: "";
  position: absolute;
  inset: -80% auto -80% -80%;
  width: 40%;
  background: linear-gradient(90deg, transparent, #ffffff50, transparent);
  transform: rotate(25deg);
  pointer-events: none;
}

.button:hover::after,
.button:focus-visible::after {
  animation: button-shine 0.65s ease-out;
}

.button:active {
  transform: translateY(1px) scale(0.98);
}

.desktop-nav a {
  position: relative;
}

.desktop-nav a::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--yellow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s;
}

.desktop-nav a:hover::after,
.desktop-nav a.is-active::after {
  transform: scaleX(1);
}

.gallery-panel {
  animation: none;
}

.screenshot-button img {
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.screenshot-button:hover img {
  transform: scale(1.025);
}

.lightbox[open] {
  animation: dialog-arrive 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.faq-list details[open] .faq-answer {
  animation: answer-arrive 0.32s ease-out;
}

@keyframes hero-arrive {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes art-arrive {
  from {
    opacity: 0;
    transform: translateY(25px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes orbit-turn {
  to {
    transform: rotate(360deg);
  }
}

@keyframes button-shine {
  to {
    left: 150%;
  }
}

@keyframes dialog-arrive {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes answer-arrive {
  from {
    opacity: 0;
    transform: translateY(-7px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 960px) {
  .hero .floating-keyboard {
    top: 7px;
    left: 0;
    padding: 11px;
    transform: rotate(-6deg);
  }
  .keyboard-help,
  .keyboard-feedback {
    font-size: 9px;
  }
  .hero .hero-bottom {
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
  }
  .hero .hero-bottom a {
    margin: 0;
  }
  .motion-toggle {
    font-size: 11px;
  }
  .hero .art-orbit::before {
    display: none;
  }
}

@media (hover: none) {
  .interactive-card::before {
    display: none;
  }
  .screenshot-button:hover img {
    transform: none;
  }
}

/* Disable both CSS and JS-driven decorative motion, including live preference changes. */
.motion-paused {
  scroll-behavior: auto;
}

.motion-paused *,
.motion-paused *::before,
.motion-paused *::after {
  animation: none !important;
  transition: none !important;
}

.motion-paused .hero-scene,
.motion-paused .feature-icon,
.motion-paused .screenshot-button img {
  transform: none !important;
}

.motion-paused .reveal.is-ready {
  opacity: 1;
  transform: none;
}

.motion-paused .interactive-card::before {
  display: none;
}

.hero.is-offscreen .hero-characters,
.hero.is-offscreen .art-orbit::after {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .hero-scene,
  .feature-icon,
  .screenshot-button img {
    transform: none !important;
  }
  .reveal.is-ready {
    opacity: 1 !important;
    transform: none !important;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
