/* --- Google Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Roboto+Slab:wght@400;700&display=swap');

/* --- CSS Variables (Color Scheme & Typography) --- */
:root {
    --primary-color: #2c3e50;    /* Midnight Blue */
    --secondary-color: #3498db;  /* Peter River Blue */
    --background-color: #f4f6f8; /* Light Gray */
    --surface-color: #ffffff;   /* White */
    --text-color: #34495e;      /* Wet Asphalt */
    --light-text-color: #ecf0f1; /* Clouds */
    --border-color: #dfe4ea;
    --error-color: #e74c3c;

    --font-primary: 'Lato', sans-serif;
    --font-secondary: 'Roboto Slab', serif;

    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* --- General & Reset Styles --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex-grow: 1;
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1, h2, h3 {
    font-family: var(--font-secondary);
    color: var(--primary-color);
    margin-bottom: 1rem;
}

a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-color);
}

/* --- Header & Navigation --- */
header {
    background-color: var(--primary-color);
    color: var(--light-text-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    color: var(--light-text-color);
    margin: 0;
    font-size: 1.5rem;
}

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

header nav a {
    color: var(--light-text-color);
    font-weight: bold;
    padding: 0.5rem;
}

header nav a:hover {
    text-decoration: underline;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important;
}

.container {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

/* --- Form Styles --- */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

form label {
    margin-bottom: 0.5rem;
    font-weight: bold;
}

form input,
form textarea {
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

form input:focus,
form textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

form textarea {
    min-height: 150px;
    resize: vertical;
}

button {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    background-color: var(--secondary-color);
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    align-self: flex-start;
}

button:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
}

.error-message {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}


/* --- Post List (Grid Layout) --- */
#posts-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.post-summary {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-summary:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

.post-meta {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 1rem;
}

.tags span {
    display: inline-block;
    background: var(--background-color);
    color: var(--text-color);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    margin-top: 0.5rem;
}

/* --- Post Detail View --- */
#post-detail .post-content {
    line-height: 1.8;
}

#post-detail .post-meta {
    margin-bottom: 2rem;
}

#comments-section {
    margin-top: 3rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.comment {
    background: var(--background-color);
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--secondary-color);
}

.comment-meta {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.comment-meta span {
    font-weight: normal;
    color: #7f8c8d;
    margin-left: 0.5rem;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 1.5rem;
    background-color: var(--primary-color);
    color: var(--light-text-color);
    margin-top: auto;
}

/* --- Responsive Design (Mobile-First) --- */

/* Tablet and larger */
@media (min-width: 768px) {
    #posts-list {
        grid-template-columns: repeat(2, 1fr);
    }

    header {
        padding: 1rem 4rem;
    }
}

/* Desktop and larger */
@media (min-width: 1024px) {
    #posts-list {
        grid-template-columns: repeat(3, 1fr);
    }
}