/* ==========================================================================
   Palette
   ========================================================================== */

:root {
    --nc-bg-1: #ffffff;
    --nc-bg-3: #e5e7eb;
    --knot-text: #120c0e;
    --knot-background: #FEEFF0;
    --knot-selection: #FCD8E0;
    --knot-target: #FCD8E0;
    --knot3: #C72259;
    --page-pad: 2rem;
    --nav-height: 2.75rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --nc-bg-1: #000000;
        --nc-bg-3: #222222;
        --knot-text: #FCD8E0;
        --knot-background: #120c0e;
        --knot-target: #3a1520;
        --knot3: #C72259;
    }
}

@media (max-width: 600px) {
    :root {
        --page-pad: 1rem;
    }
}

/* ==========================================================================
   Base
   ========================================================================== */

* {
    margin: 0;
    margin-bottom: 0.5rem;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif,
        "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

html {
    scroll-padding-top: calc(var(--nav-height) + 1rem);
}

body {
    margin: 0 auto;
    max-width: 1000px;
    padding: var(--page-pad);
    border-radius: 6px;
    overflow-x: hidden;
    overflow-wrap: break-word;
    background: var(--knot-background);
    color: var(--knot-text);
    font-size: 1.03rem;
    line-height: 1.5;
}

::selection {
    background: var(--knot-selection);
    color: var(--knot3);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1;
    color: var(--knot3);
    padding-top: 0.875rem;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--knot3);
}

h1 {
    font-size: 2.5rem;
    font-family: "October Twilight", sans-serif;
    font-weight: lighter;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.2rem;
}

a {
    color: var(--knot3);
    text-decoration-style: dotted;
}

a:hover {
    text-decoration-style: solid;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

hr {
    border: 0;
    border-bottom: 1px solid var(--nc-bg-3);
    margin: 1rem auto;
}

ol,
ul {
    padding-left: 2rem;
}

li {
    margin-top: 0.4rem;
}

ol ol,
ol ul,
ul ol,
ul ul {
    margin-bottom: 0;
}

img {
    max-width: 100%;
}

main > section + section {
    margin-top: 1.5rem;
}

/* ==========================================================================
   Page frame: header band, menu, footer
   ========================================================================== */

.skip-link {
    position: absolute;
    left: -999px;
}

.skip-link:focus {
    left: 0;
    top: 0;
    z-index: 100;
    padding: 0.4rem 0.8rem;
    background: var(--knot3);
    color: var(--knot-background);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--knot-background);
    border-bottom: 8px solid var(--knot3);
    margin: calc(0px - var(--page-pad)) calc(0px - (50vw - 50%)) 0;
    padding: calc(1rem + 30px) calc(50vw - 50%) calc(1.5rem + 30px);
}

.site-header .logo,
.site-header .logo * {
    margin: 0;
}

.site-header img {
    display: block;
}

.site-header h1 {
    border-bottom: 0;
    padding-bottom: 0;
    margin: -1rem 0; /* the two-line title may overhang the logo without making the band taller */
    text-align: right;
}

.site-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--nav-height);
    box-sizing: border-box;
    margin: 0 calc(0px - (50vw - 50%)) 1.5rem;
    padding: 0 calc(50vw - 50%);
    background: var(--knot-background);
    border-bottom: 1px solid var(--knot3);
}

.site-nav * {
    margin: 0;
}

.site-nav ul {
    display: flex;
    height: 100%;
    gap: 0 1.75rem;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.site-nav a {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    height: 100%;
    padding-top: 3px;
    border-bottom: 3px solid transparent;
    color: var(--knot-text);
    font-weight: 600;
    text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus {
    color: var(--knot3);
}

.site-nav a[aria-current="page"] {
    color: var(--knot3);
    border-bottom-color: var(--knot3);
}

.site-nav .nav-contact {
    margin-left: auto;
}

.nav-badge {
    margin-left: 0.35rem;
    padding: 0 0.4rem;
    border: 1px solid var(--knot3);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.3;
}

@media (max-width: 600px) {
    .site-nav ul {
        gap: 0 0.9rem;
    }

    .site-nav a {
        font-size: 0.92rem;
    }
}

@media (max-width: 420px) {
    .nav-badge {
        display: none;
    }

    .site-nav ul {
        gap: 0 0.5rem;
    }

    .site-nav a {
        font-size: 0.8rem;
    }
}

.site-footer {
    margin-top: 2rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--nc-bg-3);
    font-size: 0.85rem;
}

.site-footer p {
    margin-bottom: 0.25rem;
}

.site-footer:target {
    background: var(--knot-target);
    border-radius: 4px;
}

/* ==========================================================================
   Buttons and forms
   ========================================================================== */

.button {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border: 2px solid var(--knot3);
    border-radius: 6px;
    background: var(--knot3);
    color: var(--knot-background);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
}

.button:hover,
.button:focus {
    background: var(--knot-background);
    color: var(--knot3);
}

.button-secondary {
    background: transparent;
    color: var(--knot3);
}

.button-secondary:hover,
.button-secondary:focus {
    background: var(--knot3);
    color: var(--knot-background);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.actions > * {
    margin: 0;
}

input[type="search"] {
    box-sizing: border-box;
    width: 100%;
    padding: 0.35rem 0.7rem;
    font-size: 1rem;
    border: 2px solid var(--knot3);
    border-radius: 6px;
    background: var(--nc-bg-1);
    color: var(--knot-text);
}

input[type="search"]:focus {
    outline: 3px solid var(--knot-selection);
}

.search-form {
    display: flex;
    gap: 0.5rem;
}

.search-form > * {
    margin: 0;
}

.search-form input {
    flex: 1;
}

.search-bar {
    position: sticky;
    top: var(--nav-height);
    z-index: 10;
    background: var(--knot-background);
    padding: 0.4rem 0 0.1rem;
}

.search-status {
    font-size: 0.85rem;
    margin: 0.2rem 0 0;
    min-height: 1.2em;
}

/* ==========================================================================
   Home page: the book
   ========================================================================== */

.book-meta {
    opacity: 0.8;
}

.book-banner {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 0.75rem;
    border-radius: 6px;
}

/* ==========================================================================
   Materials: lectures, cover previews
   ========================================================================== */

.lecture-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0 1rem;
}

.lecture-head > * {
    margin: 0;
}

.lecture-meta {
    margin-left: auto;
    text-align: right;
}

.cover-tooltip {
    position: fixed;
    z-index: 100;
    width: 260px;
    padding: 0.3rem;
    background: var(--nc-bg-1);
    border: 1px solid var(--knot3);
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.cover-tooltip img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

/* ==========================================================================
   Reference lists: bibliography and recent papers
   ========================================================================== */

.ref-intro {
    font-size: 0.9rem;
    line-height: 1.35;
}

.ref-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.2rem;
    padding-left: 0;
    list-style: none;
    margin-bottom: 0;
}

.ref-toc li {
    margin: 0;
    font-size: 0.9rem;
}

.group > h2 {
    margin-top: 1.2rem;
    padding-top: 0.4rem;
    font-size: 1.25rem;
}

.group > h3 {
    margin-top: 0.8rem;
    padding-top: 0.2rem;
    font-size: 1.05rem;
    border-bottom-color: var(--nc-bg-3);
}

.group > p,
.link-list {
    font-size: 0.9rem;
    line-height: 1.35;
}

.ref-count {
    font-size: 0.8em;
    font-weight: normal;
    opacity: 0.75;
}

ul.ref-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.ref {
    margin: 0;
    padding: 0.12rem 0 0.12rem 2.5rem;
    text-indent: -2.5rem;
    font-size: 0.9rem;
    line-height: 1.3;
    scroll-margin-top: 3.5rem;
}

.ref * {
    margin-bottom: 0;
}

.ref + .ref {
    border-top: 1px solid var(--nc-bg-3);
}

.ref:target {
    background: var(--knot-target);
    border-radius: 4px;
}

.ref-num,
.ref-date,
.ref-score {
    display: inline-block;
    text-indent: 0;
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
}

.ref-num {
    min-width: 2.2rem;
    margin-right: 0.3rem;
    text-align: right;
}

.ref-list-dated .ref {
    padding-left: 4rem;
    text-indent: -4rem;
}

.ref-date,
.ref-score {
    width: 3.4rem;
    margin-right: 0.6rem;
    text-align: right;
}

.ref-tags {
    margin-left: 0.2rem;
}

.tag {
    display: inline-block;
    text-indent: 0;
    margin: 0 0.1rem;
    padding: 0 0.3rem;
    border: 1px solid var(--nc-bg-3);
    border-radius: 4px;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--knot3);
    cursor: pointer;
}

.tag:hover {
    border-color: var(--knot3);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.2rem 0 0.5rem;
}

.chips > * {
    margin: 0;
}

.chips-label {
    align-self: center;
    font-size: 0.85rem;
    opacity: 0.8;
}

.chips-label:not(:first-child) {
    margin-left: 0.6rem;
}

.chip {
    padding: 0.15rem 0.7rem;
    border: 1px solid var(--knot3);
    border-radius: 999px;
    background: transparent;
    color: var(--knot3);
    font-size: 0.85rem;
    cursor: pointer;
}

.chip[aria-pressed="true"],
.chip:hover,
.chip:focus {
    background: var(--knot3);
    color: var(--knot-background);
}

.ref-authors {
    font-weight: 600;
}

.ref-note,
.ref-cites {
    font-size: 0.9em;
    opacity: 0.8;
}

.ref-links {
    white-space: nowrap;
}

.ref-link {
    display: inline-block;
    text-indent: 0;
    margin-left: 0.1rem;
    padding: 0.12rem 0.3rem;
    border: 1px solid var(--knot3);
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
}

.ref-link:hover,
.ref-link:focus {
    background: var(--knot3);
    color: var(--knot-background);
}

.ref-link-mr {
    opacity: 0.7;
}

.ref-abstract {
    text-indent: inherit;
}

.ref-abstract summary {
    list-style: none;
    cursor: pointer;
}

.ref-abstract summary::-webkit-details-marker {
    display: none;
}

.ref-abstract summary::after {
    content: "streszczenie \25B8";
    margin-left: 0.5rem;
    font-size: 0.75rem;
    color: var(--knot3);
    white-space: nowrap;
}

.ref-abstract[open] summary::after {
    content: "streszczenie \25BE";
}

.ref-abstract p {
    margin: 0.2rem 0;
    text-indent: 0;
    font-size: 0.85rem;
}

.ref[hidden],
.group[hidden] {
    display: none;
}

mjx-container {
    font-size: 100% !important;
}
