/* ============================================================
   Bloom Kids — القطع المشتركة بين كل الألعاب
   (شريط المعلومات، الطبقات المنبثقة، التوست، الكونفيتي…)

   بتكمّل على css/style.css، وكل لعبة بتزوّد فوقها ملفها الخاص:
     اكتشف الفروق → css/game.css
     العين الحديدية → css/iron-eye.css
   ============================================================ */

/* عنوان للقارئ الصوتي بس — مش بيبان على الشاشة */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   صفحة لعب: الهيدر بيبقى أنحف وبعرض الشاشة كلها، عشان يفضل
   أكبر قدر من الشاشة للّعبة نفسها
   ============================================================ */
.play-page { --page-pad: 6px; --header-h: 54px; background: var(--cream); }

.play-page .site-header .container { width: 100%; padding-inline: var(--page-pad); }
.play-page .header-inner { padding-block: 0.3rem; }
.play-page .brand-logo { width: 38px; height: 38px; border-width: 2px; }
.play-page .brand-text strong { font-size: 1rem; }
.play-page .brand-text small { font-size: 0.72rem; }

/* ============ شريط المعلومات ============ */
.game-hud {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.hud-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.hud-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--cream); border-radius: 99px;
  padding: 0.4rem 0.95rem; font-weight: 800; font-size: 0.92rem;
  font-family: var(--font-head); color: var(--navy);
  border: 2px solid transparent; white-space: nowrap;
}
.hud-pill b { font-size: 1.02rem; }
.hud-found  { background: rgba(125, 194, 66, 0.16); color: #4e8720; border-color: rgba(125, 194, 66, 0.4); }
.hud-time   { background: rgba(35, 168, 159, 0.14); color: var(--teal-dark); }
.hud-miss   { background: rgba(239, 95, 124, 0.13); color: var(--pink-dark); }
.hud-score  { background: rgba(246, 169, 44, 0.18); color: #a56505; border-color: rgba(246, 169, 44, 0.45); }

.hud-level {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: 1.05rem; display: flex; align-items: center; gap: 0.6rem;
}

.level-pips { display: inline-flex; gap: 0.3rem; }
.pip {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(51, 45, 110, 0.18); transition: all 0.25s ease;
}
.pip.is-done { background: var(--green); }
.pip.is-active { background: var(--pink); transform: scale(1.45); }

.btn-icon {
  width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(51, 45, 110, 0.15);
  background: var(--white); cursor: pointer; font-size: 1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}
.btn-icon:hover { transform: translateY(-2px); background: var(--cream); }

.btn-sm { padding: 0.45rem 1.1rem; font-size: 0.9rem; }

/* بديل مختصر بيظهر مكان الكلام لما الشاشة تضيق */
.btn-label-mini { display: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* .btn فيها display:inline-flex، واللي بتلغي مفعول خاصية hidden —
   لازم نلغيها صراحةً زي ما عملنا مع .overlay */
.btn[hidden] { display: none; }

/* شريط التقدّم */
.progress-track {
  height: 8px; background: rgba(51, 45, 110, 0.1);
  border-radius: 99px; overflow: hidden; margin-bottom: 0.45rem;
}
.progress-bar {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--teal), var(--green));
  transition: width 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* ============ التوست ============ */
.toast {
  position: fixed; inset-inline: 0; bottom: 22px; margin-inline: auto;
  width: max-content; max-width: 90%; z-index: 60;
  background: var(--navy); color: var(--white);
  font-family: var(--font-head); font-weight: 700; font-size: 0.98rem;
  padding: 0.6rem 1.4rem; border-radius: 99px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(18px) scale(0.94);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.toast.is-show { opacity: 1; transform: translateY(0) scale(1); }
.toast-ok { background: #4e8720; }
.toast-no { background: var(--pink-dark); }
.toast-hint { background: var(--purple); }

/* ============ الشاشات المنبثقة ============ */
/* flex + margin:auto مش grid/place-items، عشان لو المحتوى أطول من
   شاشة الموبايل يسكرول عادي بدل ما أوله يتقص ومحدش يوصله */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  background: rgba(39, 34, 83, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 1.2rem;
  opacity: 0; transition: opacity 0.3s ease;
}
.overlay.is-show { opacity: 1; }

/* مهم: display:flex بيلغي مفعول خاصية hidden، فلازم نلغيه صراحةً —
   من غير كده الطبقة الشفافة بتفضل فوق اللعبة وتبلع كل الضغطات */
.overlay[hidden] { display: none; }
.overlay:not(.is-show) { pointer-events: none; }

.overlay-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem 1.8rem; text-align: center;
  width: min(480px, 100%);
  margin: auto; flex-shrink: 0;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.overlay.is-show .overlay-card { transform: translateY(0) scale(1); }

.overlay-card h2 { margin-bottom: 0.7rem; }
.overlay-card p { color: var(--ink-soft); font-weight: 600; margin-bottom: 1.2rem; }

.how-list {
  display: grid; gap: 0.6rem; text-align: start;
  margin: 0 auto 1.5rem; max-width: 330px;
}
.how-list[hidden] { display: none; } /* display:grid بتلغي مفعول hidden */
.how-list li {
  display: flex; align-items: center; gap: 0.7rem;
  font-weight: 700; font-size: 0.95rem;
}
.how-list span {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.1rem;
}

/* ============ اختيار المرحلة ============ */
.overlay-card-wide { width: min(620px, 100%); }

.levels-title {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: 1.05rem; margin-bottom: 0.8rem;
}

.level-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem; margin-bottom: 1.1rem;
}

.level-card {
  display: flex; align-items: center; gap: 0.7rem; text-align: start;
  background: var(--cream); border: 3px solid transparent;
  border-radius: var(--radius-sm); padding: 0.7rem 0.85rem;
  cursor: pointer; font-family: inherit; position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.level-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--teal); }
.level-card:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.level-card.is-current { border-color: var(--pink); background: rgba(239, 95, 124, 0.09); }

.level-card-emoji {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 14px;
  background: var(--white); display: grid; place-items: center;
  font-size: 1.4rem; box-shadow: 0 3px 8px rgba(51, 45, 110, 0.12);
  overflow: hidden;
}
.level-card-emoji img { width: 100%; height: 100%; object-fit: cover; }

.level-card-body { display: grid; gap: 0.15rem; min-width: 0; }
.level-card-title {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: 0.97rem; line-height: 1.3;
}
.level-card-meta {
  font-weight: 700; font-size: 0.78rem; color: var(--ink-soft);
}
.level-card-meta b { color: var(--teal-dark); }

/* علامة "خلّصتها" — جوه الكارت في آخره عشان متركبش على الكارت اللي جنبه */
.level-card-done {
  margin-inline-start: auto; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--green); color: var(--white);
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 800;
  box-shadow: 0 2px 6px rgba(125, 194, 66, 0.45);
}

/* ============ المراحل ============
   ٣٠ صورة في شاشة واحدة كانت بتبقى قايمة طويلة، فالمراحل بقت
   <details> — واحدة بس مفتوحة (اللي بيلعبها أو أول واحدة مخلصهاش)
   والباقي مقفول. القايمة نفسها بتسكرول جوّه نفسها عشان زرار
   "ابدأ" يفضل باين تحت من غير ما يجري ورا السكرول. */
.stage-list {
  display: grid; gap: 0.7rem; margin-bottom: 1.1rem;
  max-height: min(54vh, 470px); overflow-y: auto;
  padding-inline-end: 0.3rem;
  scrollbar-width: thin;
}

.stage-block {
  background: var(--cream); border: 2px solid rgba(51, 45, 110, 0.08);
  border-radius: var(--radius-sm); overflow: hidden;
}
.stage-block[open] { border-color: var(--teal); background: var(--white); }
.stage-block.is-done .stage-progress { background: var(--green); color: var(--white); }

.stage-head {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.65rem 0.8rem; cursor: pointer; list-style: none;
  text-align: start;
}
.stage-head::-webkit-details-marker { display: none; }
.stage-head:hover { background: rgba(35, 168, 159, 0.07); }
.stage-block[open] .stage-head { border-bottom: 2px dashed rgba(51, 45, 110, 0.1); }

.stage-emoji {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 13px;
  background: var(--white); display: grid; place-items: center; font-size: 1.35rem;
  box-shadow: 0 3px 8px rgba(51, 45, 110, 0.12);
}
.stage-block[open] .stage-emoji { background: var(--cream); }

.stage-info { display: grid; gap: 0.1rem; min-width: 0; flex: 1; }
.stage-info b {
  font-family: var(--font-head); font-weight: 800; color: var(--navy);
  font-size: 0.95rem; line-height: 1.3;
}
.stage-info small {
  font-weight: 700; font-size: 0.76rem; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.stage-progress {
  flex-shrink: 0; font-weight: 800; font-size: 0.8rem;
  background: rgba(51, 45, 110, 0.08); color: var(--navy);
  border-radius: 99px; padding: 0.2rem 0.55rem;
}

.stage-play { flex-shrink: 0; }

.stage-block .level-grid { margin: 0; padding: 0.7rem 0.8rem 0.85rem; }

@media (max-width: 520px) {
  .level-grid { grid-template-columns: 1fr; }
  /* على الموبايل السطر بيضيق، فالتلميح بينزل تحت والزرار يفضل مكانه */
  .stage-head { flex-wrap: wrap; }
  .stage-info { flex-basis: 100%; order: 2; }
  .stage-info small { white-space: normal; }
  .stage-progress { margin-inline-start: auto; }
}

.win-stats {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0.5rem; margin-bottom: 0.8rem;
}
.stat-chip {
  background: var(--cream); border-radius: 99px;
  padding: 0.35rem 0.9rem; font-weight: 700; font-size: 0.86rem;
  color: var(--ink-soft);
}
.stat-chip b { font-family: var(--font-head); color: var(--navy); font-size: 1rem; }

/* متخصّصة عشان تسبق `.overlay-card p` اللي بيلوّن الفقرات رمادي */
.overlay-card .win-best {
  font-family: var(--font-head); font-weight: 800;
  color: #d18e12; margin-bottom: 1.3rem;
}

.overlay-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; }

/* ============ كونفيتي ============ */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i {
  position: absolute; top: -24px; border-radius: 2px;
  animation-name: confetti-fall; animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(680deg); opacity: 0.9; }
}

/* ============ الموبايل ============ */
@media (max-width: 900px) {
  /* شريط معلومات مضغوط: الأيقونات من غير كلام، وكل حاجة أصغر —
     كل بكسل بنوفّره هنا بيروح للّعبة */
  .btn-label { display: none; }
  .btn-label-mini { display: inline; }

  .play-page { --page-pad: 8px; }

  .game-hud { justify-content: center; gap: 0.4rem; margin-bottom: 0.5rem; }
  .hud-level { font-size: 0.92rem; gap: 0.4rem; }
  .hud-pill { font-size: 0.82rem; padding: 0.32rem 0.7rem; }
  .hud-pill b { font-size: 0.92rem; }
  .btn-sm { padding: 0.4rem 0.7rem; }
  .btn-icon { width: 32px; height: 32px; }
  .toast { font-size: 0.88rem; bottom: 14px; }
}

/* ============ تقليل الحركة ============ */
@media (prefers-reduced-motion: reduce) {
  .confetti i { animation: none !important; }
  .overlay, .overlay-card, .progress-bar, .toast { transition: none !important; }
}
