:root {
    --brand-link: #006b9f;
    --brand-link-hover: #004d73;
    --focus-ring: #ffbf47;
    --page-background: #f4f6f8;
    --surface: #ffffff;
    --text: #212529;
    --muted-text: #5c636a;
    --border: #ced4da;
    --reading-width: 72ch;
}

html { scroll-padding-top: 1rem; }

body {
    background: var(--page-background);
    color: var(--text);
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.65;
    margin: 0;
    min-height: 100vh;
}

a {
    color: var(--brand-link);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.14em;
}

a:hover { color: var(--brand-link-hover); }

:where(a, button, input, textarea, select, [tabindex]):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

.skip-link {
    background: #fff;
    color: #000;
    font-weight: 700;
    left: 1rem;
    padding: 0.75rem 1rem;
    position: fixed;
    top: 0;
    transform: translateY(-150%);
    transition: transform 0.15s ease-in-out;
    z-index: 1100;
}

.skip-link:focus { transform: translateY(0.75rem); }

.navbar-brand img {
    height: 40px;
    max-width: 100%;
    object-fit: contain;
}

.nav-link[aria-current="page"] {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 0.3em;
}

.page-layout {
    flex: 1 0 auto;
    padding-bottom: 3rem;
    padding-top: 2rem;
}

.content-card,
.article-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: clamp(1rem, 3vw, 2.25rem);
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
    scroll-margin-top: 1rem;
}

h1 {
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 650;
    letter-spacing: -0.025em;
    margin: 0 0 1rem;
}

.article-body h2,
.article-section > h2 {
    font-size: clamp(1.55rem, 3.5vw, 2rem);
    margin: 2.5rem 0 0.75rem;
}

.article-body h3 {
    font-size: clamp(1.3rem, 3vw, 1.6rem);
    margin: 2rem 0 0.65rem;
}

.article-body :is(h4, h5, h6) {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    margin: 1.75rem 0 0.5rem;
}

.article-body,
.article-header,
.article-actions,
.article-section { max-width: var(--reading-width); }

.article-body p,
.article-body ul,
.article-body ol,
.article-body blockquote { margin-bottom: 1.15rem; }

.article-body li + li { margin-top: 0.35rem; }

.publication-details,
.comment-details {
    color: var(--muted-text);
    font-family: Georgia, serif;
    font-size: 0.9rem;
}

.article-figure { margin: 1.5rem 0 2rem; }

.article-figure img,
.post-summary img,
.article-body img {
    height: auto;
    max-width: 100%;
}

figcaption {
    color: var(--muted-text);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.post-list,
.search-results {
    display: grid;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.post-summary { overflow: hidden; }
.post-summary .card-title a { color: inherit; }
.post-excerpt > :last-child { margin-bottom: 0; }

.article-toc {
    background: #f8f9fa;
    border-left: 5px solid #59636d;
    margin: 1.75rem 0;
    max-width: var(--reading-width);
    padding: 0.75rem 1rem;
}

.article-toc h2 {
    font-size: 1.2rem;
    margin: 0 0 0.5rem;
}

.article-toc ul { margin-bottom: 0; }

.article-body .headerlink {
    font-size: 0.75em;
    margin-left: 0.35rem;
    opacity: 0.25;
}

.article-body :is(h2, h3, h4, h5, h6):hover .headerlink,
.article-body .headerlink:focus { opacity: 1; }

.article-body blockquote {
    border-left: 4px solid #6c757d;
    color: #3f464d;
    padding-left: 1rem;
}

.codehilite,
.article-body > pre {
    background: #f6f8fa;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    margin: 1.25rem 0;
    max-width: 100%;
    overflow-x: auto;
}

.codehilite pre,
.article-body > pre {
    background: transparent;
    border: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(0.82rem, 2vw, 0.94rem);
    line-height: 1.55;
    margin: 0;
    min-width: max-content;
    padding: 1rem;
    white-space: pre;
}

code {
    background: #edf1f4;
    border-radius: 0.2rem;
    color: #9c1c4b;
    font-size: 0.9em;
    padding: 0.12em 0.3em;
}

pre code,
.codehilite code {
    background: transparent;
    border-radius: 0;
    color: inherit;
    font-size: inherit;
    padding: 0;
}

.highlight.terminal,
.terminal .highlight,
.terminal.codehilite {
    background: #161b22;
    border-color: #4b5563;
    color: #f0f6fc;
}

.terminal::before {
    color: #d1d5db;
    content: "Terminal";
    display: block;
    font-family: system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.55rem 1rem 0;
    text-transform: uppercase;
}

.article-body table {
    border-collapse: collapse;
    display: block;
    margin: 1.25rem 0;
    max-width: 100%;
    overflow-x: auto;
    width: max-content;
}

.article-body th,
.article-body td {
    border: 1px solid #aeb5bc;
    padding: 0.6rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

.article-body th { background: #e9ecef; }
.article-body tbody tr:nth-child(even) { background: #f8f9fa; }

.admonition {
    border: 1px solid #8b949e;
    border-left-width: 6px;
    border-radius: 0.4rem;
    margin: 1.25rem 0;
    padding: 0.85rem 1rem;
}

.admonition-title {
    font-weight: 750;
    margin-bottom: 0.5rem;
}

.admonition.note,
.admonition.info {
    background: #eef5ff;
    border-left-color: #0758a8;
}

.admonition.tip {
    background: #edf8f2;
    border-left-color: #126b3b;
}

.admonition.warning,
.admonition.danger,
.admonition.important {
    background: #fff4e5;
    border-left-color: #a64b00;
}

.comment {
    border-left: 4px solid var(--border);
    margin: 1rem 0;
    padding: 0.75rem 1rem;
}

.accessible-form > div,
.accessible-form > p { margin-bottom: 1rem; }

.accessible-form label {
    display: block;
    font-weight: 650;
    margin-bottom: 0.35rem;
}

.accessible-form :is(input:not([type="hidden"]), textarea, select) {
    background: #fff;
    border: 1px solid #757b80;
    border-radius: 0.375rem;
    display: block;
    max-width: 100%;
    padding: 0.55rem 0.7rem;
    width: 100%;
}

.accessible-form textarea {
    min-height: 10rem;
    resize: vertical;
}

.errorlist {
    color: #a40022;
    font-weight: 650;
    margin: 0.35rem 0;
    padding-left: 1.25rem;
}

.pagination-nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 2rem;
}

.site-footer {
    flex-shrink: 0;
    padding: 1.25rem 0;
    text-align: center;
}

/* Two-factor authentication pages */

.two-factor-auth input[type="text"],
.two-factor-auth input[type="password"],
.two-factor-auth input[type="number"],
.two-factor-auth input[type="tel"] {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

.two-factor-auth button[type="submit"] {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    background-color: #0d6efd;
    color: white;
}

.two-factor-auth button[type="submit"]:hover {
    background-color: #0b5ed7;
}

@media (max-width: 767.98px) {
    .page-layout {
        padding-bottom: 2rem;
        padding-top: 1rem;
    }

    .content-card,
    .article-card {
        border-left: 0;
        border-radius: 0;
        border-right: 0;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
