/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

a {
  color: #0066cc;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
header {
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
}

header h1 {
  font-size: 24px;
}

header h1 a {
  color: #333;
  text-decoration: none;
}

/* Navigation */
nav ul {
  list-style: none;
  display: flex;
  gap: 20px;
}

nav a {
  color: #333;
  font-weight: 500;
}

nav li.active a {
  color: #0066cc;
}

/* Search Bar */
.search-bar form {
  display: flex;
  gap: 10px;
}

.search-bar input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 200px;
}

.search-bar button {
  padding: 8px 16px;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.search-bar button:hover {
  background: #0052a3;
}

/* Main Layout */
main {
  display: flex;
  gap: 30px;
  margin-top: 30px;
  min-height: 70vh;
}

.content {
  flex: 1;
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Sidebar */
.sidebar {
  width: 300px;
}

.widget {
  background: white;
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.widget h3 {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #0066cc;
}

.widget ul {
  list-style: none;
}

.widget li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.widget li:last-child {
  border-bottom: none;
}

/* Posts Grid - Updated for 5 columns */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.post-card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.post-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Thumbnail with 2:3 aspect ratio */
.post-card .thumbnail-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 150%; /* 2:3 aspect ratio (3/2 = 1.5 = 150%) */
  overflow: hidden;
  background: #f0f0f0;
}

.post-card img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* No image placeholder */
.post-card .no-thumbnail {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #999;
  font-size: 14px;
  text-align: center;
}

/* Title with uniform height */
.post-card .card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 15px;
}

.post-card h2 {
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 10px;
  min-height: 2.8em; /* Forces 2 lines minimum */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-card h2 a {
  color: #333;
}

.post-card .excerpt {
  display: none; /* Hide excerpt in grid view */
}

.post-meta {
  margin-top: auto; /* Push to bottom */
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #999;
}

.post-meta .category {
  color: #0066cc;
}

/* Responsive - Mobile (1 column, 20 posts = 20 rows) */
@media (max-width: 768px) {
  .posts-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .post-card {
    display: flex;
    flex-direction: row;
    height: auto;
  }
  
  .post-card .thumbnail-wrapper {
    width: 120px;
    min-width: 120px;
    padding-bottom: 0;
    height: 180px; /* 2:3 ratio: 120x180 */
  }
  
  .post-card .card-content {
    flex: 1;
    padding: 10px 15px;
  }
  
  .post-card h2 {
    font-size: 16px;
    min-height: auto;
    -webkit-line-clamp: 3;
  }
  
  .post-card .excerpt {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Tablet - 3 columns */
@media (min-width: 769px) and (max-width: 1024px) {
  .posts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Large tablets / Small desktop - 4 columns */
@media (min-width: 1025px) and (max-width: 1200px) {
  .posts-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Single Post */
.single-post {
  max-width: 800px;
}

.single-post h1 {
  font-size: 36px;
  margin-bottom: 20px;
}

.single-post .post-meta {
  padding: 0;
  margin-bottom: 30px;
}

.featured-image {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 30px;
}

.post-content {
  font-size: 18px;
  line-height: 1.8;
  color: #444;
}

.post-content p {
  margin-bottom: 20px;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 20px 0;
}

/* Tags */
.tags {
  margin: 30px 0;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.tag {
  display: inline-block;
  background: #f0f0f0;
  padding: 5px 12px;
  border-radius: 20px;
  margin-right: 10px;
  font-size: 14px;
}

/* Related Posts */
.related-posts {
  margin: 40px 0;
  padding: 30px 0;
  border-top: 2px solid #eee;
}

.related-posts h3 {
  margin-bottom: 20px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
}

.related-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
}

.related-item h4 {
  font-size: 14px;
}

/* Comments Section */
.comments-section {
  margin-top: 50px;
  padding-top: 30px;
  border-top: 2px solid #eee;
}

.comment-form {
  background: #f9f9f9;
  padding: 30px;
  border-radius: 8px;
  margin-bottom: 40px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

button[type="submit"] {
  background: #0066cc;
  color: white;
  padding: 12px 30px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
}

button[type="submit"]:hover {
  background: #0052a3;
}

/* Comments List */
.comments-list {
  margin-top: 30px;
}

.comment {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.comment-header .date {
  color: #999;
  font-size: 14px;
  margin-left: auto;
}

.comment-content {
  color: #444;
  line-height: 1.6;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 40px 0;
}

.pagination a {
  padding: 10px 20px;
  background: #0066cc;
  color: white;
  border-radius: 4px;
  text-decoration: none;
}

.pagination a:hover {
  background: #0052a3;
}

.page-info {
  color: #666;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
}

.tab-btn {
  padding: 8px 15px;
  background: #f0f0f0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.tab-btn.active {
  background: #0066cc;
  color: white;
}

.tab-content .views {
  float: right;
  color: #999;
  font-size: 12px;
}

/* Footer */
footer {
  background: #333;
  color: #fff;
  text-align: center;
  padding: 30px 0;
  margin-top: 50px;
}

/* Message Box */
.message-box {
  max-width: 600px;
  margin: 100px auto;
  padding: 40px;
  background: white;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.message-box h1 {
  color: #0066cc;
  margin-bottom: 20px;
}

.message-box p {
  margin-bottom: 20px;
  color: #666;
}

.button {
  display: inline-block;
  padding: 10px 30px;
  background: #0066cc;
  color: white;
  border-radius: 4px;
  text-decoration: none;
}

.button:hover {
  background: #0052a3;
  text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
  header .container {
    flex-direction: column;
    gap: 20px;
  }
  
  main {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
  }
  
  .posts-grid {
    grid-template-columns: 1fr;
  }
  
  nav ul {
    flex-wrap: wrap;
  }
  
  .search-bar input {
    width: 150px;
  }
}
