body {
    width: min(70ch, 100vw - 2rem);
    margin-inline: auto;
    font-family: system-ui, -apple-system-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    font-size: 1.1rem;
    line-height: 1.7rem;
    background-color: var(--background);
    color: var(--foreground);

    &:has(#gallery-main) {
        width: min(120ch, 100vw - 2rem);
    }
}

h1 {
    line-height: 100%;
}

.buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    flex-wrap: wrap;

    a, a * {
        width: 88px;
        height: 31px;
        text-decoration: none;
        outline: none;

        & img {
            transition: var(--transition-ease-out) transform;
            image-rendering: pixelated;
            user-select: none;
        }

        &:focus-visible img, &:hover img {
            outline: 2px solid var(--primary);
            transform: scale(1.2);
        }
    }
}

.pronouns, .post_li .date {
    opacity: 0.7;
    font-size: 0.9rem;
}

.avatar {
    float: right;
    max-width: 200px;
    max-height: 200px;
    aspect-ratio: 1/1;
    /* cursor: url('/static/img/cursor_boop.png'), auto; */
    margin-left: 1ch;
    margin-bottom: 1ch;
    user-select: none;
}

.boop {
    animation: boop 0.7s cubic-bezier(0.075, 0.82, 0.165, 1);
}

@keyframes boop {
    0% {
        transform: scale(1, 1);
    }
    10% {
        transform: scale(1.2, 0.7);
    }
    25% {
        transform: scale(0.7, 1.15);
    }
    50% {
        transform: scale(1.1, 0.85);
    }
    75% {
        transform: scale(0.9, 1.1);
    }
    100% {
        transform: scale(1, 1);
    }
}

a:not(:is(.buttons a, .anonmsgs a, .comments li > a)) {
    color: var(--primary);
    font-weight: bold;
    padding: 0.1em;
    outline: none;

    &:hover, &:focus-visible {
        background-color: var(--i-background);
    }
}

p {
    text-align: justify;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    justify-content: space-around;
    background-color: var(--i-background);
    width: min(70ch, 100vw - 2rem);
    margin-inline: auto;

    & a {
        text-decoration: none;
        padding: 0.5em !important;
    }
}

.grouped_title {
    & h1 {
        margin-bottom: 0.25em;
    }

    margin-bottom: 0.67em;
}

.pagination {
    text-align: center;
}

#question div, #entry div {
    display: flex;
    flex-wrap: wrap;

    & textarea, & input[type=text] {
        flex: 1;
        margin-left: 1ch;
    }
}

label {
    user-select: none;
}

input:is([type=checkbox], [type=submit]), button {
    cursor: pointer;
    outline: none;

    &:focus-visible {
        outline: 2px solid var(--primary);
    }
}

input[type=text], textarea {
    outline: none;

    &:focus {
        outline: 2px solid var(--primary);
    }
}

form:not(:last-child) {
    margin-bottom: 0.7em;
}

::selection, ::-moz-selection {
    color: var(--background);
    background-color: var(--primary);
}

.hidden {
    display: none;
}

.signatures {
    list-style: none;
    padding-left: 0;

    & li {
        display: flex;
        flex-direction: column;
        padding: 0.2rem;
        border-left: 2px solid oklch(from var(--primary) l c calc(h - 45));
        background-color: oklch(from var(--i-background) l c calc(h - 45));

        &:not(:last-child) {
            padding-bottom: 0.5em;
            margin-bottom: 1em;
        }

        &:not(:first-child) {
            padding-top: 0.5em;
        }

        & .date {
            font-style: italic;
        }

        & .name {
            font-weight: bold;
        }

        & p {
            margin-bottom: 0;
            margin-top: 0;
            text-align: left;
        }
    }
}

.commentview {
    display: flex;
    flex-direction: column;
    padding: 0.2rem;
    border-left: 2px solid oklch(from var(--primary) l c calc(h - 45));
    background-color: oklch(from var(--i-background) l c calc(h - 45));
}

.comments {
    list-style: none;
    padding-left: 0;

    & a {
        color: inherit;
        text-decoration: none;
    }

    & li {
        padding: 0.2rem;
        border-left: 2px solid oklch(from var(--primary) l c calc(h - 45));
        background-color: oklch(from var(--i-background) l c calc(h - 45));

        & > a {
            display: flex;
            flex-direction: column;
        }

        &:not(:last-child) {
            padding-bottom: 0.5em;
            border-bottom: 1px solid;
        }

        &:not(:first-child) {
            padding-top: 0.5em;
        }

        &:not(:last-child) {
            padding-bottom: 0.5em;
            margin-bottom: 1em;
        }

        &:not(:first-child) {
            padding-top: 0.5em;
        }

        & .date {
            font-style: italic;
        }

        & .name {
            font-weight: bold;
        }

        & p {
            margin-bottom: 0;
            margin-top: 0;
            text-align: left;
        }
    }
}

.anonmsgs {
    list-style: none;
    padding-left: 0;

    & a {
        color: inherit;
        text-decoration: none;
    }

    & details {
        padding-left: 2ch;

        & summary {
            transform: translateX(-2ch);
        }
    }

    & li {
        &:not(:last-child) {
            padding-bottom: 0.5em;
            border-bottom: 1px solid;
        }

        &:not(:first-child) {
            padding-top: 0.5em;
        }
    }
}

.question, .answer, .signatures li {
    white-space: pre-wrap;
    white-space: -moz-pre-wrap;
    white-space: -pre-wrap;
    white-space: -o-pre-wrap;
    word-wrap: break-word;
    margin-bottom: 0;
    margin-top: 0;
    text-align: left;
}

.question {
    font-style: italic;
    margin-left: 2ch;
    padding: 0.2rem;
    border-left: 2px solid oklch(from var(--primary) l c calc(h - 45));
    background-color: oklch(from var(--i-background) l c calc(h - 45));

    &:not(details .question) {
        margin-left: 4ch;
    }
}

.answer:not(details .answer) {
    margin-left: 2ch;
}

.answer .date, .question .date, .signatures .date {
    opacity: 0.7;
    font-size: 0.9rem;
}

.success, .error {
    font-weight: bold;

    &.success {
        color: var(--primary);
    }

    &.error {
        color: oklch(from var(--primary) l c calc(h - 110));
    }
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    justify-content: center;

    & input.imgtoggle {
        position: absolute;
        clip: rect(1px, 1px, 1px, 1px);
        padding: 0;
        border: 0;
        height: 1px;
        width: 1px;
        overflow: hidden;

        &:focus-visible ~ .imglabel .thumbnail {
            outline: 3px solid var(--primary);
        }

        &:not(:target):checked ~ .viewer, &:target:not(:checked) ~ .viewer {
            display: block;
        }
    }

    & .imglabel {
        display: flex;
        flex-direction: column;

        & a {
            text-align: center;
        }
    }

    & .thumbnail {
        object-fit: cover;
        aspect-ratio: 4/3;
        width: 350px;
        cursor: pointer;
    }

    & .viewer {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100dvw;
        height: 100dvh;
        overflow: hidden;
        z-index: 10;
        background-color: rgba(0, 0, 0, 0.8);

        & .highres {
            max-width: 90dvw;
            max-height: 90dvh;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, calc(-50% - 1em));
            border: 0.75em solid white;
        }

        & .info {
            text-align: right;
            color: #dedede;
            position: absolute;
            top: 0.5em;
            right: 1em;
            z-index: 100;
            text-shadow: 0 0 5px black;

            & ul {
                list-style: none;
                padding: 0;
            }

            & details {
                margin-top: 0.5em;
            }
        }

        & .controls {
            & .status {
                color: #dedede;
                text-shadow: 0 0 5px black;
            }
            position: absolute;
            bottom: 0.75em;
            left: 50%;
            transform: translateX(-50%);
        }

        & .close {
            color: red;
            font-weight: bold;
            cursor: pointer;
            text-shadow: 0 0 2px black;
        }
    }
}

summary {
    cursor: pointer;
}

#comment_frame {
    width: 100%;
    min-height: 350px;
}

.errorpage {
    text-align: center;
}

article img {
    max-width: 100%;
}

#darkmode {
    display: none;
}

#darkmode_label {
    position: fixed;
    right: 0.25rem;
    bottom: 0.25rem;
    z-index: 999;
    padding: 0.3rem;
    background-color: var(--i-background);
    color: var(--primary);
    font-weight: bold;
    cursor: pointer;
    animation: hide-darkmode-toggle 0.5s cubic-bezier(0.075, 0.82, 0.165, 1);
    animation-fill-mode: forwards;
    animation-delay: 3s;
    &::before {
        content: "Dark mode";
    }

    &:hover, &:focus {
        animation: none;
    }

    &:focus-visible {
        outline: 2px solid var(--primary);
    }
}

@keyframes hide-darkmode-toggle {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

:root {
    color-scheme: light dark;

    --primary: oklch(53.53% 0.1548 134.6);
    --background: oklch(from var(--primary) 95% 0.04 calc(h - 60));
    --foreground: oklch(from var(--primary) 20% 0.04 h);
    --i-background: oklch(from var(--primary) calc(l * 1.2) c h/ 30%);

    --code-background: oklch(from var(--i-background) l c calc(h - 60));
    --code-foreground: oklch(from var(--code-background) calc((1 - l) * (1 + l) - 0.2) 0.04 h/ 100%);
    --code-subtle: oklch(from var(--code-foreground) calc(l + 0.2) c h);
    --code-keyword: oklch(from var(--code-foreground) calc(l + 0.15) calc(c + 0.1) calc(h - 90));
    --code-function: oklch(from var(--code-keyword) l c calc(h - 90));
    --code-string: oklch(from var(--code-keyword) l c calc(h + 45));
    --code-namespace: oklch(from var(--code-keyword) l c calc(h - 60));
    --code-variable: oklch(from var(--code-keyword) l c calc(h - 180));
    --code-err: oklch(from var(--code-keyword) l c calc(h +  28));

    --transition-ease-out: 0.2s cubic-bezier(.08,.82,.17,1);
}

:root:has(#darkmode:checked) {
    & #darkmode_label::before {
        content: "Light mode";
    }

    --background: oklch(from var(--primary) 15% 0.02 calc(h - 60));
    --foreground: oklch(from var(--primary) 95% 0.04 h);
    --i-background: oklch(from var(--primary) calc(l * 1.2) calc(c * 0.7) h/ 30%);
    --code-background: oklch(from var(--i-background) l 0.02 calc(h - 60));
    --code-foreground: oklch(from var(--code-background) calc((1 - l) * (1 + l)) 0.04 h/ 100%);
    --code-subtle: oklch(from var(--code-foreground) calc(l - 0.1) c h);
}

@media (prefers-color-scheme: dark) {
    #darkmode_label::before {
        content: "Light mode";
    }

    :root {
        --background: oklch(from var(--primary) 15% 0.02 calc(h - 60));
        --foreground: oklch(from var(--primary) 95% 0.04 h);
        --i-background: oklch(from var(--primary) calc(l * 1.2) calc(c * 0.7) h/ 30%);
        --code-background: oklch(from var(--i-background) l 0.02 calc(h - 60));
        --code-foreground: oklch(from var(--code-background) calc((1 - l) * (1 + l)) 0.04 h/ 100%);
        --code-subtle: oklch(from var(--code-foreground) calc(l - 0.1) c h);
    }

    :root:has(#darkmode:checked) {
        & #darkmode_label::before {
            content: "Dark mode";
        }

        --background: oklch(from var(--primary) 95% 0.04 calc(h - 60));
        --foreground: oklch(from var(--primary) 20% 0.04 h);
        --i-background: oklch(from var(--primary) calc(l * 1.2) c h/ 30%);
        --code-background: oklch(from var(--i-background) l c calc(h - 60));
        --code-foreground: oklch(from var(--code-background) calc((1 - l) * (1 + l) - 0.2) 0.04 h/ 100%);
        --code-subtle: oklch(from var(--code-foreground) calc(l + 0.2) c h);
    }
}




/* pygments */
pre {
    line-height: 100%;
    background-color: var(--code-background);
    border-left: 2px solid oklch(from var(--primary) l c calc(h - 45));
    padding: 0.35rem;
    overflow: scroll;
}

.codeblock {
    color: var(--code-foreground);
    & .c, .ch, .cm, .cp, .cpf, .c1, .cs, .o, .m, .mb, .mf, .mh, .mo, .il, .mi, .gi, .go, .gt, .nl {
        color: var(--code-subtle);
    }

    & .err, .gr, .gd {
        color: var(--code-err);
    }

    & .k, .kc, .kd, .kn, .kp, .kr, .kt, .nt, .ow, .gh {
        color: var(--code-keyword);
    }

    & .nb, .sx, .bp, .nf, .fm, .gp, .gu {
        color: var(--code-function);
    }

    & .s, .sa, .sb, .sc, .dl, .s2, .sh, .sr, .s1, .ss, .sd, .se, .si {
        color: var(--code-string);
    }

    & .sd {
        font-style: italic;
    }

    & .se, .si, .nc, .nn, .k, .kc, .kd, .kn, .kp, .kr, .kt, .nt, .ow, .gs, .gp, .gu, .gh, .ges {
        font-weight: bold;
    }

    & .ges, .c, .ch, .cm, .cp, .cpf, .c1, .cs, .ge {
        font-style: italic;
    }

    & .nc, .nn, .nd {
        color: var(--code-namespace);
    }

    & .na, .no, .ni, .ne, .nv, .vc, .vg, .vi, .vm {
        color: var(--code-variable);
    }

    & .hll {
        background-color: var(--code-foreground);
        color: var(--code-background);
    }
}
