/* =========================================================
   חידת המסלול (תחנה 1) - מסך נפרד ועצמאי (route-screen).
   מעבר ממסך הפאזל, המפה הגדולה + רקע מטושטש, שכבת SVG (סמנים
   וקווי מסלול), שכבת אזורי לחיצה בלתי-נראים, מגילת חידה אחת
   בכל רגע, הודעות משוב, רמזים ופאנל השלמה.
   ========================================================= */

/* ===================== מעבר: דעיכת קווי הפאזל + הגדלה ===================== */

.puzzle-completion-panel.route-transition-out {
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.puzzle-board-frame.route-dissolving {
  border-color: transparent;
  box-shadow: none;
  background: transparent;
  transition: border-color 500ms ease, box-shadow 500ms ease, background 500ms ease;
}

.puzzle-board.route-growing {
  transform: scale(1.35);
  transition: transform 650ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

@media (prefers-reduced-motion: reduce) {
  .puzzle-completion-panel.route-transition-out,
  .puzzle-board-frame.route-dissolving,
  .puzzle-board.route-growing {
    transition: none !important;
    transform: none !important;
  }
}

/* מסתיר את רקע המרפסת/הקשתות (המשותף לכל שאר תחנה 1) רק כשמסך
   המסלול פעיל - לא נוגע בו בשני התתי-מסכים האחרים. */
#game-viewport.route-active .atmosphere-bg,
#game-viewport.route-active .puzzle-dim-overlay {
  display: none;
}

/* ===================== מסך המסלול ===================== */

.route-screen-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("../assets/images/station1-map.png");
  background-size: cover;
  background-position: center;
  filter: blur(36px) brightness(0.32) saturate(0.85);
  transform: scale(1.15); /* מכסה את קצוות הטשטוש */
}

.route-map-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.route-map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.route-svg-layer {
  position: absolute;
  /* left/top/width/height מחושבים ומוזנים דינמית ב-JS
     (positionRouteOverlayLayers, route.js) כך שיחפפו בדיוק לתחום
     שבו object-fit:contain בפועל מציג את התמונה - לא לכל
     תיבת .route-map-stage (שעלולה לכלול "אזורי ריק" בצדדים).
     לא קולטת קליקים - אלו מתבצעים על route-hotspot-layer. */
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

/* ===================== שכבת אזורי הלחיצה ===================== */
/* אותה שכבה בדיוק, ממוקמת/ממודדת ב-JS (positionRouteOverlayLayers)
   באחוזים זהים ל-viewBox של ה-SVG - כך שהקואורדינטות המאושרות
   (ROUTE_WAYPOINTS/ROUTE_WATCHTOWER) חלות זהה על שתי השכבות. */
.route-hotspot-layer {
  position: absolute;
  z-index: 3;
}

.route-hotspot-btn {
  position: absolute;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* בלתי-נראה במשחק הרגיל, אך משאיר משוב עדין לניווט מקלדת כדי
   שהמשחק יישאר נגיש (Tab/Enter/Space). */
.route-hotspot-btn:focus-visible {
  outline: 2px solid rgba(232, 194, 122, 0.85);
  outline-offset: 2px;
  border-radius: 6px;
}

.route-hotspot-btn[disabled] {
  cursor: default;
  pointer-events: none;
}

/* ===================== סמנים זהובים + קווי מסלול (SVG) ===================== */

.route-marker-ring {
  fill: none;
  stroke: var(--color-gold);
  stroke-width: 2.5;
  opacity: 0.9;
}

.route-marker-dot {
  fill: var(--color-gold);
  stroke: var(--color-ink);
  stroke-width: 1;
}

.route-marker-pulse {
  animation: routeMarkerAppear 550ms ease-out;
}

@keyframes routeMarkerAppear {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  55% {
    transform: scale(1.35);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.route-connector-line {
  fill: none;
  stroke: var(--color-bronze-light);
  stroke-width: 3.5;
  stroke-linecap: round;
  opacity: 0.92;
  filter: drop-shadow(0 0 4px rgba(232, 194, 122, 0.45));
}

.route-line-final-pulse {
  animation: routeLineFinalPulse 1.8s ease-in-out infinite;
}

@keyframes routeLineFinalPulse {
  0%,
  100% {
    stroke: var(--color-bronze-light);
    filter: drop-shadow(0 0 4px rgba(232, 194, 122, 0.45));
  }
  50% {
    stroke: var(--color-gold);
    filter: drop-shadow(0 0 12px rgba(232, 194, 122, 0.9));
  }
}

/* הילת רמז שלב 3 - מוצגת ומוסרת ב-JS לאחר 2 שניות בלבד. */
.route-hint-glow {
  fill: rgba(232, 194, 122, 0.22);
  stroke: rgba(232, 194, 122, 0.85);
  stroke-width: 2.5;
  animation: routeHintPulse 900ms ease-in-out infinite alternate;
}

@keyframes routeHintPulse {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

/* הדגשת השער המערבי עצמו ברגע התשובה הנכונה בחידת הסיכום. */
.route-marker-final-pulse .route-marker-ring,
.route-marker-final-pulse .route-marker-dot {
  animation: routeMarkerFinalPulse 1.8s ease-in-out infinite;
}

@keyframes routeMarkerFinalPulse {
  0%,
  100% {
    filter: none;
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(232, 194, 122, 0.95));
  }
}

@media (prefers-reduced-motion: reduce) {
  .route-marker-pulse,
  .route-line-final-pulse,
  .route-hint-glow,
  .route-marker-final-pulse .route-marker-ring,
  .route-marker-final-pulse .route-marker-dot {
    animation: none !important;
  }
}

/* ===================== מגילת החידה הנוכחית ===================== */

.route-riddle-scroll[hidden] {
  display: none;
}

.route-riddle-scroll:not([hidden]) {
  position: absolute;
  z-index: 4;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 84vw);
  background: linear-gradient(160deg, rgba(44, 36, 22, 0.94) 0%, rgba(26, 20, 12, 0.96) 100%);
  border: 1.5px solid rgba(216, 164, 91, 0.55);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  padding: 16px 22px;
  text-align: center;
}

/* ממוקמת בקצה העליון/תחתון של המסך לפי מיקום היעד הנוכחי
   (positionRiddleScroll, route.js) כדי שלעולם לא תסתיר אותו. */
.route-riddle-scroll.route-scroll-top {
  top: clamp(12px, 3vh, 28px);
}

.route-riddle-scroll.route-scroll-bottom {
  bottom: clamp(12px, 3vh, 28px);
}

.route-riddle-line {
  margin: 0;
  font-family: var(--font-heading);
  color: var(--color-parchment);
  font-size: clamp(0.95rem, 1.35vw, 1.1rem);
  line-height: 1.65;
}

.route-riddle-line + .route-riddle-line {
  margin-top: 2px;
}

.route-hint-line {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(216, 164, 91, 0.3);
  font-family: var(--font-body);
  font-style: italic;
  color: var(--color-bronze-light);
  font-size: clamp(0.82rem, 1.05vw, 0.95rem);
  line-height: 1.5;
}

/* ===================== הודעת משוב (שגוי / מגדל) ===================== */

.route-feedback-message[hidden] {
  display: none;
}

.route-feedback-message:not([hidden]) {
  /* ממוקמת קבוע במרכז אופקי, מעט מתחת לסרגל העליון - כך שלעולם
     לא מתנגשת עם מגילת החידה (שמוצגת תמיד בקצה העליון או
     התחתון, לעולם לא באמצע). */
  position: absolute;
  z-index: 5;
  left: 50%;
  top: clamp(14px, 3vh, 30px);
  transform: translateX(-50%);
  margin: 0;
  max-width: min(360px, 80vw);
  text-align: center;
  font-family: var(--font-heading);
  color: var(--color-bronze-light);
  font-size: clamp(0.85rem, 1.1vw, 0.98rem);
  background: rgba(6, 5, 3, 0.7);
  border: 1px solid rgba(216, 164, 91, 0.4);
  border-radius: 8px;
  padding: 9px 20px;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.85);
}

.route-feedback-message.route-feedback-pulse {
  animation: routeFeedbackFade 2.2s ease;
}

@keyframes routeFeedbackFade {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }
  12% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .route-feedback-message.route-feedback-pulse {
    animation: none !important;
  }
}

/* ===================== חידת סיכום: זיהוי השער המערבי ===================== */

.route-direction-quiz[hidden] {
  display: none;
}

.route-direction-quiz:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.route-direction-quiz-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 3, 0.45);
}

.route-direction-quiz-card {
  position: relative;
  width: min(440px, 88vw);
  background: linear-gradient(160deg, #2c2416 0%, #1a140c 100%);
  border: 2px solid rgba(216, 164, 91, 0.6);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  padding: 26px 28px;
  text-align: center;
}

#route-direction-quiz-text p {
  margin: 0;
  font-family: var(--font-heading);
  color: var(--color-gold);
  font-size: clamp(1rem, 1.3vw, 1.15rem);
  line-height: 1.6;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

#route-direction-quiz-text p + p {
  margin-top: 4px;
  color: var(--color-parchment);
  font-size: clamp(0.9rem, 1.1vw, 1rem);
}

.route-direction-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.route-direction-option-btn {
  padding: 10px 14px;
  font-family: var(--font-heading);
  font-size: clamp(0.85rem, 1.05vw, 0.98rem);
  font-weight: 700;
  color: var(--color-gold);
  background: rgba(8, 6, 4, 0.4);
  border: 1.5px solid rgba(216, 164, 91, 0.6);
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.route-direction-option-btn:hover,
.route-direction-option-btn:focus-visible {
  border-color: var(--color-gold);
  background: rgba(18, 13, 8, 0.6);
  box-shadow: 0 0 14px rgba(232, 194, 122, 0.45);
  outline: none;
}

.route-direction-feedback {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(216, 164, 91, 0.3);
  font-family: var(--font-body);
  font-style: italic;
  color: var(--color-bronze-light);
  font-size: clamp(0.85rem, 1.05vw, 0.95rem);
  line-height: 1.5;
}

.route-direction-feedback[hidden] {
  display: none;
}

/* ===================== פאנל השלמת המסלול ===================== */

.route-success-panel[hidden] {
  display: none;
}

.route-success-panel:not([hidden]) {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: clamp(20px, 5vh, 48px);
  transform: translateX(-50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.route-success-text {
  margin: 0;
  font-family: var(--font-heading);
  color: var(--color-gold);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9), 0 0 14px rgba(232, 194, 122, 0.35);
  background: rgba(6, 5, 3, 0.6);
  padding: 9px 24px;
  border-radius: 8px;
}

.reveal-stamp-btn {
  padding: 10px 32px;
  font-family: var(--font-heading);
  font-size: clamp(0.92rem, 1.15vw, 1.08rem);
  font-weight: 700;
  color: var(--color-gold);
  background: rgba(169, 102, 47, 0.4);
  border: 1.5px solid rgba(216, 164, 91, 0.65);
  border-radius: 6px;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.reveal-stamp-btn:hover {
  border-color: var(--color-gold);
  box-shadow: 0 0 16px rgba(232, 194, 122, 0.5);
}
