/* ===== Game tour (index.html?tour, js/tour.js) =====
   A dimmed layer over the whole page with holes cut out for whatever is being explained, and a
   caption card beside it. The layer is visual only: taps go through to the game, and js/tour.js
   decides which of them are allowed at each step. */

.tour {
  position: fixed;
  inset: 0;
  z-index: 300;                    /* above the swap and end-game modals (100) */
  pointer-events: none;
}

.tour-dim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.tour-shade {
  fill: rgba(10, 16, 24, 0.55);
}

/* Orange outline around each spotlight (not the map) */
.tour-rings div {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 0 0 4px rgba(255, 124, 0, 0.18);
}

/* Steps that just explain something: the page is blocked until Next */
.tour-catcher {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.tour-catcher[hidden] {
  display: none;
}

/* ---- Caption card ---- */
.tour-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 340px;
  max-width: calc(100vw - 24px);
  padding: 16px 16px 14px;
  background: var(--surface-0);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  transition: opacity 0.25s ease;
  text-wrap: pretty;
}

.tour-step-welcome {width: 300px}
.tour-step-hemisphere-open {width: 360px}
.tour-step-hemisphere-play {width: 300px}
.tour-step-hemisphere-result {width: 280px}
.tour-step-radius-open {width: 290px}
.tour-step-radius-result {width: 320px}
.tour-step-region-open {width: 290px}
.tour-step-region-play {width: 320px}
.tour-step-natural-open {width: 360px}
.tour-step-natural-result {width: 390px}
.tour-step-natural-play {width: 260px}
.tour-step-ruler-on {width: 390px}
.tour-step-ruler-measure {width: 390px}
.tour-step-ruler-off {width: 390px}
.tour-step-coast-play {width: 260px; text-wrap: initial;}
.tour-step-swap-tap {width: 260px}
.tour-step-swap-pick {width: 360px}
.tour-step-elevation-open {width: 300px}
.tour-step-elevation-check {width: 275px}
.tour-step-elevation-play {width: 320px}
.tour-step-elevation-result {width: 390px}
.tour-step-guess {width: 300px}
.tour-step-guess-again {width: 300px}
.tour-step-win {width: 390px}
.tour-step-leaderboard-open {width: 360px}
.tour-step-leaderboard {width: 330px}


/* While something is happening on screen the caption is hidden; it fades in at its next spot */
.tour-card.is-busy {
  opacity: 0;
  pointer-events: none;
}

.tour-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-primary);
}

/* ---- Buttons: Next (steps that explain) or the prompt (steps you do), and Skip tour ---- */
.tour-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.is-action .tour-actions {
  margin-top: 4px;
}

/* What to do next, e.g. "Tap to open card". Not a button: you tap the real thing in the game. */
.tour-prompt {
  flex: 1;
  margin: 0;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--accent);
  text-wrap: balance;
}

.tour-prompt:empty {
  display: none;
}

.tour-btn {
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.tour-btn[hidden] {
  display: none;
}

.tour-next {
  min-width: 80px;
  color: #fff;
  background: var(--accent);
}

/* Next waits until the step's been done (e.g. a few info cards opened) */
.tour-next:disabled {
  /*opacity: 0.4;
  cursor: default;*/
  display: none;
}

/* Skip tour: a quiet text button, always at the right */
.tour-skip {
  margin-left: auto;
  padding: 8px 4px;
  color: var(--text-secondary);
  background: none;
}

@media (hover: hover) {
  .tour-skip:hover {
    color: var(--text-primary);
    opacity: 1;
  }
}

/* ---- The last card: Play today's game ---- */
.tour-play {
  color: #fff;
  background: var(--accent);
}

.tour.is-done .tour-catcher {
  display: block;
  cursor: default;
}

.tour.is-done .tour-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 355px;
}

.tour.is-done .tour-text {
  font-size: 16px;
}

.tour.is-done .tour-text strong {
  display: block;
  margin-bottom: 4px;
  font-size: 20px;
}

/* Phones: the caption spans the screen, at the bottom or the top */
@media (max-width: 900px) {
  .tour-card,
  .tour.is-done .tour-card {
    width: calc(100vw - 24px);
  }
}

.tour.is-done .tour-actions {
  align-self: stretch;
}

/* ---- Dimming on and off ---- */
.tour-dim,
.tour-rings {
  transition: opacity 0.3s ease;
}

/* While the dots are being eliminated, and on steps where a modal already dims the page */
.tour.is-clear .tour-dim,
.tour.is-clear .tour-rings,
.tour.no-dim .tour-dim {
  opacity: 0;
}

/* ---- A tap that went somewhere it shouldn't: the caption pulses ---- */
.tour-card.is-nudge {
  animation: tour-nudge 0.6s ease;
}

.tour-card.is-nudge .tour-prompt {
  animation: tour-nudge-text 0.6s ease;
}

@keyframes tour-nudge {
  0%   { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28), 0 0 0 0 rgba(255, 124, 0, 0.7); }
  40%  { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28), 0 0 0 8px rgba(255, 124, 0, 0.45); }
  100% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28), 0 0 0 14px rgba(255, 124, 0, 0); }
}

@keyframes tour-nudge-text {
  0%, 100% { letter-spacing: 0; }
  40%      { letter-spacing: 0.04em; }
}

/* ---- Helper animation: a faint hand showing what to tap or drag ---- */
.tour-hand {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  pointer-events: none;
  will-change: transform, opacity;
}

.tour-hand.is-on {
  display: block;
}

/* the fingertip sits on the point */
.tour-hand svg {
  position: absolute;
  left: -14px;
  top: -5px;
  opacity: 0.8;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  transition: transform 0.15s ease;
  transform-origin: 14px 5px;
}

.tour-hand.is-press svg {
  transform: scale(0.88);
}

/* a ring where the finger presses */
.tour-hand-ring {
  position: absolute;
  left: -16px;
  top: -16px;
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 124, 0, 0.5);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.25s ease;
}

.tour-hand.is-press .tour-hand-ring {
  opacity: 0.8;
  transform: scale(1);
}
