/* =========================================================
   station3Valves.css
   שלב ג׳ - מרוץ השסתומים: ארבעה שסתומי ברונזה סביב שער המנגנון,
   סרגל רצף, ספירה לאחור מקומית, ומד הלחץ המשותף.
   ========================================================= */

/* ===================== מיכל מידע עליון אחד (כותרת/הוראה/סרגל/כפתור) ===================== */
/* עד כה כל אחד מהאלמנטים האלה היה ממוקם position:absolute בנפרד
   עם top קבוע משלו (בהגדרה המשותפת ב-station3.css או כאן) - זה
   גרם לחפיפה בין ארבעת עיגולי הסמלים לשורה השנייה של ההוראה, ובין
   הכפתור לסרגל הסמלים. הפתרון: מיכל אחד position:absolute יחיד
   (עוגן אחד, לא ערך top שרירותי לכל ילד) שבתוכו כל הילדים זורמים
   בזרימה רגילה (flex column + gap), בדיוק כמו שהיה נכון תמיד לבנות
   את זה. הכותרת/ההוראה/הודעת-הרמז משתמשות במחלקות משותפות עם שלב
   א'/ב' (station3.css) - לכן העקיפה כאן ממוקדת אך ורק לילדים בתוך
   #valves-info-panel (סלקטור עם id, גובר על המחלקה המשותפת בלי
   לגעת בה כלל, כך ששלב א'/ב' ממשיכים להשתמש בכללי ה-absolute
   המקוריים שלהם ללא שינוי). */
.valves-info-panel {
  position: absolute;
  z-index: 2;
  top: clamp(8px, 1.6vh, 18px);
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 92%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* כותרת/הוראה/הודעת-רמז הופכים לילדי-flow רגילים בתוך המיכל -
   מבטלים absolute/top/left/transform בלבד; הטיפוגרפיה, הצבע,
   ה-text-shadow והטקסט עצמם (station3.css) נשארים בדיוק כפי שהיו. */
#valves-info-panel.valves-info-panel > .station3-phase-title,
#valves-info-panel.valves-info-panel > .station3-phase-instruction {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  width: auto;
  max-width: 100%;
}

/* רקע-גב עדין מאוד מתחת לטקסט ההוראה בלבד (לא מלבן כהה גדול) -
   כדי לשמור על קריאות מעל המפל ברקע, בנוסף ל-text-shadow הקיים. */
#valves-info-panel.valves-info-panel > .station3-phase-instruction {
  padding: 4px 14px;
  border-radius: 10px;
  background: radial-gradient(ellipse 92% 150% at 50% 50%, rgba(4, 6, 8, 0.38) 0%, rgba(4, 6, 8, 0) 72%);
}

/* סרגל 4 הסמלים: מ-absolute עם top קבוע -> ילד flow רגיל, עם
   מרווח (margin-top בנוסף ל-gap הבסיסי של המיכל) שמבטיח מרחק ברור
   מהשורה השנייה של ההוראה ומזיז את הסרגל כ-40-50px נמוך יותר
   ממיקומו הקודם *כתוצאה* מהזרימה/המרווחים, לא מערך top קבוע יעד. */
.valve-sequence-bar {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

/* לוח הבקרה (ספירה/כפתור/הודעות): גם הוא הופך לילד flow רגיל,
   עם מרווח נוסף מעל סרגל הסמלים ו-gap פנימי בין הכפתור/הספירה
   להודעת ה-timeout/רמז שמופיעה מתחתיו. */
.valves-control-panel {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* הודעת הרמז (station3-hint-message) הועברה ב-HTML להיות בתוך
   #valves-control-panel, מתחת לכפתור/הודעת ה-timeout - עוקפים כאן
   רק את המיקום ה-absolute המשותף שלה (station3.css), לא את שאר
   העיצוב/הטקסט/ה-JS. */
#valves-control-panel > .station3-hint-message {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  width: auto;
  max-width: min(460px, 90vw);
}

.valves-countdown-wrap[hidden] {
  display: none;
}

.valves-countdown-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 18px;
  background: rgba(6, 9, 10, 0.55);
  border: 1px solid rgba(216, 164, 91, 0.4);
  border-radius: 8px;
}

.valves-countdown-label {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-parchment-dim);
}

.valves-countdown-value {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-gold);
  min-width: 2.2ch;
  text-align: center;
}

.valves-countdown-wrap.is-critical .valves-countdown-value {
  color: #e8836a;
  animation: countdownCriticalPulse 550ms ease-in-out infinite;
}

@keyframes countdownCriticalPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  .valves-countdown-wrap.is-critical .valves-countdown-value {
    animation: none !important;
  }
}

.valves-start-btn {
  padding: 10px 30px;
  font-family: var(--font-heading);
  font-size: clamp(0.9rem, 1.1vw, 1.02rem);
  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;
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

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

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

.valves-timeout-message[hidden] {
  display: none;
}

.valves-timeout-message {
  margin: 0;
  font-family: var(--font-heading);
  color: #e8a17a;
  font-size: 0.92rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

/* ===================== סרגל רצף ההפעלה (4 משבצות) ===================== */
/* מיקום/flow של .valve-sequence-bar (position:static + margin-top)
   כבר מוגדרים למעלה, ליד #valves-info-panel - כאן רק העיצוב
   הפנימי של כל משבצת. */

.sequence-slot {
  width: clamp(30px, 3vw, 44px);
  height: clamp(30px, 3vw, 44px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 11, 0.55);
  border: 1.5px solid rgba(216, 164, 91, 0.4);
  color: rgba(216, 164, 91, 0.55);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.sequence-slot svg {
  width: 60%;
  height: 60%;
}

.sequence-slot.is-revealed {
  border-color: rgba(120, 210, 225, 0.6);
  color: rgba(190, 235, 240, 0.9);
}

.sequence-slot.is-pulsing {
  border-color: var(--color-gold);
  color: var(--color-gold);
  box-shadow: 0 0 16px 3px rgba(232, 194, 122, 0.7);
}

.sequence-slot.is-done {
  border-color: #6fd88a;
  color: #6fd88a;
}

/* ===================== גלגל הברונזה הגדול (עיטור, כבר מצויר ברקע - זהו שכבת "סיבוב" נוספת מעליו בהשלמה) ===================== */

.gate-big-wheel {
  position: absolute;
  z-index: 1;
  left: 78%;
  top: 22%;
  width: 17%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  opacity: 0; /* שקוף כברירת מחדל - נראה רק בזמן/אחרי הסיבוב בהשלמה, כדי לא לכפול חזותית על הגלגל הקבוע שכבר ברקע */
  pointer-events: none;
  transform-origin: 50% 50%;
}

.gate-big-wheel.is-turning {
  opacity: 0.9;
  animation: gateBigWheelTurn 1400ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

@keyframes gateBigWheelTurn {
  0% { opacity: 0; transform: rotate(0deg); }
  15% { opacity: 0.9; }
  100% { opacity: 0.9; transform: rotate(160deg); }
}

@media (prefers-reduced-motion: reduce) {
  .gate-big-wheel.is-turning {
    animation: none !important;
    opacity: 0 !important;
  }
}

/* .gate-open-flash הבסיסי (מיקום/רקע) מוגדר משותף עם
   .aqueduct-success-flash ב-station3Aqueduct.css; מפעילים אותה
   אנימציה בדיוק (aqueductSuccessFlash) גם כאן. */
.gate-open-flash.is-active {
  animation: aqueductSuccessFlash 750ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .gate-open-flash.is-active {
    animation: none !important;
  }
}

/* ===================== מצב "השער נפתח" ברקע ===================== */

.station3-bg.is-gate-open {
  transition: filter 900ms ease;
  filter: brightness(1.12) saturate(1.08);
}

@media (prefers-reduced-motion: reduce) {
  .station3-bg.is-gate-open {
    transition: none;
  }
}

/* ===================== ארבעת השסתומים סביב השער ===================== */

.gate-mechanism {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.gate-valve {
  position: absolute;
  width: clamp(64px, 6.6vw, 104px);
  height: clamp(64px, 6.6vw, 104px);
  transform: translate(-50%, -50%);
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
  outline: none;
}

.gate-valve:focus-visible {
  filter: drop-shadow(0 0 10px var(--color-gold)) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
}

.gate-valve-pos-a { left: 84%; top: 20%; }
.gate-valve-pos-b { left: 95%; top: 40%; }
.gate-valve-pos-c { left: 80%; top: 60%; }
.gate-valve-pos-d { left: 91%; top: 80%; }

.gate-valve-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(var(--valve-rotation, 0deg));
  transition: transform 320ms ease;
  pointer-events: none;
  user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  .gate-valve-img {
    transition: transform 1ms linear;
  }
}

.gate-valve-symbol {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30%;
  height: 30%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(232, 194, 122, 0.55);
  opacity: 0.7;
  pointer-events: none;
  transition: color 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
}

.gate-valve-symbol svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gate-valve.is-pulsing .gate-valve-symbol {
  color: #fff3d6;
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(255, 230, 170, 0.9));
}

.gate-valve.is-locked .gate-valve-symbol {
  color: #8fe7f5;
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(120, 220, 235, 0.9));
}

.gate-valve.is-locked {
  filter: drop-shadow(0 0 12px rgba(120, 220, 235, 0.7)) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
}

.gate-valve.is-wrong {
  animation: gateValveWrongShake 320ms ease;
}

@keyframes gateValveWrongShake {
  0%, 100% { transform: translate(-50%, -50%); }
  25% { transform: translate(calc(-50% - 4px), -50%); }
  75% { transform: translate(calc(-50% + 4px), -50%); }
}

.gate-valve.is-disabled {
  pointer-events: none;
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  .gate-valve.is-wrong {
    animation: none !important;
  }
}

/* ===================== חשיפת חותמת המעיין ===================== */

.seal3-reveal-overlay[hidden] {
  display: none;
}

.seal3-reveal-overlay:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* ===================== רעידת מסך עדינה בסיום ===================== */

.station3-valves-shake {
  animation: station3GateShake 420ms ease;
}

@keyframes station3GateShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, -2px); }
  80% { transform: translate(2px, 2px); }
}

@media (prefers-reduced-motion: reduce) {
  .station3-valves-shake {
    animation: none !important;
  }
}
