/* General Reset --------------------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "ABeeZee", sans-serif;
    font-weight: 400;
    font-style: normal;
}

input:focus {
    outline: none;
}

button:focus {
    outline: none;
}


/* Typography ------------------------------------------------------------------------------------ */

@font-face {
    font-family: "Feroniapi";
    src: url('fonts/Feroniapi-MediumItalic.woff2') format('woff2');
    font-weight: normal;
    font-style: italic;
}

h1 {
    font-family: 'Feroniapi', sans-serif;
    padding-top: 0.2rem;
    font-style: normal;
    font-weight: 600;
    font-size: 2.5rem;
    color: #D9FF9C;
    margin-bottom: 10px;
}

h2 {
    font-family: 'Feroniapi', sans-serif;
    font-style: normal;
    font-weight: 500;
    font-size: 1.5rem;
    color: #D9FF9C;
    padding: 0.2rem;
    justify-self: center;
    margin-bottom: 10px;
}


/* Elements -------------------------------------------------------------------------------------- */

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #1E1832;
    color: #000000;
}

header {
    text-align: center;
    padding: 1rem;
}

ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}


/* Menu ------------------------------------------------------------------------------------------ */

#menu-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 15px;
}


/* Page Sections --------------------------------------------------------------------------------- */

.webpage-section {
    display: none;
    justify-content: center;
}

.section-btn {
    padding: 1rem;
    font-size: 1.5rem;
    border: none;
    background-color: #D9FF9C;
    color: #1E1832;
    border-radius: 4px;
    cursor: pointer;
    min-width: 200px;
}

.menu-btn, #play-game-btn, #instructions-container-play-game-btn {
    padding: 0.5rem;
    font-size: 1rem;
    border: none;
    background-color: #D9FF9C;
    color: #1E1832;
    border-radius: 4px;
    cursor: pointer;
    min-width: 200px;
}

#play-game-btn, #instructions-container-play-game-btn {
    margin-top: 10px;
}

.section-btn:hover, .menu-btn:hover, #play-game-btn:hover, #instructions-container-play-game-btn:hover {
    background-color: #78FDAE;
}

#theme-container, #game-container, #instructions-container {
    text-align: center;
}

/* Game Theme */
#theme-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 15px;
}

.theme-option {
    margin-bottom: 10px;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: none;
    background-color: #FDADBA;
    color: #1E1832;
    border-radius: 4px;
    cursor: pointer;
}

.theme-option.active-theme {
    outline: 2px solid #D9FF9C;
    background-color: #FBD9B3;
}

/* Game Board */
#game-container {
    text-align:center;
}

#game-stats {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#best-time {
    margin-bottom: 10px;
    padding: 0.2rem;
    font-size: 1.2rem;
    border: 1px transparent;
    border-radius: 4px;
    color: #D9FF9C;
}

#start-game {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    flex-grow: 1;
    margin-bottom: 15px;
    gap: 1rem;
}

#name-input {
    padding: 0.5rem;
    font-size: 1rem;
    border-radius: 4px;
    border: none;
    text-align: center;
    width: 100%;
} 

#start-game-buttons {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-grow: 1;
}

#start-btn {
    flex-grow: 1;
    justify-content: center;
    padding: 0.5rem;
    font-size: 1rem;
    border: none;
    background-color: #FDADBA;
    color: #1E1832;
    border-radius: 4px;
    cursor: pointer;
}

#start-btn:hover {
    background-color: #FBD9B3;
}

#game-menu-btn {
    padding: 0.5rem;
    min-width: 0px;
    justify-content: center;
    flex-grow: 1;
}

/* Game board overly */
/* Overlays to cover the board and styled the retry button */
.board-wrap {
    position: relative;
    width: 100%;
    min-height: 200px;
    margin: 0 auto 20px;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    width: 100%;
    opacity: 0.5;
}

#loading-overlay, #error-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(30, 24, 50, 0.9);
    color: #ffffff;
    border: 6px solid #FBD9B3;
    border-radius: 6px;
    z-index: 5;
    padding: 1rem;
}

.status-overlay, .overlay-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 1rem;
}

#reset-btn, #retry-btn {
    min-width: 0px;
    justify-content: center;
    flex-grow: 1;
    padding: 0.5rem;
    font-size: 1rem;
    border: none;
    background-color: #D9FF9C;
    color: #1E1832;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#reset-btn:hover, #retry-btn:hover {
    background-color: #78FDAE;
}

/* Modal Overlay */
.modal {
    display: none; 
    position: fixed; 
    z-index: 10; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

/* Modal Box */
.modal-content {
    background-color: #ffffff;
    margin: 15% auto;
    padding: 1rem;
    border-radius: 6px;
    width: 300px;
    text-align: center;
    color: #1E1832;
}

/* Time */
#timer {
    font-size: 1rem;
    margin-bottom: 15px;
    color: black;
    padding: 0.5rem;
}

/* Status */
#status {
    margin-bottom: 15px;
    font-size: 2rem;
    font-weight: bold;
    color: #FDADBA;
    font-family: 'Feroniapi', sans-serif;
}

/* Close Button */
.close {
    color: #FDADBA;
    float: right;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #FDADBA;
}

/* Cards */
.card {
    position: relative;
    width: 100px;
    height: 100px;
    perspective: 1000px; /* Adds a 3D effect for flipping. */
}

.card-inner {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border: 6px solid #FBD9B3;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

/* Card Front*/
.card-front {
    background-color: #FDADBA;
    color: #ffffff;
    background-position: 10px 0, 10px 0, 0 0, 0 0;
    background-size: 20px 20px;
    background-repeat: repeat;
}

/* Card Back */
.card-back {
    background-color: #ffffff;
    color: #000;
    transform: rotateY(180deg);
    border: 6px transparent;
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* Card Selected */
.card.selected .card-front,
.card.selected .card-back {
    border-color: #ffffff;
}


/* Game Controls ---------------------------------------------------------------------------------- */

#instructions-container {
    width: 200px;
}

#keybord-instructions {
    margin-bottom: 15px;
    margin-top: 5px;
    padding: 1rem;
    background-color: #FFFFFF;
    color: #1E1832;
    border-radius: 6px;
    border: 6px solid #FDADBA;
    font-size: 1.2rem;
}

#keybord-instructions li {
    padding: 0.5rem;
    font-size: 1rem;
}

/* Media Query ----------------------------------------------------------------------------------- */

@media (min-width: 670px) {
    
    h1 {
        font-size: 3rem;
    }

    h2 {
        font-size: 2.5rem;
    }
    
    ul {
    display: flex;
    list-style: none;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    }

    #theme-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 15px;
    }

    #game-board {
    gap: 1rem;
    }

    #best-time, #name-input {
    text-align: center;
    }

    .card {
    width: 150px;
    height: 125px;
    }

    #instructions-container {
    width: auto;
    }

}

@media (max-width: 415px) {
    
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    #theme-options {
    display: flex;
    padding: 1rem;
    }

    #best-time {
    font-size: 1rem;
    }

    #game-container {
    padding: 1rem;
    }

    .board-wrap {
    position: relative;
    width: 100%;
    margin: 0 auto 20px;
    }

    #game-board {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    width: 100%;
    opacity: 0.5;
    }

    .card {
        width: 100%;
    }

    #name-input {
    width: 100%;
    } 

    #start-game {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    }
}
