/* --- Styles for the page background (copied from characters-style.css) --- */
body {
    margin: 0;
    font-family: sans-serif;
    background-color: var(--bg-color); /* Fallback color */
    color: var(--text-color); /* Use variable */
    background-image: url('../images/treeflo-background.gif');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    z-index: 0;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background-color: var(--bg-color);
    opacity: 0.8;
}

main {
    padding: 20px;
    transition: margin-left 0.3s ease;
}

main.shifted {
    margin-left: 250px;
}

/* --- Main Layout Container --- */
.character-page-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    /* Reverse wrap allows infobox to appear first in HTML for semantics, but on the right */
    flex-wrap: wrap-reverse; 
    gap: 30px;
    align-items: flex-start; /* Align items to the top */
}

/* --- Infobox (Right Column) --- */
.character-infobox {
    flex: 1 1 300px; /* grow, shrink, basis */
    background-color: var(--sidebar-bg);
    border: 1px solid var(--separator-color);
    border-radius: 8px;
    padding: 20px;
    /* Stick to the top when scrolling */
    position: sticky;
    top: 20px;
}

.infobox-title {
    font-family: 'Cinzel', serif;
    text-align: center;
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--separator-color);
}

.infobox-image {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}

.infobox-image img {
    width: 100%;
    display: block;
}

.infobox-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.infobox-item {
    padding: 8px 0;
    font-size: 0.95em;
    border-bottom: 1px solid var(--bg-color);
}

.infobox-item:last-child {
    border-bottom: none;
}

.infobox-item strong {
    color: var(--text-color);
    margin-right: 8px;
}


/* --- Main Content (Left Column) --- */
.character-content {
    flex: 3 1 500px; /* grow, shrink, basis */
    background-color: rgba(var(--sidebar-bg-rgb, 255, 255, 255), 0.8);
    padding: 20px 30px;
    border-radius: 8px;
    border: 1px solid var(--separator-color);
}

.character-content h1 {
    font-family: 'Cinzel', serif;
    font-size: 3em;
    margin-top: 0;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--separator-color);
    padding-bottom: 10px;
}

.character-content h2 {
    font-family: 'Cinzel', serif;
    font-size: 2em;
    margin-top: 30px;
    border-bottom: 1px solid var(--separator-color);
    padding-bottom: 5px;
}

.intro-quote {
    font-style: italic;
    color: var(--text-color);
    opacity: 0.9;
    font-size: 1.1em;
    margin-bottom: 20px;
}

.character-content p {
    line-height: 1.6;
    font-size: 1.05em;
}

/* --- Gallery Section --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.gallery-grid img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--separator-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-grid img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* --- Responsiveness --- */
@media (max-width: 860px) {
    .character-infobox {
        position: static; /* Remove sticky positioning on smaller screens */
        width: 100%;
        max-width: 500px; /* Give it a max-width */
        margin-left: auto;
        margin-right: auto;
    }
}
