/* =============================================================================
   index.css — public-page layout, hero, cards, and component styles.

   Design tokens live in tokens.css (loaded before this file on every page).
   This file MUST NOT redeclare the palette or semantic tokens.
   ========================================================================== */


/* RTL Support */
[dir="rtl"] {
  font-family: var(--font-rtl);
}

[dir="ltr"] {
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  font-style: normal;
}

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

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: color 0.3s ease, background-color 0.3s ease;
}

[dir="rtl"] body {
  font-family: var(--font-rtl);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  letter-spacing: -0.015em;
  line-height: 1.25;
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6 {
  font-family: var(--font-rtl);
  letter-spacing: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header Styles */
.header {
  background-color: var(--bg-primary);
  box-shadow: 0 2px 10px var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent-primary);
}

.logo i {
  font-size: 2rem;
}

.nav-menu ul {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-menu a {
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
  padding: 0.5rem 0;
  border-radius: var(--radius-sm);
}

.nav-menu a:hover,
.nav-menu a.active {
  color: var(--accent-primary);
}

.nav-menu a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.nav-menu a::after {
  content: '';
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-primary);
  transition: width 0.3s ease;
}

.nav-menu a:hover::after,
.nav-menu a.active::after {
  width: 100%;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-toggle, .theme-toggle {
  background: var(--accent-primary);
  color: var(--on-primary);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  font-weight: 500;
  /* WCAG 2.5.5 target size — these are the only chrome controls on mobile. */
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lang-toggle:hover, .theme-toggle:hover {
  background: var(--accent-secondary);
  transform: translateY(-2px);
}

.lang-toggle:active, .theme-toggle:active {
  transform: translateY(0);
}

.lang-toggle:focus-visible,
.theme-toggle:focus-visible,
.mobile-menu-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
}

/* Page Header Styles */
.page-header {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  padding: 4rem 0;
  text-align: center;
}

.page-header-content h1 {
  font-size: 3rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

.page-header-content p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  opacity: 0.9;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.library-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-top: 2rem;
}

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

.stat-number {
  display: block;
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* Hero Section */
.hero {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  padding: 6rem 0;
  text-align: center;
}

.hero-content {
  /*max-width: 800px;*/
  max-width: 1200px;
  margin: 0 auto;
}

.hero-title {
  font-size: 3.5rem;
  font-weight: bold;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.25rem;
  margin-bottom: 2.5rem;
  opacity: 0.9;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Button Styles */
.btn {
  padding: 1rem 2rem;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease,
              border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  min-height: 44px;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* .btn sits on the teal hero/page-header gradient as often as on a plain
   surface; there the page-coloured ring disappears, so use a white one. */
.hero .btn:focus-visible,
.page-header .btn:focus-visible,
.btn-secondary:focus-visible {
  outline-color: #ffffff;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--warm-brown);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--dark-brown);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(149, 95, 48, 0.4);
}

.btn-primary:active,
.btn-outline:active,
.btn-secondary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: #ffffff;
  border: 2px solid #ffffff;
}

.btn-secondary:hover {
  background: #ffffff;
  color: var(--accent-primary);
}

.btn-outline {
  background: transparent;
  color: var(--accent-primary);
  border: 2px solid var(--accent-primary);
}

.btn-outline:hover {
  background: var(--accent-primary);
  color: var(--on-primary);
}

/* Section Styles */
.section-title {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 3rem;
  color: var(--text-primary);
  font-weight: bold;
}

.section-footer {
  text-align: center;
  margin-top: 3rem;
}

/* Filter Styles */
.blog-filters, .library-filters {
  padding: 2rem 0;
  background-color: var(--bg-secondary);
}

.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.search-box {
  position: relative;
  max-width: 400px;
  width: 100%;
}

.search-box i {
  position: absolute;
  inset-inline-start: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding-block: 1rem;
  padding-inline: 3rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 25px;
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-box input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.search-box input:focus-visible {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.category-filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-btn {
  padding: 0.75rem 1.5rem;
  min-height: 44px;
  border: 2px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  border-radius: 25px;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  font-weight: 500;
}

/* Hover is a tint, selection is a fill — they used to be identical, which
   made it impossible to tell which category was actually applied. */
.filter-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.filter-btn.active,
.filter-btn[aria-pressed="true"] {
  background: var(--accent-primary);
  color: var(--on-primary);
  border-color: var(--accent-primary);
}

.filter-groups {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 150px;
}

.filter-group label {
  font-weight: 600;
  color: var(--text-primary);
}

.filter-group select {
  padding: 0.75rem;
  min-height: 44px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.filter-group select:focus-visible {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Featured Article/Book Styles */
.featured-article, .featured-books {
  padding: 4rem 0;
  background-color: var(--bg-primary);
}

.featured-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  max-width: 1000px;
  margin: 0 auto;
}

.featured-image {
  position: relative;
  border-radius: 15px;
  overflow: hidden;
}

.featured-image img {
  width: 100%;
  height: 400px;
  object-fit: cover;
}

.featured-badge {
  position: absolute;
  top: 1rem;
  inset-inline-start: 1rem;
  background: var(--warm-brown);
  color: #ffffff;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
}

.featured-content .article-category,
.featured-content .book-category {
  display: inline-block;
  background: var(--accent-primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 15px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.featured-content h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.featured-content p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

/* Single source of truth for the card meta row (author block + stats).
   It used to be declared twice, and the later copy dropped the wrap/gap,
   so the row could overflow a narrow card before the 640px breakpoint. */
.article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.author-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.author-name {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.publish-date {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.article-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.article-stats span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Featured Books Slider */
.featured-books-slider {
  max-width: 1000px;
  margin: 0 auto;
}

.featured-book-card {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 3rem;
  align-items: start;
}

.book-cover {
  position: relative;
}

.book-cover img {
  width: 100%;
  border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow);
}

.book-badge {
  position: absolute;
  top: 1rem;
  inset-inline-end: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 15px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
}

.book-badge.bestseller {
  background: var(--warm-brown);
}

.book-badge.new {
  background: var(--accent-primary);
}

.book-info h3 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.book-author {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-style: italic;
}

.book-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stars {
  display: flex;
  gap: 0.25rem;
  color: #fbbf24;
}

.rating-score {
  font-weight: 600;
  color: var(--text-primary);
}

.rating-count {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.book-description {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.book-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.book-level {
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
}

.book-level.beginner {
  background: #10b981;
}

.book-level.intermediate {
  background: #f59e0b;
}

.book-level.advanced {
  background: #ef4444;
}

.book-pages,
.book-downloads {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Articles Section */
.articles-section, .blog-articles {
  padding: 6rem 0;
  background-color: var(--bg-secondary);
}

.articles-grid {
  display: grid;
  /*grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));*/
  gap: 2rem;
}

.article-card {
  background: var(--card-bg);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 5px 20px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px var(--shadow);
}

.article-image {
  height: 200px;
  overflow: hidden;
}

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

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

.article-content {
  padding: 1.5rem;
}

.article-category {
  margin-bottom: 1rem;
}

.article-category span {
  background: var(--accent-primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.875rem;
  font-weight: 600;
}

.article-content h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.article-content p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

/* .article-meta is declared once, above. */

.read-time {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* E-books Section */
.ebooks-section, .books-library {
  padding: 6rem 0;
  background-color: var(--bg-primary);
}

.ebooks-grid, .books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.ebook-card, .book-card {
  text-align: center;
  transition: transform 0.3s ease;
}

.ebook-card:hover, .book-card:hover {
  transform: translateY(-5px);
}

.ebook-cover, .book-card .book-cover {
  position: relative;
  margin-bottom: 1rem;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 5px 20px var(--shadow);
}

.ebook-cover img, .book-card .book-cover img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.book-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.book-card:hover .book-overlay {
  opacity: 1;
}

.btn-download, .btn-preview {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-download:hover, .btn-preview:hover {
  background: var(--accent-secondary);
  transform: scale(1.1);
}

.ebook-info, .book-card .book-info {
  padding: 0 1rem;
}

.ebook-info h3, .book-card .book-info h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.ebook-rating, .book-card .book-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ebook-rating .stars, .book-card .book-rating .stars {
  display: flex;
  gap: 0.25rem;
  color: #fbbf24;
}

.ebook-level, .book-card .book-level {
  background: var(--accent-primary);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Community Section */
.community-section {
  padding: 6rem 0;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: white;
}

.community-section .section-title {
  color: white;
}

.community-description {
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 3rem;
  opacity: 0.9;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.community-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.telegram-btn {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 2rem;
  border-radius: 15px;
  text-decoration: none;
  color: white;
  transition: background-color 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(10px);
}

.telegram-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
}

.telegram-btn i {
  font-size: 3rem;
  opacity: 0.9;
}

.telegram-info h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.telegram-info p {
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.member-count {
  font-size: 0.875rem;
  opacity: 0.7;
  font-weight: 600;
}

/* Newsletter Section */
.newsletter-section {
  padding: 4rem 0;
  background: var(--bg-primary);
  text-align: center;
}

.newsletter-content h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.newsletter-content p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.newsletter-form {
  display: flex;
  gap: 1rem;
  max-width: 400px;
  margin: 0 auto;
}

.newsletter-form input {
  flex: 1;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 25px;
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 1rem;
}

.newsletter-form input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Reading Progress Section */
.reading-progress {
  padding: 4rem 0;
  background: var(--bg-secondary);
}

.progress-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.progress-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 5px 20px var(--shadow);
  transition: transform 0.3s ease;
}

.progress-card:hover {
  transform: translateY(-5px);
}

.progress-icon {
  background: var(--accent-primary);
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.5rem;
}

.progress-info h3 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.progress-number {
  font-size: 2rem;
  font-weight: bold;
  color: var(--accent-primary);
  display: block;
  margin-bottom: 0.5rem;
}

.progress-info p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Load More Section */
.load-more-section {
  text-align: center;
  margin-top: 3rem;
}

/* Footer */
.footer {
  background-color: var(--bg-secondary);
  padding: 3rem 0 1rem;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3rem;
  margin-bottom: 2rem;
}

.footer-brand p {
  margin-top: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.footer-links {
  display: flex;
  gap: 3rem;
}

.footer-section h4 {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.footer-section ul {
  list-style: none;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.footer-section a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-section a:hover {
  color: var(--accent-primary);
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--accent-primary);
  color: white;
  border-radius: 50%;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.social-links a:hover {
  background: var(--accent-secondary);
  transform: translateY(-2px);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.footer-controls {
  display: flex;
  gap: 1rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .container {
    padding: 0 24px;
  }

  .hero {
    padding: 5rem 0;
  }

  .hero-title {
    font-size: 3rem;
  }

  .hero-subtitle {
    font-size: 1.1rem;
  }

  .page-header {
    padding: 3rem 0;
  }

  .page-header-content h1 {
    font-size: 2.5rem;
  }

  .articles-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
  }

  .ebooks-grid,
  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
  }

  .filter-controls {
    flex-wrap: wrap;
    gap: 1rem;
  }

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

  .community-buttons {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: inline-flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    inset-inline: 0;
    background: var(--bg-primary);
    box-shadow: 0 5px 20px var(--shadow);
    padding: 1rem;
  }

  .nav-menu.active {
    display: block;
  }

  .nav-menu ul {
    flex-direction: column;
    gap: 0.25rem;
  }

  /* Full-width rows so each link clears the 44px touch target. */
  .nav-menu a {
    display: block;
    padding: 0.75rem 0.5rem;
    min-height: 44px;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }

  .page-header-content h1 {
    font-size: 2.5rem;
  }

  .library-stats {
    gap: 1.5rem;
  }

  .stat-number {
    font-size: 2rem;
  }

  .featured-card,
  .featured-book-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .articles-grid {
    grid-template-columns: 1fr;
  }

  .ebooks-grid,
  .books-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }

  .filter-groups {
    flex-direction: column;
    align-items: center;
  }

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

  .community-buttons {
    grid-template-columns: 1fr;
  }

  .telegram-btn {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .newsletter-form {
    flex-direction: column;
  }

  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

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

  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 15px;
  }

  .hero {
    padding: 4rem 0;
  }

  .hero-title {
    font-size: 2rem;
  }

  .page-header-content h1 {
    font-size: 2rem;
  }

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

  .ebooks-grid,
  .books-grid {
    grid-template-columns: 1fr;
  }

  .articles-grid {
    grid-template-columns: 1fr;
  }

  .library-stats {
    flex-direction: column;
    gap: 1rem;
  }

  .filter-groups {
    gap: 1rem;
  }

  .filter-group {
    min-width: 120px;
  }
}

/* Narrowest supported phones (320-360px). Everything above already wraps;
   these only shave the display type so long words can't push a scrollbar. */
@media (max-width: 380px) {
  .container {
    padding: 0 12px;
  }

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

  .hero-subtitle,
  .page-header-content p {
    font-size: 1.05rem;
  }

  .page-header-content h1,
  .section-title {
    font-size: 1.6rem;
  }

  .btn {
    padding: 0.85rem 1.25rem;
    width: 100%;
  }

  .filter-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  /* Long unbroken titles/URLs are the only real 320px overflow source. */
  .hero-title,
  .section-title,
  .page-header-content h1,
  .article-content h3,
  .teacher-card-name {
    overflow-wrap: anywhere;
  }
  /* Header chrome (brand + 3×44px controls) is the only fixed-width row that
     can't wrap; shave it so it fits 320px without dropping the 44px targets. */
  .header .container {
    padding-inline: 12px;
  }

  .nav-controls {
    gap: 0.5rem;
  }

  .logo {
    font-size: 1.15rem;
    white-space: nowrap;
  }
}

/* RTL Specific Styles
   Only genuine overrides live here. Rules that merely restated the inherited
   `direction: rtl`, and the `flex-direction: row-reverse` pairs on
   .telegram-btn / .author-info, were removed: a flex row already reverses
   under dir="rtl", so reversing it again rendered those rows back in LTR
   order (avatar on the left of a right-aligned Persian name). */
[dir="rtl"] .article-content,
[dir="rtl"] .ebook-info,
[dir="rtl"] .book-info,
[dir="rtl"] .telegram-info {
  text-align: start;
}

/* Brand/social glyph strip stays in its authored order in both directions. */
[dir="rtl"] .social-links {
  direction: ltr;
}

/* Chevrons and arrows point "forward" — mirror them when reading direction
   flips so "next" still points away from the start edge. */
[dir="rtl"] .fa-arrow-right,
[dir="rtl"] .fa-arrow-left,
[dir="rtl"] .fa-arrow-right-long,
[dir="rtl"] .fa-arrow-left-long,
[dir="rtl"] .fa-chevron-right,
[dir="rtl"] .fa-chevron-left,
[dir="rtl"] .fa-angle-right,
[dir="rtl"] .fa-angle-left,
[dir="rtl"] .fa-angles-right,
[dir="rtl"] .fa-angles-left {
  transform: scaleX(-1);
}

/* Animation Classes */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Loading Animation */
.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Hidden class for filtering */
.hidden {
  display: none !important;
}

/* Sticky-header elevation once the page scrolls (toggled by index.js). */
.header.scrolled {
  box-shadow: 0 5px 20px var(--shadow);
}