/* ============================================================
 *  X-Shooter Demo — scoped styles
 *
 *  EVERY selector below is prefixed with .xs-demo so this file
 *  is safe to drop into ANY landing page without colliding with
 *  host styles. The only un-scoped rules are the demo-page
 *  wrapper used by the standalone demo.html (see bottom).
 * ============================================================ */

/* ─── Tunable theme (override with --xs-demo-* on the parent) ─ */
.xs-demo {
  --xs-demo-radius: 16px;
  --xs-demo-correct: #22c711;
  --xs-demo-wrong: #ff3333;
  --xs-demo-accent: #2ebdd2;
  --xs-demo-fg: #fff;
  --xs-demo-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);

  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--xs-demo-radius);
  overflow: hidden;
  background: #111 center/cover no-repeat;
  box-shadow: var(--xs-demo-shadow);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--xs-demo-fg);
  user-select: none;
  -webkit-user-select: none;
  /* cursor is set inline via JS so the URL resolves against assetPath.
     Falls back to native crosshair if the PNG is missing. */
  isolation: isolate;
}

.xs-demo *,
.xs-demo *::before,
.xs-demo *::after {
  box-sizing: border-box;
}

/* ─── Stage: where falling images + targets live ─────────────── */
.xs-demo__stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: auto;
}

/* ─── Idle / Play overlay ─────────────────────────────────────── */
.xs-demo__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.15), rgba(0,0,0,0.55));
  z-index: 50;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.xs-demo__overlay--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.xs-demo__title {
  margin: 0;
  font-size: clamp(1.6em, 4vw, 2.6em);
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6), 0 0 24px rgba(46,189,210,0.35);
}
.xs-demo__sub {
  margin: 0 0 8px;
  font-size: clamp(0.9em, 1.6vw, 1.05em);
  opacity: 0.85;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.xs-demo__btn {
  appearance: none;
  border: 2px solid rgba(255,255,255,0.4);
  background: linear-gradient(180deg, rgba(34,199,17,0.95), rgba(20,150,10,0.95));
  color: #fff;
  font: 700 1.1em system-ui, sans-serif;
  letter-spacing: 1px;
  padding: 14px 32px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.xs-demo__btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
}
.xs-demo__btn:active { transform: translateY(0); }

.xs-demo__btn--cta {
  background: linear-gradient(180deg, #ffcc33, #ff8800);
  color: #2a1a00;
}

.xs-demo__btn-secondary {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.35);
  color: #fff;
  font: 600 0.9em system-ui, sans-serif;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  margin-top: 6px;
}
.xs-demo__btn-secondary:hover { background: rgba(0,0,0,0.55); }

/* ─── Round counter (top-right) ───────────────────────────────── */
.xs-demo__hud {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 30;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.95em;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid rgba(255,255,255,0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.xs-demo__hud--visible { opacity: 1; }

/* ─── Target word bubble (glass) ──────────────────────────────── */
.xs-demo__word {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  padding: 12px 32px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.12) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.25), 0 0 40px rgba(46,189,210,0.2);
  font-size: clamp(1.2em, 2.6vw, 2.0em);
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: capitalize;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5), 0 0 30px rgba(46,189,210,0.3);
  z-index: 20;
  display: none;
  pointer-events: none;
  transition: top 0.7s ease-in-out, transform 0.7s ease-in-out, border-color 0.3s, box-shadow 0.3s, padding 0.5s, background 0.4s, border-radius 0.3s;
}
.xs-demo__word--visible { display: block; }
.xs-demo__word--docked  {
  top: 14px;
  transform: translate(-50%, 0) scale(0.78);
}
.xs-demo__word--unified {
  padding: 10px 20px;
  background: rgba(255,255,255,0.95);
  border-color: var(--xs-demo-correct);
  border-radius: 14px;
  color: #222;
  text-shadow: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 40px rgba(34,199,17,0.5);
  animation: xsDemoUnifiedFlash 1.2s ease-in-out 2;
}
.xs-demo__word--wrong-flash {
  border-color: var(--xs-demo-wrong) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 40px rgba(255,51,51,0.55);
}
@keyframes xsDemoUnifiedFlash {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 40px rgba(34,199,17,0.5); }
  50%      { box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 60px rgba(34,199,17,0.85); }
}

.xs-demo__unified-img {
  display: block;
  width: 70px;
  height: 84px;
  object-fit: cover;
  border-radius: 6px;
  margin: 6px auto 0;
}

/* ─── Falling word-image cards ────────────────────────────────── */
.xs-demo__falling {
  position: absolute;
  top: -160px;
  width: 90px;
  height: 108px;
  border: 4px solid #ddd;
  border-radius: 50%;
  overflow: hidden;
  z-index: 10;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
  animation: xsDemoFall linear forwards;
  transition: border-color 0.3s, box-shadow 0.3s, opacity 0.4s, filter 0.4s;
}
.xs-demo__falling img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.xs-demo__falling--correct {
  border-color: var(--xs-demo-correct);
  box-shadow: 0 0 22px rgba(34,199,17,0.6);
  animation-play-state: paused;
}

/* Wrong: pause + grayscale + red border + glow.
   JS handles the timed auto-resume after ~750ms. */
.xs-demo__falling--wrong {
  border-color: var(--xs-demo-wrong) !important;
  border-width: 5px;
  box-shadow: 0 0 25px rgba(255,0,0,0.65);
  filter: grayscale(0.85) brightness(0.85);
  /* animation-play-state is set inline by JS, not here, so when JS clears
     it the original .xs-demo__falling animation resumes cleanly. */
}

.xs-demo__falling--missed {
  opacity: 0.35;
  filter: grayscale(0.7);
  pointer-events: none;
}

@keyframes xsDemoFall {
  from { top: -160px; }
  to   { top: 100%; }
}

/* ─── Decorative red/white concentric-ring targets ─────────────── */
/* Same gradient as the main game's .target (styles.css line 3264). */
.xs-demo__target {
  position: absolute;
  top: -80px;
  width: 56px;
  height: 56px;
  background: radial-gradient(circle,
    white 15%,
    #ff2222 15%, #ff2222 30%,
    white 30%, white 45%,
    #ff2222 45%, #ff2222 60%,
    transparent 60%
  );
  border: 1px solid #333;
  border-radius: 50%;
  z-index: 8;            /* below word images so cards remain clickable on top */
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: xsDemoFall linear forwards;
}
.xs-demo__target--hit {
  pointer-events: none;
  animation: xsDemoTargetHit 0.4s ease-out forwards !important;
}
@keyframes xsDemoTargetHit {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ─── Bullet impact image (from bulletMaker) ──────────────────── */
/* Class only used for selectors; size/position/transitions all set inline
   by bulletMaker so each impact has its own state machine. */
.xs-demo__impact {
  pointer-events: none;
}

/* ─── Gun container (revolver sprite) ─────────────────────────── */
.xs-demo__gun {
  position: absolute;
  left: 50%;
  bottom: 0;
  /* 16:9 sprite cell scaled to ~56% of demo width. */
  width: 56%;
  max-width: 360px;
  aspect-ratio: 16 / 9;
  pointer-events: none;
  z-index: 15;
  transform: translate(-50%, 100%);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.xs-demo__gun--visible { transform: translate(-50%, 22%); }

.xs-demo__gun-character {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-position: 0% 0%;
  background-size: 400% 200%;   /* default for 4×2 shoot grid; JS overrides */
  image-rendering: -webkit-optimize-contrast;
  /* spriteOffsetY from real game's xrevolver entry */
  transform: translateY(20px);
}

/* ─── End-of-demo CTA card ────────────────────────────────────── */
.xs-demo__cta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.5), rgba(0,0,0,0.85));
  z-index: 60;
  padding: 24px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.xs-demo__cta--visible { opacity: 1; visibility: visible; }
.xs-demo__cta-title {
  margin: 0;
  font-size: clamp(1.4em, 3.5vw, 2.2em);
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.xs-demo__cta-sub {
  margin: 0 0 8px;
  opacity: 0.85;
  font-size: clamp(0.9em, 1.6vw, 1.05em);
}

/* ═════════════════════════════════════════════════════════════
 *  Standalone-page wrapper — only used by demo.html, NOT when
 *  embedded. Safe to delete this block when copying styles into
 *  a host site that already provides its own layout.
 * ═════════════════════════════════════════════════════════════ */
.xs-demo-page {
  margin: 0;
  min-height: 100vh;
  background: #15171c radial-gradient(ellipse at top, #1f2a36, #0a0c10) no-repeat;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.xs-demo-page__wrap {
  width: 100%;
  max-width: 900px;
  text-align: center;
}
.xs-demo-page__title {
  font-size: clamp(2em, 5vw, 3em);
  font-weight: 900;
  letter-spacing: 4px;
  margin: 0 0 8px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffd54a, #ff7a18);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.xs-demo-page__sub {
  margin: 0 0 24px;
  opacity: 0.75;
}
.xs-demo-page__foot {
  margin: 18px 0 0;
  font-size: 0.85em;
  opacity: 0.5;
}
