/* CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Critical for preventing layout breaks */
}

/* CSS Variables */
:root {
    --bg1: #0a0a0a;
    --bg2: #1a0a2e;
    --accent: #b412ff;
    --text: #e0e0e0;
    --link: #d18bff;
}

/* Base Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 50%, var(--bg1) 100%);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background-color: rgba(41, 4, 65, 0.8);
    padding: 30px 20px;
    border-bottom: 3px solid var(--accent);
    text-align: center;
}

h1 {
    margin: 0;
    color: var(--accent);
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-family: "Sekuya", system-ui;
    letter-spacing: 4px;
}

h2 {
    color: var(--link);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
    margin-top: 30px;
}

/* Main Content */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    flex: 1; /* Pushes footer to bottom */
    width: 100%;
}

/* --- NEW BACKGROUND SECTION STYLES --- */

/* Base style for sections with background images */
.section-bg {
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 40px; /* Extra padding for breathing room */
    border-radius: 12px;
    margin: 30px 0;
    overflow: hidden; /* Clips the overlay */
    border: 2px solid rgba(180, 18, 255, 0.3);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
}

/* Dark overlay to ensure text readability */
.section-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.75); /* Dark semi-transparent black */
    z-index: 1;
}

/* Ensure text sits on top of the overlay */
.section-bg h2, 
.section-bg p, 
.section-bg strong, 
.section-bg em {
    position: relative;
    z-index: 2;
}

/* Specific Background: "How It Started" */
.origin {
    /* Update this path if your image is in a different folder */
    background-image: url('../images/download.png');
}

/* Specific Background: "Server Optimization Tips" */
.optimization {
    /* Update this path if your image is in a different folder */
    background-image: url('../images/sean-do-EHLd2utEf68-unsplash.jpg');
}

/* Standard Section Styling (for sections WITHOUT background images) */
section:not(.section-bg) {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

section p {
    color: #d0d0d0;
    text-align: left;
    margin: 15px 0;
}

/* Typography */
strong {
    color: var(--accent);
    font-weight: bold;
}

em {
    color: var(--link);
    font-style: italic;
}

ul {
    list-style-type: square;
    padding-left: 30px;
}

li {
    margin: 10px 0;
    color: #c0c0c0;
}

/* --- UPDATED IMAGE GALLERY STYLES (Grid Layout) --- */

figure.gallery-grid {
    display: flex;
    justify-content: space-between; /* Distributes images evenly across width */
    align-items: stretch; /* Makes all images the same height */
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
    gap: 20px; /* Space between images */
    margin: 30px 0;
    padding: 0 10px; /* Small padding on sides */
}

figure.gallery-grid img {
    flex: 1 1 30%; /* Each image takes ~30% of width (3 images = 100%) */
    max-width: 30%; /* Prevents images from growing larger than 30% */
    height: 200px; /* Fixed height for uniformity */
    object-fit: cover; /* Prevents distortion */
    margin: 0;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--link);
    transition: transform 0.3s ease;
    display: block;
}

/* Hover effect */
figure.gallery-grid img:hover {
    transform: scale(1.02);
    z-index: 2;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.7);
}

/* Caption styling */
figure.gallery-grid figcaption {
    width: 100%; /* Full width caption */
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
    color: #aaa;
    font-style: italic;
    padding: 0 10px;
}

/* Keep the round-image class for other pages if needed */
img.round-image {
    border-radius: 50%;
    width: 300px;
    height: 300px;
    object-fit: cover;
    margin: 1rem auto;
    display: block;
}

/* Navigation */
nav {
    background-color: rgba(41, 4, 65, 0.6);
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

nav a {
    display: inline-block;
    padding: 12px 24px;
    color: var(--link);
    text-decoration: none;
    font-size: 1rem;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
    text-align: center;
}

nav a:hover {
    background-color: rgba(153, 0, 255, 0.3);
    color: #d080ff;
}

nav.secondary {
    text-align: right;
    background-color: rgba(41, 4, 65, 0.4);
}

/* Definition Lists */
dl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

dt {
    background-color: rgba(153, 0, 255, 0.2);
    padding: 10px 15px;
    border-radius: 5px;
    font-weight: bold;
    color: var(--link);
    font-family: 'Courier New', monospace;
}

dd {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-radius: 5px;
    margin: 0;
    color: #d0d0d0;
}

/* Footer */
footer {
    background-color: rgba(41, 4, 65, 0.8);
    padding: 20px;
    text-align: center;
    border-top: 3px solid var(--accent);
    margin-top: auto; /* Ensures footer stays at bottom */
    color: #a0a0a0;
    font-size: 0.9rem;
    width: 100%;
}

footer p {
    margin: 5px 0;
    text-align: center;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Utility Classes */
.ai-attribution {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #444;
    font-size: 0.85rem;
    color: #888;
}

.highlight-purple {
    color: var(--accent);
    font-weight: bold;
}

.highlight-fox {
    color: #ff8c00;
    font-weight: bold;
}