/*
*************************************
*           Variables
*************************************
*/
:root {
    --primary-color: #2e2e2e;
    --border-color: #424242;
    --border-color-light: #696969;
    --bg-color: #1f1f1f;
    --txt-color: #fff;
    --title-color: #f8f9fa;
    --description-color: #adb5bd;
    --tile-color: #f5f5f5;
    --tile-color-hover: #242424;
    --tile-color-success: #2f9e44;
    --danger-color: #f03e3e;
    --btn-primary-color: #405cf5;
    --btn-focus-border-color: #f1f3f5;

    --font-size: 16px;

    --border-radius: 5px;

    --tile-size: 100px;
    --input-height: 40px;
    --button-height: 40px;
}

/*
*************************************
*           Reset Defaults
*************************************
*/
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

button {
    background: transparent;
    border: 1px solid transparent;
    border-spacing: 0;
    font-weight: normal;
    margin: 0;
    padding: 0;
    outline: none;
}

button:focus {
    opacity: 0.8;
}

html {
    font-size: var(--font-size);
}

body {
    font-family: "Quicksand", cursive, Arial;
    background-color: var(--bg-color);
    color: var(--txt-color);
}

/*
*************************************
*           Button
*************************************
*/
.button {
    background-color: var(--btn-primary-color);
    color: #fff;
    box-shadow: rgba(50, 50, 93, .1) 0 0 0 1px inset, rgba(50, 50, 93, .1) 0 2px 5px 0, rgba(0, 0, 0, .07) 0 1px 1px 0;
    box-sizing: border-box;
    cursor: pointer;
    width: 100%;
    height: var(--button-height);
    border: 1px solid transparent;
    border-radius: 6px;
    border-width: 0;
    line-height: 1.15;
    outline: none;
    overflow: hidden;
    padding: 0 25px;
    position: relative;
    text-align: center;
    text-transform: none;
    transition: all .2s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    appearance: button;
    backface-visibility: hidden;
}

.button.primary {
    background-color: var(--btn-primary-color);
    border-color: var(--btn-primary-color);
}

.button:focus {
    opacity: 0.9;
    border: 1px solid var(--btn-focus-border-color);
}

/*
*************************************
*           Layout
*************************************
*/
.container {
    padding: 0 15px 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px auto 30px;
}

.heading .title {
    margin-bottom: 5px;
    color: var(--title-color);
}

.heading .description {
    font-size: 0.8rem;
    color: var(--description-color);
}

/*
*************************************
*           Board Form
*************************************
*/
#new-board-form {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 30px;
    background-color: var(--primary-color);
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    padding: 15px;
}

#new-board-form .inputs {
    display: flex;
    align-items: flex-end;
    gap: 30px;
}

#new-board-form .input-wrapper {
    max-width: 150px;
    width: 100%;
}

#new-board-form .actions-wrapper {
    display: flex;
    justify-content: flex-end;
}

#new-board-form .actions-wrapper .button {
    width: 150px;
}

#new-board-form label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

#new-board-form .asterisk {
    color: var(--danger-color);
    font-size: 0.8rem;
}

#new-board-form .input {
    width: 100%;
    height: var(--input-height);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--txt-color);
    box-shadow: none;
    outline: none;
    border: 1px solid var(--border-color);
    padding: 7px 8px;
    transition: all 0.15s;
}

#new-board-form .input:focus {
    outline: none;
    border-color: var(--border-color-light);
}

#new-board-form .input.error,
#new-board-form .input.error:focus {
    outline: unset;
    border-color: var(--danger-color);
}

/*
*************************************
*           Puzzle Board
*************************************
*/
.puzzle-board {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.puzzle-board-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.puzzle-board-header .heading .title {
    font-size: 1.05rem;
    color: var(--title-color);
    background-color: var(--primary-color);
    padding: 5px 15px 6px;
    border-top-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

.puzzle-board-header .actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1px 10px;
}

.puzzle-board-header .actions .reset,
.puzzle-board-header .actions .remove,
.puzzle-board-header .actions .shuffle {
    user-select: none;
    cursor: pointer;
    border-radius: 50%;
}

.message {
    padding: 10px;
    font-size: 0.9rem;
    text-align: center;
}

.message.success {
    border-color: var(--tile-color-success);
    color: var(--tile-color-success);
}

.empty-boards-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    text-align: center;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 5px;
    margin: 0 auto;
    padding: 20px 10px 25px;
}

.puzzle-grid .tile {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: var(--tile-size);
    width: 100%;
    max-height: var(--tile-size);
    height: 100%;
    aspect-ratio: 1 / 1;
    background-color: var(--primary-color);
    border: 1px solid var(--border-color);
    color: var(--tile-color);
    font-size: 2.4rem;
    font-weight: 700;
    border-radius: var(--border-radius);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.puzzle-grid .tile:hover {
    background-color: var(--tile-color-hover);
}

.puzzle-grid .tile.empty {
    background-color: transparent;
    cursor: default;
}

.puzzle-grid .tile.done {
    background-color: var(--tile-color-success);
    animation-name: bounce;
    animation-duration: 0.6s;
    animation-iteration-count: 1;
}

@keyframes bounce {
    0% {
        transform: scale(0.96);
    }
    
    50% {
        transform: scale(1.04);
    }

    100% {
        transform: scale(1);
    }
}


/*
*************************************
*           Media Queries
*************************************
*/
@media screen and (max-width: 650px) {
    #new-board-form {
        display: block;
    }

    #new-board-form .inputs {
        gap: 15px;
    }

    #new-board-form .input-wrapper {
        max-width: 100%;
    }

    #new-board-form .input {
        margin-bottom: 15px;
    }
}

@media screen and (max-width: 425px) {
    .header {
        display: block;
        text-align: center;
    }

    .header .actions {
        margin-top: 15px;
    }

    #new-board-form .inputs {
        display: block;
    }

    #new-board-form .actions-wrapper {
        margin-top: 15px;
    }
}

@media screen and (max-width: 300px) {
    .puzzle-board-header {
        display: block;
    }

    .puzzle-board-header .heading .title {
        text-align: center;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
    }

    .puzzle-board-header .actions {
        justify-content: center;
        margin: 10px auto;
    }
}