/* ============================================================
   BEEBAP — style.css v6
   Nouvelle palette : Pêche & Orange
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;700&family=Nunito:wght@400;500;600;700;800&display=swap');

/* ── THÈME TAFSIR (défaut) ── */
:root {
  --primary:      #CB8589;
  --primary-dark: #8B4A4E;
  --primary-light:#E8B4B8;
  --accent:       #C2C094;
  --deep:         #2C2B1A;
  --text:         #2C2B1A;
  --muted:        #7A7860;
  --surface:      #FFFFFF;
  --bg:           #F5F3EE;
  --white:        #FFFFFF;
  --border:       rgba(194,192,148,0.28);
  --border2:      rgba(203,133,137,0.35);
  --pink:         #CB8589;
  --pink-light:   #E8B4B8;
  --pink-pale:    rgba(203,133,137,0.15);
  --pink-bg:      #FDF0F0;
  --hex-color:    #C2C094;
  --nav-h:        68px;
  --topbar-h:     56px;
}

/* ── THÈME TAJWID ── */
[data-theme="tajwid"] {
  --primary:      #32746D;
  --primary-dark: #1E5750;
  --primary-light:#7BBAB5;
  --accent:       #C2C094;
  --deep:         #001011;
  --text:         #001011;
  --muted:        #4A7A75;
  --surface:      #FFFFFF;
  --bg:           #EEF4F3;
  --white:        #FFFFFF;
  --border:       rgba(50,116,109,0.2);
  --border2:      rgba(50,116,109,0.35);
  --pink:         #32746D;
  --pink-light:   #7BBAB5;
  --pink-pale:    rgba(50,116,109,0.12);
  --pink-bg:      #E8F2F1;
  --hex-color:    #32746D;
  --nav-h:        68px;
  --topbar-h:     56px;
}

*, *::before, *::after { box-sizing: border-box; max-width: 100%; }
html { overflow-x: hidden; width: 100%; height: 100%; }
body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg); color: var(--text);
  overflow-x: hidden; width: 100%; min-height: 100%;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
h1, h2, h3, .title { font-family: 'DM Sans', sans-serif; }
h1 { font-size: clamp(1.3rem, 5vw, 1.6rem); font-weight: 700; line-height: 1.3; }
h2 { font-size: clamp(1.1rem, 4vw, 1.3rem); font-weight: 700; }
p, li, label { font-size: 0.95rem; line-height: 1.75; }

.screen { display: none; width: 100%; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; animation: fadeIn .2s ease; }
#screen-login, #screen-subject, #screen-flashcard,
#screen-qcm, #screen-trous, #screen-results, #screen-admin {
  padding-bottom: 0 !important;
}

/* ── TOP BAR ── */
.top-bar {
  width: 100%; height: var(--topbar-h);
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; flex-shrink: 0;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.top-bar-brand { display: flex; align-items: center; gap: 0.5rem; }
.top-bar-brand .name { font-family: 'DM Sans', sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.top-bar-subject {
  font-family: 'DM Sans', sans-serif; font-size: 0.78rem; font-weight: 600;
  padding: 0.3rem 0.8rem; border-radius: 99px;
  background: var(--pink-bg); color: var(--primary-dark);
  border: 1px solid var(--border2); white-space: nowrap;
}

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 1.25rem 1.25rem 1.5rem; width: 100%;
}
.page-content.no-nav { padding-bottom: 1.5rem; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,0.97);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(240,149,106,0.08);
  display: flex; align-items: stretch;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 0 2px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.nav-tab:active { opacity: 0.6; }
.nav-icon { color: var(--muted); transition: color .15s; }
.nav-icon svg { width: 22px; height: 22px; display: block; }
.nav-lbl { font-family: 'Nunito', sans-serif; font-size: 10px; color: var(--muted); white-space: nowrap; }
.nav-tab.active .nav-icon { color: var(--primary); }
.nav-tab.active .nav-lbl  { color: var(--primary); font-weight: 700; }

/* ── BOUTON CTA CENTRAL ── */
.nav-cta { flex: 1.2; position: relative; padding-bottom: 4px; }
.nav-icon-cta {
  position: relative;
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(240,149,106,0.5);
  margin-bottom: 2px;
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.nav-icon-cta svg { width: 20px; height: 20px; color: white; display: block; margin-left: 2px; }
.nav-cta:active .nav-icon-cta { transform: scale(0.92); }
.nav-lbl-cta { font-family: 'Nunito', sans-serif; font-size: 10px; color: var(--primary); font-weight: 700; white-space: nowrap; }
.nav-cta.active .nav-icon-cta { box-shadow: 0 4px 22px rgba(240,149,106,0.65); }
.nav-icon-cta.loaded {
  width: 54px; height: 54px;
  border-radius: 16px;
  background: var(--primary-dark);
  box-shadow: 0 5px 22px rgba(212,97,58,0.5);
}
.cta-badge-el {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--deep); color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
  opacity: 0; transform: scale(0);
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
.cta-badge-el.show { opacity: 1; transform: scale(1); }
.nav-lbl-cta.loaded { font-weight: 800; }

/* ── LOGIN ── */
#screen-login { padding-bottom: 0 !important; background: var(--bg); }
.login-bg {
  position: relative; flex: 1;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 2rem 1.25rem;
}
.login-center {
  position: relative; z-index: 1; width: 100%; display: flex; justify-content: center;
}
.login-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 8px 40px rgba(240,149,106,0.12);
  padding: 2.25rem 2rem;
  width: 100%; max-width: 480px;
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo img { width: 200px; height: auto; }
.login-logo p { font-size: 0.88rem; color: var(--muted); margin-top: 0.25rem; font-weight: 600; }
.sakura-bg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Rester connecté */
.remember-row { margin-bottom: 1rem; }
.remember-label {
  display: flex; align-items: center; gap: 0.6rem;
  cursor: pointer; font-size: 0.88rem; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.remember-label input[type="checkbox"] { display: none; }
.remember-check {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  border: 1.5px solid var(--border2); background: var(--bg);
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.remember-label input:checked + .remember-check { background: var(--primary); border-color: var(--primary); }
.remember-label input:checked + .remember-check::after { content: '✓'; font-size: 12px; color: white; }

/* ── CHOIX MATIÈRE ── */
#screen-subject { justify-content: center; align-items: center; padding: 2rem 1.25rem; overflow-y: auto; }
.subject-header { text-align: center; margin-bottom: 2.5rem; }
.subject-header .arabic { font-size: 2.2rem; color: var(--primary); direction: rtl; }
.subject-header h1 { font-size: 1.5rem; margin-top: 0.4rem; }
.subject-header p  { font-size: 0.9rem; color: var(--muted); margin-top: 0.3rem; }
.subject-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 380px; }
.subject-card { background: var(--white); border-radius: 18px; border: 2px solid var(--border); padding: 1.75rem 0.75rem; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: all .2s; }
.subject-card:active { transform: scale(0.97); border-color: var(--primary); }
.subject-card.coming-soon { opacity: 0.55; cursor: default; }
.subject-card .s-arabic { font-size: 1.8rem; color: var(--primary); direction: rtl; margin-bottom: 0.5rem; }
.subject-card .s-name { font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 700; color: var(--text); }
.subject-card .s-sub  { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.soon-badge { display: inline-block; margin-top: 0.5rem; background: var(--pink-bg); color: var(--primary-dark); font-size: 0.65rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border2); }

/* ── FORMULAIRES ── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.06em; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.85rem 1.1rem;
  border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 1rem; font-family: 'Nunito', sans-serif;
  background: var(--bg); color: var(--text);
  transition: border-color .2s; outline: none;
  -webkit-appearance: none; appearance: none;
}
.form-group input:focus { border-color: var(--primary); background: white; }
.error-msg { background: #fef2f4; border: 1px solid #fca5a5; color: #b91c1c; padding: 0.7rem 1rem; border-radius: 10px; font-size: 0.88rem; margin-bottom: 1.1rem; display: none; }

/* ── BOUTONS ── */
.btn { display: block; width: 100%; padding: 0.95rem 1.1rem; background: var(--primary); color: white; border: none; border-radius: 14px; font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 700; cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: all .15s; }
.btn:active { opacity: 0.88; transform: scale(0.99); background: var(--primary-dark); }
.btn-outline { display: inline-block; background: none; border: 1.5px solid var(--border2); color: var(--muted); padding: 0.6rem 1rem; border-radius: 99px; font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; white-space: nowrap; transition: all .15s; outline: none; }
.btn-outline:focus { outline: none; }
.btn-outline:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-outline:active { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: none; border: none; color: var(--muted); font-family: 'Nunito', sans-serif; font-size: 0.9rem; cursor: pointer; padding: 0.4rem; white-space: nowrap; }
.tabs { display: flex; background: var(--pink-bg); border-radius: 12px; padding: 4px; margin-bottom: 1.75rem; }
.tab-btn { flex: 1; padding: 0.6rem; border: none; background: transparent; border-radius: 9px; cursor: pointer; font-size: 0.9rem; color: var(--muted); font-family: 'DM Sans', sans-serif; font-weight: 600; transition: all .15s; }
.tab-btn.active { background: white; color: var(--primary-dark); box-shadow: 0 2px 8px rgba(240,149,106,0.15); }

/* ── DASHBOARD ── */
.welcome-card { background: var(--primary); border-radius: 22px; padding: 1.4rem; margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: space-between; position: relative; overflow: hidden; }
.welcome-card::after { content: ''; position: absolute; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,0.08); top: -35px; right: -25px; }
.welcome-card h2 { color: white; font-size: 1.15rem; }
.welcome-card p  { color: rgba(255,255,255,0.75); font-size: 0.85rem; margin-top: 0.2rem; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1.25rem; }
.stat-card { background: var(--white); border: 1.5px solid var(--border); border-radius: 16px; padding: 0.9rem 0.75rem; text-align: center; }
.stat-num   { font-family: 'DM Sans', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: 0.72rem; color: var(--muted); margin-top: 3px; font-weight: 600; }
.section-title { font-family: 'DM Sans', sans-serif; font-size: 0.82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 1.25rem 0 0.7rem; }
.chapter-list { display: flex; flex-direction: column; gap: 10px; }
.chapter-row { background: var(--white); border: 1.5px solid var(--border); border-radius: 16px; padding: 1rem 1.1rem; display: flex; align-items: center; gap: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: all .15s; }
.chapter-row:active { border-color: var(--primary); background: var(--pink-bg); }
.chap-num { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; background: var(--pink-bg); display: flex; align-items: center; justify-content: center; font-family: 'DM Sans', sans-serif; font-size: 0.78rem; font-weight: 700; color: var(--primary-dark); }
.chap-body { flex: 1; min-width: 0; overflow: hidden; }
.chap-title { font-family: 'DM Sans', sans-serif; font-size: 0.92rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chap-bar-wrap { height: 4px; background: var(--pink-pale); border-radius: 99px; margin-top: 5px; overflow: hidden; }
.chap-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }
.chap-arabic { font-size: 0.9rem; color: var(--primary); direction: rtl; flex-shrink: 0; }
.badges-row { display: flex; gap: 9px; flex-wrap: wrap; }
.badge-chip { display: flex; align-items: center; gap: 7px; background: var(--white); border: 1.5px solid var(--border); border-radius: 12px; padding: 0.65rem 0.9rem; }
.badge-chip.locked { opacity: 0.38; filter: grayscale(1); }
.badge-icon { font-size: 1.3rem; }
.badge-info .badge-name { font-family: 'DM Sans', sans-serif; font-size: 0.78rem; font-weight: 700; color: var(--text); }
.badge-info .badge-desc { font-size: 0.68rem; color: var(--muted); }

/* ── PAGE LECTURE ── */
.lecture-chapters-list { display: flex; flex-direction: column; gap: 10px; }
.lecture-chap-row { background: var(--white); border: 1.5px solid var(--border); border-radius: 16px; padding: 1rem 1.1rem; display: flex; align-items: center; gap: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: all .15s; }
.lecture-chap-row:active { border-color: var(--primary); background: var(--pink-bg); }
.lecture-chap-arrow { color: var(--muted); font-size: 1rem; flex-shrink: 0; }
.lecture-chapter-title { font-family: 'DM Sans', sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 0.3rem; }
.lecture-arabic-title { font-size: 1.1rem; color: var(--primary); direction: rtl; text-align: right; margin-bottom: 1.5rem; }
.lecture-section { margin-bottom: 1.5rem; }
.lecture-section-title { font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.lecture-subtitle { font-family: 'DM Sans', sans-serif; font-size: 0.9rem; font-weight: 700; color: var(--text); margin: 0.75rem 0 0.4rem; }
.lecture-text { font-size: 0.92rem; line-height: 1.8; color: var(--text); margin-bottom: 0.75rem; }
.lecture-verse { background: var(--pink-bg); border-right: 3px solid var(--primary); border-radius: 10px; padding: 1rem 1.1rem; margin: 0.75rem 0; text-align: right; }
.lecture-verse .arabic-text { font-size: 1.2rem; line-height: 2; color: var(--primary-dark); direction: rtl; margin-bottom: 0.5rem; }
.lecture-verse .verse-translation { font-size: 0.85rem; color: var(--muted); font-style: italic; text-align: left; }
.lecture-verse .verse-ref { font-size: 0.78rem; color: var(--primary); font-weight: 700; margin-top: 0.3rem; text-align: left; }
.lecture-hadith { background: rgba(245,201,160,0.15); border: 1px solid rgba(245,201,160,0.4); border-radius: 10px; padding: 1rem 1.1rem; margin: 0.75rem 0; }
.lecture-hadith .arabic-text { font-size: 1.1rem; line-height: 2; color: var(--primary-dark); direction: rtl; text-align: right; margin-bottom: 0.5rem; }
.lecture-hadith .hadith-translation { font-size: 0.85rem; color: var(--text); font-style: italic; }
.lecture-hadith .hadith-narrator { font-size: 0.75rem; color: var(--muted); margin-top: 0.35rem; font-weight: 600; }
.lecture-quote { border-left: 3px solid var(--primary-light); padding: 0.5rem 1rem; margin: 0.5rem 0; background: var(--pink-bg); border-radius: 0 8px 8px 0; }
.lecture-quote .quote-text { font-size: 0.88rem; color: var(--text); font-style: italic; }
.lecture-quote .quote-author { font-size: 0.75rem; color: var(--primary); font-weight: 700; margin-top: 0.25rem; }
.lecture-list { margin: 0.5rem 0 0.75rem 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.lecture-list li { font-size: 0.9rem; line-height: 1.6; color: var(--text); display: flex; gap: 8px; }
.lecture-list li::before { content: '•'; color: var(--primary); flex-shrink: 0; font-size: 1rem; }

/* ── TABLEAU DES EXÉGÈTES ── */
.exegetes-table-wrap { margin: 0.75rem 0; }
.exegete-card { background: var(--white); border: 1.5px solid var(--border); border-radius: 16px; margin-bottom: 10px; overflow: hidden; }
.exegete-card-header { padding: 0.85rem 1rem; background: var(--pink-bg); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exegete-name { font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 700; color: var(--text); }
.exegete-arabic { font-size: 0.82rem; color: var(--primary); direction: rtl; }
.exegete-body { padding: 0.85rem 1rem; }
.exegete-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.exegete-row:last-child { margin-bottom: 0; }
.exegete-row-label { font-size: 0.68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; width: 75px; flex-shrink: 0; }
.exegete-hidden-wrap { flex: 1; position: relative; min-height: 36px; }
.exegete-answer { font-size: 0.85rem; color: var(--text); line-height: 1.5; padding: 0.4rem 0.75rem; }
.exegete-mask { position: absolute; inset: 0; background: var(--pink-bg); border: 1px dashed var(--border2); border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: opacity .2s; }
.exegete-mask span { font-size: 0.7rem; color: var(--primary); pointer-events: none; font-weight: 600; }
.exegete-mask.hidden { opacity: 0; pointer-events: none; }
.exegete-visible { flex: 1; font-size: 0.85rem; color: var(--text); line-height: 1.5; }
.exegete-mode-bar { display: flex; gap: 6px; margin-bottom: 1rem; flex-wrap: wrap; }
.exegete-mode-btn { padding: 0.35rem 0.8rem; border-radius: 99px; font-size: 0.75rem; font-family: 'DM Sans', sans-serif; font-weight: 600; cursor: pointer; border: 1.5px solid var(--border2); background: none; color: var(--muted); -webkit-tap-highlight-color: transparent; transition: all .15s; }
.exegete-mode-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ── RÉVISION ── */
.chap-select-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1.25rem; }
.chap-select-item { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1.5px solid var(--border); border-radius: 14px; padding: 0.9rem 1.1rem; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: all .15s; }
.chap-select-item.selected { border-color: var(--primary); background: var(--pink-bg); }
.chk { width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0; border: 2px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; transition: all .15s; }
.chap-select-item.selected .chk { background: var(--primary); border-color: var(--primary); color: white; }
.quick-row { display: flex; gap: 9px; margin-bottom: 0.9rem; flex-wrap: wrap; }
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 1.25rem; }
.mode-card { background: var(--white); border: 1.5px solid var(--border); border-radius: 18px; padding: 1.1rem 0.75rem; text-align: center; cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: all .15s; }
.mode-card.selected { border-color: var(--primary); background: var(--pink-bg); }
.mode-card:active { transform: scale(0.97); }
.mode-icon { font-size: 1.75rem; margin-bottom: 0.4rem; }
.mode-name { font-family: 'DM Sans', sans-serif; font-size: 0.88rem; font-weight: 700; color: var(--text); }
.mode-desc { font-size: 0.72rem; color: var(--muted); margin-top: 3px; }
.mode-count { display: inline-block; margin-top: 6px; background: var(--pink-bg); color: var(--primary-dark); font-size: 0.68rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--border2); }
.mode-count.zero { background: #f1efe8; color: #888780; border-color: #d3d1c7; }
.mode-check { position: absolute; top: 8px; right: 9px; width: 20px; height: 20px; border-radius: 50%; background: transparent; border: 1.5px solid var(--border2); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: transparent; }
.mode-card.selected .mode-check { background: var(--primary); border-color: var(--primary); color: white; }

/* ── FLASHCARDS ── */
#screen-flashcard { height: 100vh; height: 100dvh; }
.fc-wrap { flex: 1; display: flex; flex-direction: column; padding: 1rem 1.25rem 1.25rem; min-height: 0; overflow: hidden; }
.prog-top { display: flex; align-items: center; gap: 10px; margin-bottom: 0.8rem; flex-shrink: 0; }
.prog-dots { display: flex; gap: 4px; flex: 1; overflow: hidden; }
.prog-dot { flex: 1; height: 5px; border-radius: 99px; background: var(--pink-pale); min-width: 4px; max-width: 30px; }
.prog-dot.done { background: var(--primary); }
.prog-dot.current { background: var(--primary-light); }
.prog-count { font-size: 0.8rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; font-weight: 600; }
.flashcard-scene { flex: 1; perspective: 1000px; cursor: pointer; min-height: 220px; max-height: calc(100dvh - var(--topbar-h) - 130px); margin-bottom: 0.8rem; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.flashcard-inner { width: 100%; height: 100%; min-height: 220px; transition: transform 0.5s cubic-bezier(.4,0,.2,1); transform-style: preserve-3d; position: relative; }
.flashcard-scene.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face { position: absolute; inset: 0; background: var(--white); border: 1.5px solid var(--border); border-radius: 22px; padding: 1.5rem; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow-y: auto; }
.flashcard-back { transform: rotateY(180deg); background: var(--pink-bg); }
.fc-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.75rem; flex-shrink: 0; font-weight: 700; }
.fc-question { font-family: 'DM Sans', sans-serif; font-size: 1.1rem; font-weight: 600; color: var(--text); text-align: center; line-height: 1.55; }
.fc-arabic   { font-size: 1.15rem; color: var(--primary); direction: rtl; text-align: center; margin-top: 0.6rem; line-height: 1.8; }
.fc-answer   { font-size: 0.92rem; color: var(--text); text-align: center; line-height: 1.75; }
.flip-hint   { text-align: center; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.6rem; flex-shrink: 0; font-weight: 600; }
.fc-actions  { display: flex; gap: 9px; flex-shrink: 0; }
.fc-btn { flex: 1; padding: 0.75rem 0.3rem; border-radius: 14px; border: 1.5px solid; font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 700; cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.fc-btn:active { transform: scale(0.96); }
.fc-btn-wrong { border-color: rgba(220,80,80,0.25); color: #b91c1c; background: rgba(220,80,80,0.06); }
.fc-btn-flip  { border-color: var(--border2); color: var(--primary); background: var(--pink-bg); flex: 0 0 50px; }
.fc-btn-right { border-color: rgba(34,197,94,0.25); color: #15803d; background: rgba(34,197,94,0.06); }

/* ── QCM ── */
.qcm-wrap { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 1rem 1.25rem 1.25rem; -webkit-overflow-scrolling: touch; }
.qcm-question-card { background: var(--white); border: 1.5px solid var(--border); border-radius: 18px; padding: 1.35rem; margin-bottom: 1.1rem; }
.qcm-q-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.6rem; font-weight: 700; }
.qcm-q-text  { font-family: 'DM Sans', sans-serif; font-size: 1.05rem; font-weight: 600; color: var(--text); line-height: 1.6; }
.qcm-options { display: flex; flex-direction: column; gap: 9px; }
.qcm-option { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1.5px solid var(--border); border-radius: 14px; padding: 0.9rem 1.1rem; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: all .15s; }
.qcm-option:active:not(.disabled) { background: var(--pink-bg); }
.qcm-option.selected-wrong  { border-color: #fca5a5; background: rgba(220,80,80,0.07); }
.qcm-option.selected-right  { border-color: #86efac; background: rgba(34,197,94,0.07); }
.qcm-option.correct-reveal  { border-color: #86efac; background: rgba(34,197,94,0.07); }
.qcm-option.disabled        { cursor: default; }
.opt-letter { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; background: var(--pink-bg); border: 1px solid var(--border2); display: flex; align-items: center; justify-content: center; font-family: 'DM Sans', sans-serif; font-size: 0.78rem; font-weight: 700; color: var(--primary-dark); }
.qcm-option.selected-right .opt-letter { background: #86efac; border-color: #86efac; color: #15803d; }
.qcm-option.selected-wrong .opt-letter { background: #fca5a5; border-color: #fca5a5; color: #b91c1c; }
.qcm-option.correct-reveal .opt-letter { background: #86efac; border-color: #86efac; color: #15803d; }
.opt-text { font-size: 0.92rem; color: var(--text); line-height: 1.45; }
.qcm-feedback { padding: 0.85rem 1rem; border-radius: 12px; font-size: 0.88rem; margin-top: 0.85rem; display: none; line-height: 1.6; }
.qcm-feedback.show  { display: block; }
.qcm-feedback.right { background: rgba(34,197,94,0.1); color: #15803d; border: 1px solid rgba(34,197,94,0.25); }
.qcm-feedback.wrong { background: rgba(220,80,80,0.07); color: #b91c1c; border: 1px solid rgba(220,80,80,0.18); }
.btn-next { display: none; margin-top: 0.85rem; width: 100%; }
.btn-next.show { display: block; }

/* ── TEXTE À TROUS ── */
.trous-card { background: var(--white); border: 1.5px solid var(--border); border-radius: 18px; padding: 1.35rem; margin-bottom: 1.1rem; }
.trous-text { font-size: 0.95rem; line-height: 2.4; color: var(--text); }
.trou { display: inline-block; min-width: 80px; border-bottom: 2px solid var(--primary); background: var(--pink-bg); border-radius: 4px; padding: 0 0.4rem; color: transparent; cursor: pointer; vertical-align: middle; font-size: 0.95rem; transition: all .25s; -webkit-tap-highlight-color: transparent; }
.trou.revealed { color: var(--primary-dark); background: rgba(240,149,106,0.1); }
.trous-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ── RÉSULTATS ── */
.results-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.25rem; text-align: center; overflow-y: auto; }
.results-emoji { font-size: 3.2rem; margin-bottom: 0.75rem; }
.results-title { font-size: 1.6rem; margin-bottom: 0.4rem; }
.results-sub   { font-size: 0.9rem; color: var(--muted); margin-bottom: 1.5rem; font-weight: 500; }
.score-circle { width: 120px; height: 120px; border-radius: 50%; border: 4px solid var(--pink-pale); display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 1.5rem; background: var(--pink-bg); }
.score-num   { font-family: 'DM Sans', sans-serif; font-size: 2.4rem; font-weight: 700; color: var(--primary); }
.score-total { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.results-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }

/* ── SCORES ── */
.score-chapter-row { background: var(--white); border: 1.5px solid var(--border); border-radius: 14px; padding: 0.9rem 1.1rem; display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.score-pct { font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 700; color: var(--primary); min-width: 40px; text-align: right; }

/* ── PROFIL ── */
.profile-avatar { width: 68px; height: 68px; border-radius: 50%; background: var(--pink-bg); border: 2px solid var(--border2); display: flex; align-items: center; justify-content: center; font-family: 'DM Sans', sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--primary); margin: 0 auto 0.75rem; }
.profile-name  { font-family: 'DM Sans', sans-serif; font-size: 1.2rem; font-weight: 700; color: var(--text); text-align: center; }
.profile-email { font-size: 0.85rem; color: var(--muted); text-align: center; margin-bottom: 1.5rem; }
.profile-section { background: var(--white); border: 1.5px solid var(--border); border-radius: 18px; overflow: hidden; margin-bottom: 1rem; }
.profile-row { display: flex; align-items: center; justify-content: space-between; padding: 0.95rem 1.1rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; color: var(--text); }
.profile-row:last-child { border-bottom: none; }

/* ── ADMIN ── */
.admin-section { background: var(--white); border: 1.5px solid var(--border); border-radius: 18px; padding: 1.35rem; margin-bottom: 1rem; }
.admin-section h3 { font-size: 1rem; margin-bottom: 1rem; font-weight: 700; }

/* ── LOADING ── */
.loading-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 999; gap: 1rem; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--pink-pale); border-top-color: var(--primary); animation: spin .8s linear infinite; }

@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
@keyframes spin   { to { transform:rotate(360deg); } }

@media (min-width: 600px) {
  .page-content { padding-left: 1.75rem; padding-right: 1.75rem; }
  .mode-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Dashboard hero ring ── */
#prog-ring { stroke: #ffffff; }
#prog-pct  {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'DM Sans', sans-serif;
  font-size: .95rem; font-weight: 700;
  color: #ffffff;
}
.dash-hero-ring circle:first-child { stroke: rgba(255,255,255,0.25); }

/* ── Champ mot de passe avec oeil ── */
.input-eye-wrap { position: relative; }
.input-eye-wrap input { width: 100%; padding-right: 42px; }
.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--muted); display: flex; align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.eye-btn svg { width: 18px; height: 18px; }
.eye-btn:focus { outline: none; }

/* ── Mot de passe oublié ── */
.forgot-pwd-btn {
  background: none; border: none; cursor: pointer;
  font-size: .82rem; color: var(--primary); font-family: 'Open Sans', sans-serif;
  padding: 0; text-decoration: underline; text-underline-offset: 2px;
  -webkit-tap-highlight-color: transparent;
}
.forgot-pwd-btn:focus { outline: none; }

/* ── GAME CARD (dashboard) ── */
.game-card {
  background: var(--white); border: 1.5px solid var(--border2);
  border-radius: 14px; padding: .9rem 1rem;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; margin-bottom: 1rem;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s;
}
.game-card:active { transform: scale(0.98); }
.game-card-icon { font-size: 1.6rem; flex-shrink: 0; }
.game-card-body { flex: 1; }
.game-card-title { font-family: 'DM Sans', sans-serif; font-size: .92rem; font-weight: 500; color: var(--text); }
.game-card-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.game-card-arrow { font-size: 1.2rem; color: var(--primary); }

/* ── MEMORIES GAME ── */
.memories-intro { padding: 1rem; }
.memories-intro h2 { font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: .4rem; }
.memories-intro p { font-size: .82rem; color: var(--muted); line-height: 1.55; }

.memories-books-grid { display: flex; flex-direction: column; gap: 10px; padding: 0 1rem 1rem; }
.memory-book-card {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 14px; padding: .85rem 1rem;
  transition: border-color .2s, background .2s;
}
.memory-book-card.correct { border-color: #4CAF50; background: rgba(76,175,80,0.06); }
.memory-book-card.wrong   { border-color: #E53935; background: rgba(229,57,53,0.06); }
.memory-book-card.drag-over { border-color: var(--primary); background: rgba(240,149,106,0.08); border-style: dashed; }
.book-title-ar { font-size: .9rem; color: var(--primary); direction: rtl; text-align: right; margin-bottom: 3px; }
.book-title-fr { font-size: .78rem; color: var(--muted); font-style: italic; margin-bottom: .5rem; }
.book-drop-zone {
  min-height: 36px; border: 1.5px dashed rgba(240,149,106,0.3);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; padding: 4px 8px;
  font-size: .75rem; color: rgba(240,149,106,0.5);
  transition: all .2s;
}
.book-drop-zone.filled { border-style: solid; border-color: var(--primary); }
.book-drop-zone .author-tag { background: var(--pink-bg); color: var(--deep); border-radius: 6px; padding: 4px 10px; font-size: .78rem; font-family: 'DM Sans', sans-serif; }

.memories-authors { padding: 0 1rem 1rem; }
.memories-authors-title { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .6rem; }
.authors-pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; }
.author-tag {
  background: var(--pink-bg); color: var(--deep);
  border: 1.5px solid rgba(240,149,106,0.25);
  border-radius: 99px; padding: 6px 14px;
  font-size: .8rem; font-family: 'DM Sans', sans-serif; font-weight: 500;
  cursor: grab; user-select: none; -webkit-user-select: none;
  touch-action: none; transition: transform .15s, box-shadow .15s;
}
.author-tag:active { transform: scale(1.05); box-shadow: 0 4px 12px rgba(240,149,106,0.3); }
.author-tag.dragging { opacity: .5; }

.memories-validate-btn {
  display: block; width: calc(100% - 2rem); margin: 0 1rem 1rem;
  background: var(--primary); color: white; border: none; border-radius: 12px;
  padding: .85rem; font-family: 'DM Sans', sans-serif; font-size: .95rem; font-weight: 500;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: opacity .2s;
}
.memories-validate-btn:disabled { opacity: .5; cursor: default; }
.memories-validate-btn.next { background: var(--deep); }

.memory-comment-card {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: 14px; padding: .85rem 1rem; margin-bottom: 10px;
}
.memory-comment-text { font-size: .82rem; color: var(--text); line-height: 1.6; }
.comment-drop-zone {
  min-height: 40px; border: 1.5px dashed rgba(240,149,106,0.3);
  border-radius: 8px; padding: 4px 8px; margin-top: .5rem;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; color: rgba(240,149,106,0.5);
}
.comment-drop-zone.filled { border-style: solid; border-color: var(--primary); }

.memories-success {
  text-align: center; padding: 2rem 1rem;
}
.memories-success .success-emoji { font-size: 3rem; margin-bottom: .75rem; }
.memories-success h2 { font-family: 'DM Sans', sans-serif; font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: .5rem; }
.memories-success p { font-size: .85rem; color: var(--muted); }


/* ── TRANSITION THÈME ── */
body, .top-bar, .bottom-nav, .page-content,
.btn, .stat-card, .chapter-row, .mode-card,
.login-card, .flash-card, .qcm-card {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}

/* ── TOGGLE TAFSIR / TAJWID ── */
.subject-toggle-wrap {
  padding: .5rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.subject-toggle {
  display: flex; background: var(--pink-bg);
  border-radius: 99px; padding: 3px; gap: 3px;
}
.subject-toggle-btn {
  flex: 1; text-align: center; padding: .45rem .5rem;
  border-radius: 99px; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: .82rem; font-weight: 600;
  transition: all .25s; -webkit-tap-highlight-color: transparent;
  background: transparent; color: var(--muted);
}
.subject-toggle-btn.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ── ALVÉOLES HEXAGONALES (remplace pétales) ── */
.honeycomb-wrap {
  display: flex; align-items: center; justify-content: center;
  gap: 3px; margin-bottom: 3px;
}
.hex-cell {
  width: 14px; height: 16px;
  background: var(--hex-color);
  clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%);
  opacity: .18; transition: opacity .3s;
}
.hex-cell.filled { opacity: 1; }

/* ── DESKTOP — Container centré ── */
@media (min-width: 768px) {
  body {
    background: #E8E4DC;
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }

  /* Wrapper qui simule le téléphone sur desktop */
  #app-shell {
    width: 850px;
    min-height: 100vh;
    position: relative;
    background: var(--bg);
    box-shadow: 0 0 60px rgba(0,0,0,0.18);
    overflow: hidden;
  }

  .bottom-nav {
    width: 100%;
    left: 50%;
    transform: translateX(-50%);
  }

  .top-bar {
    width: 100%;
  }

  /* Fond desktop avec motif nid d'abeille subtil */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      repeating-linear-gradient(
        60deg,
        rgba(194,192,148,0.08) 0px,
        rgba(194,192,148,0.08) 1px,
        transparent 1px,
        transparent 30px
      ),
      repeating-linear-gradient(
        -60deg,
        rgba(194,192,148,0.08) 0px,
        rgba(194,192,148,0.08) 1px,
        transparent 1px,
        transparent 30px
      );
    pointer-events: none;
    z-index: 0;
  }

  #app-shell { z-index: 1; }
}

/* ============================================================ */
/*  BEEBAP — Mini-jeu Mnémo (Tajwid) + Toggle Tafsir/Tajwid     */
/*  À ajouter à la fin de style.css                              */
/* ============================================================ */

/* ── Toggle de visibilité Tafsir / Tajwid ───────────────────── */
/* Par défaut (mode Tafsir) : les éléments .tajwid-only sont cachés */
.tajwid-only { display: none !important; }

/* En mode Tajwid : on inverse — .tafsir-only caché, .tajwid-only visible */
[data-theme="tajwid"] .tafsir-only { display: none !important; }
[data-theme="tajwid"] .tajwid-only { display: flex !important; }

/* Cas spécial : les section-title sont des blocs simples, pas des flex */
[data-theme="tajwid"] .section-title.tajwid-only { display: block !important; }

/* ── Animation pulse pour la « prochaine case attendue » ────── */
@keyframes mnemoPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(212, 97, 58, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(212, 97, 58, 0);
        transform: scale(1.08);
    }
}

/* En mode Tajwid, on utilise une animation séparée avec la couleur du thème (vert) */
[data-theme="tajwid"] .mnemo-next-cell {
    animation-name: mnemoPulseTajwid !important;
}

@keyframes mnemoPulseTajwid {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(50, 116, 109, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(50, 116, 109, 0);
        transform: scale(1.08);
    }
}

/* ── Animation shake pour les mauvaises réponses ────────────── */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    50%      { transform: translateX(6px); }
    75%      { transform: translateX(-4px); }
}

/* ── Réglages spécifiques au screen mnemo-game ──────────────── */
#screen-mnemo-game .page-content {
    padding: 0;
}

#mnemo-content {
    min-height: 60vh;
}

/* Police arabe agréable pour les phrases mnémo (si dispo) */
#mnemo-content [style*="direction:rtl"],
#mnemo-content .mnemo-next-cell {
    font-family: 'Amiri', 'Scheherazade New', 'Traditional Arabic', serif;
}

/* ============================================================ */


/* ============================================================ */
/*  BEEBAP — Thème Jazariyah                                    */
/* ============================================================ */

/* Thème Jazariyah : violet sobre + or (texte ancien, tradition) */
[data-theme="jazariyah"] {
    --primary:      #5B4E8C;
    --primary-dark: #4A3F75;
    --primary-light:#7D6FA8;
    --accent:       #C9A961;
    --deep:         #1A0F33;
    --text:         #1A0F33;
    --muted:        #6A5F8C;
    --surface:      #FFFFFF;
    --bg:           #F4F1FA;
    --white:        #FFFFFF;
    --border:       rgba(91,78,140,0.2);
    --border2:      rgba(91,78,140,0.35);
    --pink:         #5B4E8C;
    --pink-light:   #7D6FA8;
    --pink-pale:    rgba(91,78,140,0.12);
    --pink-bg:      #EDE8F7;
    --hex-color:    #5B4E8C;
    --nav-h:        68px;
    --topbar-h:     56px;
}

/* Réglages spécifiques au screen Jazariyah */
#screen-jazariyah .page-content {
    padding: 0;
    padding-bottom: 2rem;
}

#jazariyah-content {
    min-height: 60vh;
}

/* ============================================================ */
