/* Gruvbox Dark Color Palette */
:root {
  --bg: #282828;        /* Background */
  --fg: #fbf1c7;        /* Foreground/Text */
  --red: #fb4934;       /* Red */
  --green: #b8bb26;     /* Green */
  --yellow: #fabd2f;    /* Yellow */
  --blue: #83a598;      /* Blue */
  --purple: #d3869b;   /* Purple */
  --aqua: #8ec07c;      /* Aqua */
  --orange: #fe8019;    /* Orange */
  --gray: #928374;      /* Gray */
}

/* Base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'JetBrains Mono', monospace;
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

/* Header styles */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 0;
  margin-bottom: 2rem;
  position: relative;
}

.profile-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.5rem;
}

.profile-img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px solid var(--purple);
  object-fit: cover;
  margin-bottom: 1rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.profile-img:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(211, 134, 155, 0.4);
}

.name {
  font-size: 2rem;
  font-weight: 600;
  color: var(--fg);
  text-align: center;
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

.name:hover {
  color: var(--yellow);
}

.homepage-link {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background-color: transparent;
  color: var(--aqua);
  border: 1px solid var(--aqua);
  border-radius: 20px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  text-align: center;
}

.homepage-link:hover {
  background-color: rgba(142, 192, 124, 0.1);
  color: var(--yellow);
  transform: translateY(-2px);
}

/* Search functionality */
.search-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--blue);
  border-radius: 25px;
  padding: 0.5rem 1rem;
  z-index: 1000;
  opacity: 1;
  transform: translateX(0);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-container.hidden {
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}

.search-icon {
  margin-right: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--blue);
  transition: color 0.3s ease;
}

.search-icon:hover {
  color: var(--yellow);
}

.search-input {
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 0.3rem 0.5rem;
  width: 0;
  opacity: 0;
  transition: all 0.3s ease;
  font-family: 'JetBrains Mono', monospace;
}

.search-input:focus {
  outline: none;
}

.search-container.active .search-input {
  width: 200px;
  opacity: 1;
  margin: 0 0.5rem;
}

.close-search {
  display: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--red);
  transition: color 0.3s ease;
  font-weight: bold;
}

.search-container.active .close-search {
  display: block;
}

.close-search:hover {
  color: var(--orange);
}

/* Container and posts */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
}

.posts-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Post item styles (for the list view) */
.post-item {
  background-color: rgba(40, 40, 40, 0.9);
  border: 1px solid var(--blue);
  border-radius: 8px;
  padding: 1.2rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(20px);
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
}

.post-item.visible {
  opacity: 1;
  transform: translateY(0);
}

.post-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
  border-color: var(--yellow);
}

.post-preview-container {
  flex-shrink: 0;
  width: 120px;
  min-width: 120px;
  height: 80px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
}

.post-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gray);
  display: block;
}

.post-info {
  flex: 1;
}

.post-title-clickable {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--green);
  cursor: pointer;
  transition: color 0.3s ease;
  margin-top: 0;
}

.post-title-clickable:hover {
  color: var(--yellow);
  text-decoration: underline;
}

.post-description {
  color: #d5c4a1;
  margin-bottom: 0;
  font-style: italic;
}

/* Modal styles for full post content */
.post-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(40, 40, 40, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.post-modal {
  background-color: var(--bg);
  border: 1px solid var(--blue);
  border-radius: 8px;
  max-width: 90%;
  max-height: 90%;
  width: 800px;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--blue);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.8rem;
  color: var(--green);
  margin: 0;
}

.close-modal {
  font-size: 2rem;
  cursor: pointer;
  color: var(--red);
  transition: color 0.3s ease;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.close-modal:hover {
  color: var(--orange);
  background-color: rgba(40, 40, 40, 0.5);
}

.modal-content {
  padding: 1.5rem;
}

.modal-preview {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--gray);
  display: block;
}

.full-post-content {
  color: var(--fg);
  line-height: 1.7;
}

.full-post-content h1,
.full-post-content h2,
.full-post-content h3,
.full-post-content h4,
.full-post-content h5,
.full-post-content h6 {
  margin: 1.5rem 0 1rem 0;
  color: var(--aqua);
}

.full-post-content p {
  margin-bottom: 1rem;
}

/* Ensure markdown images fit within the modal/content width */
.full-post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.5rem auto;
}

.full-post-content a {
  color: var(--blue);
  text-decoration: none;
}

.full-post-content a:hover {
  color: var(--yellow);
  text-decoration: underline;
}

.full-post-content ul,
.full-post-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.full-post-content li {
  margin-bottom: 0.5rem;
}

.full-post-content code {
  background-color: rgba(40, 40, 40, 0.8);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--orange);
}

.full-post-content pre {
  background-color: rgba(40, 40, 40, 0.8);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
}

.full-post-content pre code {
  background: none;
  padding: 0;
  color: var(--fg);
}

/* Loading state */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--fg);
  font-style: italic;
}

/* Performance optimized animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease forwards;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-right {
  animation: slideInRight 0.4s ease forwards;
  will-change: transform, opacity; /* Optimize for animation performance */
}

/* Optimize search container animation */
.search-container {
  will-change: transform, opacity; /* Optimize for animation performance */
}

/* Optimize post item hover effects */
.post-item {
  will-change: transform; /* Optimize for animation performance */
}

/* Responsive design */
@media (max-width: 992px) {
  .container {
    max-width: 95%;
  }
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .header {
    padding: 1rem 0;
  }
  
  .profile-img {
    width: 100px;
    height: 100px;
  }
  
  .name {
    font-size: 1.7rem;
  }
  
  .search-container {
    top: 10px;
    right: 10px;
    padding: 0.3rem 0.8rem;
  }
  
  .search-input {
    width: 0;
  }
  
  .search-container.active .search-input {
    width: 150px;
  }
  
  .post-item {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .post-preview-container {
    width: 100%;
    height: 150px;
    min-width: auto;
    min-height: auto;
  }
  
  .post-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  
  .post-title-clickable {
    font-size: 1.2rem;
  }
  
  .post-modal {
    width: 95%;
    max-width: 95%;
  }
}

@media (max-width: 480px) {
  .name {
    font-size: 1.5rem;
  }
  
  .profile-img {
    width: 80px;
    height: 80px;
  }
  
  .search-container {
    top: 5px;
    right: 5px;
  }
  
  .search-container.active .search-input {
    width: 120px;
  }
  
  .post-title-clickable {
    font-size: 1.1rem;
  }
  
  .post-item {
    padding: 0.8rem;
  }
  
  .modal-header {
    padding: 1rem;
  }
  
  .modal-content {
    padding: 1rem;
  }
  
  .modal-title {
    font-size: 1.5rem;
  }
}

/* Extra small devices */
@media (max-width: 360px) {
  .name {
    font-size: 1.3rem;
  }
  
  .profile-img {
    width: 70px;
    height: 70px;
  }
  
  .post-title-clickable {
    font-size: 1rem;
  }
  
  .search-container.active .search-input {
    width: 80px;
  }
}

/* Ensure search bar works well on mobile */
@media (max-width: 480px) {
  .search-container {
    position: sticky;
    right: auto;
    left: 0;
    top: 0;
    width: 100%;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--blue);
    padding: 0.8rem;
  }
  
  .search-container.active {
    position: fixed;
    z-index: 1001;
  }
  
  .search-input {
    flex: 1;
  }
  
  .search-container.active .search-input {
    width: calc(100% - 60px);
  }
}

/* Responsive modal */
@media (max-width: 768px) {
  .post-modal {
    max-width: 95%;
    max-height: 95%;
  }
  
  .modal-preview {
    max-height: 200px;
  }
}

/* Extra small devices preview */
@media (max-width: 480px) {
  .post-preview-container {
    width: 100%;
    height: 120px;
    min-width: auto;
    min-height: auto;
  }
}