*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background-color: #fff;
  color: #000;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Styles */
body.dark-mode {
  background-color: #000;
  color: #fff;
}

body.dark-mode .nav {
  background-color: #000;
  border-bottom-color: #262626;
}

/* Updated: Exclude red heart from filter */
body.dark-mode .icon:not([src*="red.png"]),
body.dark-mode .search-icon,
body.dark-mode .profile-icon,
body.dark-mode .pfp img,
body.dark-mode .avatar-img {
  filter: invert(1) brightness(2);
}

body.dark-mode .post {
  background-color: #000;
}

body.dark-mode .search-bar input {
  background-color: #262626;
  color: #fff;
}

body.dark-mode .search-bar input::placeholder {
  color: #a8a8a8;
}

body.dark-mode .profile,
body.dark-mode .avatar {
  background-color: #262626;
}

body.dark-mode .top-bar {
  border-bottom-color: #262626;
}

body.dark-mode .post-tile {
  background-color: #1a1a1a;
}

/* nav */
.nav {
  position: sticky;
  top: 0;
  width: 100%;
  height: 60px;
  background-color: #fff;
  border-bottom: 1px solid #dbdbdb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 1000;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.icon {
  width: 28px;
  height: 28px;
}

.icon-like {
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.nav-right,
.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-home,
.nav-explore {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dark-mode-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.3s ease;
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
}

.dark-mode-icon {
  display: block;
}

.profile {
  width: 36px;
  height: 36px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #e0e0e0;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.profile-icon {
  width: 24px;
  height: 24px;
}

.pfp {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 50%;
  background-color: #e0e0e0;
  padding: 6px;
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

/* Invert person icons in dark mode */
body.dark-mode .pfp,
body.dark-mode .avatar-img {
  filter: invert(1) brightness(2);
}

.nav-text {
  display: none;
}

/* home page */
.feed {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 0;
}

.post {
  margin-bottom: 24px;
  transition: background-color 0.3s ease;
}

.behind-the-feed {
  font-family: "Inter", sans-serif;
  font-style: italic;
  font-size: 96px;
  font-weight: bold;
  text-align: left;
  line-height: 1.2;
  margin: 0;
  padding: 170px 20px;
  background-color: #000;
  color: #fff;
}

body.dark-mode .behind-the-feed {
  background-color: #fff;
  color: #000;
}

.post-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.post-header .username {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1;
}

.post-image {
  width: 100%;
  height: auto;
  margin: 0;
}

.post-img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  margin: 0;
}

.post-img.grayscale {
  filter: grayscale(100%);
}

.post-actions {
  padding: 12px 16px;
}

.action-icons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.action-icons .icon {
  width: 28px;
  height: 28px;
}

.post-content {
  padding: 12px 16px 0 16px;
}

.caption {
  padding: 0;
  margin: 4px 0;
}

.caption-username {
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 4px 0;
  display: inline;
}

.caption {
  display: inline;
  font-size: 16px;
}

.comments {
  font-weight: 600;
  font-size: 16px;
  margin: 8px 0 4px 0;
}

.comment-username {
  font-weight: 600;
  font-size: 16px;
  margin: 4px 0;
  display: inline;
}

.comment {
  display: inline;
  font-size: 16px;
}

.button {
  padding: 16px;
  text-align: center;
  margin: 12px 16px 50px 16px;
  cursor: pointer;
}

.button p {
  background-color: #e31e24;
  color: white;
  font-size: 24px;
  padding: 12px 24px;
  border-radius: 25px;
  margin: 0;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: "Anton", sans-serif;
}

/* explore page */
.search-bar {
  position: relative;
  width: 100%;
  margin: 16px auto;
  padding: 0 16px;
}

.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  z-index: 1;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 48px;
  border: none;
  border-radius: 8px;
  background-color: #efefef;
  font-size: 16px;
  font-family: "Inter", sans-serif;
  outline: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.search-bar input::placeholder {
  color: #8e8e8e;
  transition: color 0.3s ease;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  margin: 0;
  padding: 0;
}

.search-img {
  width: 100%;
  height: auto;
  aspect-ratio: 1/1;
  object-fit: cover;
  display: block;
}

/* -- Bio Page -- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid #dbdbdb;
  transition: border-color 0.3s ease;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
  column-gap: 32px;
}

.profile-sidebar {
  padding: 32px 24px;
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background-color: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.avatar-img {
  width: 80px;
  height: auto;
  max-width: 100%;
  display: block;
}

.name {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 18px;
}

.username {
  margin-bottom: 30px;
  font-size: 18px;
}

.bio {
  line-height: 1.4;
  margin-bottom: 19px;
  margin-top: 19px;
}

.bio-strong {
  line-height: 1.4;
  font-weight: 700;
}

.content {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stats-row {
  display: flex;
  justify-content: flex-start;
  gap: 40px;
  padding-bottom: 29px;
  padding-top: 9px;
}

.stat-number {
  font-weight: 600;
  margin-bottom: 2px;
  text-align: center;
  padding-bottom: 3px;
}

.stat-label {
  font-size: 13px;
  text-align: center;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.post-tile {
  position: relative;
  overflow: hidden;
  background-color: #000;
  color: #fff;
  transition: background-color 0.3s ease;
}

.post-tile::before {
  content: "";
  display: block;
  padding-top: 100%;
}

.post-inner {
  position: absolute;
  inset: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.post-title {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 6px;
}

footer {
  width: 100%;
  padding: 100px 24px 24px 24px;
  text-align: center;
  font-size: 14px;
  color: #ffffff;
  background-color: #000;
}

body.dark-mode footer {
  background-color: #1a1a1a;
}

/* ---------- Mobile ---------- */
/* - For max width - */
@media (max-width: 968px) {
  .top-bar {
    max-width: 480px;
    margin: 0 auto;
    padding: 12px 16px;
  }

  .page {
    max-width: 480px;
    grid-template-columns: 1fr;
    border-left: none;
    border-right: none;
  }

  .profile-sidebar {
    padding-bottom: 9px;
  }
  .profile-header {
    flex-direction: row;
    align-items: center;
    gap: 24px;
  }

  .avatar {
    width: 72px;
    height: 72px;
    margin-bottom: 0;
  }

  .avatar-img {
    width: 48px;
  }

  .stats-row {
    padding-top: 0;
    padding-bottom: 0;
    gap: 16px;
  }

  .stats-row .stat-number {
    font-size: 16px;
  }

  .stats-row .stat-label {
    font-size: 12px;
  }

  .content {
    padding-top: 16px;
  }

  .posts-grid {
    margin-top: 40px;
    gap: 8px;
  }

  .post-title {
    font-size: 15px;
  }
}

/* - For min width - */
@media (min-width: 768px) {
  .image-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* - For Home Page - */
@media (min-width: 850px) {
  .nav-text {
    display: none;
  }

  .feed {
    max-width: 900px;
    padding: 24px 0;
  }

  .post {
    display: grid;
    grid-template-areas:
      "header header"
      "image content";
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 0;
    margin-bottom: 0;
  }

  .post-header {
    grid-area: header;
  }

  .post-image {
    grid-area: image;
  }

  .post-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .post-content {
    grid-area: content;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 16px;
    gap: 8px;
  }

  .post .button p {
    margin: 0;
  }

  .behind-the-feed {
    font-size: 96px;
    padding: 80px 40px;
    display: flex;
    align-items: center;
    height: 100%;
  }
}