html {
  scroll-behavior: smooth;
}

header {
  position: sticky;
  top: 0;
  z-index: 1000;
}


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

body{
    font-family: Arial, sans-serif;
    background-color: #eee;
    color: #333;
    line-height: 1.6;
}

header{
    background-color: #fff;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
}

header h1{
    font-size: 1.5rem;
}

.search-wrapper {
    position: relative;
    display: inline-block;
}

#search-input {
    padding-right: 40px; /* Space for the icon inside the input */
    height: 36px;
    font-size: 14px;
}

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
}

nav ul{
    display: flex;
    list-style: none;
    gap: 1rem;
}

nav a{
   text-decoration: none;
   color: #333;
   font-weight: bold; 
}

#theme-toggle{
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

main{
    display: flex;
    margin: 2rem;
}

aside{
    width: 25%;
    background-color: #fff;
    padding: 1rem;
    margin-right: 2rem;
    border: 1px solid #eee;
}

#main-content{
    width: 75%;
}


section{
    margin-bottom: 2rem;
    scroll-margin-top: 80px;
}

#popular-posts,
#latest-articles{
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(250px,1fr));
    gap: 1rem;
    
}

.blog-card{
    background-color: #fff;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    
}

.blog-card h3{
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-card:hover{
    transform: scale(1.02);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

#write-post-btn{
    background-color: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.edit-btn,
.delete-btn{
    cursor: pointer;
    min-height: 44px;
    margin-bottom: 0.5rem;
    display: inline-block;
    margin-right: 0.5rem;
}

#write-post-form{
    display: none;
    background-color: #fff8e1;
    border: 2px solid #ff9800;
    border-radius: 12px;
    padding: 2rem;
    width: 80%;
    font-family: 'Poppins',sans-serif;
    transition: transform 0.3s ease;
    margin: 2rem auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);

}

#write-post-form input,
#write-post-form textarea,
#write-post-form select{
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
}

#write-post-form button[type='submit']{
    background-color: #ff9800;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

#write-post-btn:hover{
    background-color: #0056b3;
}

#write-post-form:hover{
   transform: scale(1.02);
}

#write-post-form button[type='submit']:hover{
    background-color: #f57c00;
}

#cancel-btn{
    background-color: crimson;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    float: right;

}

/* dark mode styles */

body.dark-mode{
    background-color: #121212;
    color: #eee;
}


body.dark-mode header,
body.dark-mode aside,
body.dark-mode .blog-card{
    background-color: #1e1e1e;
    color: #eee;
    border-color: #333;
}

body.dark-mode a{
    color: #ddd;
}

.blog-card img {
    border-radius: 8px;
    margin-bottom: 10px;
}

.blog-card img {
  max-width: 100%;
  height: auto;
  display: block;
  height: 200px;
  object-fit: cover;
}

.post-content.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 2; /* show only 2 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-content.expanded {
  display: block;
}
.post-content{
  transition: max-height 0.3s ease;
}
/* Responsive layout for mobile screens */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.5rem;
  }

  header h1{
    font-size: 1rem;
  }

  nav a{
    display: inline-block;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    text-align: center;
    display: block;
  }

  .search-wrapper {
    width: 100%;
  }

  nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    padding-left: 0;
    width: 100%;
    padding-left: 0;
  }

  main {
    flex-direction: column;
    margin: 1rem;
  }

  aside {
    width: 100%;
    margin-right: 0;
    margin-bottom: 1rem;
  }

  #main-content {
    width: 100%;
  }

  #write-post-form {
    width: 100%;
    padding: 1rem;
  }

  #search-input {
    width: 100%;
    box-sizing: border-box;
  }

  #write-post-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
  }

  #cancel-btn {
    width: 100%;
    float: none;
    margin-top: 1rem;
  }

  .blog-card {
    font-size: 0.95rem;
    padding: 1rem;
  }
  #theme-toggle{
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.2rem;
  }

  .blog-card {
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
  }
}
