/* =========================================================================
   שביל הבחירה — עיצוב
   פלטה: ירוק יער כהה (רקע) + זהב/חרדל (מותג) + תכלת (רכיבי חידה)
   פונט: PING (אם קיים בנכסים) עם נפילה לפונט עברי מודגש
   ========================================================================= */

@font-face {
  font-family: "Ping";
  src: url("assets/fonts/PingHL-Heavy.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: "Ping";
  src: url("assets/fonts/PingHL-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --forest-950: #0d1c14;
  --forest-900: #12261c;
  --forest-800: #1b3527;
  --gold: #d9a441;
  --gold-light: #f0c674;
  --cyan: #2fb7d6;
  --cyan-dark: #1c8ba3;
  --cream: #f6f1e6;
  --ok: #4caf7d;
  --err: #d9614f;
  --font-display: "Ping", "Rubik", "Arial Hebrew", system-ui, sans-serif;
  --font-body: "Ping", "Rubik", "Arial Hebrew", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--forest-950);
  color: var(--cream);
  font-family: var(--font-body);
  overflow: hidden;
}
button { font-family: inherit; }
h1, h2 { font-family: var(--font-display); margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  .screen { transition: opacity .35s ease, transform .35s ease; }
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  opacity: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.screen.active {
  display: block;
  opacity: 1;
}

/* ---------- מותג ---------- */
.brand {
  font-weight: 800;
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  letter-spacing: -0.5px;
  color: var(--gold-light);
  text-shadow: 0 2px 12px rgba(0,0,0,.45);
}
.brand span {
  display: block;
  font-size: 0.5em;
  font-weight: 400;
  color: var(--cream);
  letter-spacing: 2px;
}
.brand.small { font-size: clamp(1.3rem, 6vw, 1.7rem); }
.brand-wrap { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 44px; width: auto; display: block; }

/* ---------- כפתורים ---------- */
.btn-primary, .btn-secondary {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 16px 36px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: var(--forest-950);
  box-shadow: 0 8px 24px rgba(217,164,65,.35);
}
.btn-primary:active { transform: scale(.97); }
.btn-secondary {
  background: transparent;
  color: var(--cream);
  border: 2px solid var(--cream);
}

/* ---------- מסך פתיחה ---------- */
.splash-bg, .home-bg, .puzzle-bg, .solved-bg, .finish-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.splash-bg {
  background: radial-gradient(circle at 50% 20%, var(--forest-800), var(--forest-950) 70%),
              url("assets/backgrounds/splash.jpg") center/cover;
  background-blend-mode: soft-light;
}
.splash-content, .finish-content {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  gap: 14px;
}
.splash-logo { height: 60px; width: auto; max-width: 70%; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.splash-leaf { font-size: 3rem; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.splash-sub, .finish-sub { color: rgba(246,241,230,.8); margin-bottom: 10px; max-width: 320px; }

/* ---------- מסך הבית / רשימת התחנות ---------- */
.home-bg {
  background: linear-gradient(180deg, rgba(13,28,20,.55), rgba(13,28,20,.85)),
              url("assets/backgrounds/home.jpg") center/cover;
}
.home-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}
.progress-pill {
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: .9rem;
}
.stations-list {
  position: relative;
  z-index: 1;
  height: calc(100% - 70px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  padding: 10px 20px 56px;
  -webkit-overflow-scrolling: touch;
}
.station-btn {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 3px solid var(--gold-light);
  background-size: cover;
  background-position: center;
  background-color: var(--forest-800);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,.4);
  flex-shrink: 0;
}
.station-btn::after {
  content: attr(data-label);
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: .78rem;
  font-weight: 700;
  color: var(--cream);
  text-shadow: 0 2px 6px rgba(0,0,0,.6);
}
.station-btn.solved {
  border-color: var(--ok);
}
.station-btn.solved::before {
  content: "✓";
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--ok);
  color: #08331e;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 2px solid var(--forest-950);
}
.station-btn:active { transform: scale(.95); }

/* ---------- מסך חידה ---------- */
.puzzle-bg { background-color: var(--forest-800); }
.puzzle-overlay {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 30px;
  background: linear-gradient(180deg, rgba(0,0,0,.1) 0%, rgba(0,0,0,.45) 55%, rgba(0,0,0,.75) 100%);
  overflow-y: auto;
}
.btn-back {
  align-self: flex-start;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.3);
  color: var(--cream);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: .9rem;
  cursor: pointer;
  margin-bottom: 14px;
}
.puzzle-name {
  font-size: clamp(1.4rem, 6vw, 2rem);
  color: var(--gold-light);
  margin-bottom: 6px;
  text-align: center;
}
.puzzle-prompt {
  text-align: center;
  color: rgba(246,241,230,.85);
  margin: 0 0 20px;
  font-size: .95rem;
}
.puzzle-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.puzzle-feedback {
  text-align: center;
  min-height: 24px;
  font-weight: 700;
}
.puzzle-feedback.err { color: var(--err); }
.puzzle-feedback.ok { color: var(--ok); }

/* ---------- נגן אודיו ---------- */
.audio-player {
  width: 100%;
  max-width: 380px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 16px;
  padding: 12px 14px;
}
.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  direction: ltr; /* פקדי הנגן (נגן/פאוז/סרגל) תמיד משמאל לימין, כמו בכל נגן מדיה סטנדרטי */
}
.audio-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: var(--cream);
  cursor: pointer;
  font-size: .85rem;
}
.audio-btn { width: 38px; height: 38px; }
.audio-btn-play {
  width: 46px;
  height: 46px;
  background: var(--cyan);
  color: #06303a;
  font-size: 1.1rem;
}
.audio-time {
  font-size: .75rem;
  color: rgba(246,241,230,.8);
  min-width: 34px;
  text-align: center;
}
.audio-seek {
  flex: 1;
  height: 4px;
  accent-color: var(--cyan);
  cursor: pointer;
  direction: ltr;
}

/* ---------- ווידג'ט: הקלדת טקסט חופשי ---------- */
.text-input-field {
  width: 100%;
  max-width: 360px;
  text-align: center;
  font-size: 1.2rem;
  padding: 16px;
  border-radius: 14px;
  border: 2px solid var(--cyan);
  background: rgba(0,0,0,.3);
  color: var(--cream);
  /* הכיוון נקבע ב-JS לפי השפה (input.dir) */
}
.text-input-field:focus { outline: 2px solid var(--gold-light); }

/* ---------- ווידג'ט: עיגולי ספרות (digit-circles) ---------- */
.digit-circles-row { display: flex; gap: 12px; direction: ltr; }
.digit-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--cyan);
  color: #06303a;
  font-size: 1.6rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.2), 0 6px 14px rgba(0,0,0,.35);
}
.digit-circle:active { transform: translateY(2px); }

/* ---------- ווידג'ט: תיבות + מקלדת ספרות (keypad-boxes) ---------- */
.digit-boxes-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; direction: ltr; }
.digit-box {
  width: 46px;
  height: 56px;
  border-radius: 10px;
  background: var(--cyan);
  color: #06303a;
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.2);
}
.digit-box.filled { background: var(--gold-light); }
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 10px;
}
.keypad-key {
  height: 56px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,.12);
  color: var(--cream);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
}
.keypad-key:active { background: rgba(255,255,255,.25); }
.keypad-key.wide { grid-column: span 1; background: rgba(217,97,79,.35); }
.keypad-key.submit { background: rgba(76,175,125,.4); }

/* ---------- ווידג'ט: רשת בחירה (grid-select) ---------- */
.grid-select {
  display: grid;
  gap: 6px;
  direction: ltr; /* כדי ש-[0,0] יהיה בפינה שמאל-למעלה, כמו שמוגדר ב-stations.js */
}
.grid-cell {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  border: 2px solid rgba(255,255,255,.2);
  cursor: pointer;
}
.grid-cell.selected { background: var(--cyan); border-color: var(--cyan-dark); }

/* ---------- ווידג'ט: פסנתר (piano-sequence) ---------- */
.piano {
  display: flex;
  gap: 4px;
  background: #0a1810;
  padding: 10px;
  border-radius: 12px;
}
.piano-key {
  width: 38px;
  height: 90px;
  background: var(--cream);
  border: 1px solid #333;
  border-radius: 0 0 6px 6px;
  color: #333;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  cursor: pointer;
}
.piano-key:active { background: var(--gold-light); }
.piano-sequence-display {
  min-height: 28px;
  font-size: .9rem;
  color: rgba(246,241,230,.7);
  text-align: center;
  word-break: break-word;
  max-width: 320px;
}

/* ---------- ווידג'ט: גלגלות (rotary-dial) ---------- */
.dials-row { display: flex; gap: 10px; direction: ltr; }
.dial {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dial button {
  width: 44px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,.15);
  color: var(--cream);
  font-size: 1.1rem;
  cursor: pointer;
}
.dial-value {
  width: 44px;
  height: 54px;
  background: var(--cyan);
  color: #06303a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
}

/* ---------- ווידג'ט: בחירת מילים (word-select) ---------- */
.word-select-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 420px;
}
.word-chip {
  border: 2px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.08);
  color: var(--cream);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .85rem;
  cursor: pointer;
}
.word-chip.selected { background: var(--cyan); border-color: var(--cyan-dark); color: #06303a; font-weight: 700; }

/* ---------- כפתור בדיקה כללי ---------- */
.btn-check {
  margin-top: 6px;
  background: var(--gold);
  color: var(--forest-950);
  border: none;
  border-radius: 999px;
  padding: 12px 32px;
  font-weight: 800;
  cursor: pointer;
}

/* ---------- מסך פתרון חידה ---------- */
.solved-bg { background: radial-gradient(circle at 50% 30%, var(--forest-800), var(--forest-950) 75%); }
.solved-content {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 0 24px;
}
.solved-check {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--ok);
  color: #08331e;
  font-size: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.solved-name { color: var(--gold-light); font-size: 1.4rem; }
.solved-sub { color: rgba(246,241,230,.8); margin-bottom: 14px; }

/* ---------- מסך סיום ---------- */
.finish-return { font-weight: 700; color: var(--cream); margin-bottom: 18px; }
.finish-bg { background: radial-gradient(circle at 50% 20%, var(--forest-800), var(--forest-950) 70%); }

/* מובייל צר */
@media (max-width: 340px) {
  .station-btn { width: 92px; height: 92px; }
  .keypad-grid { grid-template-columns: repeat(3, 56px); }
}

/* ---------- בחירת שפה ---------- */
.lang-switch { display: flex; gap: 8px; margin-top: 10px; direction: ltr; }
.lang-switch button {
  border: 1px solid rgba(246,241,230,.45);
  background: transparent;
  color: var(--cream);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: .9rem;
  cursor: pointer;
}
.lang-switch button.active {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: var(--forest-950);
  font-weight: 700;
}
.lang-switch.small { margin-top: 0; gap: 4px; }
.lang-switch.small button { padding: 4px 10px; font-size: .75rem; }
