/* Non-critical CSS - loaded asynchronously for better performance */

/* Article styles */
.article {
    font-size: 1rem;

    p.mw-empty-elt {
        display: none;
    }

    /* Hide reference superscripts */
    sup.reference {
        display: none;
    }

    /* Hide reference sections */
    h2:has(span#References),
    h2:has(span#Notes),
    h2:has(span#Citations),
    h2:has(span#Further_reading),
    h2:has(span#External_links),
    h2:has(span#See_also) {
        display: none;
    }

    /* Hide content after References/Notes/Citations sections */
    h2:has(span#References) ~ *,
    h2:has(span#Notes) ~ *,
    h2:has(span#Citations) ~ * {
        display: none;
    }
}

.article-title {
    font-size: 2em;
    letter-spacing: -0.1rem;
}

.mw-parser-output div.hatnote {
    padding: 0 !important;
    margin: 0 !important;
    font-style: normal !important;
    font-size: 0.9rem !important;
    color: var(--neutral-500) !important;
}

.article-content {
    font-size: 1.1em;
    line-height: 1.8;
}

.article-first-section {
    letter-spacing: -0.01em;

    a {
        color: var(--neutral-900);
        font-weight: 500;
        text-decoration: underline;
    }

    table.infobox {
        width: 100%;
        border-spacing: 0;
        margin-bottom: 3rem;

        tbody {
            display: flex;
            flex-direction: column;
            gap: 0;
        }
    }

    tr {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0.25rem;

        &:not(:last-child) {
            border-bottom: 1px solid var(--neutral-300) !important;
        }
    }

    tr:has(th.infobox-above) {
        display: none;
    }

    .infobox-image {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;

        > span {
            display: block;
            width: 100%;
            aspect-ratio: 2 / 1;
            height: 100%;
            flex: 1;
            overflow: hidden;
            
            > a {
                display: block;
                width: 100%;
                height: 100%;
                overflow: hidden;
                aspect-ratio: 1 / 1;

                img {
                    display: block;
                    width: 100%;
                    height: 100%;
                    object-fit: cover;
                }
            }
        }

        .infobox-caption {
            font-size: 0.8em;
            color: var(--neutral-500);
            flex: 1;
            line-height: 1.6;
        }

    }

    tr {

        &:has(th.infobox-header) {
            border-bottom: none !important;
        }

        th.infobox-header {
            background-color: #fff !important;
            text-align: left !important;
        }
    }

    tr > th.infobox-label {
        text-align: left;
        font-size: 1rem;
        width: 150px;
        font-weight: 500;
    }

    tr > td.infobox-data {
        text-align: left;
        font-size: 1rem;
        flex: 1;
    }

}

.article-first-section,
.article-section {
    font-size: 1.1em;
    line-height: 1.8;
    margin-bottom: 30px;
}

.article-first-section p,
.article-section p {
    margin-bottom: 1em;

    a {
        color: var(--accent);
        text-decoration: none;
        border-bottom: 1px solid hsl(from var(--accent) h s l / 0.5);
        font-weight: 400;
    }
}

.article-first-section h2,
.article-section h2,
.article-first-section h3,
.article-section h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.article-first-section ul,
.article-section ul,
.article-first-section ol,
.article-section ol {
    margin-left: 2em;
    margin-bottom: 1em;
}

/* Make images larger */
.article-first-section img,
.article-section img {
    max-width: 100%;
    height: auto;
    margin: 1.5em 0;
}

.article-first-section figure,
.article-section figure {
    margin: 2em 0;
    max-width: 100%;
}

.article-first-section figure img,
.article-section figure img {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: block;
}

/* Back to TOC link */
.back-to-toc {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--neutral-500);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: calc(var(--radius-base) * 2);
    opacity: 0.7;
    transition: opacity 0.2s, background-color 0.2s;

    &:hover {
        opacity: 1;
        background-color: var(--neutral-100);
    }
}

.article-first-section h2,
.article-section h2,
.article-first-section h3,
.article-section h3 {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Table of Contents */
.toc {
    position: relative;
    border-top: 2px solid var(--neutral-500);
    border-bottom: 2px solid var(--neutral-500);
    padding-block: 1rem;
}

.toc h2 {
    font-size: 1.5rem;
    margin: 0;
}

ul.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 1rem;
    
    > li.toc-item {
        margin: 0;

        &:not(:last-child) {
            border-bottom: 1px solid var(--neutral-400);
        }
        
        .toc-link {
            text-decoration: none;
            cursor: pointer;
            display: flex;
            color: var(--neutral-500);
            padding-block: 0.25rem;
            padding-inline: 0.5rem;
            align-items: center;
            justify-content: space-between;

            &:hover, &:focus {
                .toc-link-show {
                    opacity: 1;
                    visibility: visible;
                }
            }

            .toc-link-show {
                opacity: 0;
                visibility: hidden;
                border: 1px solid var(--neutral-500);
                padding: 0.05rem 0.5rem;
                border-radius: calc(var(--radius-base) * 15);
                font-size: 0.7rem;
                font-weight: 600;
                color: var(--neutral-500);
                text-transform: uppercase;
            }
        }
    }
}

.toc-link:hover {
    background-color: var(--neutral-200);
}

.toc-link.loaded {
    color: #27ae60;
    font-weight: 500;
}

.toc-link:focus {
    outline: 2px solid var(--neutral-500);
    outline-offset: 4px;
    border: none !important;
}

/* Article footer */
.article-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.article-footer .article-link,
.article-footer .back-link {
    margin-right: 10px;
}

.section-error {
    color: #e74c3c;
    padding: 10px;
    text-align: center;
}

.keyboard-hint {
    font-size: 0.8rem;
    color: var(--neutral-500);
    text-align: center; 
    justify-content: center;
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-inline: 1rem;

    span {
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }


    kbd {
        background: #ffffff;
        border-radius: 0.25rem;
        border: 1px solid var(--neutral-400);
        border-bottom-width: 2px;
        font-size: 0.8rem;
        font-weight: 500;
        color: var(--neutral-900);
        flex: 1;
        width: fit-content;
        height: 24px;
        aspect-ratio: 1/1;

        &.key-enter {
            padding-inline: 0.5rem;
        }

        &.key-escape {
            padding-inline: 0.5rem;
        }
    }

    i {
        font-style: normal;
    }
}

.article-link {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.3s;
}

.article-link:hover {
    background: #2980b9;
}

.back-link {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background: #95a5a6;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.3s;
}

.back-link:hover {
    background: #7f8c8d;
}

.error {
    color: #e74c3c;
    padding: 20px;
    text-align: center;
}

a {
    color: var(--accent);
    text-decoration: none;
}
