* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body,
body * {
  font-family: var(--font-ui);
}
html {
  scroll-behavior: smooth;
}

/* Design tokens live in css/tokens.css, which loads before this file.
   This file previously redeclared :root and [data-theme="dark"] with an older
   palette — and because it loads later, those values silently overrode the
   token layer for --bg-color, --text-color, --primary-color, --radius-*,
   --transition-*, --glass-* and --shadow-*. Removed so tokens.css is the
   single source of truth. */


/* Selection styling */
::selection {
  background: rgba(var(--primary-rgb), 0.2);
  color: var(--text-color);
}

/* Animations */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-fade-up {
  animation: fadeUp var(--transition-slow) forwards;
  opacity: 0;
}

.animate-fade-in {
  animation: fadeIn var(--transition-slow) forwards;
  opacity: 0;
}

.animate-scale-in {
  animation: scaleIn var(--transition-slow) forwards;
  opacity: 0;
}

.delay-1 {
  animation-delay: 0.1s;
}

.delay-2 {
  animation-delay: 0.2s;
}

.delay-3 {
  animation-delay: 0.3s;
}

.delay-4 {
  animation-delay: 0.4s;
}

.delay-5 {
  animation-delay: 0.5s;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  min-height: 100dvh;
  direction: rtl;
  padding-bottom: 0;
  font-weight: var(--font-weight);
  transition:
    background-color var(--transition-normal),
    color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  body {
    /* Clears the docked tab bar plus the home indicator. */
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  }
}

/* Utilities */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--elev-2);
  border-radius: var(--radius-lg);
  /* Transition only what changes — `all` also animated layout properties. */
  transition:
    box-shadow var(--transition-normal),
    border-color var(--transition-normal),
    transform var(--transition-normal);
}

/* Lift only cards that actually do something. Previously every glass card
   lifted 4px and turned its border green on hover, including static ones. */
.glass-card:is(a, button, [role="button"], [onclick]):hover {
  box-shadow: var(--elev-4);
  transform: translateY(-2px);
  border-color: rgba(var(--primary-rgb), 0.4);
}

@media (hover: none) {
  .glass-card:is(a, button, [role="button"], [onclick]):hover {
    transform: none;
    box-shadow: var(--elev-2);
    border-color: var(--glass-border);
  }
}

.background-ornament {
  position: fixed;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(100px);
  z-index: var(--z-below);
  opacity: 0.12;
  pointer-events: none;
}

.ornament-1 {
  top: -150px;
  left: -150px;
  background: var(--primary-color);
}

.ornament-2 {
  bottom: -150px;
  right: -150px;
  background: var(--secondary-color);
}

/* App Header ---------------------------------------------------------------
   Sits flush to the top edge and spans the full width rather than floating as
   an inset pill, so it reads as real app chrome and the safe-area inset on
   notched devices is filled instead of showing a stripe of page behind it. */
.app-header {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  padding-block: var(--space-2);
  padding-inline: var(--space-4);
  padding-block-start: calc(var(--space-2) + var(--safe-top));
  display: flex;
  align-items: center;
  gap: var(--space-2);
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-header);
  margin: 0;
  border: none;
  border-block-end: 1px solid var(--border-color);
  border-radius: 0;
  min-height: var(--header-height);
}

.visitor-badge {
  display: none !important;
}

.app-header h1 {
  font-size: var(--text-lg);
  color: var(--text-color);
  margin: 0;
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  text-align: start;
  /* Long surah names must not push the action buttons off-screen. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-left-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.settings-btn,
.header-back-btn,
.menu-toggle-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Was 40px — below the 44px minimum comfortable hit area. */
  width: var(--tap-target);
  height: var(--tap-target);
  flex-shrink: 0;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast);
}

.menu-toggle-btn {
  background: transparent;
  color: var(--text-color);
}

.settings-btn:hover,
.header-back-btn:hover,
.menu-toggle-btn:hover {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-color);
}

.settings-btn:active,
.header-back-btn:active,
.menu-toggle-btn:active {
  background: rgba(var(--primary-rgb), 0.18);
}

.app-content {
  padding-block: var(--space-6) var(--space-10);
  padding-inline: var(--space-4);
  max-width: var(--container);
  margin: 0 auto;
}

/* Section rhythm ------------------------------------------------------------
   Gives every page the same vertical cadence instead of each one inventing
   its own margins. */
.app-content > * + * {
  margin-block-start: var(--space-5);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.feature-card {
  padding: 32px;
  text-align: center;
  text-decoration: none;
  color: var(--text-color);
  display: block;
}

.feature-icon {
  font-size: 54px;
  margin-bottom: 20px;
  transition: transform var(--transition-normal);
}

.feature-card:hover .feature-icon {
  transform: scale(1.1) rotate(5deg);
}

.feature-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.feature-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.stats-section {
  padding: 40px;
  margin-bottom: 48px;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-number {
  font-size: 42px;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Daily Verse & Resume Reading */
.verse-card {
  padding: 36px 24px;
  margin-bottom: 32px;
  position: relative;
  text-align: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.verse-card::before {
  content: '"';
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 80px;
  font-family: serif;
  color: var(--primary-color);
  opacity: 0.1;
}

.verse-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 24px;
  text-transform: uppercase;
  letter-spacing: 2px;
  display: block;
}

.verse-ref {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(var(--primary-rgb), 0.08);
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
}

/* Hadith Card */
.hadith-card {
  padding: 32px;
  margin-bottom: 32px;
  border-right: 4px solid var(--secondary-color);
  position: relative;
  overflow: hidden;
}

.hadith-card::before {
  content: "\F2AB";
  /* bi-chat-quote */
  font-family: "bootstrap-icons";
  position: absolute;
  top: -10px;
  left: -10px;
  font-size: 80px;
  color: var(--secondary-color);
  opacity: 0.05;
}

.hadith-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary-color);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hadith-text {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-color);
  font-weight: 500;
}

/* Prayer Times Widget */
.prayer-widget {
  margin-bottom: 32px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pw-title {
  font-weight: 700;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pw-location {
  font-size: 13px;
  color: var(--text-secondary);
}

.pw-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}

.pw-item {
  text-align: center;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  background: rgba(var(--primary-rgb), 0.05);
  transition: all var(--transition-fast);
}

/* Was `color: white`, inherited from when the widget row was filled with the
   accent. The row is now a tinted paper row, so white was invisible. */
.pw-item.active {
  background: var(--primary-color);
  color: var(--on-primary);
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.pw-name {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.pw-time {
  font-size: 14px;
  font-weight: 700;
}

.pw-footer {
  text-align: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--primary-color);
}

.detect-location-container {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
}

.detect-location-btn {
  background: var(--primary-color);
  color: var(--on-primary);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.detect-location-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.detect-location-btn i {
  font-size: 16px;
}

/* Quick Tools */
.quick-tools {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 40px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.tool-btn:hover {
  background: var(--primary-color);
  color: var(--on-primary);
  transform: translateY(-4px);
}

.tool-btn i {
  font-size: 20px;
}

.tool-label {
  font-size: 12px;
  font-weight: 600;
}

/* Sidebar */
/* Navigation drawer --------------------------------------------------------
   Animates with transform rather than the `right` offset: transform is
   compositor-driven, and a physical `right` transition animates the wrong
   edge under a direction flip. */
.desktop-sidebar {
  position: fixed;
  /* Opens from the inline-start edge — the right-hand side under dir="rtl". */
  inset-inline-start: 0;
  inset-block-start: 0;
  width: min(var(--sidebar-width), 86vw);
  height: 100dvh;
  background: var(--surface-1);
  border-inline-start: 1px solid var(--border-color);
  box-shadow: var(--elev-5);
  z-index: var(--z-drawer);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
  padding-block-start: var(--safe-top);
  padding-block-end: var(--safe-bottom);
}

/* RTL: the drawer sits on the right, so it hides by moving further right.
   In LTR it sits on the left and must hide to the left instead. */
:dir(ltr) .desktop-sidebar {
  transform: translateX(-100%);
}

.desktop-sidebar.active {
  transform: translateX(0);
}

.sidebar-logo {
  padding-block: var(--space-5);
  padding-inline: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
  gap: var(--space-4);
  border-block-end: 1px solid var(--border-color);
}

.sidebar-logo-text {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--primary-color);
}

.sidebar-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  /* Was 32px — under the minimum hit area. */
  width: var(--tap-target);
  height: var(--tap-target);
  flex-shrink: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast);
}

.sidebar-close-btn:hover {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-color);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-3);
  padding-inline: var(--space-4);
  min-height: var(--tap-target);
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  position: relative;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast);
}

.sidebar-nav-item:hover {
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--text-color);
}

/* Active item uses a tinted surface plus an edge marker rather than a solid
   green fill, so it reads as selection instead of a button. */
.sidebar-nav-item.active {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary-color);
  font-weight: var(--weight-semibold);
}

.sidebar-nav-item.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block: 20%;
  width: 3px;
  border-radius: var(--radius-full);
  background: var(--primary-color);
}

.sidebar-nav-label {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.sidebar-nav-item.active .sidebar-nav-label {
  font-weight: var(--weight-semibold);
}

.sidebar-footer {
  padding: var(--space-4);
  border-block-start: 1px solid var(--border-color);
  text-align: center;
}

.sidebar-version {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 12, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: var(--z-overlay);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--transition-slow),
    visibility var(--transition-slow);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Bottom Nav */
/* Bottom navigation --------------------------------------------------------
   Docked to the edge and extended through the home-indicator area, so it
   behaves like native tab bars. Previously it floated 20px off every edge,
   which left a strip of scrolling content visible underneath it. */
.bottom-nav {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  display: none;
  justify-content: space-around;
  align-items: stretch;
  gap: var(--space-1);
  padding-block: var(--space-1);
  padding-block-end: calc(var(--space-1) + var(--safe-bottom));
  padding-inline: var(--space-2);
  border-radius: 0;
  border: none;
  border-block-start: 1px solid var(--border-color);
  box-shadow: none;
  z-index: var(--z-nav);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  /* Full-height target so the whole tab is tappable, not just the glyph. */
  min-height: var(--tap-target);
  padding-block: var(--space-1);
  border-radius: var(--radius-sm);
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast);
  flex: 1 1 0;
  min-width: 0;
  position: relative;
}

.nav-item:hover {
  color: var(--text-secondary);
}

.nav-item.active {
  color: var(--primary-color);
}

/* Active tab gets a shape cue as well as colour, so the state does not rely
   on colour alone. */
.nav-item.active .nav-icon {
  background: rgba(var(--primary-rgb), 0.14);
}

.nav-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 26px;
  border-radius: var(--radius-full);
  margin-bottom: 0;
  transition: background-color var(--transition-fast);
}

.nav-label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }

  .app-content {
    padding-inline: var(--space-4);
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 32px;
  border-radius: var(--radius-lg);
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-heavy);
  animation: scaleIn var(--transition-normal);
}

.modal .modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.modal .modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  background: rgba(var(--primary-rgb), 0.14);
  color: var(--primary-color);
}

.modal .modal-icon.warning {
  background: rgba(212, 130, 10, 0.18);
  color: #d4820a;
}

.modal .modal-icon.error {
  background: rgba(211, 47, 47, 0.18);
  color: #d32f2f;
}

.modal .modal-icon.success {
  background: rgba(27, 94, 32, 0.18);
  color: var(--primary-color);
}

.modal .modal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-color);
}

.modal .modal-message {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-color);
  opacity: 0.88;
}

.modal .modal-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal .modal-btn {
  min-width: 110px;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast),
    color var(--transition-fast),
    opacity var(--transition-fast);
}

.modal .modal-btn:focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.45);
  outline-offset: 2px;
}

.modal .modal-btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  color: var(--on-primary);
  box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.3);
}

.modal .modal-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(var(--primary-rgb), 0.34);
}

.modal .modal-btn-primary:active {
  transform: translateY(0);
  opacity: 0.95;
}

.modal .modal-btn-secondary {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.modal .modal-btn-secondary:hover {
  background: rgba(var(--primary-rgb), 0.16);
}

@media (max-width: 480px) {
  .modal {
    padding: 24px;
  }

  .modal .modal-actions {
    flex-direction: column;
  }

  .modal .modal-btn {
    width: 100%;
  }
}
