/* ==========================================================================
   USTAZ AQEEDAH PLATFORM — v5.2 ENHANCED STYLESHEET
   Matches Official USTAZ Quran & Arabic Identity with Flawless Mobile UX
   ========================================================================== */

:root {
  --green-900: #064e3b;
  --green-800: #065f46;
  --green: #0f5c52;
  --green-600: #059669;
  --green-300: #6ee7d5;
  --green-100: #ccfbf1;
  --green-50: #f0fdf4;
  --gold: #c8a25a;
  --gold-light: #fef9ee;
  --gold-dark: #8c6d23;
  --s50: #fafaf9;
  --s100: #f5f5f4;
  --s200: #e7e5e4;
  --s300: #d6d3d1;
  --s500: #78716c;
  --s700: #44403c;
  --s900: #1c1917;
  --font-amiri: 'Amiri', serif;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Lora', Georgia, serif;
}

.hidden { display: none !important; }

html {
  font-family: var(--font-sans);
  background-color: var(--s50);
  color: var(--s900);
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Typography Classes */
.font-ar { font-family: var(--font-amiri); }
.font-display { font-family: var(--font-serif); }
.font-sans { font-family: var(--font-sans); }

/* Logo Mark */
.mark {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}

/* Top Sticky Header */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--s200);
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Badges & Pills */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

/* Lesson Playlist Item */
.lesson-item {
  transition: all 0.15s ease-in-out;
  cursor: pointer;
  border: 1px solid transparent;
}
.lesson-item:hover {
  background-color: var(--s100);
}
.lesson-item.active {
  background-color: #f0fdf4 !important;
  border-color: #86efac !important;
}
.lesson-item.active .lesson-title {
  color: #065f46 !important;
  font-weight: 700 !important;
}

/* Scholarly Matn Box (Sage Green Box) */
.matn-box {
  background-color: #f2f7f4;
  border: 1.5px solid #a3c4b5;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
  box-shadow: 0 1px 3px rgba(15, 92, 82, 0.05);
}

/* Distinction & Benefit Box (Warm Amber Box) */
.benefit-box {
  background-color: #fcf9f2;
  border: 1.5px solid #e8d7a7;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  margin: 0.65rem 0;
}

/* 3D Leitner Flashcard Engine */
.scene {
  width: 100%;
  max-width: 480px;
  height: 240px;
  margin: 0 auto;
  perspective: 1000px;
  cursor: pointer;
}
@media (max-width: 640px) {
  .scene {
    height: 210px;
  }
}
.fc {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.fc.flipped {
  transform: rotateY(180deg);
}
.face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  box-sizing: border-box;
}
.face.front {
  background: linear-gradient(135deg, #ffffff 0%, #fafaf9 100%);
  border: 1.5px solid var(--s300);
}
.face.back {
  background: linear-gradient(135deg, #f0fdf4 0%, #e6f7ec 100%);
  border: 1.5px solid #86efac;
  transform: rotateY(180deg);
}
.face-content {
  font-family: var(--font-amiri);
  font-size: 1.25rem;
  line-height: 1.7;
  color: var(--s900);
  margin: auto 0;
  text-align: center;
}
.face-hint {
  font-size: 0.75rem;
  color: var(--s500);
  text-align: center;
  font-family: var(--font-sans);
}

/* Buttons */
.btn-primary {
  background-color: var(--green);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
  padding: 0.5rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary:hover {
  background-color: var(--green-900);
}

.btn-again {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  padding: 0.5rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-again:hover {
  background-color: #fecaca;
}

.btn-got {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
  border-radius: 10px;
  padding: 0.5rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-got:hover {
  background-color: #bbf7d0;
}

/* Modals */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overscroll-behavior: contain;
}
.modal-dlg {
  background: #fff;
  border: 1px solid var(--s200);
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  padding: 1.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--s200);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
@media (max-width: 1023px) {
  .mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-sizing: border-box;
    height: calc(60px + env(safe-area-inset-bottom));
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
  }
  body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
}
.m-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--s500);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 8px;
  transition: all 0.15s ease;
  background: none;
  border: none;
  cursor: pointer;
  flex: 1;
}
.m-nav-item.active {
  color: var(--green-900);
  font-weight: 800;
}
.m-nav-item.active .m-nav-icon {
  transform: scale(1.15);
}
.m-nav-icon {
  font-size: 1.15rem;
  line-height: 1.2;
  transition: transform 0.15s ease;
}

/* Floating Quick Support Pill */
.floating-support-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 60;
  background-color: var(--green);
  color: #fff;
  border-radius: 9999px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 18px rgba(15, 92, 82, 0.35);
  border: 1.5px solid rgba(200, 162, 90, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}
@media (max-width: 1023px) {
  .floating-support-btn {
    bottom: calc(74px + env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
    padding: 8px 14px;
    font-size: 0.78rem;
  }
}
.floating-support-btn:hover {
  background-color: var(--green-900);
  transform: translateY(-2px);
}

/* PWA Banner */
.pwa-banner {
  position: fixed;
  bottom: 84px;
  left: 20px;
  max-width: 380px;
  background: #ffffff;
  border: 1.5px solid #c8a25a;
  box-shadow: 0 10px 30px rgba(6, 78, 59, 0.15), 0 2px 8px rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 12px 14px;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: inherit;
  animation: slideInUp 0.35s ease-out;
}
@media (max-width: 640px) {
  .pwa-banner {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(72px + env(safe-area-inset-bottom));
    max-width: none;
  }
  .modal-bg {
    align-items: flex-end;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .modal-dlg {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
    border-radius: 20px;
  }
  .m-nav-item {
    min-width: 0;
    min-height: 48px;
    padding-left: 3px;
    padding-right: 3px;
    touch-action: manipulation;
  }
  #top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: calc(100vw - 112px);
    row-gap: 4px;
  }
  #auth-chip {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 78, 59, 0.96);
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1.5px solid var(--gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 999999;
  font-weight: 600;
  font-size: 0.9rem;
  transition: opacity 0.3s ease;
  pointer-events: none;
  text-align: center;
}
