.projectsContainer {
  display: grid;
  grid-template-columns: 1fr;
  margin: 5em 1em;
}

.projectTitleContainer {
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 1.5em;
}

.projectTitleContainer h2 {
  border-bottom: 3px solid var(--color-text);
  display: inline-block;
  padding-bottom: 0.5em;
  font-size: var(--font-size-h2);
}

#anchor-project {
  scroll-margin-top: 5em;
}

.project-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  overflow-y: auto;
  padding: 2em 1em;
  box-sizing: border-box;
}

.project-modal.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--color-surface);
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 1em;
  right: 1em;
  background: rgba(0, 0, 0, 0.5);
  color: var(--color-text);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5em;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.modal-image-container {
  width: 100%;
  height: 300px;
  overflow: hidden;
}

.modal-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-details {
  padding: 2em;
  color: var(--color-text);
}

.modal-title {
  font-size: var(--font-size-h2);
  margin-bottom: 0.5em;
  text-transform: capitalize;
  color: var(--color-accent);
}

.modal-description {
  line-height: 1.5;
  margin-bottom: 1.5em;
  font-size: var(--font-size-p);
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em;
  margin-bottom: 2em;
}

.modal-tags .tag {
  background: var(--color-accent);
  color: var(--color-text);
  padding: 0.5em 1em;
  border-radius: 12px;
  font-size: 0.8em;
  text-transform: capitalize;
}

.modal-actions {
  display: flex;
  gap: 1em;
  flex-wrap: wrap;
}

.modal-btn {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.8em 1.5em;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.modal-btn img {
  width: 20px;
  height: 20px;
}

.github-btn,
.demo-btn {
  background: var(--color-accent);
  color: var(--color-text);
}

.github-btn:hover,
.demo-btn:hover {
  background: var(--color-text);
  color: var(--color-accent);
}

.filter-icon-container {
  position: relative;
  display: inline-block;
  margin-bottom: 1.5em;
}

.filter-toggle {
  background: transparent;
  color: var(--color-text);
  border: none;
  padding: 0.6em;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-icon {
  width: 20px;
  height: 20px;
}

.filter-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-surface);
  border-radius: 8px;
  padding: 1.5em;
  width: 280px;
  z-index: 100;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  margin-top: 0.5em;
}

.filter-dropdown.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-section {
  margin-bottom: 1.2em;
}

.filter-section h3 {
  font-size: 1em;
  margin-bottom: 0.7em;
  color: var(--color-accent);
  border-bottom: 1px solid var(--color-text);
  padding-bottom: 0.3em;
  text-transform: capitalize;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.filter-options label {
  display: flex;
  align-items: center;
  gap: 0.5em;
  cursor: pointer;
  font-size: 0.9em;
  transition: color 0.2s;
}

.filter-options label:hover {
  color: var(--color-accent);
}

.filter-options input[type="checkbox"] {
  accent-color: var(--color-accent);
}

.filter-actions {
  display: flex;
  gap: 0.8em;
  margin-top: 1em;
}

.filter-actions button {
  padding: 0.6em 1em;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.3s ease;
}

.apply-filters {
  background: var(--color-accent);
  color: var(--color-text);
  flex: 2;
}

.apply-filters:hover {
  background: var(--color-accent);
}

.clear-filters {
  background: var(--color-text);
  color: var(--color-background);
  border: none;
  flex: 1;
}

.clear-filters:hover {
  background: rgba(255, 255, 255, 0.1);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em;
}

.active-filter {
  background: var(--color-accent);
  color: var(--color-text);
  padding: 0.8em 0.4em 0.8em 1.2em;
  border-radius: 20px;
  font-size: 0.8em;
  display: flex;
  align-items: center;
  gap: 0.5em;
  text-transform: capitalize;
}

.active-filter button {
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.projects-grid {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  max-height: 70vh;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.projects-grid::-webkit-scrollbar {
  display: none;
}

.projectItem {
  flex: 0 0 auto;
  scroll-snap-align: center;
  width: 100%;
  max-width: clamp(280px, 90%, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: center;
  transition: opacity 0.4s ease, transform 0.4s ease;
  box-sizing: border-box;
  padding: 1em;
}

.projectItem.hide {
  display: none;
}

.projectDescriptionContainer {
  color: var(--color-text);
  border-radius: 10px;
  background-color: var(--color-surface);
  text-align: center;
  padding: 1.2em;
  width: 100%;
  margin-top: 1em;
  box-sizing: border-box;
  word-wrap: break-word;
}

.projectDescriptionContainer h2 {
  font-size: var(--font-size-h2);
  text-transform: capitalize;
  margin-bottom: 0.5em;
}

.projectImage {
  width: 100%;
  border-radius: 10px;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.projectImage:hover {
  transform: scale(1.02);
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  justify-content: center;
  margin-top: 0.8em;
}

.tag {
  background: var(--color-accent);
  color: var(--color-text);
  padding: 0.5em 1em;
  border-radius: 12px;
  font-size: 0.7em;
  text-transform: capitalize;
}

.scroll-arrows {
  display: none;
}

.project-image-link {
  display: block;
  cursor: pointer;
}

@media (width >=768px) and (width < 1024px) {
  .projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    overflow-x: hidden;
    overflow-y: auto;
    margin-bottom: 10em;
    gap: 2em;
  }

  .filter-dropdown {
    width: 320px;
  }

  .scroll-arrows {
    display: none;
  }

  .projectItem {
    max-width: none;
    width: 100%;
  }
}

@media (width >=1024px) and (width < 1400px) {
  .projects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: hidden;
    overflow-y: auto;
    margin-bottom: 10em;
    gap: 2em;
  }

  .filter-dropdown {
    width: 320px;
  }

  .scroll-arrows {
    display: none;
  }

  .projectItem {
    max-width: none;
    width: 100%;
  }
}

@media (width >=1400px) {
  .projectsContainer {
    margin: 7em 10em 20em 10em;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 60px;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "title . . . arrows"
      "filter filter filter filter arrows"
      "projects projects projects projects arrows";
    gap: 1em 1.5em;
  }

  .projectTitleContainer {
    grid-area: title;
    margin-bottom: 0;
    margin-left: -8em;
  }

  .filter-icon-container {
    grid-area: filter;
    justify-self: end;
    align-self: start;
    margin-bottom: 0;
  }

  .active-filters {
    grid-area: filter;
    align-self: start;
    justify-self: start;
    margin: 0;
  }

  .projects-grid {
    grid-area: projects;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2em;
    overflow-y: auto;
    max-height: 740px;
    padding-right: 10px;
    margin-bottom: 0;
    scroll-behavior: smooth;
  }

  .projects-grid::-webkit-scrollbar {
    width: 6px;
  }

  .projects-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
  }

  .projects-grid::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 3px;
  }

  .projects-grid::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
    opacity: 0.8;
  }

  .scroll-arrows {
    grid-area: arrows;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5em;
    margin-top: 0;
    margin-bottom: 0.5em;
  }

  .scroll-arrows a {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .scroll-arrows img {
    width: 25px;
    height: 25px;
  }

  .scroll-arrows a:first-child img {
    transform: rotate(0);
  }

  .scroll-arrows a:last-child img {
    transform: rotate(180deg);
  }

  .filter-dropdown {
    left: auto;
    right: 0;
  }

  .projectItem {
    max-width: none;
    width: 100%;
    padding: 0.8em;
    height: 360px;
  }

  .projectDescriptionContainer {
    padding: 0.9em;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .projectDescriptionContainer h2 {
    font-size: 1.1em;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
  }

  .projectDescriptionContainer p {
    font-size: 0.85em;
    line-height: 1.4;
    flex-grow: 1;
  }

  .project-tags {
    margin-top: 0.7em;
    gap: 0.4em;
  }

  .tag {
    padding: 0.4em 0.8em;
    font-size: 0.65em;
  }

  #anchor-project {
    min-height: 400px;
  }
}

@media (width <=768px) {
  .modal-image-container {
    height: 200px;
  }

  .modal-details {
    padding: 1.5em;
  }

  .modal-title {
    font-size: var(--font-size-h2);
  }

  .modal-actions {
    flex-direction: column;
  }

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