@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
  /* Color Palette - Blue & Yellow Theme */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  --accent-yellow: #fde047;
  --accent-yellow-glow: rgba(253, 224, 71, 0.8);

  --ink-50: #f8fafc;
  --ink-100: #f1f5f9;
  --ink-400: #94a3b8;
  --ink-500: #64748b;
  --ink-600: #475569;
  --ink-700: #334155;
  --ink-800: #1e293b;
  --ink-900: #0f172a;

  --paper-50: #ffffff;
  --paper-200: #e2e8f0;

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-dark-bg: rgba(15, 23, 42, 0.7);
  --glass-dark-border: rgba(30, 41, 59, 0.6);

  --bg-light: #f8fafc;
  --bg-dark: #020617;
}

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

body {
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
  background-color: var(--bg-light);
  color: var(--ink-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: var(--bg-dark);
    color: var(--paper-50);
  }
}

a {
  text-decoration: none;
  color: inherit;
}

button,
input {
  font-family: inherit;
}

/* Utility Classes */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-1 {
  gap: 0.25rem;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-6 {
  gap: 1.5rem;
}

.gap-10 {
  gap: 2.5rem;
}

.flex-wrap {
  flex-wrap: wrap;
}

.text-center {
  text-align: center;
}

.font-bold {
  font-weight: 700;
}

.font-black {
  font-weight: 900;
}

.text-lg {
  font-size: 1.125rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

/* Header & Glassmorphism */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
}

@media (prefers-color-scheme: dark) {
  .glass {
    background: var(--glass-dark-bg);
    border-bottom: 1px solid var(--glass-dark-border);
  }
}

.header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 5rem;
  transition: all 0.3s ease;
}

@media (min-width: 768px) {
  .header {
    top: 1.5rem;
    max-width: 1200px;
    width: calc(100% - 3rem);
    margin-left: auto;
    margin-right: auto;
    border-radius: 1.5rem;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.2);
  }
}

@media (min-width: 768px) and (prefers-color-scheme: dark) {
  .header {
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
  }
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 800;
  white-space: nowrap;
}

.text-yellow-highlight {
  color: var(--primary-600);
}

@media (prefers-color-scheme: dark) {
  .text-yellow-highlight {
    color: var(--accent-yellow);
  }
}

.nav-link {
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.nav-link:hover {
  color: var(--primary-600);
  background: rgba(37, 99, 235, 0.1);
}

@media (prefers-color-scheme: dark) {
  .nav-link:hover {
    color: var(--accent-yellow);
    background: rgba(253, 224, 71, 0.1);
  }
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(to top left, var(--primary-700), var(--primary-500));
  color: white;
  padding: 0.625rem 1.25rem;
  border-radius: 0.75rem;
  font-weight: 700;
  transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -10px var(--primary-500);
}

/* Hero Section */
.hero-section {
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 80% 20%, rgba(253, 224, 71, 0.22) 0%, transparent 48%),
    radial-gradient(circle at 15% 80%, rgba(37, 99, 235, 0.18) 0%, transparent 50%),
    linear-gradient(150deg, #020617 0%, #0f172a 40%, #1e3a8a 100%);
  padding: 4rem 0;
}

.hero-grid-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.9) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.9) 1px, transparent 1px);
  background-size: 32px 32px;
}

.hero-glow-1 {
  position: absolute;
  top: -5rem;
  right: -5rem;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.2;
  background: var(--accent-yellow);
  pointer-events: none;
}

.hero-glow-2 {
  position: absolute;
  bottom: -6rem;
  left: -4rem;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.3;
  background: var(--primary-500);
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: white;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 900;
  color: white;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: 3rem;
  }
}

.hero-title .highlight {
  color: var(--accent-yellow);
}

.hero-desc {
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 1.5rem;
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
}

/* Search Bar */
.search-container {
  max-width: 42rem;
  margin: 0 auto 1.5rem;
}

.search-box {
  position: relative;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 1.25rem;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.search-box:focus-within {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 25px rgba(250, 204, 21, 0.4), 0 8px 32px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.search-icon {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.3s ease;
}

.search-box:focus-within .search-icon {
  color: var(--accent-yellow);
}

.search-input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 1.25rem 4rem 1.25rem 8rem;
  font-size: 1.125rem;
  color: white;
  outline: none;
  transition: all 0.3s ease;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.search-btn {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.75rem 1.75rem;
  border-radius: 0.875rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink-900);
  background: linear-gradient(135deg, var(--accent-yellow) 0%, #fbbf24 100%);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(250, 204, 21, 0.3);
}

.search-btn:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 6px 20px rgba(250, 204, 21, 0.5);
  background: linear-gradient(135deg, #fef08a 0%, var(--accent-yellow) 100%);
}

.search-btn:active {
  transform: translateY(-50%) scale(0.95);
}


/* Stats */
.stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  color: white;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-num {
  font-size: 1.125rem;
  font-weight: 900;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

.stat-divider {
  color: rgba(255, 255, 255, 0.2);
  font-size: 1.125rem;
}

/* Features Strip */
.features-strip {
  background: white;
  border-bottom: 1px solid var(--paper-200);
  padding: 0.75rem 0;
}

@media (prefers-color-scheme: dark) {
  .features-strip {
    background: #0a1411;
    border-color: rgba(255, 255, 255, 0.05);
  }
}

.features-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-500);
}

@media (prefers-color-scheme: dark) {
  .features-container {
    color: var(--ink-400);
  }
}

@media (min-width: 768px) {
  .features-container {
    gap: 2.5rem;
  }
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* Responsive Hidden Classes */
.hidden {
  display: none;
}

@media (min-width: 768px) {
  .md-flex {
    display: flex;
  }

  .md-hidden {
    display: none;
  }
}

.mobile-search-btn {
  padding: 0.625rem;
  border-radius: 0.75rem;
  color: var(--ink-600);
  transition: all 0.3s ease;
}

.mobile-search-btn:hover {
  background: var(--ink-100);
}

@media (prefers-color-scheme: dark) {
  .mobile-search-btn {
    color: var(--paper-200);
  }

  .mobile-search-btn:hover {
    background: var(--ink-800);
  }
}

/* Sections */
.section {
  padding: 4rem 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 28px;
  background: linear-gradient(180deg, var(--primary-600), rgba(37, 99, 235, 0.5));
  border-radius: 9999px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 700;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-600);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  opacity: 0.8;
}

@media (prefers-color-scheme: dark) {
  .btn-secondary {
    color: var(--accent-yellow);
    background: rgba(253, 224, 71, 0.1);
  }

  .section-title::before {
    background: linear-gradient(180deg, var(--accent-yellow), rgba(253, 224, 71, 0.5));
  }
}

/* Categories Grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .categories-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.category-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 1rem;
  background: white;
  border: 1px solid var(--paper-200);
  transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .category-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.06);
  }
}

.category-card:hover {
  border-color: var(--primary-400);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.category-icon {
  flex-shrink: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.15);
  transition: transform 0.3s ease;
}

.category-card:hover .category-icon {
  transform: scale(1.1);
}

.category-info {
  flex: 1;
  min-width: 0;
}

.category-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.category-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--primary-600);
}

@media (prefers-color-scheme: dark) {
  .category-meta {
    color: var(--accent-yellow);
  }
}

/* Post Cards (Books/Content) */
.post-card {
  display: flex;
  align-items: stretch;
  /* So left/right columns stretch */
  gap: 1rem;
  background: white;
  border: 1px solid var(--paper-200);
  border-radius: 1.5rem;
  padding: 1rem;
  transition: all 0.2s ease;
  position: relative;
  min-width: 18rem;
  width: 20rem;
  /* Fixed width for the slider */
  max-width: 85vw;
  /* Prevent page overflow on small screens */
}

.post-card-fluid {
  min-width: 0;
  width: 100%;
  max-width: none;
}

@media (prefers-color-scheme: dark) {
  .post-card {
    background: #0a111a;
    border-color: rgba(255, 255, 255, 0.05);
  }
}

.post-card:hover {
  border-color: var(--primary-400);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.post-image-wrapper {
  position: relative;
  width: 5.5rem;
  height: 7.5rem;
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--primary-50);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .post-image-wrapper {
    width: 6rem;
    height: 8rem;
  }
}

@media (prefers-color-scheme: dark) {
  .post-image-wrapper {
    background: rgba(255, 255, 255, 0.05);
  }
}

.post-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.post-card:hover .post-image {
  transform: scale(1.05);
}

.post-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.post-title {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-900);
}

@media (min-width: 768px) {
  .post-title {
    font-size: 1rem;
  }
}

@media (prefers-color-scheme: dark) {
  .post-title {
    color: var(--paper-50);
  }
}

.post-desc {
  font-size: 0.75rem;
  color: var(--ink-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.75rem;
}

@media (prefers-color-scheme: dark) {
  .post-desc {
    color: var(--ink-400);
  }
}

.post-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  /* Align to the right in RTL */
  gap: 0.5rem;
  margin-top: auto;
}

.post-stat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.3rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 5rem;
}

.stat-views {
  background: var(--ink-100);
  color: var(--ink-700);
}

.stat-downloads {
  background: rgba(59, 130, 246, 0.08);
  /* Transparent blue background */
  color: var(--primary-600);
}

.stat-rating {
  background: rgba(253, 224, 71, 0.12);
  /* Transparent yellow background */
  color: #b45309;
  /* Amber text */
}

@media (prefers-color-scheme: dark) {
  .stat-views {
    background: rgba(255, 255, 255, 0.05);
    color: var(--ink-400);
  }

  .stat-downloads {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-400);
  }

  .stat-rating {
    background: rgba(253, 224, 71, 0.15);
    color: var(--accent-yellow);
  }
}

.rank-badge {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  z-index: 10;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  border: 2px solid white;
}

@media (prefers-color-scheme: dark) {
  .rank-badge {
    border-color: var(--bg-dark);
  }
}

/* Rank Specific Styles (Gold, Silver, Bronze, Blue) */
.categories-grid>a:nth-child(1) .rank-badge {
  background: linear-gradient(135deg, var(--accent-yellow), #facc15);
  /* Gold */
  color: #78350f;
}

.categories-grid>a:nth-child(2) .rank-badge {
  background: linear-gradient(135deg, #f1f5f9, #cbd5e1);
  /* Silver */
  color: #334155;
}

.categories-grid>a:nth-child(3) .rank-badge {
  background: linear-gradient(135deg, #ffedd5, #fdba74);
  /* Bronze */
  color: #7c2d12;
}

.categories-grid>a:nth-child(4) .rank-badge {
  background: linear-gradient(135deg, var(--primary-100), var(--primary-400));
  /* Blue */
  color: var(--primary-900);
}

@media (prefers-color-scheme: dark) {
  .rank-badge {
    background: rgba(253, 224, 71, 0.2);
    color: var(--accent-yellow);
    border-color: rgba(253, 224, 71, 0.3);
  }
}


/* Telegram CTA Banner */
.cta-banner {
  background: linear-gradient(to left, var(--primary-800), var(--primary-600));
  border-radius: 2rem;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(37, 99, 235, 0.2);
  margin: 4rem 0 2rem;
}

@media (min-width: 768px) {
  .cta-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 4rem;
  }
}

.cta-bg-pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.cta-glow {
  position: absolute;
  top: -50%;
  left: -20%;
  width: 50%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  transform: rotate(30deg);
  pointer-events: none;
}

.cta-content {
  position: relative;
  z-index: 1;
  max-width: 32rem;
}

.cta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
}

.cta-title {
  color: white;
  font-size: 1.75rem;
  font-weight: 900;
  margin-bottom: 1rem;
  line-height: 1.4;
}

@media (min-width: 768px) {
  .cta-title {
    font-size: 2.25rem;
  }
}

.cta-desc {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  line-height: 1.7;
}

.cta-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 260px;
}

@media (min-width: 480px) {
  .cta-actions {
    flex-direction: row;
    align-items: center;
  }
}

@media (min-width: 768px) {
  .cta-actions {
    flex-direction: column;
    min-width: 220px;
  }
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.3s ease;
  text-decoration: none;
  width: 100%;
}

.cta-btn-primary {
  background: white;
  color: var(--primary-700);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.cta-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.cta-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
}

.cta-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Footer */
.footer {
  background-color: #060c18;
  /* Rich deep navy blue */
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 4rem;
  padding-top: 4rem;
  color: var(--ink-400);
}

.footer-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  padding-bottom: 3rem;
}

@media (min-width: 768px) {
  .footer-main {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.footer-brand {
  max-width: 26rem;
}

.footer-desc {
  font-size: 0.875rem;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.5);
}

.footer-col-title {
  color: white;
  font-size: 1.125rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-col-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 16px;
  background-color: var(--accent-yellow);
  /* Yellow marker */
  border-radius: 4px;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  transition: all 0.2s ease;
}

.footer-link:hover {
  color: white;
  transform: translateX(-4px);
}

.footer-icon-box {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.08);
  /* Transparent blue bg by default */
  color: var(--primary-400);
  /* Theme blue icon */
  border: 1px solid rgba(59, 130, 246, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-link:hover .footer-icon-box {
  background: var(--accent-yellow);
  /* Turn gold on hover */
  color: var(--ink-900);
  /* Dark text on hover */
  border-color: var(--accent-yellow);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(253, 224, 71, 0.25);
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.5rem 0;
}

.footer-copyright {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.4);
}

.footer-credit {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

/* ================================================== */
/* Mobile Redesign: Bottom Navigation & Layout Tweaks */
/* ================================================== */

/* Bottom Navigation Bar */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--paper-200);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  .bottom-nav {
    background: rgba(10, 17, 26, 0.85);
    border-top-color: rgba(255, 255, 255, 0.1);
  }
}

.bottom-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 4.5rem;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: var(--ink-500);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  flex: 1;
  height: 100%;
  transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .bottom-nav-item {
    color: var(--ink-400);
  }
}

.bottom-nav-item.active {
  color: var(--primary-600);
}

@media (prefers-color-scheme: dark) {
  .bottom-nav-item.active {
    color: var(--accent-yellow);
  }
}

.bottom-nav-icon {
  width: 1.5rem;
  height: 1.5rem;
  transition: transform 0.2s ease;
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px);
}

/* Spacer to prevent content from hiding behind bottom nav on mobile */
.bottom-nav-spacer {
  display: none;
  height: 5.5rem;
}

/* Mobile Adjustments (max-width: 768px) */
@media (max-width: 768px) {

  /* Show Bottom Nav and Spacer */
  .bottom-nav,
  .bottom-nav-spacer {
    display: block;
  }

  /* Hide Desktop Nav in Header */
  .header .md-hidden {
    display: none;
  }

  .header .nav-link {
    display: none;
  }

  /* Improve Hero Section for Mobile */
  .hero-section {
    padding: 6rem 1rem 3rem;
  }

  .hero-title {
    font-size: 2.25rem;
    line-height: 1.2;
  }

  .hero-desc {
    font-size: 1.05rem;
    margin-bottom: 2rem;
  }

  .stats {
    flex-direction: column;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.5rem;
    padding: 1.5rem;
  }

  .stat-divider {
    display: none;
    /* Hide dots */
  }

  /* Reduce overall section padding on mobile */
  .section {
    padding: 2.5rem 0;
  }

  .section-title {
    font-size: 1.35rem;
  }

  /* Improve Features Strip on mobile */
  .features-container {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    gap: 1.25rem;
  }

  .features-container::-webkit-scrollbar {
    display: none;
  }

  .feature-item {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.75rem;
  }

  /* Horizontal Slider for Books on Mobile */
  .mobile-slider {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 0.875rem;
    padding-bottom: 1.25rem;
    /* Space for scrollbar */
    scrollbar-width: none;
    margin: 0 -1rem;
    /* Full bleed on mobile */
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .mobile-slider::-webkit-scrollbar {
    display: none;
  }

  .mobile-slider>* {
    flex: 0 0 78vw;
    /* 78% width shows a peek of the next card */
    scroll-snap-align: center;
    /* Center the active card */
    width: 100%;
    min-width: 0;
  }

  /* Optimize Cards for Mobile */
  .post-card {
    flex-direction: column;
    padding: 0.875rem;
    gap: 0.75rem;
    height: 100%;
    /* Ensure equal height in flex */
  }

  .post-image-wrapper {
    width: 100%;
    height: 10rem;
    /* Perfectly sized image for 2-column mobile grid */
  }

  .post-image {
    object-position: top;
  }

  .category-card {
    padding: 1rem;
    gap: 0.5rem;
    flex-direction: column;
    text-align: center;
    align-items: center;
    justify-content: center;
  }

  .category-icon {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.25rem;
    border-radius: 0.75rem;
  }

  .category-title {
    font-size: 0.85rem;
  }

  .category-meta {
    justify-content: center;
  }

  /* Adjust search box size on mobile */
  .search-input {
    padding: 1rem 3.5rem 1rem 6rem;
    font-size: 1rem;
  }

  .search-btn {
    padding: 0.625rem 1rem;
    font-size: 0.9rem;
  }

  /* Improve CTA Section */
  .cta-banner {
    padding: 2rem 1.25rem;
    border-radius: 1.5rem;
  }

  .cta-title {
    font-size: 1.75rem;
  }

  .cta-desc {
    font-size: 0.95rem;
  }

  .cta-actions {
    flex-direction: column;
    width: 100%;
  }

  .cta-btn {
    width: 100%;
    justify-content: center;
  }

  /* Compact Mobile Header */
  .header {
    height: 4rem !important;
  }

  .header .container {
    padding: 0 1rem;
    gap: 0.5rem;
  }

  .header img {
    width: 28px !important;
    height: 28px !important;
  }

  .header .logo-title {
    font-size: clamp(0.75rem, 3.8vw, 1.05rem) !important;
    white-space: nowrap !important;
  }

  .header .btn-primary {
    padding: 0.5rem 0.875rem !important;
    font-size: 0.8rem !important;
    border-radius: 0.625rem !important;
  }

  .header .btn-primary svg {
    width: 14px !important;
    height: 14px !important;
  }

  /* Shorten header button text to fits screens perfectly */
  .header .btn-primary span:last-child {
    display: none !important;
  }

  .header .btn-primary span.hidden {
    display: inline !important;
  }
}

/* ================================================== */
/* Shimmer Skeleton Loading Animations */
/* ================================================== */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 37%, #e2e8f0 63%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

@media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 37%, rgba(255, 255, 255, 0.05) 63%);
    background-size: 200% 100%;
  }
}

.skeleton-text {
  height: 1rem;
  border-radius: 4px;
}

.skeleton-title {
  height: 1.25rem;
  border-radius: 6px;
}

.skeleton-card-cat {
  pointer-events: none;
  opacity: 0.85;
}

.skeleton-card-book {
  pointer-events: none;
  opacity: 0.85;
}

/* ================================================== */
/* Bottom Sheet / Modal Dialog for Telegram WebApp Download */
/* ================================================== */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: flex-end; /* Bottom sheet on mobile */
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.bottom-sheet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet-card {
  background: white;
  border-radius: 2rem 2rem 0 0; /* Rounded top corners on mobile */
  width: 100%;
  max-width: 28rem;
  padding: 2.25rem 1.75rem 1.75rem;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  text-align: center;
}

.bottom-sheet-overlay.active .bottom-sheet-card {
  transform: translateY(0);
}

/* Close Button (X) */
.bottom-sheet-close {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem; /* RTL friendly */
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink-700);
  border: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bottom-sheet-close:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.05);
}

/* Success Checkmark Circle */
.bottom-sheet-success-circle {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: #10b981; /* Premium Green */
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.75rem;
  margin: 0 auto 1.5rem;
  box-shadow: 0 10px 20px -5px rgba(16, 185, 129, 0.3);
  animation: pulse-success 2s infinite;
}

@keyframes pulse-success {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.bottom-sheet-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--ink-900);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.bottom-sheet-desc {
  font-size: 1rem;
  color: var(--ink-600);
  line-height: 1.6;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.bottom-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bottom-sheet-btn-primary {
  background: #10b981; /* Green open chat button */
  color: white;
  border: none;
  border-radius: 1.25rem;
  padding: 1.1rem;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  transition: all 0.3s ease;
  box-shadow: 0 6px 15px -3px rgba(16, 185, 129, 0.25);
}

.bottom-sheet-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(16, 185, 129, 0.35);
  background: #059669;
}

.bottom-sheet-btn-secondary {
  background: transparent;
  color: var(--ink-500);
  border: 1px solid var(--paper-300);
  border-radius: 1.25rem;
  padding: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bottom-sheet-btn-secondary:hover {
  background: var(--paper-50);
  color: var(--ink-800);
  border-color: var(--paper-400);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .bottom-sheet-card {
    background: #0a111a;
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
  }

  .bottom-sheet-close {
    background: rgba(255, 255, 255, 0.05);
    color: var(--paper-200);
  }

  .bottom-sheet-close:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .bottom-sheet-title {
    color: var(--paper-50);
  }

  .bottom-sheet-desc {
    color: var(--ink-400);
  }

  .bottom-sheet-btn-secondary {
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--paper-300);
  }

  .bottom-sheet-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.02);
    color: white;
  }
}

/* Desktop Styles: Center Dialog instead of bottom slide */
@media (min-width: 576px) {
  .bottom-sheet-overlay {
    align-items: center; /* Center on desktop */
  }

  .bottom-sheet-card {
    border-radius: 2rem; /* Fully rounded on desktop */
    transform: scale(0.9) translateY(20px);
  }

  .bottom-sheet-overlay.active .bottom-sheet-card {
    transform: scale(1) translateY(0);
  }
}