/* ─────────────────────────────────────────────────────────────────────
   مساعد الحفظ — Quran Memorization Assistant
   Spaced-repetition styling (Anki-style) on the parchment palette.
   Cache: v=33
   ──────────────────────────────────────────────────────────────────── */

/* ── Layout ───────────────────────────────────────────────────────── */
body.mem-body {
  background: var(--bg, #FAF6EE);
  color: var(--text, #2C2418);
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  direction: rtl;
  min-height: 100vh;
  background-image: var(--pattern-paper, none);
}

/* Top nav identical pattern to sanctuary.html */
.mem-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 238, 0.94);
  border-bottom: 1px solid rgba(184, 153, 104, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0.75rem 1rem;
}
[data-theme="dark"] .mem-nav {
  background: rgba(14, 22, 38, 0.92);
  border-bottom-color: rgba(201, 166, 107, 0.25);
}
.mem-nav-inner {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.mem-nav-logo {
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text, #2C2418);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.mem-nav-logo-mark {
  width: 34px;
  height: 34px;
  background: var(--text, #2C2418);
  color: var(--bg, #FAF6EE);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.mem-nav-spacer { flex: 1; }
.mem-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--text-muted, #5a6a7a);
  text-decoration: none;
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  font-weight: 700;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(184, 153, 104, 0.3);
  background: rgba(184, 153, 104, 0.08);
  transition: all 280ms ease;
}
.mem-nav-back:hover {
  color: #B89968;
  border-color: #B89968;
  background: rgba(184, 153, 104, 0.18);
}
.mem-theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(184, 153, 104, 0.3);
  background: rgba(184, 153, 104, 0.08);
  color: var(--text, #2C2418);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
  transition: all 280ms ease;
}
.mem-theme-toggle:hover { border-color: #B89968; color: #B89968; }

/* ── Main shell ───────────────────────────────────────────────────── */
.mem-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ── Hero ─────────────────────────────────────────────────────────── */
.mem-hero {
  text-align: center;
  padding: 2.25rem 1rem 1.75rem;
  position: relative;
}
.mem-hero h1 {
  font-family: 'Aref Ruqaa', serif;
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin: 0 0 0.5rem;
  color: var(--text, #2C2418);
  letter-spacing: 0.02em;
}
.mem-hero p {
  margin: 0;
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-muted, #5a6a7a);
}
.mem-hero::after {
  content: '';
  display: block;
  height: 1px;
  width: 60%;
  margin: 1.75rem auto 0;
  background: linear-gradient(90deg, transparent, #B89968, transparent);
}

/* ── Dashboard ────────────────────────────────────────────────────── */
.mem-dashboard {
  animation: mem-fade-in 380ms cubic-bezier(.25,.8,.25,1) both;
}
.mem-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.75rem;
}
.mem-stat {
  background: #FFFEFA;
  border: 1px solid rgba(184, 153, 104, 0.25);
  border-radius: 16px;
  padding: 1.25rem 0.75rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(15, 27, 45, 0.04);
  transition: all 280ms ease;
  position: relative;
  overflow: hidden;
}
.mem-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #B89968, transparent);
  opacity: 0.65;
}
.mem-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(15, 27, 45, 0.08);
  border-color: #B89968;
}
[data-theme="dark"] .mem-stat {
  background: #161F35;
  border-color: rgba(201, 166, 107, 0.25);
}
.mem-stat-value {
  display: block;
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  font-size: 2.2rem;
  color: #B89968;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}
.mem-stat-label {
  display: block;
  font-size: 0.92rem;
  color: var(--text-muted, #5a6a7a);
  font-family: 'Aref Ruqaa', 'Amiri', serif;
}

/* ── Actions ──────────────────────────────────────────────────────── */
.mem-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem;
  margin: 1.5rem 0 2.25rem;
}
.btn-gold-large {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.75rem;
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: #FFFEFA;
  background: linear-gradient(135deg, #B89968, #caa96e);
  border: 1px solid #B89968;
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all 280ms ease;
  box-shadow: 0 6px 18px rgba(184, 153, 104, 0.28);
}
.btn-gold-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(184, 153, 104, 0.4);
  background: linear-gradient(135deg, #caa96e, #B89968);
}
.btn-gold-large:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.btn-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.4rem;
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  font-size: 1rem;
  color: #FFFEFA;
  background: linear-gradient(135deg, #B89968, #caa96e);
  border: 1px solid #B89968;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all 280ms ease;
}
.btn-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(184, 153, 104, 0.32);
}
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text, #2C2418);
  background: transparent;
  border: 1px solid rgba(184, 153, 104, 0.4);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all 280ms ease;
}
.btn-outline:hover {
  border-color: #B89968;
  background: rgba(184, 153, 104, 0.1);
  color: #B89968;
}

/* ── Onboarding / empty state ─────────────────────────────────────── */
.mem-empty {
  text-align: center;
  padding: 3rem 1rem;
  background: #FFFEFA;
  border: 1px solid rgba(184, 153, 104, 0.25);
  border-radius: 24px;
  margin: 1rem 0;
  box-shadow: 0 12px 32px rgba(15, 27, 45, 0.06);
  position: relative;
  overflow: hidden;
}
.mem-empty::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, #B89968, transparent);
}
[data-theme="dark"] .mem-empty {
  background: #161F35;
  border-color: rgba(201, 166, 107, 0.25);
}
.mem-empty-icon {
  font-size: 4rem;
  margin-bottom: 0.75rem;
  animation: mem-float 3s ease-in-out infinite;
}
.mem-empty h2 {
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.8rem;
  margin: 0 0 0.75rem;
  color: var(--text, #2C2418);
}
.mem-empty p {
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-muted, #5a6a7a);
  margin: 0.35rem 0;
  line-height: 1.7;
}
.mem-empty .btn-gold-large {
  margin-top: 1.5rem;
}

/* ── Review session card ──────────────────────────────────────────── */
.mem-session {
  animation: mem-fade-in 380ms cubic-bezier(.25,.8,.25,1) both;
}
.mem-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.mem-progress {
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #B89968;
  background: rgba(184, 153, 104, 0.1);
  border: 1px solid rgba(184, 153, 104, 0.3);
  padding: 0.45rem 1rem;
  border-radius: 999px;
}

.mem-card {
  background: #FFFEFA;
  border: 1px solid rgba(184, 153, 104, 0.3);
  border-radius: 24px;
  padding: 2.5rem 1.75rem;
  box-shadow: 0 24px 60px rgba(15, 27, 45, 0.08);
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.mem-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, #B89968 30%, #D4AF37 50%, #B89968 70%, transparent);
}
.mem-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #B89968, transparent);
  opacity: 0.5;
}
[data-theme="dark"] .mem-card {
  background: #161F35;
  border-color: rgba(201, 166, 107, 0.25);
}
.mem-verse-ref {
  text-align: center;
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.1rem;
  color: #B89968;
  font-weight: 700;
  margin: 0 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed rgba(184, 153, 104, 0.3);
}
.mem-verse-text {
  font-family: 'Amiri', 'Scheherazade New', serif;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  line-height: 2.4;
  text-align: center;
  color: var(--text, #2C2418);
  letter-spacing: 0.01em;
  padding: 0.5rem 0.25rem 1.25rem;
  direction: rtl;
}
.mem-word {
  display: inline-block;
  margin: 0 0.15em;
  transition: all 280ms ease;
}
.mem-word-hidden {
  background: linear-gradient(135deg, rgba(184, 153, 104, 0.2), rgba(184, 153, 104, 0.1));
  border-radius: 8px;
  color: transparent;
  position: relative;
  cursor: pointer;
  border: 1px dashed rgba(184, 153, 104, 0.45);
  padding: 0 0.6em;
  user-select: none;
}
.mem-word-hidden::before {
  content: '···';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #B89968;
  font-family: 'Aref Ruqaa', serif;
  font-size: 0.6em;
  letter-spacing: 0.15em;
}
.mem-word-revealed {
  background: rgba(184, 153, 104, 0.08);
  border-radius: 6px;
  color: var(--text, #2C2418);
  padding: 0 0.25em;
  border: 1px dashed transparent;
  animation: mem-reveal 380ms ease both;
}
.mem-word-revealed::before { content: none; }

.mem-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ── Rating buttons ───────────────────────────────────────────────── */
.mem-rating {
  background: #FFFEFA;
  border: 1px solid rgba(184, 153, 104, 0.25);
  border-radius: 20px;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 12px 32px rgba(15, 27, 45, 0.06);
  animation: mem-slide-up 380ms cubic-bezier(.25,.8,.25,1) both;
}
[data-theme="dark"] .mem-rating {
  background: #161F35;
  border-color: rgba(201, 166, 107, 0.25);
}
.mem-rating h3 {
  text-align: center;
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.25rem;
  margin: 0 0 1rem;
  color: var(--text, #2C2418);
}
.mem-rating-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.mem-rating-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.2rem 0.75rem;
  background: var(--bg, #FAF6EE);
  border: 1.5px solid rgba(184, 153, 104, 0.3);
  border-radius: 16px;
  cursor: pointer;
  transition: all 280ms ease;
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  color: var(--text, #2C2418);
}
[data-theme="dark"] .mem-rating-btn {
  background: #0E1626;
  border-color: rgba(201, 166, 107, 0.25);
}
.mem-rating-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(15, 27, 45, 0.08);
  border-color: #B89968;
}
.mem-rating-btn[data-rating="hard"]:hover {
  border-color: #B1373F;
  background: rgba(177, 55, 63, 0.06);
}
.mem-rating-btn[data-rating="good"]:hover {
  border-color: #B89968;
  background: rgba(184, 153, 104, 0.08);
}
.mem-rating-btn[data-rating="easy"]:hover {
  border-color: #4A6B3A;
  background: rgba(74, 107, 58, 0.08);
}
.mem-rating-emoji {
  font-size: 2rem;
  line-height: 1;
}
.mem-rating-label {
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  font-size: 1.05rem;
}
.mem-rating-btn small {
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 0.78rem;
  color: var(--text-muted, #5a6a7a);
}

/* ── All-verses list (browse) ─────────────────────────────────────── */
.mem-all-verses {
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid rgba(184, 153, 104, 0.25);
}
.mem-all-verses h2 {
  font-family: 'Aref Ruqaa', serif;
  font-size: 1.5rem;
  margin: 0 0 1rem;
  text-align: center;
  color: var(--text, #2C2418);
}
.mem-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.mem-filter button {
  padding: 0.55rem 1.1rem;
  font-family: 'Aref Ruqaa', 'Amiri', serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-muted, #5a6a7a);
  background: transparent;
  border: 1px solid rgba(184, 153, 104, 0.3);
  border-radius: 999px;
  cursor: pointer;
  transition: all 220ms ease;
}
.mem-filter button:hover {
  border-color: #B89968;
  color: #B89968;
}
.mem-filter button.active {
  background: #B89968;
  border-color: #B89968;
  color: #FFFEFA;
  box-shadow: 0 4px 12px rgba(184, 153, 104, 0.3);
}
.mem-verses-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.mem-verse-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  background: #FFFEFA;
  border: 1px solid rgba(184, 153, 104, 0.2);
  border-radius: 14px;
  transition: all 280ms ease;
}
[data-theme="dark"] .mem-verse-item {
  background: #161F35;
  border-color: rgba(201, 166, 107, 0.2);
}
.mem-verse-item:hover {
  border-color: #B89968;
  transform: translateX(-4px);
  box-shadow: 0 6px 16px rgba(15, 27, 45, 0.05);
}
.mem-verse-info { flex: 1; min-width: 0; }
.mem-verse-title {
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text, #2C2418);
  margin-bottom: 0.2rem;
}
.mem-verse-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--text-muted, #5a6a7a);
}
.mem-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-family: 'Aref Ruqaa', serif;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.mem-level-0 { background: rgba(177, 55, 63, 0.12); color: #B1373F; border: 1px solid rgba(177, 55, 63, 0.25); }
.mem-level-1 { background: rgba(184, 153, 104, 0.12); color: #B89968; border: 1px solid rgba(184, 153, 104, 0.3); }
.mem-level-2 { background: rgba(184, 153, 104, 0.18); color: #B89968; border: 1px solid rgba(184, 153, 104, 0.4); }
.mem-level-3 { background: rgba(184, 153, 104, 0.25); color: #8a6f44; border: 1px solid rgba(184, 153, 104, 0.5); }
.mem-level-4 { background: rgba(74, 107, 58, 0.15); color: #4A6B3A; border: 1px solid rgba(74, 107, 58, 0.35); }
.mem-level-5 { background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(184, 153, 104, 0.18)); color: #8a6f1f; border: 1px solid #D4AF37; box-shadow: 0 0 12px rgba(212, 175, 55, 0.25); }

.mem-verse-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.mem-verse-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(177, 55, 63, 0.35);
  background: transparent;
  color: #B1373F;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
  transition: all 220ms ease;
}
.mem-verse-remove:hover {
  background: #B1373F;
  color: #fff;
  transform: scale(1.08);
}

.mem-empty-list {
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--text-muted, #5a6a7a);
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 1rem;
  background: rgba(184, 153, 104, 0.05);
  border: 1px dashed rgba(184, 153, 104, 0.3);
  border-radius: 14px;
}

/* ── Complete screen ──────────────────────────────────────────────── */
.mem-complete {
  text-align: center;
  padding: 3rem 1.5rem;
  background: #FFFEFA;
  border: 1px solid rgba(184, 153, 104, 0.3);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(15, 27, 45, 0.08);
  position: relative;
  overflow: hidden;
  animation: mem-fade-in 380ms cubic-bezier(.25,.8,.25,1) both;
}
.mem-complete::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, #D4AF37, transparent);
}
[data-theme="dark"] .mem-complete {
  background: #161F35;
  border-color: rgba(201, 166, 107, 0.25);
}
.mem-complete-icon {
  font-size: 4.5rem;
  margin-bottom: 0.5rem;
  animation: mem-celebrate 1.2s ease-out;
}
.mem-complete h2 {
  font-family: 'Aref Ruqaa', serif;
  font-size: 2rem;
  margin: 0 0 0.75rem;
  color: #B89968;
}
.mem-complete p {
  font-family: 'Amiri', serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-muted, #5a6a7a);
  margin: 0.4rem 0;
  line-height: 1.7;
}
.mem-complete-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 1.75rem;
}

/* ── Toast notification (for "verse added") ───────────────────────── */
.mem-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #2C2418;
  color: #FAF6EE;
  font-family: 'Aref Ruqaa', serif;
  font-size: 1rem;
  padding: 0.85rem 1.5rem;
  border-radius: 14px;
  border: 1px solid #B89968;
  box-shadow: 0 12px 32px rgba(15, 27, 45, 0.3);
  z-index: 1000;
  transition: transform 380ms cubic-bezier(.25,.8,.25,1);
  max-width: 90vw;
}
.mem-toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ── Footer ───────────────────────────────────────────────────────── */
.mem-footer {
  max-width: 920px;
  margin: 3rem auto 0;
  padding: 2rem 1rem;
  border-top: 1px solid rgba(184, 153, 104, 0.25);
}

/* ── Animations ───────────────────────────────────────────────────── */
@keyframes mem-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes mem-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes mem-reveal {
  from { background: rgba(212, 175, 55, 0.35); transform: scale(1.08); }
  to   { background: rgba(184, 153, 104, 0.08); transform: scale(1); }
}
@keyframes mem-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes mem-celebrate {
  0%   { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  50%  { transform: scale(1.2) rotate(15deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .mem-main { padding: 1rem 0.85rem 3rem; }
  .mem-hero { padding: 1.5rem 0.5rem 1.25rem; }
  .mem-card { padding: 1.75rem 1rem; border-radius: 18px; }
  .mem-verse-text { font-size: 1.4rem; line-height: 2.2; }
  .mem-stat-value { font-size: 1.8rem; }
  .mem-rating-emoji { font-size: 1.6rem; }
  .mem-rating-buttons { grid-template-columns: 1fr; gap: 0.6rem; }
  .mem-rating-btn { flex-direction: row; justify-content: flex-start; padding: 0.85rem 1rem; }
  .mem-rating-btn small { margin-inline-start: auto; }
  .btn-gold-large { font-size: 1rem; padding: 0.85rem 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .mem-empty-icon,
  .mem-complete-icon { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
