/* The game itself, as classic Windows Minesweeper drew it: the mine counter, the face and the timer, the board and its
   cells. Raised parts are white at the top and left and dark grey at the bottom and right, sunken ones the other way
   round. The pictures are pixel drawings in the classic style, and the mine from img/icons/mine.ico (img/classic). */

/* The header: a sunken panel with the counter, the face and the timer */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #c0c0c0;
    padding: 5px 6px;
    border: 3px solid;
    border-color: #808080 #fff #fff #808080;
    margin: 8px 6px;
}

/* The counter and the timer: three red LED digits on black, sunken a little (js/minesweeper.js showLed()) */
.mine-counter, .timer {
    display: flex;
    height: min(34px, 10vw);
    background-color: #000;
    border: 1px solid;
    border-color: #808080 #fff #fff #808080;
}

.led {
    height: 100%;
    aspect-ratio: 13 / 23;
    background: #000 center / 100% 100% no-repeat;
}

.led[data-ch="0"] { background-image: url("../img/icons/led-0.svg"); }
.led[data-ch="1"] { background-image: url("../img/icons/led-1.svg"); }
.led[data-ch="2"] { background-image: url("../img/icons/led-2.svg"); }
.led[data-ch="3"] { background-image: url("../img/icons/led-3.svg"); }
.led[data-ch="4"] { background-image: url("../img/icons/led-4.svg"); }
.led[data-ch="5"] { background-image: url("../img/icons/led-5.svg"); }
.led[data-ch="6"] { background-image: url("../img/icons/led-6.svg"); }
.led[data-ch="7"] { background-image: url("../img/icons/led-7.svg"); }
.led[data-ch="8"] { background-image: url("../img/icons/led-8.svg"); }
.led[data-ch="9"] { background-image: url("../img/icons/led-9.svg"); }
.led[data-ch="minus"] { background-image: url("../img/icons/led-minus.svg"); }

/* The face: a raised button with a thin dark edge; pressed in, the face moves with it */
#reset-button {
    width: min(40px, 12vw);
    height: min(40px, 12vw);
    padding: 0;
    background: #c0c0c0 center / 72% no-repeat;
    border: 3px solid;
    border-color: #fff #808080 #808080 #fff;
    outline: 1px solid #808080;
    cursor: pointer;
}

#reset-button:active {
    border-color: #808080 #c0c0c0 #c0c0c0 #808080;
    background-position: calc(50% + 1px) calc(50% + 1px);
}

#reset-button[data-face="smile"] { background-image: url("../img/icons/face-smile.svg"); }
#reset-button[data-face="oh"] { background-image: url("../img/icons/face-oh.svg"); }
#reset-button[data-face="dead"] { background-image: url("../img/icons/face-dead.svg"); }
#reset-button[data-face="cool"] { background-image: url("../img/icons/face-cool.svg"); }

/* The board: sunken, the cells right up to its edge */
#game-board {
    min-height: 0; /* It shrinks to the room left in the window (css/page.css), and scrolls */
    overflow: auto;
    display: grid;
    gap: 0;
    margin: 0 6px 6px 6px;
    background-color: #c0c0c0;
    border: 3px solid;
    border-color: #808080 #fff #fff #808080;
}

/* A cell: raised until it's opened. Its size includes its border, so an open cell's thinner one doesn't move the
   board. */
.cell {
    box-sizing: border-box;
    width: min(36px, calc(8vw + 6px));
    height: min(36px, calc(8vw + 6px));
    background: #c0c0c0 center / 100% 100% no-repeat;
    border: 4px solid;
    border-color: #fff #808080 #808080 #fff;
    font-size: 0; /* The number is a picture (below): its text is for screen readers, and the Easter egg */
    cursor: pointer;
    user-select: none;
}

/* Pressed (the mouse button or a finger still down), a closed cell looks opened, as the classic one did */
.cell:not(.revealed):not(.flagged):active,
.cell.revealed {
    border-width: 2px 0 0 2px;
    border-color: #808080;
}

.cell.select {
    box-shadow: 0 0 0 2px #000080 inset;
}

/* The numbers, each in its classic colour */
.cell[data-value="1"] { background-image: url("../img/icons/1.svg"); }
.cell[data-value="2"] { background-image: url("../img/icons/2.svg"); }
.cell[data-value="3"] { background-image: url("../img/icons/3.svg"); }
.cell[data-value="4"] { background-image: url("../img/icons/4.svg"); }
.cell[data-value="5"] { background-image: url("../img/icons/5.svg"); }
.cell[data-value="6"] { background-image: url("../img/icons/6.svg"); }
.cell[data-value="7"] { background-image: url("../img/icons/7.svg"); }
.cell[data-value="8"] { background-image: url("../img/icons/8.svg"); }

/* The mines, once the game is lost */
.cell.mine {
    background-image: url("../img/icons/mine.svg");
    background-size: min(32px, 94%); /* Its own 32 px where the cell has the room (sharpest), smaller on small screens */
}

/* A flag; and, once the game is lost, the flags that were right stay as they were (after .mine: they're mines too) */
.cell.flagged,
.cell.mine.mine-flagged-correct {
    background-image: url("../img/icons/flag.svg");
    background-size: 100% 100%;
    border-width: 4px;
    border-color: #fff #808080 #808080 #fff;
}

/* The mine that went off */
.cell.mine.triggered {
    background-color: #ff0000;
}

/* A flag where there was no mine: the mine crossed out in red */
.cell.mine-flagged-wrong {
    background-image: url("../img/icons/wrong.svg"), url("../img/icons/mine.svg");
    background-size: 100% 100%, min(32px, 94%);
}

/* Responsive styles */
@media screen and (max-width: 600px) {
    .cell {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }

    .cell.flagged,
    .cell.mine.mine-flagged-correct {
        border-width: 3px;
    }

    .header {
        padding: 4px;
    }

    #reset-button {
        border-width: 2px;
    }
}

@media screen and (max-width: 400px) {
    .cell {
        width: 24px;
        height: 24px;
        border-width: 2px;
    }

    .cell:not(.revealed):not(.flagged):active,
    .cell.revealed {
        border-width: 1px 0 0 1px;
    }

    .cell.flagged,
    .cell.mine.mine-flagged-correct {
        border-width: 2px;
    }
}
