@font-face {
    font-family: 'Noto Color Emoji';
    src: url('/NotoColorEmoji-Regular.ttf') format('truetype');
    unicode-range: U+2???, U+F???, U+1F???;
}

html, body {
    font-family: "Crimson Text", serif;
    font-weight: 400;
    font-size: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-size: inherit;
    text-decoration: inherit;
    font-weight: inherit;
    font-style: inherit;
    list-style: none outside;
}

a:link {
    color: #591516;
}

a:visited {
    color: #591516;
}

a:hover {
    color: #74191b;
    text-decoration: underline;
}

body {
    display: block;
    min-height: 100vh;
    background: #232323 url('/background-damask.jpg') 50% 50% repeat;
    
    padding: 0 20px 20px 20px;

    & > * {
        min-width: 300px;
        max-width: 1200px;
        margin: 0 auto;
    }

    & > header {
        background: #6c1213 url('/header-damask.jpg') 50% 50% repeat;
        background-size: 288px 257px;
        position: relative;

        & > div#auth {
            position: absolute;
            top: 0;
            right: 0;
            width: auto;
            display: block;
            background-color: rgba(255, 255, 255, 0.85);
            padding: 0.5rem 1rem;
            border-radius: 0 0 0 0.5rem;

            & > span.username {
                display: inline-block;
                margin-right: 0.5rem;
                border-right: 1px solid #591516;
                padding-right: 0.5rem;
            }

            & > a {
                display: inline-block;
            }
        }

        & > h1 {
            aspect-ratio: 8 / 1;
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            padding: 1rem 5rem;

            & > img {
                display: block;
                max-height: 12rem;
            }

            & > span {
                display: block;
                color: #fff;
                font-family: Iceberg, 'Noto Color Emoji';
                font-size: 200%;
                white-space: nowrap;
            }
        }

        & > nav {
            padding: 10px;
            background-color: rgba(0, 0, 0, 0.25);

            & > ul {
                border: solid 2px #fff;
                border-radius: 5px;
                background-color: #591516;
                overflow: hidden;
                display: flex;
                flex-direction: row;
                justify-content: start;
                align-items: center;

                & > li {
                    & > a:link, & > a:visited, & > a:hover {
                        display: block;
                        padding: 10px 15px;
                        color: #fff;
                        font-size: 125%;
                    }

                    &.current {
                        background: linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.3) 45%, rgba(255, 255, 255, 0.1) 55%, rgba(255, 255, 255, 0) 100%);
                    }
                }
            }
        }
    }

    & > main {
        & em {
            font-style: italic;
            color: #591516;
        }

        & strong {
            font-weight: 700;
            color: #591516;
        }

        padding: 10px;
        background-color: #fff;
        color: #000;
        min-height: 35vh;

        & > h2 {
            font-family: Iceberg, 'Noto Color Emoji';
            font-size: 150%;
            color: #591516;
        }

        & > h3 {
            font-family: Iceberg, 'Noto Color Emoji';
            font-size: 125%;
            color: #591516;
        }

        & > p {
            & + p, & + section, & + ul {
                margin-top: 1rem;
            }
        }

        & > section {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: flex-start;
            gap: 20px;

            h1 + p, h2 + p, h3 + p, p + p, p + h2, p + h3 {
                margin-top: 0.5rem;
            }

            & + * {
                margin-top: 1rem;
            }

            &.thread {
                display: grid;
                grid-template-columns: auto 1fr;
                gap: 0;
                align-items: stretch;
                margin-top: 1rem;

                & a:link {
                    font-weight: bold;
                    color: #591516;

                    &:visited {
                        color: #591516 !important;
                    }

                    &:hover {
                        text-decoration: underline;
                        color: #74191b !important;
                    }
                }
                
                & > .post-list-headings {
                    grid-column: 1/3;
                    background-color: #591516;
                    color: #fff;
                    font-weight: bold;
                    display: grid;
                    grid-template-columns: subgrid;
                    border-radius: 0.3rem 0.3rem 0 0;

                    & > .writer {
                        grid-column: 1/2;
                        padding: 0.25rem 1rem;
                    }

                    & > .content {
                        grid-column: 2/3;
                        padding: 0.25rem 1rem;
                    }
                }

                & > .writer {
                    grid-column: 1/2;
                    padding: 0.25rem 1rem;
                    background-color: #eee;
                    border-left: 1px solid #591516;
                    border-top: 1px solid #591516;
                    border-bottom: 1px solid #591516;
                    display: flex;
                    flex-direction: column;
                    min-height: 3rem;
                }

                & > .content {
                    grid-column: 2/3;
                    padding: 0.1rem 1rem;
                    background-color: #eee;
                    border: 1px solid #591516;

                    display: flex;
                    flex-direction: column;
                    align-items: stretch;

                    & > h3 {
                        font-family: Iceberg, 'Noto Color Emoji';
                        font-size: 130%;
                    }

                    & > h4 {
                        font-family: Iceberg, 'Noto Color Emoji';
                        font-size: 110%;
                    }

                    & > h5 {
                        font-family: Iceberg, 'Noto Color Emoji';
                        font-style: italic;
                    }

                    & > p {
                        & a:link {
                            display: inline-block;
                        }

                        &.post-actions {
                            border-top: 1px solid #591516;
                            margin-top: 1rem;
                            padding-top: 0.5rem;
                            padding-bottom: 0.5rem;

                            & > a:link {
                                padding: 0.1rem 0.3rem;
                                background-color: #fff;
                                border-radius: 0.2rem;

                                & + a:link {
                                    margin-left: 1rem;
                                }
                            }
                        }

                        & + p, & + h3, & + h4, & + h5, & + ul, & + ol {
                            margin-top: 1rem;
                        }
                    }

                    & > ul {
                        & > li {
                            list-style-type: disc;
                            list-style-position: outside;
                            margin-left: 2rem;
                        }
                    }
                }
            }

            &.forums, &.forum {
                display: grid;
                grid-template-columns: 1fr auto auto;
                gap: 0;
                align-items: stretch;

                & > .forum-group {
                    grid-column: 1/4;
                    color: #fff;
                    font-weight: bold;
                    background: linear-gradient(180deg, #666, #222);
                    padding: 0.5rem 1rem;
                    border-radius: 0.3rem 0.3rem 0 0;

                    &:not(:first-child) {
                        margin-top: 1rem;
                    }
                }

                & > .forum-group-headings {
                    grid-column: 1/4;
                    background-color: #591516;
                    color: #fff;
                    font-weight: bold;
                    display: grid;
                    grid-template-columns: subgrid;

                    & > .forum {
                        grid-column: 1/2;
                        padding: 0.25rem 1rem;
                    }

                    & > .thread-count {
                        grid-column: 2/3;
                        padding: 0.25rem 1rem;
                    }

                    & > .thread {
                        grid-column: 3/4;
                        padding: 0.25rem 1rem;
                    }
                }

                & > .thread-list-headings {
                    grid-column: 1/4;
                    background-color: #591516;
                    color: #fff;
                    font-weight: bold;
                    display: grid;
                    grid-template-columns: subgrid;

                    & > .thread {
                        grid-column: 1/2;
                        padding: 0.25rem 1rem;
                    }

                    & > .post-count {
                        grid-column: 2/3;
                        padding: 0.25rem 1rem;
                    }

                    & > .post {
                        grid-column: 3/4;
                        padding: 0.25rem 1rem;
                    }
                }

                & > .forum, & > .thread {
                    grid-column: 1/2;
                    padding: 0.25rem 1rem;
                    background-color: #eee;
                    border-left: 1px solid #591516;
                    border-top: 1px solid #591516;
                    border-bottom: 1px solid #591516;
                    display: flex;
                    flex-direction: column;
                    min-height: 3rem;

                    & > a.title {
                        font-family: Iceberg, 'Noto Color Emoji';
                        color: #591516;
                        font-size: 120%;

                        &:hover {
                            text-decoration: underline;
                        }
                    }

                    & > .description {
                        font-size: 90%;
                    }
                }

                & > .thread-count, & > .post-count {
                    grid-column: 2/3;
                    padding: 0.1rem 1rem;
                    background-color: #eee;
                    border-left: 1px solid #591516;
                    border-top: 1px solid #591516;
                    border-bottom: 1px solid #591516;
                    text-align: right;
                }

                & > .last-post {
                    grid-column: 3/4;
                    padding: 0.1rem 1rem;
                    background-color: #eee;
                    border: 1px solid #591516;

                    display: flex;
                    flex-direction: column;
                    align-items: stretch;

                    & a:link {
                        font-weight: bold;
                        color: #591516;


                        &:hover {
                            text-decoration: underline;
                        }
                    }
                }
            }

            &.top {
                & > .main {
                    flex-grow: 1;
                    flex-shrink: 1;

                    & > h1 {
                        font-family: Iceberg, 'Noto Color Emoji';
                        font-size: 150%;
                        color: #591516;
                        margin-bottom: 0.5rem;
                    }

                    & > p {
                        & + p, & + h1, & + h2, & + h3, & + ul {
                            margin-top: 1rem;
                        }
                    }

                    & > ul {
                        & > li {
                            list-style-type: disc;
                            list-style-position: outside;
                            margin-left: 2rem;
                        }
                    }
                }

                & > .schedule {
                    flex-grow: 0;
                    flex-shrink: 0;
                    background-color: #591516;
                    color: #fff;
                    padding: 10px;

                    & > h2 {
                        white-space: nowrap;
                        margin-bottom: 0.5rem;
                    }

                    & > ul {
                        display: flex;
                        flex-direction: column;
                        justify-content: stretch;
                        align-items: start;
                        gap: 10px;
                        & > li {
                            & > a {
                                & > span {
                                    display: block;
                                    white-space: nowrap;

                                    &.date {
                                        font-size: 80%;
                                    }

                                    &.title {
                                        padding-left: 20px;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    & > footer {
        background-color: #000;
        color: #fff;
        padding: 20px;
    }
}

form {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    justify-content: stretch;
    align-items: stretch;
    position: relative;
    max-width: 40rem;
    background-color: #eee;
    border: 1px solid #591516;
    padding: 1rem;
    border-radius: 0.5rem;

    & > .form-field {
        grid-column: 1/3;
        display: grid;
        grid-template-columns: subgrid;
        justify-content: stretch;
        align-items: stretch;

        & > label {
            grid-column: 1/2;
            display: block;
        }

        & > input, & > select, & > textarea {
            display: block;
            grid-column: 2/3;
            padding: 0.1rem 0.2rem;
            background-color: #fff;
            border: 1px solid #591516;
            border-radius: 0.1rem;
        }

        & > textarea {
            height: 5rem;
            min-height: 5rem;
            max-height: 10rem;
            resize: vertical;
            font-family: 'Noto Color Emoji', monospace;
        }
    }

    & > .form-actions {
        grid-column: 2/3;
        display: flex;
        flex-direction: row;
        gap: 1rem;

        & > input, & > button {
            display: block;
            border: 1px solid #74191b;
            background-color: #591516;
            color: #fff;
            cursor: pointer;
            padding: 0.25rem 0.5rem;
            border-radius: 0.25rem;

            &:hover { 
                text-decoration: underline;
                background-color: #74191b;
            }
        }
    }

    & + * {
        margin-top: 1rem;
    }
}

dialog {
    display: none;
    &:open {
        display: flex;
    }
    flex-direction: column;
    position: fixed;
    width: 30rem;
    height: 10rem;
    left: calc(50vw - 15rem);
    top: calc(50vh - 5rem);
    background-color: #eee;
    border: 1px solid #591516;
    border-radius: 0.5rem;
    padding: 1rem;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    box-shadow: 0.2rem 0.4rem 0.5rem rgba(0, 0, 0, 0.25);

    & > p {
        font-size: 115%;
    }

    & > .dialog-actions {
        display: flex;
        flex-direction: row;
        gap: 1rem;

        & > a {
            display: block;
            background-color: #fff;
            border: 1px solid #591516;
            border-radius: 0.25rem;
            padding: 0.5rem;
            box-shadow: 0.1rem 0.2rem 0.3rem rgba(0, 0, 0, 0.25);

            &.highlighted {
                font-weight: bold;
                color: #591516;
            }

            &:hover {
                background-color: #e3d1d2;
            }
        }
    }

    &::backdrop {
        background-color: rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(3px);
    }
}