/*
    VARIABLES
*/

:root {
    --text-color: #DFDFDF;
    --date-color: #7F7F7F;
    --background-color: #171717;
    --background-sub-color: #000000;
    --header-background-color: #3F3F5F;
    --header-button-hover-color: #3F3F9F;
    --layer-color: rgba(127,127,127,0.25);
}

@media (prefers-color-scheme: light) {
    :root {
        --text-color: #000000;
        --date-color: #7F7F7F;
        --background-color: #FFFFFF;
        --background-sub-color: #FFFFFF;
        --header-background-color: #DFDFFF;
        --header-button-hover-color: #BFBFFF;
        --link-color: #003FBF;
        --visited-link-color: #7F00BF;
        --error-text-color: #BF0000;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #DFDFDF;
        --date-color: #7F7F7F;
        --background-color: #171717;
        --background-sub-color: #000000;
        --header-background-color: #3F3F5F;
        --header-button-hover-color: #3F3F9F;
        --link-color: #7FBFFF;
        --visited-link-color: #BF9FFF;
        --error-text-color: #FF7F7F;
    }
    
    header a:visited {
        color: inherit;
    }
    
    .darkinvert {
        filter: invert(1)
    }
}

/*
    BASIC
*/

html {
    font-family: var(--font-sans-serif);
    font-weight: 400;
    background-color: var(--background-color);
    color: var(--text-color);
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: calc(100% - 16px);
    margin: 8px;
}

/*
    HEADER
*/

header {
    font-family: RobotoMono, NotoSans, sans-serif;
    height: 50px;
    background: var(--header-background-color);
    padding: 5px;
    position: relative;
    margin-bottom: 5px;
    z-index: 200;
    display: flex;
}

header a {
    color: inherit;
    text-decoration: inherit;
}

.header-logo {
    margin: 1px 1px;
}

.header-logo > img {
    width: 48px;
    height: 48px;
}

.header-text {
    height: 100%;
    margin: 1px 7px;
    line-height: 22px;
    text-align: center;
    font-size: large;
}

header nav {
    display: flex;
    flex: 1;
    align-items: center;
}

.header-button {
    font-weight: 500;
    padding: 1px 10px;
    font-size: 16px;
    line-height: 48px;
    height: 48px;
    float: right;
    display: block;
    cursor: pointer;
    transition: background-color 250ms ease-in-out, border-top-width 250ms, border-bottom-width 250ms;
}

.header-button:has(img) {
    padding: 1px 1px;
}

.header-button > img {
    width: 48px;
    height: 48px;
}

.header-button.disabled {
    color: #7F7F7F;
}

.header-button:hover {
    background: var(--layer-color);
    /* border-top: 5px solid var(--header-background-color);
    border-bottom: 5px solid var(--header-button-hover-color); */
}

.header-button.disabled:hover {
    background: var(--layer-color);
    /* border-top: 5px solid var(--header-background-color);
    border-bottom: 5px solid silver; */
}

nav #newlink, nav #editlink, nav #deletelink {
    display: none;
}

header input#article_search {
    background: var(--layer-color);
    height: 18px;
    line-height: 18px;
    font-size: 18px;
    padding: 8px;
    padding-inline: 12px;
    margin-right: 8px;
    transition: padding-top 250ms ease-in-out, padding-bottom 250ms ease-in-out;
    border: none;
    flex: 1;
    color: var(--text-color);
    font-family: var(--font-monospace);
}

header input#article_search::placeholder {
    color: var(--date-color);
    opacity: 1;
}

header input#article_search:focus {
    padding-top: 20px;
    padding-bottom: 20px;
    outline: 1px solid var(--text-color);
}

header #article_search_list {
    background: var(--header-background-color);
    margin: 0;
    transition: height padding-bottom 250ms ease-in-out;
    border: none;
    color: var(--text-color);
    font-family: var(--font-sans-serif);
    position: absolute;
    top: 100%;
    min-width: 25%;
    max-width: 100%;
    max-width: -moz-available;
    max-width: -webkit-fill-available;
    max-width: stretch;
    padding: 0;
    display: none;
}

header #article_search_list:active {
    display: block;
}

header:has(input#article_search:focus) #article_search_list {
    display: block;
}

header #article_search_list > li {
    height: 18px;
    line-height: 18px;
    font-size: 18px;
    padding: 8px;
    padding-inline: 12px;
    cursor: pointer;
    transition: background-color 250ms ease-in-out;
}

header #article_search_list > li:hover {
    background: var(--layer-color);
}

header #article_search_list > li::marker {
    content: none;
}

/*
    ALERT
*/

#wiklo-alert-container {
    position: fixed;
    bottom: 0;
    right: 0;

    div {
        opacity: 0;
        position: relative;
        background: var(--background-color);
        color: var(--text-color);
        transition: right 8192ms ease-in-out;
        bottom: 0;
        right: 0;
        width: max-content;
        margin: 12px;
        margin-left: auto;
        padding: 4px;
        border-radius: 2px;
        --box-shadow-color: var(--text-color);
        box-shadow: 0px 0px 4px 2px var(--box-shadow-color);

        a {
            color: var(--link-color);
        }
        
        a:visited {
            color: var(--visited-link-color);
        }

        a[href] {
            text-decoration-line: none;
        }

        a:hover {
            text-decoration-line: underline;
        }
    }

    div.TRACE {
        --box-shadow-color: #7F7F7F;
    }

    div.DEBUG {
        --box-shadow-color: #BFBFBF;
    }

    div.INFO {
        --box-shadow-color: #00BF00; /* #00FF00 */
    }

    div.WARN {
        --box-shadow-color: #BF5F00; /* #FF7F00 */
    }

    div.ERROR {
        --box-shadow-color: #BF0000; /* #FF0000 */
    }

    div.FATAL {
        --box-shadow-color: #BF0000; /* #FF0000 */
    }
}

/*
    ARTICLE
*/

section {
    flex: 1;
}

article {
    white-space: break-spaces;
    display: block;
    max-width: 87.5%;
    margin-inline: auto;

    * {
        scrollbar-width: thin;
    }

    h1, h2, h3, h4, h5, h6 {
        white-space: nowrap;
        margin: 0.5em 0 0.25em;
        display: inline-block;
    }

    .page-header {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;

        h1.page-title {
            font-size: xx-large;
            margin: 0;
        }

        .page-info {
            text-align: right;
        }

        /* .page-info > span::after {
            content: ' | ';
        }

        .page-info > span:last-child::after {
            content: inherit;
        } */
    }

    p, ul, ol {
        margin: 0.25em 0;
        ul, ol {
            margin: 0;
        }
    }

    a {
        color: var(--link-color);
    }
    
    a:visited {
        color: var(--visited-link-color);
    }
    
    a.no-article {
        color: var(--error-text-color);
    }

    a[href] {
        text-decoration-line: none;
    }

    a[href^="http://"]::after, a[href^="https://"]::after {
        content: '⎋ ';
        display: inline-block;
        max-height: 1lh;
        transform: scaleX(-1);
        font-size: small;
    }

    a[href^="http://"]:hover::after, a[href^="https://"]:hover::after {
        text-decoration-line: underline;
    }

    a:hover {
        text-decoration-line: underline;
        text-decoration-style: inherit;
    }

    a.self-link {
        color: inherit;
        font-weight: bold;
        text-decoration-line: inherit;
        cursor: inherit;
    }

    *[title]:not(a) {
        text-decoration-style: dotted;
        text-decoration-line: underline;
        cursor: help;
    }

    a[href][title] {
        cursor: pointer;
    }

    a[href][title].self-link {
        cursor: inherit;
    }

    cite {
        font-style: inherit;
    }

    code {
        font-family: var(--font-monospace);
        font-weight: 300;
        line-height: 1lh;
    }

    div.hatnote {
        padding-left: 1.5em;
        margin-bottom: 0.5em;
        font-style: italic;
    }

    section.included {
        display: inline;
    }

    .module-error {
        font-size: large;
        color: var(--error-text-color);
        font-weight: 700;
    }

    sup:has(a + div.refhover) {
        user-select: none;
    }

    div.refhover, div.linkhover {
        display: inline-block;
        margin-right: 8px;
        background: var(--background-color);
        color: var(--text-color);
        padding: 4px;
        border-radius: 2px;
        box-shadow: 0px 0px 4px 2px var(--date-color);
        opacity: 0;
        transition: opacity 125ms;
        font-size: initial;
        font-weight: 400;
        font-style: initial;
        pointer-events: none;
        user-select: none;
        z-index: 250;
        h1 {
            display: block;
            margin: 0;
            margin-bottom: 4px;
            font-size: large;
        }
    }

    div.refhover {
        position: absolute;
    }
    
    div.linkhover {
        position: absolute;
        a {
            color: inherit;
        }
        left: 0;
    }

    a:hover + div.refhover, div.refhover:hover, div.refhover:focus {
        pointer-events: all;
        user-select: text;
        opacity: 1;
    }

    a:hover + div.linkhover {
        opacity: 1;
    }

    img, audio, video {
        vertical-align: middle;
    }

    ruby rt {
        user-select: none;
    }

    div.mediamodule {
        button {
            width: 24px;
            height: 24px;
            display: flex;
            background-color: transparent;
            background-size: contain;
            background-repeat: no-repeat;
            transition: background 250ms, opacity 100ms;
            cursor: pointer;
            border: none;
        }

        button:active {
            opacity: 0.75;
        }

        input[type="range"] {
            accent-color: var(--text-color);
            cursor: pointer;
            height: 4px;
            border-radius: 2px;
            padding: 0;
            border: none;
            background: none;
            background-image: linear-gradient(to right, transparent 6px, var(--layer-color) 6px, var(--layer-color) calc(100% - 6px), transparent calc(100% - 6px));
            transition: height 200ms ease-in-out;
            -webkit-appearance: none;
        }

        input[type="range"]:hover {
            height: 6px;
        }

        input[type="range"]:active {
            height: 6px;
        }

        input[type="range"]::-moz-range-thumb {
            height: 12px;
            width: 12px;
            opacity: 0;
            background: var(--text-color);
            border: none;
            transition: opacity 200ms ease-in-out;
            cursor: pointer;
        }

        input[type="range"]:hover::-moz-range-thumb {
            opacity: 1;
        }

        input[type="range"]:active::-moz-range-thumb {
            opacity: 1;
        }

        input[type="range"]::-moz-range-track {
            height: 4px;
            padding: 10px;
        }

        input[type="range"]::-moz-range-track {
            background: transparent;
        }

        input[type="range"]::-webkit-slider-thumb {
            height: 12px;
            width: 12px;
            opacity: 0;
            background: var(--text-color);
            border: none;
            transition: opacity 200ms ease-in-out;
            -webkit-appearance: none;
            cursor: pointer;
            border-radius: 50%;
            margin-top: -6px;
        }

        input[type="range"]:hover::-webkit-slider-thumb {
            opacity: 1;
        }

        input[type="range"]:active::-webkit-slider-thumb {
            opacity: 1;
        }

        input[type="range"]::-webkit-slider-runnable-track {
            -webkit-appearance: none;
            height: 4px;
            padding-top: 10px;
            padding-bottom: 10px;
        }

        .seeker {
            width: 80px;
        }
        
        .volume {
            width: 60px;
        }

        .play-pause {
            background-image: url('./icons/play.svg');
        }

        .loop {
            background-image: url('./icons/loop-off.svg');
        }

        .volume-icon {
            background-image: url('./icons/volume-4.svg');
        }

        .info {
            background-image: url('./icons/info.svg');
        }

        .fullscreen {
            background-image: url('./icons/fullscreen-enable.svg');
        }

        .current {
            font-family: var(--font-monospace);
            letter-spacing: -1px;
            font-size: 12px;
            padding-inline: 4px;
            color: var(--text-color);
        }
    }

    div.mediamodule:has(audio) {
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        vertical-align: middle;
        audio {
            display: none;
        }
        @media (prefers-color-scheme: light) {
            button {
                filter: invert(1);
            }
        }
    }

    div.mediamodule:has(video) {
        --text-color: #FFFFFF;
        display: inline;
        vertical-align: middle;
        .videomask {
            position: fixed;
            z-index: 102;
            .seeker {
                position: absolute;
                width: calc(100% - 12px);
                left: 6px;
                bottom: 32px;
                z-index: 103;
            }
            .controls {
                display: flex;
                position: absolute;
                bottom: 0;
                height: 64px;
                width: calc(100% - 24px);
                padding: 4px 12px;
                background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,1));
                justify-content: space-between;
                align-items: flex-end;
                transition: opacity 200ms ease-in-out;
                div {
                    display: flex;
                    align-items: center;
                }
            }
        }
        .videomask:not(.shown) * {
            display: none;
        }
        video {
            max-width: 100%;
        }
    }
    div.mediamodule:fullscreen {
        .videomask {
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        video {
            width: 100%;
            height: 100%;
        }
        button.fullscreen {
            background-image: url('./icons/fullscreen-disable.svg');
        }
    }
}

.wiklo-popup-layer {
    background-color: var(--layer-color);
    margin: 0;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 500;

    .wiklo-popup-container {
        background: var(--background-color);
        color: var(--text-color);
        transition: opacity 256ms ease-in-out;
        margin: auto;
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        width: max-content;
        height: max-content;
        max-height: 75%;
        padding: 8px;
        border-radius: 4px;
        box-shadow: 0px 0px 8px 4px var(--text-color);
        overflow: scroll;
    }
}

ol.wiklo-page-history {
    font-family: var(--font-monospace);
    padding-left: 24px;
    padding-right: 24px;
    list-style: none;
    counter-reset: reversed(counter);
    li {
        color: var(--date-color);
        cursor: pointer;
        a {
            color: inherit;
            text-decoration: inherit;
            padding-left: 48px;
        }
        a::before {
            counter-increment: counter -1;
            content: counter(counter) '.';
            text-align: right;
            position: absolute;
            left: 24px;
            width: 48px;
        }
    }
    li.current {
        color: var(--text-color);
        cursor: inherit;
    }
    li:hover {
        color: var(--text-color);
        font-weight: bold;
    }
    li.current:hover {
        font-weight: inherit;
    }
}

/*
    EDITOR
*/

form {
    input[type=text], textarea {
        font-family: var(--font-monospace);
        font-size: 14px;
        background-color: var(--background-sub-color);
        color: var(--text-color);
        border: 1px solid var(--date-color);
    }
    input[type=text]:focus, textarea:focus {
        outline: 1px solid var(--text-color);
    }
    input[type=text]:disabled, textarea:disabled {
        background-color: var(--background-color);
        color: var(--date-color);
    }
    input[type=text]#uuid {
        width: 280px;
    }
    input[type=text]#name {
        width: 240px;
    }
    input[type=text]#description {
        width: 800px;
    }
    textarea#content {
        width: 800px;
        max-width: calc(100% - 6px);
        height: 320px;
        padding: 2px;
    }
    input[type=file] {
        display: none;
    }
    input[type=file]#file + .label-file {
        display: inline-block;
        width: 800px;
        max-width: calc(100% - 6px);
        height: 80px;
        padding: 2px;
        border: 1px solid var(--text-color);
        padding: 2px;
        cursor: pointer;
        text-align: center;
        padding: auto;
    }
    input#resetFile {
        position: absolute;
        padding: 4px;
        border: 0;
        left: 8px;
        margin: 1px;
        background-color: transparent;
        color: var(--text-color);
        opacity: 0.75;
        cursor: pointer;
    }
    input#resetFile:disabled {
        display: none;
    }
    input#resetFile:hover {
        opacity: 1;
    }
    ol#categorylist {
        margin: 0;
        margin-top: 8px;
        padding: 0;
    }
    ol#categorylist > li {
        display: inline list-item;
        padding: 2px;
        border: 1px solid var(--date-color);
        background-color: var(--background-sub-color);
        margin: 2px;
        border-radius: 4px;
        cursor: pointer;
    }
}

/*
    PRINT
*/

@media print {
    body {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact; 
    }

    article {
        max-width: unset;
        a:visited {
            color: var(--link-color);
        }
    }

    header, header nav, footer {
        display: none;
    }

    .videomask {
        display: none;
    }

    video {
        visibility: hidden;
    }
}

/*
    CODE
*/

code[lang="json"] {
    .key {
        color: #FF7FBF;
    }
    .string {
        color: #00FF00;
    }
    .number {
        color: #FF7F00;
    }
    .boolean {
        color: #3FBFFF;
    }
    .null {
        color: #9F9F9F;
    }
}