/* Importing External CSS Files */
@import "theme.css";
@import "header.css";
@import "footer.css";
@import "controls.css";
@import "buttons.css";
@import "nav.css";
@import "breadcrumbs.css";
@import "author.css";
@import "section.css";
@import "icons.css";
@import "share.css";
@import "books.css";
@import "grid.css";
@import "download.css";

/* General Styling */
html, body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    height: 100%;
}

body {
    font-size: var(--font-size-base);
    font-family: Arial, sans-serif;
    width: 100%;
    height: 100vh;
    line-height: 1.8;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Accessible Focus */
a:focus, button:focus {
    outline: 3px dashed var(--color-link);
    outline-offset: 2px;
}

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

/* Typography */
h1 {
    font-size: 2.5rem;
    line-height: 3rem;
    color: var(--title-fg);
}

h2 {
    font-size: 2rem;
    margin: 0 0 0.5rem;
    padding: 0 1rem;
    color: #fff;
    background-color: #000;
}

h3  {
    margin: 1rem 0;
}

h4, h5 {
    margin: 0;
}

h3 {
    font-size: 1.75rem;
    color: #fff;
    background: var(--title-h3);
    padding-left: 1rem;
}

h4 {
    font-size: 1.5rem;
    color: var(--title-h4-fg);
    background: var(--title-h4);
}

p {
    margin-bottom: 1rem;
}

pre {
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f5f5f5;
    padding: 1em;
    border-radius: 5px;
    max-width: 100%;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Links */
a {
    color: var(--link-color);
    text-decoration: underline;
}

a:hover, a:focus {
    text-decoration: none;
}

/* Containers */
.container {
    flex: 1;
    display: flex;
    flex-direction: row;
    width: 100%;
    overflow: hidden;
}

.container pre, .container pre code {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
}

/* Sidebar Navigation */
aside.nav {
    flex: 0 0 250px;
    max-height: 100%;
    overflow-y: scroll; /* Always show vertical scrollbar */
    scrollbar-gutter: stable both-edges; /* Reserve space for scrollbar */
}

main {
    flex: 1;
    padding: 2rem 1rem;
    margin: 0 auto;
    background-color: var(--main-bg);
    overflow-y: scroll; /* Always show vertical scrollbar */
    scrollbar-gutter: stable both-edges; /* Reserve space for scrollbar */
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background-color: var(--footer-bg);
    color: var(--footer-text-color);
}

/* BW Mode Overrides */
.bw-mode * {
    background: white !important;
    color: black !important;
}

.bw-mode img {
    display: none !important;
}

.bw-mode aside img {
    display: block !important;
}

.bw-mode header img {
    display: block !important;
}

.bw-mode .site-footer img {
    display: block !important;
}

.footer-logo.light {
    display: block;
}
.bw-mode .footer-logo.light {
    display: none;
}

.footer-logo.bw {
    display: none;
}
.bw-mode .footer-logo.bw {
    display: block;
}

.bw-mode .site-footer {
    background: white !important;
    color: black !important;
}

/* Icon Detail in BW Mode */
.bw-mode icon-detail {
    --background-color: white !important;
    --foreground-color: black !important;
}

.bw-mode icon-detail::part(title),
.bw-mode icon-detail::part(description) {
    color: var(--foreground-color);
}

@media (max-width: 800px) {
    .container {
        flex-direction: column;
    }

    aside.nav {
        flex: none;
    }

    main {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
        line-height: 1.3;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3, h4 {
        font-size: 1.25rem;
    }
}
