/* ---- BRAND COLOR ---- */
:root {
    --sspai-red: #d71a1b;
}

/* ---- FONTS ---- */
:root {
    --body-font-family:
        system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei",
        "Noto Sans CJK SC", sans-serif;
}

/* ---- LIGHT THEME with reddish hue ---- */
:root {
    --body-background: #fdf8f7;
    --body-font-color: black;
    --color-link: var(--sspai-red);
    --color-visited-link: var(--sspai-red);
    --icon-filter: none;
    --gray-100: #faf3f1;
    --gray-200: #eddfdc;
    --gray-300: #e0d0cc;
    --gray-500: #adb5bd;
    color-scheme: light;
}

/* ---- LOGO ---- */
.book-brand img {
    height: 2rem;
    width: auto;
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* ---- HEADINGS ---- */
.markdown h1 {
    font-size: 1.4em;
}
.markdown h2 {
    font-size: 1.2em;
}
.markdown h3 {
    font-size: 1.1em;
}
.markdown h4 {
    font-size: 1em;
}
.markdown h5 {
    font-size: 1em;
}
.markdown h6 {
    font-size: 1em;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
    color: var(--sspai-red);
    font-weight: bold;
}

/* ---- DEFINITION LISTS ---- */
.markdown dl dt {
    display: inline;
    font-weight: bolder;
}

.markdown dl dt::after {
    content: " ";
}

.markdown dl dd {
    display: inline;
    margin-inline-start: 0;
}

.markdown dl dd::after {
    content: "";
    display: block;
    margin-bottom: 0.5rem;
}

/* ---- FRAGMENT HIGHLIGHT ---- */
:root {
    --target-highlight: color-mix(in srgb, var(--color-link) 22%, transparent);
}

.markdown :target {
    animation: target-highlight-fade 2.4s ease-out forwards;
    border-radius: 0.15rem;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    scroll-margin-top: 1rem;
}

::target-text {
    animation: target-highlight-fade 2.4s ease-out forwards;
    background-color: var(--target-highlight);
}

@keyframes target-highlight-fade {
    0%,
    65% {
        background-color: var(--target-highlight);
    }

    100% {
        background-color: transparent;
    }
}

/* Headings inside admonitions use default body color */
.book-hint h1,
.book-hint h2,
.book-hint h3,
.book-hint h4,
.book-hint h5,
.book-hint h6 {
    color: inherit;
}

/* ---- TABLES ---- */
.markdown table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    border-top: 0.2rem solid var(--sspai-red);
    border-bottom: 0.05rem solid var(--sspai-red);
    border-left: none;
    border-right: none;
}

.markdown table tr th,
.markdown table tr td {
    border: none;
}

@media screen and (max-width: 48rem) {
    .markdown table tr th,
    .markdown table tr td {
        min-width: 9rem;
    }

    .markdown table tr > :first-child:nth-last-child(2),
    .markdown table tr > :first-child:nth-last-child(2) ~ * {
        min-width: 12rem;
    }
}

.markdown table th {
    color: var(--sspai-red);
    background: none;
}

/* ---- HINTS / ALERTS (admonitions) ---- */
.book-hint {
    font-size: 1em;
}

.book-hint > p:first-child {
    font-weight: bold;
}

.markdown .book-hint.note {
    border-color: var(--gray-300);
    background-color: var(--gray-100);
}

/* ---- LEGAL NUMBERING ---- */
/* Add .unnumbered to a heading or list item to exclude it from numbering. */
.book-type-legal .markdown {
    counter-reset: part;

    h1 {
        counter-reset: part;
    }

    h2:not(.unnumbered) {
        counter-reset: clause;
    }
    h2:not(.unnumbered)::before {
        counter-increment: part;
        content: counter(part) ". ";
    }

    h3:not(.unnumbered) {
        counter-reset: section;
    }
    h3:not(.unnumbered)::before {
        counter-increment: clause;
        content: counter(part) "." counter(clause) " ";
    }

    > ol {
        list-style: none;
        margin-left: 0 !important;
        padding-left: 0 !important;

        > li {
            margin-left: 0 !important;
            margin-right: 0.5em;
            margin-bottom: 0.5em;

            &:not(.unnumbered) {
                counter-increment: section;

                &::before {
                    content: "(" counter(section) ") ";
                }
                > p:first-child {
                    display: inline;
                }
            }

            > ol {
                counter-reset: paragraph;
                list-style: none;
                margin-top: 0.3em;

                > li {
                    margin-left: 0 !important;
                    margin-right: 0.5em;
                    margin-bottom: 0.3em;

                    &:not(.unnumbered) {
                        counter-increment: paragraph;

                        &::before {
                            content: "(" counter(paragraph, lower-alpha) ") ";
                        }
                        > p:first-child {
                            display: inline;
                        }
                    }

                    > ol {
                        counter-reset: subparagraph;
                        list-style: none;
                        margin-top: 0.3em;

                        > li {
                            margin-left: 0 !important;
                            margin-right: 0.5em;
                            margin-bottom: 0.3em;

                            &:not(.unnumbered) {
                                counter-increment: subparagraph;

                                &::before {
                                    content: "("
                                        counter(subparagraph, lower-roman) ") ";
                                }
                                > p:first-child {
                                    display: inline;
                                }
                            }

                            > ol {
                                counter-reset: subsubparagraph;
                                list-style: none;
                                margin-top: 0.3em;

                                > li {
                                    margin-left: 0 !important;
                                    margin-right: 0.5em;
                                    margin-bottom: 0.3em;

                                    &:not(.unnumbered) {
                                        counter-increment: subsubparagraph;

                                        &::before {
                                            content: "("
                                                counter(
                                                    subsubparagraph,
                                                    upper-alpha
                                                )
                                                ") ";
                                        }
                                        > p:first-child {
                                            display: inline;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

/* ---- NAVIGATION MENU ---- */
.book-menu nav a {
    font-weight: bold;
}

/* ---- FRAGMENT TARGET HIGHLIGHT ---- */
@keyframes target-fade {
    from {
        background-color: rgba(215, 26, 27, 0.12);
    }
    to {
        background-color: transparent;
    }
}

:target {
    animation: target-fade 2s ease-out;
}

/* ---- LIST MARKERS ---- */
.markdown ul li::marker {
    color: var(--sspai-red);
}

/* ---- STEPS ---- */

.markdown .book-steps > ol > li::before {
    background: var(--sspai-red);
}
