@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&family=Fredoka:wght@400;500;600;700&display=swap');

:root {
  --primary: #ff6b8b;      /* Playful Coral Pink */
  --secondary: #ffbe0b;    /* Warm Yellow */
  --accent: #06d6a0;       /* Playful Green */
  --sky-blue: #3a86c8;     /* Sky Blue */
  --purple: #7209b7;       /* Royal Purple */
  --text-dark: #2b2d42;    /* Charcoal */
  --text-light: #f8f9fa;   /* Warm White */
  --bg-gradient: linear-gradient(135deg, #eef1f6 0%, #e0e9f5 100%);
  --card-shadow: 0 12px 32px rgba(43, 45, 66, 0.08);
  --playful-shadow: 0 8px 0px rgba(0, 0, 0, 0.15);
  --border-radius: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: 'Cairo', 'Fredoka', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
  direction: rtl; /* Standard RTL direction for Arabic */
}

/* Background floating elements (cartoon feel) */
.floating-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.cloud {
  position: absolute;
  background: white;
  border-radius: 100px;
  opacity: 0.8;
  filter: blur(1px);
  animation: floatCloud 25s linear infinite;
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: white;
  border-radius: 100px;
}

.cloud-1 {
  width: 120px;
  height: 40px;
  top: 15%;
  left: -150px;
  animation-duration: 35s;
}
.cloud-1::before { width: 50px; height: 50px; top: -20px; left: 15px; }
.cloud-1::after { width: 70px; height: 70px; top: -35px; right: 15px; }

.cloud-2 {
  width: 180px;
  height: 60px;
  top: 45%;
  left: -200px;
  animation-duration: 25s;
  animation-delay: 5s;
}
.cloud-2::before { width: 80px; height: 80px; top: -35px; left: 25px; }
.cloud-2::after { width: 100px; height: 100px; top: -50px; right: 25px; }

.cloud-3 {
  width: 100px;
  height: 35px;
  top: 75%;
  left: -120px;
  animation-duration: 40s;
  animation-delay: 12s;
}
.cloud-3::before { width: 45px; height: 45px; top: -15px; left: 10px; }
.cloud-3::after { width: 55px; height: 55px; top: -25px; right: 15px; }

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

/* App Main Container */
.app-container {
  width: 90%;
  max-width: 1050px;
  min-height: 650px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 4px solid #ffffff;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  z-index: 10;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Screen Transitions */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  width: 100%;
  flex: 1;
  animation: fadeIn 0.6s ease-out;
}

.screen.active {
  display: flex;
}

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

/* Start Screen Styling */
#start-screen {
  text-align: center;
}

.welcome-character {
  font-size: 80px;
  margin-bottom: 20px;
  animation: bounce 2s infinite ease-in-out;
  display: inline-block;
}

.welcome-title-ar {
  font-size: 3rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 10px;
  text-shadow: 2px 2px 0px #fff, 4px 4px 0px rgba(0,0,0,0.05);
}

.welcome-title-en {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--sky-blue);
  margin-bottom: 35px;
}

.play-btn {
  background: var(--secondary);
  color: var(--text-dark);
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  padding: 16px 60px;
  border: 4px solid var(--text-dark);
  border-radius: 50px;
  cursor: pointer;
  box-shadow: var(--playful-shadow);
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
  display: flex;
  align-items: center;
  gap: 15px;
}

.play-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 0px rgba(0, 0, 0, 0.15);
  background: #ffe169;
}

.play-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0px 0px rgba(0, 0, 0, 0.15);
}

.play-btn .icon {
  font-size: 2.2rem;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

/* Header Area */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px 10px 40px;
  border-bottom: 3px dashed #cbd5e1;
  z-index: 5;
}

.header-title-container {
  display: flex;
  flex-direction: column;
}

.header-title-ar {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
}

.header-title-en {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--sky-blue);
}

.home-btn {
  background: white;
  border: 3px solid var(--text-dark);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--text-dark);
  transition: transform 0.1s, box-shadow 0.1s;
  font-size: 1.5rem;
}

.home-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--text-dark);
}

.home-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0px 0 var(--text-dark);
}

/* Mode Switcher (Lesson vs Playground) */
.mode-tabs {
  display: flex;
  gap: 15px;
}

.tab-btn {
  padding: 10px 20px;
  border: 3px solid var(--text-dark);
  border-radius: 15px;
  background: white;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--text-dark);
  transition: all 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab-btn span.en {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: #64748b;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 0 var(--text-dark);
  transform: translateY(2px);
}

.tab-btn.active span.en {
  color: #f1f5f9;
}

/* Lesson Container Layout */
.lesson-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  width: 100%;
  align-items: center;
}

@media (max-width: 850px) {
  .lesson-layout {
    grid-template-columns: 1fr;
    text-align: center;
  }
  body {
    padding: 10px;
  }
  .app-container {
    min-height: auto;
  }
  .screen {
    padding: 20px;
  }
}

.lesson-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.bilingual-box {
  background: rgba(255, 255, 255, 0.9);
  padding: 25px;
  border-radius: var(--border-radius);
  border: 3px solid var(--text-dark);
  box-shadow: var(--playful-shadow);
  position: relative;
  overflow: hidden;
}

.bilingual-box::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 100%;
  background: var(--primary);
}

.bilingual-box.blue::before { background: var(--sky-blue); }
.bilingual-box.green::before { background: var(--accent); }
.bilingual-box.yellow::before { background: var(--secondary); }

.text-ar {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.7;
  color: var(--text-dark);
  margin-bottom: 8px;
  white-space: pre-line;
}

.text-en {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.5;
  color: #555c75;
  direction: ltr; /* English reads left-to-right */
  text-align: right; /* Align to the right in the RTL context or left if preferred */
  white-space: pre-line;
}
/* Ensure clean reading alignment for English translations */
body[dir="rtl"] .text-en {
  text-align: right;
}

.sound-btn {
  background: var(--primary);
  color: white;
  border: 2px solid var(--text-dark);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--text-dark);
  transition: transform 0.1s, box-shadow 0.1s;
  font-size: 1.2rem;
  margin-top: 10px;
  vertical-align: middle;
}

.sound-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--text-dark);
  background: #ff476f;
}

.sound-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0px 0 var(--text-dark);
}

.sound-btn.playing {
  animation: pulse-sound 1s infinite alternate;
}

@keyframes pulse-sound {
  from { transform: scale(1); }
  to { transform: scale(1.1); background-color: var(--purple); }
}

/* Clock Wrapper & SVG Clock */
.clock-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.clock-svg-container {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1/1;
  position: relative;
}

svg#interactive-clock {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Interactive elements in SVG */
.hand-grab-target {
  cursor: grab;
  fill: transparent;
  stroke: transparent;
  stroke-width: 25px;
}

.hand-grab-target:hover {
  stroke: rgba(6, 214, 160, 0.15);
  cursor: grab;
}

.hand-grab-target:active {
  cursor: grabbing;
}

.clock-hand {
  stroke-linecap: round;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.clock-hand.dragging {
  transition: none !important;
}

.clock-number-label {
  font-size: 26px;
  font-weight: 900;
  fill: var(--text-dark);
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: 'Fredoka', sans-serif;
  cursor: pointer;
  transition: fill 0.2s, transform 0.2s;
}

.clock-number-label:hover {
  fill: var(--primary);
  transform: scale(1.2);
}

.clock-face-rim {
  stroke: var(--text-dark);
  stroke-width: 10;
  fill: #ffffff;
}

.clock-face-inner {
  fill: #f1f5f9;
}

/* Interactive Playground Specific Styling */
.playground-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  width: 100%;
}

@media (max-width: 800px) {
  .playground-layout {
    grid-template-columns: 1fr;
  }
}

.playground-controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 25px;
}

.time-display-box {
  background: white;
  border: 4px solid var(--text-dark);
  border-radius: var(--border-radius);
  padding: 30px;
  text-align: center;
  box-shadow: var(--playful-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.digital-time {
  font-family: 'Fredoka', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--purple);
  background: #f1f5f9;
  padding: 10px 30px;
  border-radius: 15px;
  border: 3px solid var(--text-dark);
}

.spoken-text-ar {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.4;
}

.spoken-text-en {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
  color: var(--sky-blue);
  font-weight: 600;
  direction: ltr;
}

.speak-now-btn {
  background: var(--accent);
  color: white;
  border: 3px solid var(--text-dark);
  border-radius: 50px;
  padding: 12px 35px;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--playful-shadow);
  transition: all 0.1s;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.speak-now-btn:hover {
  background: #05be8f;
  transform: translateY(-3px);
  box-shadow: 0 11px 0 var(--text-dark);
}

.speak-now-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0px 0 var(--text-dark);
}

/* Quick Set Preset Buttons */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.preset-btn {
  background: white;
  border: 3px solid var(--text-dark);
  border-radius: 15px;
  padding: 12px 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--text-dark);
  transition: all 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.preset-btn span.en {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 2px;
}

.preset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--text-dark);
  background: #f8fafc;
}

.preset-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0px 0 var(--text-dark);
}

/* Navigation & Slider Controls */
.navigation-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding: 20px 40px 30px 40px;
}

.progress-container {
  display: flex;
  gap: 8px;
}

.progress-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 2px solid var(--text-dark);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

.progress-dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

.nav-btn {
  background: white;
  border: 3px solid var(--text-dark);
  border-radius: 20px;
  padding: 10px 25px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--text-dark);
  transition: all 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--text-dark);
}

.nav-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0px 0 var(--text-dark);
}

.nav-btn.primary {
  background: var(--primary);
  color: white;
}

.nav-btn.primary:hover {
  background: #ff4d73;
}

.nav-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Scenarios Screen Layout */
.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  width: 100%;
}

.scenario-card {
  background: white;
  border: 4px solid var(--text-dark);
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--playful-shadow);
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.scenario-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 0 rgba(0, 0, 0, 0.15);
  background: #f8fafc;
}

.scenario-card.active {
  background: var(--secondary);
  border-color: var(--text-dark);
  transform: scale(1.03);
}

.scenario-card .icon {
  font-size: 3.5rem;
}

.scenario-card .title-ar {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-dark);
}

.scenario-card .title-en {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  color: #64748b;
}

.scenario-card.active .title-en {
  color: var(--text-dark);
  font-weight: 600;
}

/* Detailed Scenario Overlay / Info panel */
.scenario-details-box {
  margin-top: 30px;
  width: 100%;
}

/* Parts Highlight styles */
.highlight-btn {
  padding: 6px 12px;
  background: #f1f5f9;
  border: 2px solid var(--text-dark);
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  margin: 4px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.2s;
}

.highlight-btn.active {
  background: var(--secondary);
}

.highlight-btn span.en {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.7rem;
  color: #64748b;
}

/* SVG animations and markers */
.hand-hour-glow {
  filter: drop-shadow(0px 0px 8px var(--primary));
}

.hand-minute-glow {
  filter: drop-shadow(0px 0px 8px var(--sky-blue));
}

.clock-face-glow {
  filter: drop-shadow(0px 0px 8px var(--secondary));
}

.hand-second-glow {
  filter: drop-shadow(0px 0px 8px #ff4757);
}

.number-glow {
  fill: var(--purple) !important;
  font-size: 30px !important;
  filter: drop-shadow(0px 0px 8px var(--secondary));
}

/* Footer / Credits */
.app-footer {
  margin-top: 20px;
  font-size: 0.9rem;
  color: #64748b;
  text-align: center;
  z-index: 10;
  display: flex;
  gap: 10px;
  align-items: center;
}

.app-footer span.en {
  font-family: 'Fredoka', sans-serif;
  direction: ltr;
}

/* Helpful indicators and helper tags */
.drag-hint {
  font-size: 0.9rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  animation: pulse-hint 1.5s infinite alternate;
}

@keyframes pulse-hint {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* Confetti / Particle animation container */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 12px;
  height: 12px;
  background-color: var(--primary);
  border-radius: 50%;
  animation: dropConfetti 4s linear infinite;
}

@keyframes dropConfetti {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(700px) rotate(360deg); opacity: 0; }
}
