/* Style.css - Kids Fun Learning Academy */

/* Smooth custom animations */
@keyframes floatSlow {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-14px) rotate(2deg); }
}

@keyframes cloudDrift1 {
  0% { transform: translateX(110vw); }
  100% { transform: translateX(-20vw); }
}

@keyframes cloudDrift2 {
  0% { transform: translateX(115vw); }
  100% { transform: translateX(-30vw); }
}

@keyframes cloudDrift3 {
  0% { transform: translateX(120vw); }
  100% { transform: translateX(-25vw); }
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

@keyframes scaleUp {
  0% { opacity: 0; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes balloonFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.02); }
}

.animate-fadeIn {
  animation: fadeIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.animate-scaleUp {
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.animate-spin-slow {
  animation: spinSlow 12s linear infinite;
}

.animate-wiggle {
  animation: wiggle 1.2s ease-in-out infinite;
}

/* Clouds in background */
.cloud {
  position: absolute;
  font-size: 4.5rem;
  opacity: 0.45;
  user-select: none;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.05));
}
.cloud-1 { top: 8%; animation: cloudDrift1 45s linear infinite; }
.cloud-2 { top: 40%; animation: cloudDrift2 65s linear infinite 10s; }
.cloud-3 { top: 75%; animation: cloudDrift3 55s linear infinite 20s; }

.floating-stars .star {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.5;
  animation: floatSlow 4s ease-in-out infinite;
}

/* Card Glow Effect */
.card-glow {
  position: absolute;
  inset: -20px;
  border-radius: 9999px;
  filter: blur(24px);
  pointer-events: none;
}

/* Game Pieces & Interactions */
.draggable-piece {
  cursor: grab;
  touch-action: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.draggable-piece:active {
  cursor: grabbing;
  transform: scale(1.08) rotate(3deg);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

.drop-target-active {
  border-color: #FACC15 !important;
  background-color: #FEF9C3 !important;
  transform: scale(1.04);
}

/* Balloon Game Styles */
.balloon-item {
  animation: balloonFloat 3s ease-in-out infinite;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.balloon-item:hover {
  transform: translateY(-8px) scale(1.08);
}

/* River hop stones */
.river-stone {
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.river-stone:hover {
  transform: translateY(-6px) scale(1.05);
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.03);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.4);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.8);
}

/* Coloring template gallery */
#templateGrid button {
  min-height: 64px;
  touch-action: manipulation;
}
#templateGrid::-webkit-scrollbar {
  width: 5px;
}
#templateGrid::-webkit-scrollbar-thumb {
  background: rgba(251, 113, 133, 0.5);
  border-radius: 10px;
}

/* Coloring canvas keeps its aspect ratio on every screen */
#paintCanvas {
  max-width: 100%;
  height: auto;
  touch-action: none;
}

/* Quick game cards on the hub */
.quick-game-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  min-height: 56px;
}
.quick-game-card:active {
  transform: scale(0.95);
}

/* Keep long game instructions tidy on small phones */
#gameInstruction {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== خلفية ملوّنة متحركة ===== */
body {
  background-image: linear-gradient(140deg, #e0f2fe, #f0fdfa, #fef3c7, #fce7f3, #e0f2fe);
  background-size: 300% 300%;
  animation: dreamyBg 26s ease-in-out infinite;
}

@keyframes dreamyBg {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.aurora-blob {
  position: absolute;
  border-radius: 9999px;
  filter: blur(48px);
  opacity: 0.45;
  will-change: transform;
}

.blob-1 {
  width: 46vw; height: 46vw; max-width: 320px; max-height: 320px;
  background: #7dd3fc; top: -8%; right: -12%;
  animation: blobFloat1 24s ease-in-out infinite;
}
.blob-2 {
  width: 40vw; height: 40vw; max-width: 280px; max-height: 280px;
  background: #fcd34d; bottom: 8%; left: -14%;
  animation: blobFloat2 30s ease-in-out infinite;
}
.blob-3 {
  width: 38vw; height: 38vw; max-width: 260px; max-height: 260px;
  background: #86efac; top: 42%; left: -10%;
  animation: blobFloat3 27s ease-in-out infinite;
}
.blob-4 {
  width: 36vw; height: 36vw; max-width: 250px; max-height: 250px;
  background: #f9a8d4; bottom: -12%; right: -8%;
  animation: blobFloat1 33s ease-in-out infinite reverse;
}

@keyframes blobFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-28px, 34px) scale(1.12); }
}
@keyframes blobFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(34px, -26px) scale(1.08); }
}
@keyframes blobFloat3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(22px, 30px) scale(1.1); }
}

/* أقراص لعبة سيمون */
.simon-pad {
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
}
.simon-pad-on {
  filter: brightness(1.65) saturate(1.2);
  transform: scale(1.06);
  box-shadow: 0 0 0 4px #fff, 0 0 26px rgba(255, 255, 255, 0.9), inset 0 -6px 0 rgba(0, 0, 0, 0.12);
}

/* ================= لوحة متابعة الوالدين ================= */
.pp-hidden { display: none !important; }

.parent-entry {
  background: linear-gradient(125deg, #1e293b, #0f172a);
  border: 3px solid #334155;
  border-radius: 24px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 16px 30px -24px rgba(15, 23, 42, 0.95);
}
.parent-entry h4 { color: #ffffff; font-size: 15px; font-weight: 900; line-height: 1.3; }
.parent-entry p { color: #cbd5e1; font-size: 11px; font-weight: 600; line-height: 1.5; }
.parent-entry-icon {
  width: 46px; height: 46px; border-radius: 16px; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.12);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.parent-entry-btn {
  flex-shrink: 0; background: #34d399; color: #052e23;
  font-size: 12px; font-weight: 900; padding: 11px 14px; border-radius: 14px;
  font-family: inherit;
}
.parent-entry-btn:active { transform: scale(0.95); }
@media (max-width: 420px) {
  .parent-entry { flex-direction: column; align-items: stretch; text-align: center; }
  .parent-entry .flex { flex-direction: column; }
}

.pp-shell {
  display: flex; flex-direction: column; gap: 14px;
  width: 100%; max-width: 760px; margin: 0 auto;
  font-family: Tajawal, sans-serif; color: #1e293b;
}

.pp-topbar {
  display: flex; align-items: center; gap: 12px;
  background: #ffffff; border: 2px solid #e2e8f0; border-radius: 22px;
  padding: 12px 14px;
  box-shadow: 0 14px 30px -26px rgba(15, 23, 42, 0.9);
}
.pp-back {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0;
  background: #eef2ff; color: #3730a3; font-size: 20px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.pp-back:active { transform: scale(0.94); }
.pp-h2 { font-size: 16px; font-weight: 900; line-height: 1.35; color: #1e293b; }
.pp-sub { font-size: 11px; font-weight: 700; color: #64748b; }
.pp-logout {
  margin-inline-start: auto; flex-shrink: 0; font-family: inherit;
  font-size: 11px; font-weight: 900; color: #b91c1c;
  background: #fee2e2; border-radius: 12px; padding: 10px 13px;
}
.pp-logout:active { transform: scale(0.95); }

.pp-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: linear-gradient(125deg, #1e1b4b, #3730a3 55%, #0f766e);
  color: #ffffff; border-radius: 24px; padding: 18px;
  box-shadow: 0 20px 36px -28px rgba(30, 27, 75, 1);
}
.pp-hero-tag {
  display: inline-block; font-size: 10px; font-weight: 900;
  background: rgba(255, 255, 255, 0.18); border-radius: 999px; padding: 3px 10px;
}
.pp-hero-title { font-size: 19px; font-weight: 900; margin-top: 8px; line-height: 1.35; }
.pp-hero-sub { font-size: 12px; font-weight: 700; color: #c7d2fe; margin-top: 4px; }
.pp-hero-ring {
  width: 82px; height: 82px; border-radius: 999px; flex-shrink: 0;
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.pp-hero-ring-num { font-size: 23px; font-weight: 900; line-height: 1; }
.pp-hero-ring-lbl { font-size: 9px; font-weight: 800; color: #c7d2fe; }

.pp-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .pp-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pp-tile {
  background: #ffffff; border: 2px solid #e2e8f0; border-radius: 18px;
  padding: 12px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
}
.pp-tile-icon { font-size: 18px; }
.pp-tile-num { font-size: 22px; font-weight: 900; color: #0f172a; line-height: 1.1; }
.pp-tile-lbl { font-size: 10px; font-weight: 800; color: #64748b; }

.pp-card { background: #ffffff; border: 2px solid #e2e8f0; border-radius: 22px; padding: 14px; }
.pp-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.pp-h3 { font-size: 14px; font-weight: 900; color: #1e293b; }
.pp-hint { font-size: 10px; font-weight: 800; color: #64748b; }

.pp-chart { display: flex; align-items: flex-end; gap: 6px; height: 122px; }
.pp-bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 4px; height: 100%; justify-content: flex-end;
}
.pp-bar-value { font-size: 10px; font-weight: 900; color: #4338ca; }
.pp-bar-track {
  width: 100%; flex: 1; display: flex; align-items: flex-end;
  background: #eef2ff; border-radius: 10px; overflow: hidden; min-height: 12px;
}
.pp-bar-fill {
  width: 100%; min-height: 4px;
  background: linear-gradient(180deg, #818cf8, #4338ca);
  border-radius: 10px 10px 0 0;
}
.pp-bar-label { font-size: 9px; font-weight: 800; color: #64748b; }

.pp-subjects { display: flex; flex-direction: column; gap: 10px; }
.pp-subject-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 800; color: #334155; margin-bottom: 4px;
}
.pp-subject-val { color: #b45309; }
.pp-subject-track { height: 9px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.pp-subject-fill {
  height: 100%; min-width: 2px; border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #0d9488);
}

.pp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-chip {
  font-size: 10px; font-weight: 800; padding: 5px 9px; border-radius: 999px;
  background: #f1f5f9; color: #94a3b8; border: 1px solid #e2e8f0;
}
.pp-chip.on { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

.pp-filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.pp-filters button {
  flex-shrink: 0; font-family: inherit; font-size: 11px; font-weight: 900;
  padding: 7px 12px; border-radius: 999px;
  background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0;
}
.pp-filters button.on { background: #4338ca; color: #ffffff; border-color: #4338ca; }

.pp-log {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 340px; overflow-y: auto; padding-inline-end: 2px;
}
.pp-day { display: flex; flex-direction: column; gap: 6px; }
.pp-day-label {
  font-size: 10px; font-weight: 900; color: #64748b;
  background: #f8fafc; border-radius: 8px; padding: 4px 8px; align-self: flex-start;
}
.pp-row {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 8px 10px;
}
.pp-row-icon { font-size: 15px; flex-shrink: 0; }
.pp-row-text { flex: 1; font-size: 12px; font-weight: 700; color: #334155; line-height: 1.45; }
.pp-row-time { font-size: 10px; font-weight: 800; color: #94a3b8; flex-shrink: 0; }
.pp-row-star { border-inline-start: 4px solid #fbbf24; }
.pp-row-win { border-inline-start: 4px solid #10b981; }
.pp-row-game { border-inline-start: 4px solid #6366f1; }
.pp-row-trophy { border-inline-start: 4px solid #a855f7; }
.pp-row-art { border-inline-start: 4px solid #f43f5e; }
.pp-empty { font-size: 12px; font-weight: 700; color: #94a3b8; text-align: center; padding: 16px 8px; }

.pp-actions { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 480px) { .pp-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pp-action {
  font-family: inherit; font-size: 12px; font-weight: 900;
  padding: 12px; border-radius: 14px; text-align: center;
  background: #f1f5f9; color: #334155; border: 2px solid #e2e8f0;
}
.pp-action:active { transform: scale(0.98); }
.pp-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.pp-label { display: block; font-size: 11px; font-weight: 900; color: #475569; margin: 10px 0 5px; }
.pp-input {
  width: 100%; border: 2px solid #e2e8f0; border-radius: 14px;
  padding: 12px 14px; font-size: 16px; font-weight: 800; color: #1e293b;
  background: #f8fafc; font-family: inherit;
}
.pp-input:focus {
  outline: none; border-color: #6366f1; background: #ffffff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.pp-primary {
  width: 100%; margin-top: 14px; padding: 14px; border-radius: 16px;
  font-family: inherit; font-size: 14px; font-weight: 900; color: #ffffff;
  background: linear-gradient(135deg, #4338ca, #0f766e);
  box-shadow: 0 14px 24px -18px rgba(67, 56, 202, 0.95);
}
.pp-primary:active { transform: scale(0.98); }
.pp-error {
  font-size: 11px; font-weight: 800; color: #b91c1c;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 10px; padding: 8px 10px; margin-top: 10px;
}
.pp-fine { font-size: 10px; font-weight: 700; color: #94a3b8; margin-top: 12px; text-align: center; line-height: 1.7; }
.pp-note { font-size: 11px; font-weight: 700; color: #64748b; line-height: 1.75; margin-top: 6px; }
.pp-badge {
  display: inline-block; font-size: 10px; font-weight: 900; color: #4338ca;
  background: #eef2ff; border-radius: 999px; padding: 3px 10px;
}
.pp-setup, .pp-login { max-width: 420px; margin: 0 auto; width: 100%; }
.pp-mini-btn {
  font-family: inherit; font-size: 10px; font-weight: 900;
  padding: 7px 11px; border-radius: 10px; background: #eef2ff; color: #4338ca;
}
.pp-pin-form { margin-top: 12px; border-top: 2px dashed #e2e8f0; padding-top: 6px; }

.pp-dots { display: flex; justify-content: center; gap: 12px; margin: 8px 0 4px; }
.pp-dots i {
  width: 14px; height: 14px; border-radius: 999px; display: block;
  background: #e2e8f0; transition: transform 0.15s ease, background 0.15s ease;
}
.pp-dots i.on { background: #4338ca; transform: scale(1.15); }
.pp-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pp-key {
  height: 56px; border-radius: 16px; font-family: inherit;
  background: #f1f5f9; border: 2px solid #e2e8f0;
  font-size: 20px; font-weight: 900; color: #1e293b;
}
.pp-key:active { transform: scale(0.95); background: #e0e7ff; }
.pp-key-ghost { font-size: 13px; color: #64748b; background: #ffffff; }

/* ===== أدوات مساعدة للتجاوب ===== */
.minw-0 { min-width: 0; }
.clip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.only-sm, .only-md { display: none; }
@media (min-width: 640px) { .only-sm { display: block; } }
@media (min-width: 768px) { .only-md { display: inline-block; } }

/* ===== منع التمرير الأفقي على الشاشات الصغيرة ===== */
html, body { max-width: 100%; }
img, canvas, svg, video { max-width: 100%; }
main { overflow-x: clip; }

#viewHub, #viewLessonsList, #viewGameStage, #viewColoring, #viewParent,
#gameArena, #lessonsGrid, #allGamesGrid, #parentContent { min-width: 0; max-width: 100%; }

.quick-game-card { min-width: 0; max-width: 100%; overflow: hidden; }
.quick-game-card .qg-text { min-width: 0; }
.quick-game-card .qg-name,
.quick-game-card .qg-desc { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== لوحة الوالدين: كل صف يتقلص بدل أن يوسّع الصفحة ===== */
.pp-shell, .pp-card, .pp-hero, .pp-topbar, .pp-tile, .pp-row, .pp-day, .pp-subject { min-width: 0; max-width: 100%; }
.pp-shell { width: 100%; }
.pp-topbar > div { min-width: 0; flex: 1 1 auto; }
.pp-topbar .pp-h2 { overflow-wrap: anywhere; line-height: 1.35; }
.pp-hero > div:first-child { min-width: 0; flex: 1 1 auto; }
.pp-hero-title { overflow-wrap: anywhere; }
.pp-tiles { width: 100%; }
.pp-chart { width: 100%; max-width: 100%; overflow: hidden; }
.pp-bar-col { min-width: 0; }
.pp-row-text { min-width: 0; overflow-wrap: anywhere; }
.pp-log { max-width: 100%; overflow-x: hidden; }
.pp-filters { max-width: 100%; }
.pp-keypad { width: 100%; }
.pp-key { width: 100%; min-width: 0; }
.pp-subject-head span { min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  .cloud, .floating-stars .star, .animate-wiggle, .animate-spin-slow, .animate-bounce, .balloon-item, .aurora-blob {
    animation: none !important;
  }
  body {
    animation: none !important;
  }
}