/* ==========================================================================
   Appendix Page Styles
   ========================================================================== */

.page-body {
    background: var(--paper);
}

/* Header matches landing page style */
.page-body header {
    background: rgba(248, 247, 244, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.page-body .logo {
    color: var(--steel);
}

.page-body .logo:hover {
    color: var(--accent);
}

.page-body nav a {
    color: var(--steel);
}

.page-body nav a:hover {
    color: var(--accent);
}

/* ==========================================================================
   Page Content Layout
   ========================================================================== */

.page-content {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 4rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10rem 4rem 4rem;
}

article {
    min-width: 0;
}

.article-header {
    margin-bottom: 3rem;
    position: relative;
    z-index: 1;
}

.appendix-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    display: block;
    background: rgba(199, 62, 29, 0.08);
    padding: 0.5rem 1rem;
    border-radius: 2px;
    margin-bottom: 1.5rem;
    width: fit-content;
}

.article-header-content {
    width: 100%;
}

.article-header h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 2.5rem;
    color: var(--ink);
    margin-bottom: 1rem;
    line-height: 1.2;
}

.article-meta {
    font-size: 0.9rem;
    color: var(--silver);
    margin-bottom: 0;
}

/* Book purchase section */
.book-purchase {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 2rem 0;
    border-top: 1px solid rgba(0,0,0,0.1);
    margin-top: 2rem;
}

.book-purchase .btn {
    font-size: 0.85rem;
    padding: 0.75rem 1.5rem;
}

/* ==========================================================================
   Article Body
   ========================================================================== */

.article-body {
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--steel);
}

.article-body section {
    margin-bottom: 3rem;
}

.article-body h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.6rem;
    color: var(--ink);
    margin-bottom: 1.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.article-body h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.article-body h3 {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.article-body p {
    margin-bottom: 1.25rem;
}

.article-body ul,
.article-body ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.article-body li {
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   Equations
   ========================================================================== */

.equation {
    background: rgba(0,0,0,0.02);
    border-left: 3px solid var(--accent);
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    overflow-x: auto;
}

.equation p {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--silver);
}

/* ==========================================================================
   Code Blocks
   ========================================================================== */

.article-body pre {
    background: var(--ink);
    border-radius: 4px;
    padding: 1.5rem;
    margin: 2rem 0;
    overflow-x: auto;
}

.article-body pre code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--paper);
}

.article-body code:not(pre code) {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    background: rgba(0,0,0,0.05);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    color: var(--accent);
}

/* ==========================================================================
   Figures
   ========================================================================== */

.article-figure {
    margin: 2.5rem 0;
}

.article-figure img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.article-figure figcaption {
    font-size: 0.85rem;
    color: var(--silver);
    text-align: center;
    margin-top: 1rem;
    font-style: italic;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.9rem;
}

.data-table caption {
    font-size: 0.85rem;
    color: var(--silver);
    text-align: left;
    margin-bottom: 1rem;
    font-style: italic;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.data-table th {
    background: rgba(0,0,0,0.02);
    font-weight: 600;
    color: var(--ink);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:hover {
    background: rgba(199, 62, 29, 0.02);
}

.data-table .total-row {
    background: rgba(0,0,0,0.03);
    font-weight: 600;
}

/* ==========================================================================
   References
   ========================================================================== */

.references-list {
    font-size: 0.9rem;
    color: var(--steel);
}

.references-list li {
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.page-sidebar {
    position: sticky;
    top: 8rem;
    height: fit-content;
}

.toc {
    background: rgba(0,0,0,0.02);
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.toc h3 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.toc ul {
    list-style: none;
}

.toc li {
    margin-bottom: 0.5rem;
}

.toc a {
    font-size: 0.85rem;
    color: var(--steel);
    text-decoration: none;
    transition: color 0.3s;
    display: block;
    padding: 0.25rem 0;
}

.toc a:hover {
    color: var(--accent);
}

.sidebar-cta {
    background: var(--ink);
    border-radius: 4px;
    padding: 1.5rem;
    text-align: center;
}

.sidebar-cta p {
    font-size: 0.9rem;
    color: var(--silver);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.sidebar-cta .btn {
    width: 100%;
    justify-content: center;
}

/* Appendix Navigation */
.appendix-nav {
    background: rgba(199, 62, 29, 0.05);
    border: 1px solid rgba(199, 62, 29, 0.2);
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.appendix-nav h3 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 1px;
    /*overflow: hidden;*/
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.appendix-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.appendix-nav li {
    margin-bottom: 0.75rem;
}

.appendix-nav li:last-child {
    margin-bottom: 0;
}

.appendix-nav a {
    font-size: 0.85rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    display: block;
    padding: 0.25rem 0;
}

.appendix-nav a:hover {
    color: var(--accent);
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    padding: 4rem 4rem 2rem;
    background: var(--ink);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.footer-section {
    display: flex;
    flex-direction: column;
}

.footer-copyright {
    font-size: 0.85rem;
    color: var(--paper);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.footer-publisher {
    font-size: 0.8rem;
    color: var(--silver);
}

.footer-heading {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.85rem;
    color: var(--paper);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    font-weight: 600;
}

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

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    font-size: 0.85rem;
    color: var(--silver);
    text-decoration: none;
    transition: color 0.3s;
    line-height: 1.6;
}

.footer-links a:hover {
    color: var(--accent);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .page-content {
        grid-template-columns: 1fr;
        padding: 7rem 2rem 3rem;
        display: flex;
        flex-direction: column;
    }

    /* Place the sidebar above the article on smaller screens */
    .page-sidebar {
        position: static;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
        order: -1;
        margin-bottom: 1.5rem;
    }

    /* Ensure sidebar navigation content is visible on small screens */
    .page-sidebar .appendix-nav,
    .page-sidebar .toc {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .page-sidebar .appendix-nav ul,
    .page-sidebar .toc ul {
        display: block !important;
        margin: 0;
        padding: 0;
    }

    .page-sidebar .appendix-nav a,
    .page-sidebar .toc a {
        display: block !important;
        color: var(--ink) !important;
        padding: 0.25rem 0 !important;
    }
}

@media (max-width: 640px) {
    .page-sidebar {
        grid-template-columns: 1fr;
    }

    .article-header h1 {
        font-size: 1.8rem;
    }

    .article-body {
        font-size: 1rem;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}

/* ==========================================================================
   Off-canvas sidebar (small screens)
   ========================================================================== */

/* Sidebar toggle removed - using stacked sidebar on small screens */

@media (max-width: 1024px) {
    /* On smaller screens show sidebar inline below the article (stacked) */
    .page-sidebar {
        position: static;
        width: auto;
        max-width: none;
        height: auto;
        transform: none;
        box-shadow: none;
        padding: 0;
        overflow: visible;
        z-index: auto;
    }

    .page-content {
        grid-template-columns: 1fr;
        padding-right: 0;
    }
}

/* Generated TOC styling inside sidebar */
.sidebar-generated-toc ul {
    margin-top: 0.5rem;
}
.sidebar-generated-toc li a,
.sidebar a.sidebar-gen-link {
    color: var(--ink);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
}
.sidebar-generated-toc li a:hover,
.sidebar a.sidebar-gen-link:hover {
    color: var(--accent);
}

/* ==========================================================================
   Citation / Meta styles
   ========================================================================== */

.article-meta {
    color: var(--steel);
    font-style: normal;
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.cite-block {
    margin-top: 0.5rem;
    padding: 0.65rem 1rem;
    background: rgba(43,122,238,0.05);
    border-left: 4px solid rgba(43,122,238,0.9);
    border-radius: 4px;
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.35;
}

.cite-block strong {
    display: inline-block;
    width: 9.5rem;
    color: var(--accent);
    font-weight: 600;
}
