/* ============================================
   RESET & BASE – (همان کد قبلی)
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.ml-library-wrapper {
  font-family: 'Vazirmatn', sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* ============================================
   HEADER
   ============================================ */
.ml-library-header {
  width: 100%;
  text-align: center;
  padding: 30px 20px 10px;
}
.ml-library-header h1 {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.ml-library-header p {
  color: #64748b;
  font-size: 1.2rem;
  max-width: 700px;
  margin: 0 auto 20px;
  line-height: 1.8;
}

/* ============================================
   CATEGORY TABS
   ============================================ */
.ml-category-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 35px;
  width: 100%;
  max-width: 1200px;
}
.ml-category-tabs button {
  background: #ffffff;
  border: none;
  padding: 14px 32px;
  border-radius: 60px;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  box-shadow: 0 10px 20px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid transparent;
}
.ml-category-tabs button i {
  font-size: 1.2rem;
}
.ml-category-tabs button:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.1);
  border-color: #fdbb2d;
}
.ml-category-tabs button.active {
  background: #1a2a6c;
  color: #fff;
  border-color: #1a2a6c;
  box-shadow: 0 12px 24px rgba(26,42,108,0.3);
}
.ml-category-tabs button.active i {
  color: #fff;
}

/* ============================================
   BOOK GRID
   ============================================ */
.ml-books-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}
.ml-align {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 35px 30px;
  padding: 0;
  list-style: none;
}
.ml-align > li {
  display: none;
  flex: 0 0 auto;
  width: 210px;
  min-height: 300px;
  transition: 0.3s ease;
}
.ml-align > li.show {
  display: inline-block;
  animation: fadeUp 0.5s ease forwards;
}
@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ============================================
   3D BOOK
   ============================================ */
.ml-book {
  position: relative;
  width: 190px;
  height: 260px;
  margin: 0 auto;
  perspective: 1500px;
  transform-style: preserve-3d;
  transition: 0.3s ease;
}
.ml-book:hover {
  transform: scale(1.03);
}

.ml-hardcover_front,
.ml-hardcover_back,
.ml-book_spine,
.ml-hardcover_front li,
.ml-hardcover_back li,
.ml-book_spine li {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.ml-hardcover_front {
  transform: rotateY(-34deg) translateZ(10px);
  z-index: 100;
  transition: all 0.8s ease, z-index 0.6s;
  transform-origin: 0% 100%;
}
.ml-hardcover_front li:first-child {
  background: #eee;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  transform: translateZ(3px);
  box-shadow: inset -3px 0 12px rgba(0,0,0,0.15);
}
.ml-hardcover_front li:last-child {
  transform: rotateY(180deg) translateZ(3px);
  background: #f5f0e8;
  border-radius: 0 8px 8px 0;
}

.ml-hardcover_back {
  transform: rotateY(-15deg) translateZ(-10px);
  transform-origin: 0% 100%;
}
.ml-hardcover_back li:first-child {
  background: #f5f0e8;
  border-radius: 0 8px 8px 0;
  transform: translateZ(3px);
}
.ml-hardcover_back li:last-child {
  transform: translateZ(-3px);
  background: #e0d8cd;
  border-radius: 0 8px 8px 0;
}

.ml-book_spine {
  transform: rotateY(60deg) translateX(-6px) translateZ(-14px);
  width: 18px;
  z-index: 0;
}
.ml-book_spine li:first-child {
  background: #ccc;
  transform: translateZ(3px);
}
.ml-book_spine li:last-child {
  background: #555;
  transform: translateZ(-3px);
}

.ml-page {
  position: absolute;
  top: 1.5%;
  left: 4%;
  width: 100%;
  height: 97%;
  z-index: 10;
  transform-style: preserve-3d;
}
.ml-page > li {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(to right, #e1ddd8 0%, #fffbf6 100%);
  box-shadow: inset 0 -1px 2px rgba(50,50,50,0.1), inset -1px 0 1px rgba(150,150,150,0.2);
  border-radius: 0 6px 6px 0;
  transition: transform 0.6s cubic-bezier(0.25,0.46,0.45,0.94);
}
.ml-page > li:nth-child(1) { transform: rotateY(-28deg); }
.ml-page > li:nth-child(2) { transform: rotateY(-30deg); }
.ml-page > li:nth-child(3) { transform: rotateY(-32deg); }
.ml-page > li:nth-child(4) { transform: rotateY(-34deg); }
.ml-page > li:nth-child(5) { transform: rotateY(-36deg); }

.ml-book:hover > .ml-hardcover_front {
  transform: rotateY(-145deg) translateZ(0);
  z-index: 0;
}
.ml-book:hover > .ml-page li:nth-child(1) { transform: rotateY(-30deg); transition-duration: 1.5s; }
.ml-book:hover > .ml-page li:nth-child(2) { transform: rotateY(-35deg); transition-duration: 1.8s; }
.ml-book:hover > .ml-page li:nth-child(3) { transform: rotateY(-118deg); transition-duration: 1.6s; }
.ml-book:hover > .ml-page li:nth-child(4) { transform: rotateY(-130deg); transition-duration: 1.4s; }
.ml-book:hover > .ml-page li:nth-child(5) { transform: rotateY(-140deg); transition-duration: 1.2s; }

.ml-page .ml-btn {
  display: inline-block;
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2a6c;
  color: #fff;
  padding: 8px 22px;
  border-radius: 40px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  border: 2px solid #1a2a6c;
  transition: 0.3s ease;
  white-space: nowrap;
  z-index: 20;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  font-family: 'Vazirmatn', sans-serif;
}
.ml-page .ml-btn i {
  margin-left: 8px;
}
.ml-page .ml-btn:hover {
  background: transparent;
  color: #1a2a6c;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transform: translateX(-50%) scale(1.05);
}

.ml-coverDesign {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  overflow: hidden;
  backface-visibility: hidden;
  border-radius: 0 8px 8px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px 12px;
  text-align: center;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2);
}
.ml-coverDesign .ml-book-title {
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1.4;
  text-shadow: 0 3px 10px rgba(0,0,0,0.3);
  margin-bottom: 6px;
  word-break: break-word;
}
.ml-coverDesign .ml-book-author {
  font-size: 0.75rem;
  opacity: 0.95;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.18);
  padding: 4px 16px;
  border-radius: 30px;
  backdrop-filter: blur(2px);
  margin-top: 4px;
}
.ml-coverDesign .ml-book-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fdbb2d;
  color: #1e293b;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 4px 14px;
  border-radius: 30px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  letter-spacing: 0.3px;
}

/* ============================================
   FOOTER
   ============================================ */
.ml-library-footer {
  width: 100%;
  max-width: 1200px;
  margin: 60px auto 20px;
  background: #ffffff;
  border-radius: 24px;
  padding: 45px 40px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.05);
  text-align: center;
}
.ml-library-footer h2 {
  font-size: 2rem;
  margin-bottom: 12px;
  color: #1a2a6c;
}
.ml-library-footer p {
  color: #64748b;
  line-height: 2;
  font-size: 1.05rem;
  max-width: 800px;
  margin: 0 auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media screen and (max-width: 1024px) {
  .ml-align > li { width: 180px; }
  .ml-book { width: 165px; height: 230px; }
  .ml-coverDesign .ml-book-title { font-size: 1rem; }
}
@media screen and (max-width: 768px) {
  .ml-library-wrapper { padding: 12px; }
  .ml-library-header h1 { font-size: 2.4rem; }
  .ml-category-tabs button { padding: 12px 20px; font-size: 0.9rem; }
  .ml-align { gap: 25px 20px; }
  .ml-align > li { width: 155px; min-height: 240px; }
  .ml-book { width: 140px; height: 195px; }
  .ml-coverDesign .ml-book-title { font-size: 0.9rem; }
  .ml-page .ml-btn { font-size: 0.7rem; padding: 6px 16px; bottom: 14px; }
  .ml-library-footer { padding: 30px 20px; }
}
@media screen and (max-width: 480px) {
  .ml-align > li { width: 140px; }
  .ml-book { width: 125px; height: 175px; }
  .ml-coverDesign .ml-book-title { font-size: 0.8rem; }
  .ml-coverDesign .ml-book-author { font-size: 0.6rem; padding: 2px 12px; }
  .ml-page .ml-btn { font-size: 0.6rem; padding: 4px 12px; bottom: 10px; }
  .ml-category-tabs button { padding: 8px 14px; font-size: 0.75rem; }
}