/* New header design with sitename left, links right */
nav { 
    background: #2c3e50; 
    padding: 1rem 0;
    margin-bottom: 0;
    position: relative;
}
nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
nav .sitename {
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    text-transform: uppercase;
}
nav .nav-contact {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border: 1px solid white;
    border-radius: 4px;
    transition: all 0.3s ease;
}
nav .nav-contact:hover {
    background: white;
    color: #2c3e50;
}

/* Page header styling */
header {
    background: #2c3e50 !important;
    color: white !important;
    text-align: center !important;
    padding: 2rem 0 !important;
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    margin-bottom: 0 !important;
    position: relative;
}
header h1 { 
    color: white !important; 
    text-transform: uppercase !important; 
    font-size: 1.75rem !important;
    margin-bottom: 1rem !important;
}

/* Masthead styling for homepage */
.masthead {
    background: #2c3e50 !important;
    color: white !important;
    text-align: center !important;
    padding: 3rem 0 !important;
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    margin-bottom: 0 !important;
    position: relative;
}
.masthead h1 { 
    color: white !important; 
    text-transform: uppercase !important; 
    font-size: 2rem !important;
    margin-bottom: 1rem !important;
}
.masthead p { color: white !important; font-size: 1.2rem !important; }

/* Section styling with logical spacing */
section {
    padding: var(--pico-spacing) 0;
    text-align: center;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    margin-top: 0;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(1.5rem, 4vw, 3rem);
}

section .container {
    display: flex;
    flex-direction: column;
    gap: clamp(1rem, 3vw, 2rem);
    align-items: center;
}

/* Book section button container */
#book .container > a[role="button"] {
    align-self: center;
}

/* Allow multiple buttons side by side if space allows */
#book .container {
    align-items: stretch;
}

#book .featured-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    align-items: center;
}

/* Category buttons layout */
.category-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

/* Search widget styling */
#search-widget {
    max-width: 600px;
    margin: 0 auto;
}
/* Specific section coloring: masthead(dark) -> book(light) -> search(dark) -> contact(light) */
#book { background: white; color: #333; }
#search { background: #2c3e50; color: white; }
#contact { background: white; color: #333; }

/* Button styling for specific sections */
/* Light sections (#book, #contact) need dark buttons */
#book [role="button"], #contact [role="button"] {
    color: #333 !important;
    border-color: #333 !important;
}
#book [role="button"]:hover, #contact [role="button"]:hover {
    background: #333 !important;
    color: white !important;
    border-color: #333 !important;
}

/* Dark sections (#search) need light buttons */
#search [role="button"] {
    color: white !important;
    border-color: white !important;
}
#search [role="button"]:hover {
    background: white !important;
    color: #2c3e50 !important;
    border-color: white !important;
}

/* Fix specific text color in search section */
#search h3 {
    color: white !important;
}
section h2 { 
    color: inherit; 
    text-transform: uppercase;
    margin-bottom: var(--pico-spacing);
}

/* Star divider styling */
.star-divider {
    margin: var(--pico-spacing) 0; 
    width: 60px; 
    margin-left: auto; 
    margin-right: auto; 
    position: relative;
}
.star {
    display: block;
    text-align: center;
    color: inherit; 
    font-size: 2rem;
    margin: 1rem 0;
}

/* Button styling */
[role="button"] {
    background: transparent;
    border: 2px solid currentColor;
    color: inherit;
    padding: 1rem 2rem;
    margin: 0.5rem;
    display: inline-block;
    text-decoration: none;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 1.1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

/* Default button styling for article pages */
main [role="button"] {
    color: #333 !important;
    border-color: #333 !important;
}
main [role="button"]:hover {
    background: #333 !important;
    color: white !important;
    border-color: #333 !important;
}

/* Dark sections (odd) - white text on dark background */
section:nth-of-type(odd) [role="button"] {
    color: white;
    border-color: white;
}
section:nth-of-type(odd) [role="button"]:hover {
    background: white !important;
    color: #2c3e50 !important;
    border-color: white !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

/* Light sections (even) - dark text on white background */
section:nth-of-type(even) [role="button"] {
    color: #333;
    border-color: #333;
}
section:nth-of-type(even) [role="button"]:hover {
    background: #333 !important;
    color: white !important;
    border-color: #333 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}


/* Content styling */
main { padding: 0; }

/* Remove Bootstrap remnants */
.row, .col-lg-8, .page-content {
    all: unset;
    display: block;
}

/* Article content styling */
.container > .row,
.container > .col-lg-8,
.container > .page-content {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: var(--pico-spacing);
}

/* Hide section numbers */
.section-number-2,
.section-number-3,
.section-number-4 {
    display: none;
}

/* Footer styling */
footer {
    background: #2c3e50 !important;
    color: #ffffff !important;
    padding: 4rem 0 !important;
    text-align: center !important;
    margin-top: 0 !important;
    clear: both;
    position: relative;
    z-index: 1;
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
}
footer * {
    color: #ffffff !important;
}
footer a { 
    color: #ffffff !important; 
    text-decoration: underline !important;
}
footer a:hover { 
    color: #18bc9c !important; 
    text-decoration: none !important;
}
footer h3 {
    color: #ffffff !important;
    margin-bottom: 1rem !important;
}
footer p {
    margin-bottom: 1rem !important;
    color: #ffffff !important;
}
footer small {
    opacity: 0.8 !important;
    color: #ffffff !important;
}

/* Pagefind search styling for dark section */
#search .pagefind-ui__form input {
    background: white !important;
    color: #333 !important;
    border: 1px solid white !important;
    border-radius: 8px !important;
}
#search .pagefind-ui__form {
    border-radius: 8px !important;
}
#search .pagefind-ui__search-input {
    border-radius: 8px !important;
}
#search .pagefind-ui__results {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
    gap: 1rem !important;
    align-items: stretch !important;
    justify-items: stretch !important;
}
#search .pagefind-ui__results * {
    color: #333 !important;
}
#search .pagefind-ui__message {
    color: white !important;
}
#search .pagefind-ui__search-clear {
    color: #333 !important;
}
#search .pagefind-ui__drawer {
    background: rgba(44, 62, 80, 0.95) !important;
    border: 1px solid white !important;
}
#search .pagefind-ui__summary {
    color: white !important;
}
#search .pagefind-ui__message {
    color: white !important;
    background: rgba(255,255,255,0.1) !important;
    padding: 1rem !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
}
#search .pagefind-ui__result {
    background: white !important;
    border: 1px solid #ddd !important;
    padding: 1rem !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}
#search .pagefind-ui__result-title {
    color: #333 !important;
}
#search .pagefind-ui__result-excerpt {
    color: #666 !important;
}

/* Readability improvements */
body {
    line-height: 1.6;
    font-size: 16px;
}

p, li, td {
    line-height: 1.7;
    font-size: 1rem;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-bottom: 1rem;
}

/* Ensure good contrast for all text */
section:nth-of-type(odd) {
    background: #2c3e50;
    color: #ffffff;
}
section:nth-of-type(even) {
    background: #ffffff;
    color: #333333;
}

/* Table styling */
table {
    font-size: 0.85rem;
    line-height: 1.4;
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

table th {
    background: #2c3e50 !important;
    color: white !important;
    padding: 0.75rem 0.5rem !important;
    font-weight: bold !important;
    text-align: left !important;
    border-bottom: 2px solid #34495e !important;
}

table td {
    padding: 0.6rem 0.5rem !important;
    border-bottom: 1px solid #e9ecef !important;
    vertical-align: top !important;
}

table tr:nth-child(even) {
    background: #f8f9fa !important;
}

table tr:hover {
    background: #e9ecef !important;
}

/* Responsive table */
@media (max-width: 768px) {
    table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    table th, table td {
        padding: 0.4rem 0.3rem !important;
        min-width: 80px;
    }
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
    /* Prevent horizontal scroll and eliminate right margin */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    /* Fix full-width sections on mobile */
    section, header, .masthead, footer {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        box-sizing: border-box !important;
    }
    
    /* Reduce header padding on mobile */
    header {
        padding: 0.75rem 0 !important;
    }
    
    .masthead {
        padding: 1.5rem 0 !important;
    }
    
    /* Smaller header text on mobile */
    header h1 {
        font-size: 1.25rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .masthead h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Hide star divider on mobile for compactness */
    header .star-divider {
        display: none;
    }
    
    /* Container fixes for mobile */
    .container {
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Navigation mobile fixes */
    nav {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Button spacing on mobile */
    [role="button"] {
        margin: 0.25rem;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Improve mobile readability */
    body {
        font-size: 18px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    /* Mobile navigation - collapse links */
    nav {
        padding: 0.5rem 0 !important;
    }
    
    nav .sitename {
        font-size: 1.4rem !important;
    }
    
}