/* ===== projects.css ===== */

/* تنظیم کلی باکسینگ */
.projects * {
  box-sizing: border-box;
}

/* صفر کردن margin و padding */
.projects,
.projects html,
.projects body {
  margin: 0;
  padding: 0;
}

/* کانتینر اصلی */
.projects {
  padding: 2rem 0;
  font-family: sans-serif;
  background: #1c1c1c;
  color: #fff;
  display: flex;
  align-items: flex-start;
  margin-top: 200px;
}

/* حذف عنوان عمودی */
.projects__title {
  display: none;
}

/* Wrapper برای دکمه‌ها و گرادیان لبه */
.projects__wrapper {
  position: relative;
  flex: 1;
}
.projects__wrapper::before,
.projects__wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2rem;
  pointer-events: none;
  z-index: 5;
}
.projects__wrapper::before {
  left: 0;
  background: linear-gradient(to right, #1c1c1c 0%, transparent 100%);
}
.projects__wrapper::after {
  right: 0;
  background: linear-gradient(to left, #1c1c1c 0%, transparent 100%);
}

/* کاروسل */
.projects__carousel {
  overflow-x: auto;
  white-space: nowrap;
  scroll-behavior: smooth;
  padding: 0 1rem 1rem;
  scrollbar-width: none;
  position: relative;
  /* مرز نازک بالای اسلایدر */
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.projects__carousel::-webkit-scrollbar {
  height: 0;
}
.projects__carousel:hover {
  scrollbar-width: thin;
}
.projects__carousel:hover::-webkit-scrollbar {
  height: 8px;
}
.projects__carousel:hover::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}
.projects__carousel:hover::-webkit-scrollbar-thumb {
  background: rgb(40, 44, 86);
  border-radius: 4px;
  transition: background 0.2s;
}
.projects__carousel:hover::-webkit-scrollbar-thumb:hover {
  background: rgb(40, 44, 86);
}
.projects__carousel {
  scrollbar-color: rgb(249, 201, 0) #1c1c1c;
}

/* استایل اولیه آیتم‌ها (بدون انیمیشن) */
.projects__carousel .item {
  display: inline-block;
  position: relative;
  width: calc((100% - 3rem) / 4);
  margin-left: 1rem;
  border-radius: 4px;
  overflow: hidden;
  vertical-align: top;
  background: #000;
  opacity: 0;
  transform: translateY(20px);
  animation: none;
}

/* اولین آیتم لبه چپ را بچسباند */
.projects__carousel .item:first-child {
  margin-left: 0;
}

/* وقتی کاروسل دیده شد، انیمیشن را فعال کن */
.projects__carousel.visible .item {
  animation: projects-slideIn 0.6s ease-out forwards;
}

/* تنظیم تأخیر بر اساس متغیر --i */
.projects__carousel.visible .item:nth-child(1) { --i: 1; }
.projects__carousel.visible .item:nth-child(2) { --i: 2; }
.projects__carousel.visible .item:nth-child(3) { --i: 3; }
.projects__carousel.visible .item:nth-child(4) { --i: 4; }
.projects__carousel.visible .item:nth-child(5) { --i: 5; }
.projects__carousel.visible .item:nth-child(6) { --i: 6; }
.projects__carousel.visible .item:nth-child(7) { --i: 7; }
.projects__carousel.visible .item:nth-child(8) { --i: 8; }

.projects__carousel.visible .item {
  animation-delay: calc(0.1s * var(--i));
}

/* کلیدفریم انیمیشن slideIn */
@keyframes projects-slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* تصویر داخل آیتم */
.projects__carousel .item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  will-change: transform;
}
.projects__carousel .item:hover img {
  transform: scale(1.1);
}

/* اورلِی متن */
.projects__carousel .item .overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  transition: background 0.3s ease;
}
.projects__carousel .item:hover .overlay {
  background: linear-gradient(transparent, rgba(0,0,0,0.9));
}
.projects__carousel .item .overlay h3,
.projects__carousel .item .overlay p {
  margin: 0;
  line-height: 1.2;
}
.projects__carousel .item .overlay h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}
.projects__carousel .item .overlay p {
  font-size: 0.85rem;
  color: #ddd;
}

/* دکمه‌های ناوبری (در صورت استفاده) */
.btn.prev,
.btn.next {
  display: none;
}
/* ===== مدیا کوئری واکنش‌گرایی ===== */

/* موبایل: تا 480px (یک آیتم در هر اسکرول) */
/* موبایل: تا 480px */
@media (max-width: 480px) {
  .projects__carousel .item {
    width: 80%; /* قبلاً 100% بود */
    margin-left: 1rem;
  }
  .projects__carousel .item:first-child {
    margin-left: 0;
  }

  .projects {
    padding: 1rem 0;
  }
  .projects__carousel {
    padding: 0 0.5rem 1rem;
  }
  .projects__carousel .item .overlay h3 {
    font-size: 0.9rem;
  }
  .projects__carousel .item .overlay p {
    font-size: 0.75rem;
  }
}


/* تبلت کوچک: 481px تا 768px (دو آیتم) */
@media (min-width: 481px) and (max-width: 768px) {
  .projects__carousel .item {
    width: calc((100% - 1rem) / 2);
    margin-left: 1rem;
  }
  .projects__carousel .item:first-child {
    margin-left: 0;
  }
}

/* تبلت بزرگ/لپ‌تاپ کوچک: 769px تا 1024px (سه آیتم) */
@media (min-width: 769px) and (max-width: 1024px) {
  .projects__carousel .item {
    width: calc((100% - 2rem) / 3);
    margin-left: 1rem;
  }
  .projects__carousel .item:first-child {
    margin-left: 0;
  }
}

/* بزرگ‌تر از 1024px: همان چهار آیتم اصلی */
@media (min-width: 1025px) {
  .projects__carousel .item {
    width: calc((100% - 3rem) / 4);
  }
}

/* برای بهبود لمس و اسکرول در موبایل */
.projects__carousel {
  -webkit-overflow-scrolling: touch;
}

/* در صورت نیاز می‌توانید دکمه‌های ناوبری را فعال کنید */
.btn.prev,
.btn.next {
  display: block;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  z-index: 10;
}
.btn.prev { left: 0.5rem; }
.btn.next { right: 0.5rem; }

/* و در JS اضافه کنید که با کلیک روی این دکمه‌ها کاروسل اسکرول کند: */
@media (max-width: 768px) {
  .projects__carousel {
    scrollbar-width: auto !important; /* Firefox */
  }
  .projects__carousel::-webkit-scrollbar {
    height: 8px !important; /* Chrome, Safari, Opera */
  }
}
