/* style.css */

/* --- Global Styles & Variables --- */
:root {
    --primary-color: #007bff; /* Example blue */
    --secondary-color: #6c757d; /* Example gray */
    --light-gray: #f8f9fa;
    --dark-gray: #343a40;
    --border-color: #dee2e6;
    --code-bg: #e9ecef;
    --accent-color: #ffc107; /* Example yellow for highlights */

    --font-primary: 'Lato', sans-serif;
    --font-code: 'Roboto Mono', monospace;

    --base-font-size: 16px;
    --line-height: 1.7;
    --spacing-unit: 1rem; /* Approx 16px */
}

/* Apply smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
    font-size: var(--base-font-size);
}

body {
    font-family: var(--font-primary);
    line-height: var(--line-height);
    color: var(--dark-gray);
    margin: 0;
    background-color: #fff;
}

.container {
    max-width: 900px; /* Comfortable reading width */
    margin: 0 auto;
    padding: 0 calc(var(--spacing-unit) * 1.5); /* Horizontal padding */
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-top: calc(var(--spacing-unit) * 2);
    margin-bottom: var(--spacing-unit);
    color: var(--dark-gray);
}

h1 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 0.5em;
}

h2 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.3em;
    display: inline-block; /* Keep border tight */
}

h3 {
    font-size: 1.4rem;
    color: var(--secondary-color);
    margin-top: calc(var(--spacing-unit) * 1.5);
}

h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5em;
}

p {
    margin-bottom: var(--spacing-unit);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover, a:focus {
    color: #0056b3; /* Darker blue on hover */
    text-decoration: underline;
}

ul, ol {
    margin-bottom: var(--spacing-unit);
    padding-left: calc(var(--spacing-unit) * 1.5);
}

li {
    margin-bottom: calc(var(--spacing-unit) / 2);
}

/* --- Header --- */
.site-header {
    background-color: var(--light-gray);
    padding: calc(var(--spacing-unit) * 3) 0;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.tagline {
    font-size: 1.1rem;
    color: var(--secondary-color);
    max-width: 600px;
    margin: 0 auto;
}

/* --- Main Content Sections --- */
.content-section {
    padding-top: calc(var(--spacing-unit) * 1.5);
    padding-bottom: calc(var(--spacing-unit) * 1.5);
    margin-bottom: var(--spacing-unit);
}

/* --- Table of Contents (TOC) --- */
.toc-section ul {
    list-style: none;
    padding: 0;
    columns: 2; /* Simple two-column layout for TOC on wider screens */
    column-gap: calc(var(--spacing-unit) * 2);
}

.toc-section li {
    margin-bottom: calc(var(--spacing-unit) * 0.75);
    break-inside: avoid-column; /* Prevent list items from breaking across columns */
}

.toc-section a {
    font-weight: 700;
}

/* --- Pitfall Sections (Accordion Style) --- */
.pitfall {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    overflow: hidden; /* Contain content within borders */
    transition: box-shadow 0.3s ease;
}

.pitfall:hover {
     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pitfall summary {
    padding: var(--spacing-unit) calc(var(--spacing-unit) * 1.5);
    cursor: pointer;
    background-color: var(--light-gray);
    border-bottom: 1px solid var(--border-color); /* Separator when closed */
    list-style: none; /* Remove default marker */
    display: flex; /* Use flex for alignment */
    align-items: center;
    justify-content: space-between; /* Push marker to the right */
    transition: background-color 0.2s ease;
}

.pitfall summary:hover {
    background-color: #e2e6ea; /* Slightly darker gray on hover */
}

/* Custom accordion marker */
.pitfall summary::after {
    content: '+'; /* Plus sign when closed */
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    transition: transform 0.3s ease;
    margin-left: var(--spacing-unit);
}

.pitfall[open] summary::after {
    content: '−'; /* Minus sign when open */
    transform: rotate(180deg);
}

/* Style the content inside the accordion */
.pitfall-content {
    padding: calc(var(--spacing-unit) * 1.5);
    border-top: 1px solid var(--border-color); /* Separator when open */
}

/* Ensure h2 within summary doesn't have default h2 styles */
.pitfall summary h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin: 0; /* Remove margins */
    font-size: 1.5rem; /* Adjust size */
    display: inline; /* Allow marker to align */
}

/* --- Code Blocks --- */
pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: var(--spacing-unit);
    overflow-x: auto; /* Enable horizontal scrolling */
    margin-bottom: var(--spacing-unit);
    font-size: 0.9rem;
}

code {
    font-family: var(--font-code);
    background-color: transparent; /* Reset background if inline */
    padding: 0;
}

pre code {
    background-color: transparent; /* Ensure code inside pre has no extra bg */
    color: var(--dark-gray);
}

/* --- Takeaway Boxes --- */
.takeaway {
    background-color: #fff3cd; /* Light yellow background */
    border-left: 5px solid var(--accent-color);
    padding: var(--spacing-unit);
    margin-top: calc(var(--spacing-unit) * 1.5);
    border-radius: 0 5px 5px 0;
}

.takeaway h4 {
    margin-top: 0;
    color: #856404; /* Darker yellow text */
}

.takeaway p {
    margin-bottom: 0;
}


/* --- Footer --- */
.site-footer {
    background-color: var(--dark-gray);
    color: var(--light-gray);
    text-align: center;
    padding: calc(var(--spacing-unit) * 2) 0;
    margin-top: calc(var(--spacing-unit) * 3);
    font-size: 0.9rem;
}

.site-footer p {
    margin-bottom: 0.5em;
    opacity: 0.8;
}

/* --- Interactivity --- */

/* Back to Top Button */
#back-to-top {
    display: none; /* Hidden by default, shown by JS */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99;
    border: none;
    outline: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 50%; /* Make it round */
    font-size: 1.2rem;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#back-to-top:hover {
    background-color: #0056b3; /* Darker blue on hover */
    opacity: 1;
}


/* --- Responsive Design --- */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.6rem; }
    .pitfall summary h2 { font-size: 1.3rem; }
    .container { padding: 0 var(--spacing-unit); }

    /* Stack TOC columns */
    .toc-section ul {
        columns: 1;
    }
}

@media (max-width: 480px) {
    :root { --base-font-size: 15px; }
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.4rem; }
    .pitfall summary h2 { font-size: 1.2rem; }
    #back-to-top {
        padding: 8px 12px;
        font-size: 1rem;
        bottom: 15px;
        right: 15px;
    }
}