.posts-wrapper {
  padding: 16px 20px 20px 20px;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin: 0 auto;
}

#posts {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

#post {
  padding: 0;
  flex: 1;
  min-width: 0;

  & article {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--light-gray);
  }

  & .header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
  }

  /* Dropdown */
  & .sort-dropdown {
    position: relative;
    display: inline-block;
  }

  & .sort-button {
    padding: 0 20px;
    height: 44px;
    max-height: 44px;
    background-color: var(--white);
    border: 1px solid var(--dark-gray);
    border-radius: 30px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s ease;
  }

  & .sort-button:hover {
    background-color: var(--light-gray);
  }

  & .dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    left: 0;
    background-color: var(--white);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    z-index: 1;
    border: 0.5px solid var(--dark-gray);
    overflow: hidden;
    margin-top: 1px;
  }

  & .sort-dropdown:hover .dropdown-content {
    display: block;
  }

  & .sort-link {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--dark-gray);
  }

  & .sort-link:hover {
    background-color: var(--light-gray);
  }

  & .sort-link.active {
    background-color: var(--white);
  }

  & #search-container {
    display: block;
    flex: 1 1 100%;
  }

  & #search-results {
    width: 100%;
  }

  & #search-form {
    width: 100%;
  }

  & .action-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  & .new-link-wrapper {
    display: block;
    border: 0.5px solid var(--dark-gray);
    height: 44px;
    border-radius: 30px;
    max-height: 44px;
    transition: background-color 0.2s ease;
  }

  & .new-link-wrapper:hover {
    background-color: var(--light-gray);
  }

  & .new-link-wrapper a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 16px;
    gap: 8px;
  }

  & h2 {
    font-size: 1.25rem;
    margin: 6px 0;
    color: var(--black);
    line-height: 1.4;
  }

  & .post-link-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: inherit;
  }

  & .active {
    background-color: var(--black);
  }

  & .post-topic {
    display: flex;
    align-items: center;
  }

  & .user-avatar {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    margin-right: 5px;
  }

  & .post-user {
    display: flex;
    align-items: center;
  }

  & .post-topic-image {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    margin-right: 4px;
  }

  & .post-topic-date {
    color: var(--dark-gray);
    margin-left: 5px;
  }

  & .post-info-container {
    display: flex;
    align-items: center;
    margin: 12px -20px 0;
    gap: 16px;
    padding: 12px 20px 0;
    border-top: 1px solid var(--light-gray);
  }

  & h3 {
    font-size: 0.9rem;
    color: var(--dark-gray);
    margin-bottom: 0;
    margin-right: 4px;
  }

  & .post-user-name {
    font-size: 0.9rem;
    color: var(--dark-gray);
  }

  & .post-like-container {
    display: flex;
    align-items: center;
    gap: 1px;
  }
}

.posts-divider {
  margin: 1rem -20px;
  border: 0;
  border-top: 1px solid var(--light-gray);
  opacity: 1;
}

.post-topics-aside {
  display: block;
  position: fixed;
  top: 0;
  left: -100%;
  height: 100vh;
  width: 85%;
  max-width: 300px;
  background-color: var(--white);
  z-index: 11;
  transition: left 0.3s ease;
  overflow-y: auto;
  padding: 20px;
}

.online-users {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  color: var(--dark-gray);
}

.dot-icon {
  width: 10px;
  height: 10px;
  fill: var(--green);
  animation: ripple 1.5s 3;
}

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

.post-topics-aside.active {
  left: 0;
}

/* Overlay when sidebar is open */
.topics-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.topics-overlay.active {
  display: block;
  opacity: 1;
}

aside .post-topics {
  border-radius: 0;
  padding: 20px 0;
  background: var(--white);
}

aside .post-topics h3 {
  margin-bottom: 10px;
  color: var(--dark-gray);
}

aside .post-topics ul {
  list-style-type: none;
  padding: 0;
}

aside .post-topics li {
  margin-bottom: 8px;
}

aside .post-topics .topic-link {
  text-decoration: none;
  color: var(--dark-gray);
  transition: color 0.3s ease, background-color 0.3s ease;
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
}

aside .post-topics .topic-link-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

aside .post-topics .topic-image {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

aside .post-topics .topic-count {
  margin-left: auto;
  background-color: var(--light-gray);
  color: var(--dark-gray);
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 12px;
}

aside .post-topics .topic-link:hover {
  background-color: var(--light-gray);
}

aside .post-topics .topic-link.active {
  background-color: var(--gray);
  color: var(--white);
}

aside .post-topics .topic-link.active span {
  color: var(--white);
}

aside .post-topics .topic-link.active .topic-count {
  background-color: var(--white);
  color: var(--dark-gray);
}

.icon-heart,
.icon-comment {
  width: 24px;
  height: 24px;
  fill: var(--dark-gray);
  transition: fill 0.3s ease;
}

@media (min-width: 1024px) {
  #post {
    & .sort-dropdown,
    & .action-right,
    & #search-container {
      flex: none;
    }

    & #search-container {
      min-width: 400px;
    }

    & .sort-dropdown {
      order: 1;
    }

    & .action-right {
      order: 3;
    }

    & #search-container {
      order: 2;
    }
  }

  .post-topics-aside {
    position: sticky;
    top: calc(4.375rem + 20px);
    width: 300px;
    height: calc(100vh - 40px);
    box-shadow: none;
    overflow-y: auto;
    padding: 0;
    z-index: 0;
  }

  aside .post-topics {
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--light-gray);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }

  .mobile-topics-toggle {
    display: none;
  }

  .topics-overlay {
    display: none !important;
  }

  .posts-wrapper {
    padding: 24px 48px;
    gap: 48px;
  }
}
