/* Wudhu Time -- a calm, self-paced game that teaches young children how to make
   wudhu (ablution). Design goals mirror the other Alula games: a low-arousal
   palette (soft teal / sky / cream), big tap targets, rounded corners, one
   clear thing on screen at a time, no flashing, and full reduced-motion
   support. No score, no timers, no winning, on purpose. */

:root {
  --bg:        #eef6f5;   /* soft watery cream-teal, low glare */
  --panel:     #ffffff;
  --ink:       #2f3d44;   /* soft near-black */
  --muted:     #7c8d92;
  --line:      #d7e7e6;
  --teal:      #5fa8a3;   /* primary calm accent */
  --teal-dim:  #4a8d88;
  --sky:       #7fb0d4;   /* secondary accent (water) */
  --sky-dim:   #5f95bd;
  --cream:     #f7efe2;
  --gold:      #d8a85a;   /* fardhu star, warm but quiet */
  --shadow:    0 6px 18px rgba(47, 61, 68, 0.08);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "Segoe UI Rounded", "Hiragino Maru Gothic ProN",
               "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; justify-content: center; }

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---- Screen switching ------------------------------------------------- */
.screen { display: none; flex: 1; flex-direction: column; padding: 20px; }
.screen.is-active { display: flex; }
[hidden] { display: none !important; }

/* ====================== HOME / CHARACTER PICKER ====================== */
.home { align-items: center; }
.home-head { text-align: center; margin: 18px 0 14px; }
.home-head h1 { font-size: clamp(26px, 7vw, 36px); font-weight: 800; letter-spacing: 0.2px; }
.tagline { color: var(--muted); margin-top: 6px; font-size: clamp(14px, 4vw, 17px); }
.pick-label { color: var(--muted); font-size: clamp(14px, 4vw, 16px); margin: 6px 0 12px; text-align: center; }

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 460px;
}
.char-card {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 20px;
  padding: 12px 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.char-card:hover { border-color: var(--teal); }
.char-card:active { transform: scale(0.97); }
.char-card.is-selected { border-color: var(--teal); background: #f2fbfa; }
.char-card canvas { width: 100%; height: 92px; display: block; }
.char-card .name { font-size: clamp(13px, 4vw, 16px); font-weight: 800; }
.char-card .age { font-size: 12px; color: var(--muted); }

.text-btn {
  margin-top: 18px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn:hover { color: var(--teal-dim); }
.text-btn.home { display: inline-block; text-decoration: none; font-size: 13px; margin-top: 14px; }

/* ====================== SHARED TOP BAR ====================== */
.play-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.icon-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 44px;
}
.icon-btn:hover { border-color: var(--teal); }
.cat-name { font-size: 16px; font-weight: 800; color: var(--teal-dim); }

/* Step rail (orientation only, never a score). */
.rail { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; flex: 1; }
.rail .pip {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line);
  transition: background 0.2s ease, transform 0.2s ease;
}
.rail .pip.done { background: var(--teal); }
.rail .pip.current { background: var(--sky); transform: scale(1.35); }

/* ====================== READING SCREENS (niat / doa) ====================== */
.reading { align-items: center; }
.read-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 22px 20px;
  width: 100%;
  max-width: 460px;
  text-align: center;
  margin: 6px 0 4px;
}
.read-intro { color: var(--ink); font-size: clamp(15px, 4.4vw, 18px); line-height: 1.5; margin-bottom: 16px; }
.read-intro strong { color: var(--teal-dim); }

.arabic {
  font-size: clamp(26px, 8vw, 38px);
  line-height: 1.9;
  font-weight: 600;
  color: var(--ink);
  margin: 4px 0 14px;
  font-family: "Traditional Arabic", "Scheherazade New", "Amiri", "Geeza Pro", serif;
}
.translit {
  font-size: clamp(15px, 4.4vw, 18px);
  font-style: italic;
  color: var(--teal-dim);
  line-height: 1.55;
  margin-bottom: 12px;
}
.meaning {
  font-size: clamp(14px, 4vw, 16px);
  color: var(--muted);
  line-height: 1.55;
  max-width: 34ch;
  margin: 0 auto 16px;
}

/* ====================== STEPS SCREEN ====================== */
.play { gap: 4px; }
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 8px;
}
.scene {
  width: min(70vw, 300px);
  height: min(52vw, 230px);
  max-height: 38vh;
  border-radius: 28px;
  background: linear-gradient(180deg, #eaf6fb 0%, #f3f9f3 100%);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  display: block;
  touch-action: manipulation;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.step-count { color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.5px; }
.step-title { font-size: clamp(20px, 6vw, 27px); font-weight: 800; line-height: 1.2; }
.step-title .star { color: var(--gold); }
.step-sub { color: var(--muted); font-size: clamp(14px, 4.2vw, 17px); line-height: 1.4; max-width: 26ch; }
.step-side { color: var(--sky-dim); font-size: 14px; font-weight: 700; }
.step-niat {
  background: #fdf3f6;
  color: #b56a83;
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
}

/* Tap-to-wash 1.2.3 dot row. */
.wash-dots { display: flex; gap: 10px; }
.wash-dots .dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--sky);
  background: transparent;
  transition: background 0.2s ease, transform 0.2s ease;
}
.wash-dots .dot.filled { background: var(--sky); transform: scale(1.1); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.next-row { display: flex; gap: 12px; margin-top: 4px; }

/* ====================== BUTTONS ====================== */
.round-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(15px, 4.4vw, 18px);
  border-radius: 18px;
  padding: 14px 22px;
  min-height: 54px;
  cursor: pointer;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.round-btn:active { transform: scale(0.97); }
.round-btn.big { margin-top: 18px; padding: 16px 34px; min-height: 60px; font-size: clamp(17px, 5vw, 20px); }
.round-btn:disabled { opacity: 0.45; cursor: default; }

.round-btn.soft { background: var(--panel); border-color: var(--line); color: var(--ink); }
.round-btn.soft:hover { border-color: var(--sky); }

.round-btn.go { background: var(--teal); color: #fff; }
.round-btn.go:hover { background: var(--teal-dim); }

.round-btn.wash {
  background: var(--sky);
  color: #fff;
  font-size: clamp(16px, 5vw, 19px);
  padding: 16px 30px;
  min-height: 60px;
}
.round-btn.wash:hover { background: var(--sky-dim); }
.round-btn.wash.splash { animation: splash 0.34s ease-out; }

/* ====================== DOA / DONE ====================== */
.done-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 8px; }
.done-scene {
  width: min(50vw, 200px);
  height: min(42vw, 170px);
  max-height: 26vh;
  display: block;
}
.done-title { font-size: clamp(20px, 6vw, 26px); font-weight: 800; color: var(--teal-dim); text-align: center; }

/* ====================== GROWN-UPS SHEET ====================== */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(47, 61, 68, 0.35);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.sheet-card {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(47, 61, 68, 0.25);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow-y: auto;
}
.sheet-card h2 { font-size: 22px; }
.sheet-card h3 { font-size: 16px; color: var(--teal-dim); margin-top: 2px; }
.sheet-note { font-size: 14px; color: var(--muted); line-height: 1.55; }
.rukun-list, .batal-list { padding-left: 22px; font-size: 15px; line-height: 1.6; }
.rukun-list li, .batal-list li { margin-bottom: 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 16px; }
.row.toggle input { width: 22px; height: 22px; accent-color: var(--teal); }
.about { font-size: 14px; color: var(--muted); line-height: 1.55; }
.about summary { cursor: pointer; color: var(--teal-dim); font-weight: 700; }
.about p { margin-top: 8px; }

/* ====================== FOOTER ====================== */
.foot {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  padding: 8px;
}

/* ====================== MOTION ====================== */
@keyframes splash {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Respect reduced-motion: both the OS setting and the in-app toggle (which adds
   .reduce-motion to <body>). The canvas droplet loop also checks this flag. */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
body.reduce-motion * { animation: none !important; transition: none !important; }
