@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Poppins:wght@300;400;600&display=swap');

:root {
    /* Dark Mode (Default) */
    --primary-color: #D4ADFC; /* A richer lavender */
    --secondary-color: #282828; /* Slightly softer charcoal */
    --text-color: #EAEAEA;
    --background-color: #1B1B1B;
    --main-content-background: #222222; /* Slightly lighter dark for main content */
    --header-border-color: var(--primary-color);
}

@media (prefers-color-scheme: light) {
    :root {
        /* Light Mode */
        --primary-color: #C154C1; /* Orchid Pink */
        --secondary-color: #FDFDFD;
        --text-color: #333333;
        --background-color: #F4F4F4;
        --main-content-background: #FFFFFF; /* Pure white for main content */
        --header-border-color: #E0E0E0;
    }
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    background-color: var(--background-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zm12 12V8h-2v4h-4v2h4v4h2v-4h4v-2h-4zM0 34v-4h-2v4H-4v2h4v4h2v-4h4v-2h-4zM0 0v-4h-2V0H-4v2h4v4h2V2h4V0h-4zm12 12V8h-2v4h-4v2h4v4h2v-4h4v-2h-4zM36 0v-4h-2V0H-4v2h4v4h2V2h4V0h-4zm0 12V8h-2v4h-4v2h4v4h2v-4h4v-2h-4zM12 0v-4h-2V0H-4v2h4v4h2V2h4V0h-4zM24 24v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0 12v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm24 0v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-12v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM12 24v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0 12v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM24 0v-4h-2V0H-4v2h4v4h2V2h4V0h-4zM48 24v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM24 12v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM12 48v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm-12 0v-4h-2v4H-4v2h4v4h2v-4h4v-2h-4zm24 0v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0 12v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm24 0v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-12v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM36 48v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm-12 0v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm-12 0v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM48 48v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4z'/%3E%3C/g%3E%3C/g%3E%3C/svg");
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

p {
    line-height: 1.8;
    margin-bottom: 1.8rem;
    max-width: 70ch; /* Optimal line length for readability (70 characters) */
    margin-left: auto;
    margin-right: auto;
}

.qa-section p {
    margin-bottom: 0;
    line-height: 1.7;
}

header {
    background-color: var(--secondary-color);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--header-border-color);
    transition: background-color 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow items to wrap */
}

nav .logo {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--primary-color);
    text-decoration: none;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap; /* Allow nav items to wrap */
}

nav li {
    margin-left: 2rem;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.3s ease;
}

nav a:hover, nav a.active {
    color: var(--primary-color);
    transform: translateY(-2px);
}

main {
    flex: 1;
    padding: 3rem;
    max-width: 900px;
    margin: 2rem auto;
    width: 100%;
    background-color: var(--main-content-background);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 15px;
    transition: background-color 0.3s ease;
}

h1, h2 {
    font-family: 'Playfair Display', serif;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: 0.05em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

footer {
    background-color: var(--secondary-color);
    color: var(--text-color);
    text-align: center;
    padding: 0.25rem;
    margin-top: auto;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

article .post-date {
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
    color: #999;
    margin-bottom: 2rem;
}

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

.qa-section {
    background-color: var(--secondary-color);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.qa-section h2 {
    text-align: left;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.qa-section p {
    margin-bottom: 0;
}

.blog-post-card {
    background-color: var(--secondary-color);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.blog-post-card h2 {
    text-align: left;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    nav {
        flex-direction: column;
        align-items: flex-start;
    }

    nav ul {
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
    }

    nav li {
        margin: 0.5rem 0;
    }

    main {
        padding: 1.5rem;
        margin: 1rem auto;
        border-radius: 8px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }
}

/* Random Image Components */
.image-container {
    max-width: 800px;
    margin: 2rem auto;
    text-align: center;
}

/* Blog-specific image styles */
.blog-image {
    margin: 3rem auto;
    position: relative;
}

.blog-image img {
    border: 1px solid var(--primary-color);
    transition: transform 0.3s ease;
}

.blog-image img:hover {
    transform: scale(1.02);
}

.image-container img {
    max-width: 100%;
    height: auto;
    margin: 1rem auto;
    border-radius: 2px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.image-container img.loading {
    opacity: 0.5;
}

.error-message {
    color: #ff4444;
    margin: 1rem;
    padding: 1rem;
    border: 1px solid #ff4444;
    border-radius: 4px;
    display: none;
}

.roll-button {
    background-color: var(--primary-color);
    color: var(--background-color);
    border: none;
    padding: 0.5rem 1rem;
    font-size: 1.2rem;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    font-family: 'Poppins', sans-serif;
}

.roll-button:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

.roll-button:active {
    transform: translateY(0);
}

@media (max-width: 480px) {
    nav .logo {
        font-size: 1.5rem;
    }

    nav a {
        font-size: 0.9rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .qa-section,
    .blog-post-card {
        padding: 1rem;
    }
    
    .image-container {
        margin: 1rem auto;
    }
    
    .roll-button {
        font-size: 1rem;
        padding: 0.4rem 0.8rem;
    }
}