/* --- General Body & Background --- */
body {
    background-color: #4a3c2a;
    background-image: url('https://www.transparenttextures.com/patterns/crissxcross.png'); /* Subtle background pattern */
    color: #e0d5c1; /* Off-white, like aged paper */
    font-family: 'Lora', serif;
    margin: 0;
    padding: 10px;
    font-size: 16px;
    line-height: 1.6;
}

/* --- Typography & Header --- */
h1, h2 {
    font-family: 'Cinzel', serif;
    text-align: center;
    color: #c5a05a; /* A metallic gold/brass color */
    text-shadow: 2px 2px 4px #000;
}

h1 {
    font-size: 2em;
    margin-bottom: 0;
}

h2 {
    font-size: 1.5em;
    margin-top: 5px;
    font-weight: normal;
}

header {
    border-bottom: 3px double #8c7853; /* Double border for a classic look */
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.intro {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 40px auto;
    font-style: italic;
    font-size: 1.1em;
}


/* --- The Image Gallery Grid --- */
.gallery-grid {
    display: grid;
    /* This creates responsive columns: they are at least 300px wide, 
       and the browser will fit as many as it can per row. */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px; /* The space between images */
    max-width: 1200px;
    margin: 0 auto; /* Center the grid container */
}

/* --- Individual Gallery Items --- */
.gallery-item {
    background-color: #3d2c1d;
    border: 5px solid #8c7853; /* A metallic bronze/brass border */
    padding: 10px;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.6);
    text-align: center;
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

.gallery-item:hover {
    transform: scale(1.05); /* Enlarge the item on hover */
    box-shadow: 8px 8px 20px rgba(0, 0, 0, 0.8);
    z-index: 10;
}

.gallery-item img {
    max-width: 100%;
    height: auto;
    display: block;
    filter: sepia(0.5); /* Adds a subtle sepia tone */
    transition: filter 0.3s;
}

.gallery-item:hover img {
    filter: sepia(0); /* Remove the sepia effect on hover to make it 'pop' */
}

.caption {
    font-family: 'Cinzel', serif;
    padding-top: 10px;
    font-size: 1.1em;
    color: #c5a05a;
}


/* --- Footer --- */
footer {
    text-align: center;
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid #8c7853;
    font-size: 0.8em;
    color: #a9987d;
}

/* Center the main container for the single puzzle */
.single-puzzle-container {
    max-width: 900px; /* Widen the container for the new layout */
    margin: 0 auto; /* This centers the block */
}

/* Style for the main puzzle title */
.puzzle-title {
    font-family: 'Cinzel', serif;
    font-size: 1.5em;
    color: #c5a05a;
    text-shadow: 1px 1px 3px #000;
    text-align: center;
    margin-bottom: 20px;
}

/* Style for the detailed description text */
.puzzle-description {
    font-size: 1.1em;
    text-align: justify; /* Justified text looks more like a book page */
    margin: 0; /* Reset margin as flex gap will handle spacing */
    padding: 0 15px;
    color: #d1c6b4;
}

/* Style for inline code/cipher snippets */
.cipher-text {
    font-family: 'Courier New', Courier, monospace;
    background-color: #2c2117; /* A slightly darker shade to stand out */
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #8c7853;
    color: #f0e6d6; /* A slightly brighter text color for emphasis */
}

/* --- General Link Styling --- */
a {
    color: #c5a05a; /* The same gold/brass color as headers */
    text-decoration: none; /* Remove the default underline */
    border-bottom: 1px dotted #c5a05a; /* Add a subtle, thematic underline */
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
}

a:hover {
    color: #f0e6d6; /* A brighter, aged paper color on hover */
    border-bottom-color: #f0e6d6;
}

/* --- Book Layout --- */
.book-layout {
    display: flex;
    align-items: flex-start; /* Align items to the top */
    gap: 25px; /* Space between image and text */
    margin-bottom: 30px;
}

.book-image {
    flex: 1; /* Let the image container take up available space */
    min-width: 300px; /* Prevent the image from becoming too small */
}

.book-text {
    flex: 1.5; /* Give the text slightly more space than the image */
    margin-top: 0;
    padding: 0;
    /* Remove the top margin from the paragraph inside */
    & p { margin-top: 0; }
}

/* Container for the navigation buttons */
.puzzle-navigation {
    margin-top: 30px;
    display: flex; /* Use flexbox for alignment */
    gap: 20px; /* Add space between buttons if there are more than one */
}

/* Styling for the navigation buttons */
.nav-button {
    font-family: 'Cinzel', serif;
    color: #e0d5c1;
    flex: 1; /* This makes each button grow to fill available space */
    text-align: center; /* Ensure text inside the button is centered */
    text-decoration: none;
    background-color: #5a4a35;
    border: 2px solid #8c7853;
    padding: 10px 20px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.nav-button:hover {
    background-color: #8c7853;
    color: #fff;
    box-shadow: 0 0 10px #c5a05a;
}

/* --- Collapsible Answer Form --- */
.answer-details {
    margin-top: 40px;
    border: 2px solid #8c7853;
    border-radius: 5px;
    background-color: #3d2c1d;
}

.answer-summary {
    font-family: 'Cinzel', serif;
    font-size: 1.2em;
    color: #c5a05a;
    padding: 15px 20px;
    cursor: pointer;
    list-style: none; /* Remove default arrow marker */
    transition: background-color 0.3s ease;
}

.answer-summary:hover {
    background-color: #5a4a35;
}

/* Hide the default marker/arrow for all browsers */
.answer-summary::-webkit-details-marker {
    display: none;
}

/* --- Answer Submission Form --- */
.answer-form-container {
    padding: 20px;
    padding-top: 20px;
    background-color: #3d2c1d; /* Same as gallery item for consistency */
    border-radius: 5px;
}

.answer-form-container form {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.answer-input {
    font-family: 'Lora', serif;
    font-size: 1em;
    padding: 10px;
    border: 2px solid #8c7853;
    background-color: #e0d5c1;
    color: #3d2c1d;
    border-radius: 5px;
    width: 80%; /* Adjust width as needed */
}

/* --- Responsive Adjustments for Mobile --- */
@media (max-width: 600px) {
    /* Stack the book layout vertically on small screens */
    .book-layout {
        flex-direction: column;
        align-items: center;
    }

    .answer-form-container form {
        flex-direction: column;
        align-items: stretch; /* Make items fill the width */
    }

    .answer-input {
        width: 100%;
        box-sizing: border-box; /* Ensure padding is included in the width */
        text-align: center;
    }
}