@import url('https://fonts.googleapis.com/css2?family=Roboto&family=Orbitron&display=swap');

:root {
    --contrast-color: #000000;
    --game-tile-size: 40px;
    --game-spacer-width: 3px;
    --w95-menu-spacer-width: 2px;
    --w95-theme-bg-color: #c0c0c0;
    --w95-theme-border-color-topleft: #FFFFFF;
    --w95-theme-border-color-bottomright: #434343;
    --w95-theme-button-fg-color: #030303;
    --w95-theme-button-active-bg-color: #000080;
    --w95-theme-button-active-fg-color: #FCFCFC;
    --w95-theme-button-inactive-bg-color: #5878B0;
    --w95-theme-button-inactive-fg-color: #000080;
}

body {
    margin: 0;
    background-color: #DDD;
}

/* Removes outline on focus */
button, input:focus-visible {
    outline: none;
}
button:focus-visible:not(.w95-menu-button) {
    filter: brightness(1.2);
}

.border-black-white {
    border-style: solid;
    border-width: var(--game-spacer-width);
    border-color: #888 #FFF #FFF #888;
}
.border-white-black {
    border-style: solid;
    border-width: var(--game-spacer-width);
    border-color: #FFF #888 #888 #FFF;
}

.desaturation {
    filter: saturate(0) brightness(1.2) contrast(0.7)
}

.window-popup {
    position: absolute; /* relative to #minesweeper */
    z-index: 3; /* 1 is the smiley (reset button) and 2 are (dropdown) menus */
    top: 30px;
    left: 30px;
    user-select: none;
    color: var(--contrast-color);
}
    .hidden {
        display: none;
    }
    .window-popup table {
        margin: 3px;
    }
    .window-popup b {
        color: var(--contrast-color);
    }
    .window-popup label {
        color: var(--contrast-color);
    }
    .window-popup input {
        border-style: solid;
        border-width: var(--w95-menu-spacer-width);
        border-color: var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-topleft) var(--w95-theme-border-color-topleft) var(--w95-theme-border-color-bottomright);
        width: 60px;
    }
    .window-popup .wide-button {
        margin-top: 0
    }
    .window-popup table td:not(.color-input-container) {
        padding-block: 8px;
    }
    .window-popup tr:not(.divider) > td:nth-child(1) {
        padding-right: 25px;
    }
    #about-minesweeper-menu p, #recreation-by-menu p {
        margin-block: 0;
    }
    #about-minesweeper-menu table {
        margin: 15px;
    }
    #about-minesweeper-menu .menu-key-values {
        margin: 0;
    }
        #about-minesweeper-menu .menu-key-values td, #recreation-by-menu .menu-key-values td {
            padding-block: 3px;
        }
        #about-minesweeper-menu hr, #recreation-by-menu hr {
            margin-top: 15px;
        }
    /* Hides input number arrows */
    .window-popup  input[type=number]::-webkit-outer-spin-button, .window-popup  input[type=number]::-webkit-inner-spin-button {
        -webkit-appearance: none; /* Chrome, Safari, Edge, Opera */
        margin: 0;
    }
    .window-popup  input[type=number] {
        -moz-appearance: textfield; /* Firefox */
    }





.window-wrapper {
    border-style: solid;
    border-width: var(--w95-menu-spacer-width);
    border-color: var(--w95-theme-border-color-topleft) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-topleft);
    padding: var(--w95-menu-spacer-width);
    background: var(--w95-theme-bg-color);
    box-shadow: #000A var(--w95-menu-spacer-width) var(--w95-menu-spacer-width) var(--w95-menu-spacer-width);
}
    .window-topbar {
        display: flex;
        flex-flow: row;
        justify-content: space-between;
        align-items: center;
        padding-left: 5px;
        background: var(--w95-theme-button-active-bg-color);
        color: var(--w95-theme-button-active-fg-color);
    }
        .menu-title {
            display: flex;
            align-items: center;
            font-weight: bold;
            font-style: italic;
            font-size: 20px;
            margin-right: 8px;
            user-select: none;
        }
            .menu-title>img {
                height: 23px;
                margin-right: 4px;
            }
            .menu-button {
                border-style: solid;
                background: var(--w95-theme-bg-color);
                color: var(--contrast-color);
                padding: 0;
                margin: 2px;
                cursor: pointer;
            }
                .menu-button:not(#restart-button) {
                    border-width: var(--w95-menu-spacer-width);
                    border-color: var(--w95-theme-border-color-topleft) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-topleft);
                }
                .menu-button:hover {
                    /*background-color: #aaa;*/
                }
                .menu-button:active {
                    border-color: #888 #FFF #FFF #888;
                }
                .window-close-icon {
                    background: url(images/menuClose.svg) no-repeat;
                    background-size: contain;
                }
                .menu-button-icon {
                    display: block;
                    margin: 3px;
                    width: 11px;
                    height: 11px;
                }
                .menu-button:active .menu-button-icon {
                    margin: 4px 2px 2px 4px;
                }
                .wide-button {
                    padding-inline: 18px;
                }
                    .wide-button .menu-button-icon {
                        width: auto;
                        height: auto;
                        margin: 2px;
                    }
                    .wide-button:active .menu-button-icon {
                        margin: 3px 1px 1px 3px;
                    }
                .spread-span {
                    display: flex;
                    justify-content: space-between;
                }
                    .spread-span>span:nth-child(1) {
                        margin-right: 15px;
                    }
    .color-input-container {
        overflow: hidden;
        height: 22px;
        border: 1px solid gray;
        /*background: radial-gradient(circle, rgb(255, 255, 255) 25%, rgb(0, 0, 0) 30%);*/
        background: repeating-linear-gradient(45deg, black 0%, black 9.99%, white 10%, white 20%);
    }
        .color-input-container input[type=color] {
            padding: 0;
            border: none;
            width: calc(100% + 6px);
            height: calc(100% + 10px);
            margin-inline: -3px;
            margin-block: -5px;
            position: relative;
        }
        .color-input-container>input[type=color]:focus {
            opacity: 0.8;
        }



#game-container {
    display: flex;
    height: 100vh;
    transition: filter 1s;
}
    #minesweeper-wrapper {
        display: flex;
        flex-flow: column;
        margin: auto;
        border-style: solid;
        border-width: var(--w95-menu-spacer-width);
        border-color: var(--w95-theme-border-color-topleft) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-topleft);
        padding: var(--w95-menu-spacer-width);
        background: var(--w95-theme-bg-color);
        box-shadow: #000A var(--w95-menu-spacer-width) var(--w95-menu-spacer-width) var(--w95-menu-spacer-width);
    }
        #menus {
            display: flex;
            flex-flow: row;
            justify-content: space-between;
            padding-block: var(--w95-menu-spacer-width);
            user-select: none;
        }
            .w95-menu-button {
                border: none;
                background: none;
                position: relative;
                font-size: 20px;
                padding: 5px 10px;
                color: var(--w95-theme-button-fg-color);
                cursor: pointer;
            }
                .w95-menu-button > span:not(.menu) {
                    pointer-events: none;
                }
            .w95-menu-button:hover, .w95-menu-button:focus {
                color: var(--w95-theme-button-active-fg-color);
                background: var(--w95-theme-button-active-bg-color);
            }
            .w95-menu-button:focus .menu {
                display: block;
            }
                .menu {
                    display: none;
                    position: absolute;
                    top: 100%;
                    left: 0;
                    border-style: solid;
                    border-width: var(--w95-menu-spacer-width);
                    border-color: var(--w95-theme-border-color-topleft) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-bottomright) var(--w95-theme-border-color-topleft);
                    z-index: 2; /* 1 is the smiley (reset button) and 3 are popup windows */
                    color: var(--w95-theme-button-fg-color);
                    background: var(--w95-theme-bg-color);
                    box-shadow: #000A var(--w95-menu-spacer-width) var(--w95-menu-spacer-width) var(--w95-menu-spacer-width);
                }
                    .menu table {
                        text-align: left;
                        border-collapse: collapse;
                        white-space: nowrap;
                    }
                        .menu tr:not(.divider):hover {
                            color: var(--w95-theme-button-active-fg-color);
                            background: var(--w95-theme-button-active-bg-color);
                        }
                            .menu tr:not(.divider) td {
                                padding: 6px 3px;
                            }
                            .menu tr>td:nth-child(3) {
                                padding-right: 35px;
                            }
                            .divider {
                                cursor: auto;
                            }
                                .divider hr {
                                    margin-block: 2px;
                                    border-width: 1px 0;
                                    border-top-color: #0000; /* hr's top-border is darkened somehow. this is a bodgefix */
                                    background: var(--w95-theme-border-color-bottomright);
                                    border-bottom-color: var(--w95-theme-border-color-topleft);
                                }
                        .menu tr[disabled] {
                            opacity: 0.5;
                            font-style: italic;
                            cursor: auto;
                        }
            .settings-icon {
                background-image: url(images/cog.svg);
                background-size: contain;
                background-repeat: no-repeat;
                aspect-ratio: 1;
                margin: 5px;
                animation-name: rotateClockwise;
                animation-duration: 2s;
                animation-iteration-count: infinite;
                animation-play-state: paused;
                animation-timing-function: linear;
                height: 23px; /* Strange behavior on Chrome if 100% height left it to stretch to its wrapper */
                outline: none;
            }
                .settings-icon:focus-visible:after {
                    content: "";
                    display: block;
                    width: 100%;
                    height: 100%;
                    background: radial-gradient(var(--contrast-color) 15%, transparent 25%);
                }
                .settings-icon:hover {
                    animation-play-state: running;
                }
                .settings-icon.color-invert {
                    filter: contrast(0) brightness(2);
                }
        #minesweeper {
            position: relative; /* for popup windows */
            width: max-content;
            padding: 10px;
            background-color: #BBB;
        }
            #scoreboard {
                position: relative;
                height: 40px;
                padding: 10px;
                margin-bottom: 10px;
                font-size: 30px;
                font-family: Orbitron, monospace;
            }
                #mines-left {
                    display: inline-block;
                    position: absolute;
                    left: 10px;
                    top: 50%;
                    transform: translateY(-50%);

                    padding: 1px;
                    color: red;
                    background-color: black;
                    user-select: none;
                }

                #restart-button {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                    background: #C0C0C0;
                    z-index: 1; /* 2 are (dropdown) menus and 3 are popup windows */
                    box-shadow: #000A var(--w95-menu-spacer-width) var(--w95-menu-spacer-width) var(--w95-menu-spacer-width);
                    cursor: pointer;
                }
                    #smiley {
                        background: url(images/smiley.svg) no-repeat;
                        background-size: contain;
                        width: 30px;
                        height: 30px;
                    }

                #game-time-counter {
                    display: inline-block;
                    position: absolute;
                    right: 10px;
                    top: 50%;
                    transform: translateY(-50%);

                    padding: 1px;
                    color: red;
                    background-color: black;
                    user-select: none;
                }
            

            #minefield {
                display: table;
            }
                .row {
                    display: flex;
                    white-space: nowrap;
                }
                    .tile {
                        position: relative;
                        width: var(--game-tile-size);
                        height: var(--game-tile-size);
                        background-color: #BBB;
                        font-family: sans-serif;
                    }
                        .tile-safe, .tile.tile-undiscovered:active {
                            border-width: 1px;
                            border-color: gray;
                        }
                            .tile-safe:not(.tile-undiscovered) > .marking, .tile.tile-undiscovered:active > .marking {
                                /* similar styling to not having .tile-undiscovered class, so same styles there apply here also */
                                width: calc(100% - ((2px * 2) + (var(--game-spacer-width) * 2)));
                                height: calc(100% - ((2px * 2) + (var(--game-spacer-width) * 2)));
                                margin: calc(((2px * 2) + (var(--game-spacer-width) * 2)) / 2);
                            }

                        .tile-color1 {
                            color: royalblue;
                        }
                        .tile-color2 {
                            color: green;
                        }
                        .tile-color3 {
                            color: red;
                        }
                        .tile-color4 {
                            color: darkblue;
                        }
                        .tile-color5 {
                            color: darkred;
                        }
                        .tile-color6 {
                            color: teal;
                        }
                        .tile-color7 {
                            color: black;
                        }
                        .tile-color8 {
                            color: gray;
                        }

                        .tile-undiscovered {
                            border-width: var(--game-spacer-width);
                            border-style: solid;
                            border-color: #FFF #888 #888 #FFF;
                            cursor: pointer;
                        }
                        
                        .inner-tile {
                            font-size: 30px;
                            font-weight: bold;
                            user-select: none;
                        }
                            .marking {
                                background-position: center;
                                background-size: contain;
                                background-repeat: no-repeat;
                                width: calc(100% - (var(--game-spacer-width) * 2));
                                height: calc(100% - (var(--game-spacer-width) * 2));
                                margin: var(--game-spacer-width);
                                position: absolute;
                                top: 0;
                                left: 0;
                            }
                                .markingFlag {
                                    background-image: url(images/flag.svg);
                                }
                                .markingQuestionmark {
                                    background-image: url(images/questionmark.svg);
                                }
                                .markingCross {
                                    background-image: url(images/cross.svg); /* I would've had 1 file and recolored it, but CSS mask works different on Firefox. It additionally requires a SVG mask element which didn't seem like an easy fix. */
                                }
                                .markingQuestionmarkHidden {
                                    background-image: none;
                                }
                                .mine {
                                    background-image: url(images/mine.svg);
                                }

/* Animations */
@keyframes animationBreathing {
    0%   {opacity: 100%; filter: drop-shadow(0 0 5px #FFF)}
    50%  {opacity: 0;    filter: drop-shadow(0 0 5px #FFF0)}
    100% {opacity: 100%; filter: drop-shadow(0 0 5px #FFF)}
}
@keyframes animationFadeout {
    from {opacity: 100%}
    to   {opacity: 0}
}
@keyframes rotateClockwise {
    from {transform: rotateZ(0deg)}
    to   {transform: rotateZ(360deg)}
}

.animationBreathing {
    animation-name: animationBreathing;
    animation-duration: 4s;
    animation-iteration-count: infinite;
}
.animationFadeout {
    animation-name: animationFadeout;
    animation-duration: 2s;
    animation-fill-mode: forwards;
 }