@font-face {
    font-family: 'C059';
    src: url('C059-Roman.woff2') format('woff2'),
        url('C059-Roman.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'C059';
    font-size: 18px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

html {
    overflow-x: hidden;
}

main {
    padding: 2rem 1rem;
    margin: 0 auto;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #282c34;
    padding: 15px;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
}

nav ul li {
    margin: 0 20px;
    cursor: pointer;
    font-size: 1.125rem;
    color: white;
    font-family: "Courier New", monospace;
    position: relative;
}

nav ul li:hover,
nav ul li.active {
    color: #61dafb;
}

h1, h2 {
    font-family: "Courier New", monospace;
    font-weight: 600;
}

h3, h4, h5, h6 {
    font-family: "C059", sans-serif;
    font-weight: 600;
}

h1, .nav-item {
    font-size: 1rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.65rem;
}

h4 {
    font-size: 1.5rem;
}

h5 {
    font-size: 1.25rem;
}

.dropdown {
    display: none;
    position: absolute;
    background-color: #282c34;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0;
    list-style: none;
    font-size: 0.9rem;
    width: calc(100% + 40px);
    left: -20px;
    top: 100%;
}

nav ul li:hover > .dropdown {
    display: block;
}

.dropdown li {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: "Courier New", monospace;
    font-size: 0.8rem;
}

.dropdown li:hover {
    background-color: #373b44;
}

footer {
    text-align: center;
    padding: 0 10px;
    background-color: #282c34;
    color: white;
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 77px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-content {
    width: 100%;
}

.footer-content p {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
}

.social-link,
.has-popover {
    display: inline-block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    padding: 10px;
}

.icon-fa {
    font-size: 1.8rem;
    color: white;
    transition: color 0.3s ease;
    line-height: 1;
}

.social-link:hover .icon-fa,
.has-popover:hover .icon-fa {
    color: #61dafb;
}

.has-popover {
    position: relative;
}

.popover-text {
    visibility: hidden;
    opacity: 0;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    transition: opacity 0.3s ease, visibility 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.popover-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.has-popover:hover .popover-text {
    visibility: visible;
    opacity: 1;
    bottom: 130%;
}

.topic {
    margin-bottom: 2rem;
    padding: 2rem;
    background-color: #fff;
}

h1[id],
h2[id],
section[id],
article[id] {
    scroll-margin-top: 140px;
}

h3[id] {
    scroll-margin-top: 80px;
}

.topic[id],
.subtopic[id] {
    scroll-margin-top: 60px;
}

.gallery-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding: 20px;
}

figure {
    margin: 0;
    border: 1px solid #ddd;
    padding: 10px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out;
}

figure:hover {
    transform: translateY(-5px);
    cursor: pointer;
}

figure img {
    display: block;
    max-width: 100%;
    height: auto;
}

figcaption {
    text-align: center;
    margin-top: 10px;
    font-size: 0.9em;
    color: #555;
}

pre {
    font-family: "Courier New", Courier, monospace;
    white-space: pre;
    background-color: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-x: auto;
    width: 100%;
}

pre code {
    font-family: inherit;
    white-space: inherit;
    min-width: 80ch;
    display: inline-block;
    display: block;
    padding: 1rem;
}

#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s, opacity 0.3s;
}

#lightbox.active {
    visibility: visible;
    opacity: 1;
}

.lightbox-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    max-width: 70vw;
    max-height: 70vh;
}

.lightbox-image-wrapper {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

#lightbox-img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
}

#lightbox-caption {
    color: #333;
    font-size: 1.1em;
    text-align: center;
    margin: 0;
    padding: 10px 0 0;
    flex-shrink: 0;
    height: 40px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2.5em;
    color: #fff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: color 0.2s, text-shadow 0.2s, background-color 0.2s;
    z-index: 1001;
}

.lightbox-close:hover {
    color: #f0f0f0;
    background-color: rgba(255, 255, 255, 0.2);
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.3);
    border: none;
    font-size: 3em;
    color: #fff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 5px;
    line-height: 1;
    transition: background-color 0.2s, color 0.2s, text-shadow 0.2s;
    z-index: 1001;
}

.lightbox-arrow:hover {
    background-color: rgba(255, 255, 255, 0.5);
    color: #eee;
}

.lightbox-arrow-left {
    left: 20px;
}

.lightbox-arrow-right {
    right: 20px;
}

.lightbox-arrow.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.references {
    margin-top: 2rem;
}

.references p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
    padding-left: 2em;
    text-indent: -2em;
}

@media screen and (max-width: 768px) {
    section[id], article[id] {
        scroll-margin-top: 160px;
    }

    .header-content {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    h2 {
        line-height: 1.7rem;
    }

    h3 {
        line-height: 1.7rem;
    }

    nav ul {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: #282c34;
        padding: 0 0 1rem;
        max-height: calc(100vh - var(--header-height) - var(--footer-height));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 999;
    }

    nav ul.active {
        display: flex;
    }

    nav ul li {
        margin: 0;
        padding: 0.5rem 1rem;
        text-align: center;
        font-size: 1.2rem;
    }

    .mobile-nav-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .dropdown {
        position: static;
        display: block !important;
        width: 100%;
        box-shadow: none;
        padding: 0;
        background-color: transparent;
        border: none;
    }

    .dropdown li {
        padding: 0.25rem 1rem;
        text-align: center;
        font-size: 1em;
    }

    .mobile-nav-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .footer-content p {
        margin-bottom: 5px;
    }

    .social-link, .has-popover {
        padding: 5px;
    }
}

@media screen and (min-width: 769px) {
    .mobile-nav-toggle {
        display: none;
    }
}

