/* Boilerplate */
*,
*:before,
*:after {
    box-sizing: border-box;
}
:root {
    --border-color: #a8a29e;
}
/* Standard styles */
body {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(1em, 1fr) minmax(auto, 1200px) minmax(1em, 1fr);
    grid-template-rows: min-content 1fr min-content;
    grid-template-areas: 
    ".... head ...."
    ".... main ...."
    ".... foot ....";
    font-size: .9rem;
    min-height: 100dvh;
    font-family: "Andika", sans-serif;
    background-color: #FFFBE9;
    color: #212121;
}
header {
    grid-area: head;
    border-bottom: 1.5px solid #212121;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}
.header-title {
    margin: 0;
    font-size: 1.5rem;
    font-family: "Andika", sans-serif;
    color: #212121;
    text-align: left;
}
#home-main {
    grid-area: main;
    width: 100%;
    max-width: 1400px;
    text-align: center;
    padding: 0 1rem;
    justify-self: center;
    align-self: stretch; 
    display: grid;
    align-items: center;
}
main {
    grid-area: main;
    width: 100%;
    max-width: 1400px;
    text-align: center;
    padding: 0 1rem;
    justify-self: center;
    align-self: stretch; 
    display: grid;
    align-content: start;
}
footer {
    grid-area: foot;
    width: 100%;
    border-top: 1.5px solid #212121;
    text-align: center;
    align-self: end;
    font-size: .6rem;
    padding: .5rem;
}
h2 {
    font-size: 1rem;
}

/* Nav */
nav {
    /* width: 100%; */
    width: auto; /* Changed from 100% to let H1 breathe side-by-side */
}
.topnav button {
    background: none;
    border: none;
    padding: 0;
}
.image {
    display: block;
    margin: 2rem 0;
    width: 100%;
    height: auto;
    border-radius: 5%;
    border: 5px solid #000;
}
#main-img {
    max-width: 660px
}
.topnav-open {
    display: block;
    margin-inline-start: auto;
}
.hamburger-icon {
    width: 3rem;
    height: 3rem;
    /* stroke: #ff5733; */
    stroke: #212121;
    /* border: 1px solid red; */
    /* padding-top: 1rem; */
    /* margin-top: 1rem; */
    margin-top: 0; /* Removed top margin to vertically align with H1 */
}
.topnav-open[aria-expanded=true] + .topnav-menu {
    translate: 0;
}
.topnav-close {
    display: block;
    margin-inline-start: auto;
    margin-block-end: 8rem;
    border: 1px solid green;
}
.topnav-close img {
    margin: 0;
    width: 2.5rem;
}
.topnav-menu {
    position: fixed;
    inset: 0;
    padding: 1em;
    background-color: #212121;
    translate: 100vw 0;
    transition: translate 0.5s ease-in-out;
}
.topnav-links {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin: 0;
    padding: 0;
    align-items: center;
    height: 50%;
    font-size: 2rem;
    
}
.topnav-item {
    list-style-type: none;
}
.topnav-link {
    display: inline-block;
    text-decoration: none;
    color: #FFF;
    transition: transform 0.2s ease-in-out, color 0.2s ease-in-out;
    font-weight: bold;
}
.topnav-link:visited {
    color: #55286F;
}
.topnav-link:hover {
    transform: translateY(-3px);
    color: #0076ff;
}

/* Home */
#home-main {
    padding-top: 3rem;
}

/* About */
.about-img {
    max-width: 660px;
    /* max-width: 500px; */
    justify-self: center; 
}

ol {
    text-align: left;
}

ul {
    text-align: left;
}

section {
    display: grid;
}

/* Contacts page */
.contact-container {
    width: 100%;
    max-width: 650px;
    background-color: #E6DFD3;
    border: 1px solid #212121;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem auto;
    padding: 1.5rem 1rem;
}
.contact-header {
    text-align: center;
}
.contact-header h2 {
    font-size: 1.3rem;
    color: #2B2620;
    margin-bottom: 0;
}
.contact-header p {
    color: #423C36;
}
.contact-form {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
label {
    font-weight: 600;
    text-align: left;
}
label span {
    color: #b91c1c;
}
input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: .4rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: #fff;
    color: #2d2926;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* --- Accessibility & Focus States --- */
input:hover, select:hover, textarea:hover {
    border-color: #4a5568;
}
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #0284c7;
    outline-offset: 1px;
    border-color: transparent;
}

/* Screen reader only utility class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

#message {
  resize: none;
}
.submit-btn {
    background-color: #5c4033;
    color: #ffffff;
    padding: .5rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    text-align: center;
}
.submit-btn:hover,
.submit-btn:focus-visible {
    background-color: #402c23;
}
/* Utility */
.bold {
    font-weight: bold;
}

/* Media Queries */
@media (prefers-reduced-motion) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .topnav-open[aria-expanded=true] + .topnav-menu {
        opacity: 1;
    }
    .topnav-menu {
        translate: 0;
        opacity: 0;
        transition: opacity 500ms ease-in-out;
    }
}

@media (min-width: 600px) {
    .books-main {
        display: grid;
        justify-content: center;
        
    }
    .books {
        background-color: #F9F6F0;
        border-radius: 12px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                    0 2px 4px -1px rgba(0, 0, 0, 0.06);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "text-side img-side"; 
        gap: 1.25rem;                    
        padding: 1.25rem;             
        align-items: center;
        margin-top: 4rem;
        max-width: 720px;
    }
    .book-text {
        grid-area: text-side; 
    }
    .book-img {
        grid-area: img-side; 
        max-width: 300px;
    }
    .books-last {
        margin-bottom: 4rem;
    }
}

@media (min-width: 688px) {
    .topnav {
        display: flex;
        justify-content: space-between; 
        align-items: center;
        padding-block: 1.5rem; 
    }
    .topnav-menu {
        position: static;   /* Removes the full-screen mobile overlay */
        translate: 0;       /* Brings it back onto the screen */
        background: none;   /* Removes the dark mobile background */
        width: auto;
    }
    .topnav button {
        display: none;
    }
    .header-title {
        font-size: 1.5rem;
    }
    .topnav-links {
        display: flex;
        flex-direction: row; 
        justify-content: flex-end;
        gap: 2rem;
        height: auto; 
        font-size: 1.3rem;
        margin: 0;
        padding: 0;
    }
    .topnav-link {
        color: #212121;
    }
    #home-main {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; 
        grid-template-rows:1fr auto;
        grid-template-areas: 
            "img img img img img img img card card card card card"
            "caption caption caption caption caption caption caption caption caption caption caption caption";
        padding-top: 0;   
    }
    #main-img {
        grid-area: img;
        padding-top: 4rem;
    }
    #main-img img {
        margin: 0;
    }

    .card {
        padding-top: 2rem;
        padding-bottom: 2rem;
        grid-area: card;
        padding: 2rem 1rem;
        font-size: 1.2rem;
    }
    #main-text-2 {
        grid-area: caption;
        margin: 0;
        padding: 0;
        align-self: start; /* Add this line */
        padding-top: 2rem;    /* Adjust padding values as desired */
        padding-bottom: 2rem;
        font-size: 1.2rem;
    }
    .general-main > section:has(div) {
        display: grid;
        grid-template-columns: repeat(12, 1fr); 
        grid-template-areas: "about-text about-text about-text about-text about-text about-text about-img about-img about-img about-img about-img about-img";
        gap: 2rem;
        align-items: center;
    }
    .general-main .general-text {
        grid-area: about-text;
    } 
    .general-img {
        grid-area: about-img;
        justify-self: unset;
    }
    .general-main .image {
        width: 100%;
        height: auto;
        display: block;
    }
    .general-main > section:has(div):nth-of-type(even) {
        grid-template-areas: "about-img about-img about-img about-img about-img about-img about-text about-text about-text about-text about-text about-text";
    }
   
    /* Contacts Page */
    .contact-container {
        padding: 2.5rem;
        border-radius: 8px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    .contact-header {
        margin-bottom: 2rem;
    }
    .contact-header h1 {
        font-size: 2.25rem;
    }
    .submit-btn {
        width: auto;
        align-self: flex-start;
    }
    footer {
        font-size: 1rem;
    }
}