/* ============================================================
   English with Miss Marwa — design system
   Light, cheerful, child-first. Mobile-first responsive.
   ============================================================ */

@font-face {
  font-family: 'Andika';
  src: url('../fonts/andika-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Andika';
  src: url('../fonts/andika-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Sans Arabic';
  src: url('../fonts/noto-sans-arabic.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #F6FAFF;
  --surface: #FFFFFF;
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --sky: #DBEAFE;
  --ink: #17324D;
  --ink-soft: #47617C;
  --reward: #FBBF24;
  --mint: #A7E1D4;
  --lavender: #EDE9FE;
  --cream: #FFF7E8;
  --marwa-brown: #6B4226;
  --ok: #16A34A;
  --radius-card: 24px;
  --radius-btn: 18px;
  --shadow-card: 0 4px 14px rgba(23, 50, 77, 0.08);
  --shadow-lift: 0 8px 22px rgba(23, 50, 77, 0.14);
  --tap: 56px;
  --space: 8px;
  --font-latin: 'Andika', 'Comic Sans MS', 'Segoe UI', sans-serif;
  --font-arabic: 'Noto Sans Arabic', 'Andika', sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-latin);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; }

button {
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 4px solid var(--primary);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ---------- layout shell ---------- */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 1.5);
  padding: calc(var(--space) * 1.25) calc(var(--space) * 2);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(23, 50, 77, 0.06);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-topbar .brand {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 1.25);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}
.app-topbar .brand img { width: 44px; height: 44px; border-radius: 50%; }
.app-topbar .brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { margin-left: auto; display: flex; gap: var(--space); align-items: center; }

.icon-btn {
  min-width: 48px;
  min-height: 48px;
  border: none;
  border-radius: 14px;
  background: var(--sky);
  color: var(--ink);
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  gap: 6px;
}
.icon-btn[aria-pressed="true"] { background: var(--primary); color: #fff; }
.icon-btn .label { font-size: 0.85rem; font-weight: 700; }

.lang-switch {
  border: 2px solid var(--sky);
  background: var(--surface);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 14px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}
.lang-switch .ckb { font-family: var(--font-arabic); }

main.app-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(var(--space) * 2) calc(var(--space) * 2) calc(var(--space) * 6);
}

.app-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  padding: var(--space) calc(var(--space) * 2) calc(var(--space) * 2);
}

/* ---------- home ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 3);
  background: linear-gradient(135deg, var(--cream), var(--sky));
  border-radius: var(--radius-card);
  padding: calc(var(--space) * 3);
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
}
.hero img.hero-character {
  width: 180px;
  max-width: 42vw;
  border-radius: 20px;
  box-shadow: var(--shadow-lift);
  flex: 0 0 auto;
}
.hero-text { flex: 1 1 240px; }
.hero-text h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 4.5vw, 2.2rem); color: var(--ink); }
.hero-text .tagline { margin: 0 0 6px; font-size: 1.05rem; color: var(--marwa-brown); font-weight: 700; }
.hero-text p { margin: 0 0 14px; color: var(--ink-soft); }

.cta-play {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 34px;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 0 var(--primary-dark);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cta-play:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--primary-dark); }

.continue-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--primary);
  background: none;
  border: none;
  text-decoration: underline;
  min-height: 44px;
}

.star-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 12px;
  font-size: 1.05rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: calc(var(--space) * 2);
  margin-top: calc(var(--space) * 3);
}

.category-card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 2.5) var(--space);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 150px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
}
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.category-card .cat-emoji { font-size: 3rem; line-height: 1; }
.category-card.tint-sky { background: var(--sky); }
.category-card.tint-mint { background: var(--mint); }
.category-card.tint-lavender { background: var(--lavender); }
.category-card.tint-cream { background: var(--cream); }
.category-card.tint-reward { background: #FEF3C7; }
.category-card.tint-rose { background: #FCE7F3; }

.home-secondary {
  margin-top: calc(var(--space) * 3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
  align-items: center;
  justify-content: center;
}

/* ---------- generic page header inside activities ---------- */

.activity-bar {
  display: flex;
  align-items: center;
  gap: var(--space);
  margin-bottom: calc(var(--space) * 2);
  flex-wrap: wrap;
}
.activity-bar h2 { margin: 0; font-size: 1.35rem; flex: 1 1 auto; }
.activity-bar .round-pill {
  background: var(--lavender);
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 700;
  font-size: 0.95rem;
}

.btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  box-shadow: var(--shadow-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.soft { background: var(--sky); }
.btn.reward { background: var(--reward); color: var(--ink); }

/* ---------- letters explorer ---------- */

.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: calc(var(--space) * 1.5);
}
.letter-tile {
  background: var(--surface);
  border: none;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  min-height: 96px;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.letter-tile small { color: var(--ink-soft); font-size: 1.4rem; }
.letter-tile:hover { box-shadow: var(--shadow-lift); }

.letter-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 3);
  text-align: center;
}
.letter-display {
  font-size: clamp(4rem, 18vw, 8rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  display: flex;
  justify-content: center;
  gap: 0.35em;
}
.letter-display .upper { color: var(--primary); }
.letter-display .lower { color: var(--marwa-brown); }

.audio-row {
  display: flex;
  gap: var(--space);
  justify-content: center;
  flex-wrap: wrap;
  margin: calc(var(--space) * 2) 0;
}

.audio-btn {
  min-height: 60px;
  padding: 0 22px;
  border: none;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--sky);
  color: var(--ink);
}
.audio-btn.playing { background: var(--primary); color: #fff; }
.audio-btn:disabled { opacity: 0.55; cursor: wait; }

.example-word {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--space) * 2);
  background: var(--cream);
  border-radius: 20px;
  padding: calc(var(--space) * 2);
  margin-top: var(--space);
  flex-wrap: wrap;
}
.example-word .pic { font-size: 4rem; line-height: 1; }
.example-word .word { font-size: 1.6rem; font-weight: 700; }

.letter-nav { display: flex; justify-content: space-between; gap: var(--space); margin-top: calc(var(--space) * 2); }

/* ---------- character guide ---------- */

.guide {
  display: flex;
  align-items: flex-end;
  gap: calc(var(--space) * 1.5);
  margin: calc(var(--space) * 2) 0;
}
.guide img.guide-face {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: var(--shadow-card);
  flex: 0 0 auto;
  object-fit: cover;
}
.guide .bubble {
  background: var(--surface);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 16px;
  box-shadow: var(--shadow-card);
  font-weight: 700;
  font-size: 1.05rem;
  max-width: 70%;
  position: relative;
}
.guide .bubble.ckb { font-family: var(--font-arabic); direction: rtl; }
.guide.cheer img.guide-face { animation: guide-bounce 0.6s ease; }
.guide.size-lg img.guide-face { width: 120px; height: 120px; }
.guide.size-sm img.guide-face { width: 60px; height: 60px; }

@keyframes guide-bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
}

/* ---------- games ---------- */

.game-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: calc(var(--space) * 2); }
.game-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 2.5);
  border: none;
  text-align: left;
  color: var(--ink);
  display: flex;
  gap: calc(var(--space) * 1.5);
  align-items: center;
  min-height: 110px;
  text-decoration: none;
}
.game-card:hover { box-shadow: var(--shadow-lift); }
.game-card .g-emoji { font-size: 2.6rem; }
.game-card h3 { margin: 0 0 2px; font-size: 1.1rem; }
.game-card p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; font-weight: 400; }

.game-stage {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 3) calc(var(--space) * 2);
  text-align: center;
}

.prompt-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space);
  margin-bottom: calc(var(--space) * 2);
  flex-wrap: wrap;
}
.prompt-text { font-size: 1.25rem; font-weight: 700; }

.choice-row {
  display: flex;
  justify-content: center;
  gap: calc(var(--space) * 2);
  flex-wrap: wrap;
}
.choice-btn {
  min-width: 110px;
  min-height: 110px;
  border-radius: 22px;
  border: 4px solid transparent;
  background: var(--sky);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  transition: transform 0.12s ease;
}
.choice-btn .sub { font-size: 1rem; font-weight: 400; color: var(--ink-soft); }
.choice-btn:hover { transform: scale(1.04); }
.choice-btn.correct { border-color: var(--ok); background: #DCFCE7; }
.choice-btn.wrong { border-color: #F87171; background: #FEF2F2; animation: shake 0.35s ease; }
.choice-btn.selected { border-color: var(--primary); }
.choice-btn:disabled { cursor: default; }

.swatch { width: 100%; height: 64px; border-radius: 14px; }

.count-objects { font-size: 2.6rem; letter-spacing: 0.15em; margin-bottom: calc(var(--space) * 2); line-height: 1.6; }

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: var(--space);
  max-width: 460px;
  margin: 0 auto;
}
.memory-card {
  aspect-ratio: 1;
  border-radius: 18px;
  border: none;
  font-size: 2.2rem;
  background: var(--primary);
  color: transparent;
  position: relative;
}
.memory-card.revealed, .memory-card.matched { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.memory-card.matched { outline: 4px solid var(--reward); }
.memory-card::after {
  content: '?';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
}
.memory-card.revealed::after, .memory-card.matched::after { content: none; }

.game-controls {
  display: flex;
  gap: var(--space);
  justify-content: center;
  margin-top: calc(var(--space) * 2.5);
  flex-wrap: wrap;
}

.result-panel { text-align: center; padding: calc(var(--space) * 3) var(--space); }
.result-panel .stars { font-size: 3rem; letter-spacing: 0.1em; }
.result-panel h3 { font-size: 1.6rem; margin: 8px 0; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ---------- vocabulary ---------- */

.vocab-tabs { display: flex; gap: var(--space); overflow-x: auto; padding-bottom: var(--space); margin-bottom: calc(var(--space) * 2); }
.vocab-tab {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: none;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}
.vocab-tab[aria-pressed="true"] { background: var(--primary); color: #fff; }

.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: calc(var(--space) * 1.5); }
.vocab-card {
  background: var(--surface);
  border: none;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 2) var(--space);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  min-height: 140px;
}
.vocab-card .pic { font-size: 3.2rem; line-height: 1.2; }
.vocab-card .word { font-weight: 700; font-size: 1.15rem; }
.vocab-card .ckb-meaning { font-family: var(--font-arabic); direction: rtl; color: var(--ink-soft); font-size: 0.95rem; }

/* ---------- watch & learn ---------- */

.video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: calc(var(--space) * 2); }
.video-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  border: none;
  padding: 0;
  text-align: left;
  color: var(--ink);
}
.video-card img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.video-card .vc-body { padding: calc(var(--space) * 1.5) calc(var(--space) * 2); }
.video-card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.video-card p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

.video-player-wrap {
  background: #000;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.video-player-wrap video { width: 100%; display: block; }
.video-summary { margin-top: calc(var(--space) * 2); background: var(--cream); border-radius: 18px; padding: calc(var(--space) * 2); }
.video-summary .ckb { font-family: var(--font-arabic); direction: rtl; text-align: right; }

/* ---------- tracing ---------- */

.trace-layout { display: flex; gap: calc(var(--space) * 2); flex-wrap: wrap; justify-content: center; }
.trace-canvas-wrap {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space);
  flex: 0 1 auto;
}
.trace-canvas-wrap canvas { display: block; border-radius: 18px; touch-action: none; background: var(--bg); }
.trace-side { flex: 1 1 200px; max-width: 320px; display: flex; flex-direction: column; gap: var(--space); }
.trace-progress { height: 14px; border-radius: 999px; background: var(--sky); overflow: hidden; }
.trace-progress > div { height: 100%; background: var(--ok); width: 0%; transition: width 0.2s ease; }
.trace-letter-picker { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: calc(var(--space) * 2); }
.trace-letter-picker button {
  min-width: 44px; min-height: 44px; border-radius: 12px; border: none;
  background: var(--surface); box-shadow: var(--shadow-card);
  font-weight: 700; font-size: 1.05rem; color: var(--ink);
}
.trace-letter-picker button[aria-pressed="true"] { background: var(--primary); color: #fff; }

/* ---------- Kurdish help / parent area ---------- */

.help-panel {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: calc(var(--space) * 3);
}
.help-panel .ckb-text { font-family: var(--font-arabic); direction: rtl; text-align: right; font-size: 1.05rem; }
.help-panel .ckb-text h3 { font-size: 1.2rem; }
.help-panel details { margin: var(--space) 0; }
.help-panel summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
.help-panel .ltr-note { direction: ltr; text-align: left; unicode-bidi: isolate; display: inline-block; }

/* ---------- misc ---------- */

.notice {
  background: var(--cream);
  border-radius: 14px;
  padding: 10px 16px;
  color: var(--ink);
  font-size: 0.95rem;
  margin: var(--space) 0;
}

.dialog-backdrop {
  position: fixed; inset: 0;
  background: rgba(23, 50, 77, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: var(--space);
}
.dialog {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: calc(var(--space) * 3);
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lift);
}
.dialog .btn-row { display: flex; gap: var(--space); justify-content: center; margin-top: calc(var(--space) * 2); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.loading-box { text-align: center; padding: calc(var(--space) * 6) var(--space); color: var(--ink-soft); }

/* ---------- Big screen mode ---------- */

body.big-screen { font-size: 120%; }
body.big-screen .app-topbar .brand span { font-size: 1.3rem; }
body.big-screen .choice-btn { min-width: 150px; min-height: 150px; font-size: 3.4rem; }
body.big-screen .letter-tile { min-height: 130px; font-size: 2.6rem; }
body.big-screen main.app-main { max-width: 1400px; }

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  main.app-main { padding: calc(var(--space) * 1.5) calc(var(--space) * 1.5) calc(var(--space) * 5); }
  .guide .bubble { max-width: 100%; font-size: 0.98rem; }
  .guide.size-lg img.guide-face { width: 84px; height: 84px; }
  .hero { padding: calc(var(--space) * 2); }
  .memory-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 400px) {
  .guide:not(.keep-small) .bubble { display: none; }
  .guide:not(.keep-small) { justify-content: center; }
  .choice-btn { min-width: 88px; min-height: 88px; font-size: 2rem; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
body.no-motion *, body.no-motion *::before, body.no-motion *::after {
  animation: none !important;
  transition: none !important;
}
