@import url('/styles.css');

:root {
    --carrier: #957b5f;
    --submarine: #fff4db;
    --battleship: #f88f3a;
    --cruiser: #bfb368;
    --destroyer: #65a9cd;
    --boardColor: rgba(178, 178, 178, 0.611);
    --fieldSize: 40px;
}

html {
    transition: all 0.15s;
}

#yourName,
#enemyName {
    margin: 25px;
    width: min-content;
    padding: 10px;
    border-radius: 7px;
}

.sunk-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 10px;
    font-size: 20px;
    z-index: 1000;
    animation: fadeIn 0.5s, fadeOut 0.5s 2.5s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.gameBoard {
    background-color: var(--boardColor);
    display: grid;
    border-radius: 7px;
    margin: 25px;
    border: 3px solid black;
    backdrop-filter: blur(5px);
    grid-template-columns: repeat(10, 1fr);
    /* laver 10 grid coloumns*/
    grid-template-rows: repeat(10, 1fr);
    box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.44);
    width: 400px;
    height: 400px;
    /*10x10 height*/
}

.functionWrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.infoBox {
    width: auto;
    display: inline-block;
    padding: .9%;
    border: 2px solid rgba(255, 255, 255, 0.692);
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.507);
    margin: 10px;
}

#gameBoardWrapper {
    width: 70%;
    margin: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
}

#gameBoardWrapper div {
    max-width: 460px;
    /*40x10 + 2x25 margin + 5 border */
}

.field {
    transition: all 0.15s;
    opacity: 1;
    height: var(--fieldSize);
    width: var(--fieldSize);
    border: 1px black;
    border-style: solid;
    box-sizing: border-box;
    cursor: pointer;
}

/* Fjerner border på fieldsene i toppen, siderne of bunden*/
.gameBoard div:nth-child(n+1):nth-child(-n+10) {
    border-top: none;
}

.gameBoard div:nth-child(10n-9) {
    border-left: none;
}

.gameBoard div:nth-child(10n) {
    border-right: none;
}

.gameBoard div:nth-child(n+91):nth-child(n+10) {
    border-bottom: none;
}

.occupiedField {
    height: var(--fieldSize);
    width: var(--fieldSize);
    border: 1px black;
    border-style: solid;
    box-sizing: border-box;
    background-color: var(--link-color) !important;
}

.field.right.occupiedField {
    background-color: initial !important;
}

/* Laver et rødt kryds på hitField ved at dele background-image op i 2 med hældningen 45% (den er transparent fra start til 50% - 1px og 50% + 1px til slut*/
.hitField {
    /* 2) Remove any default border/outline/box-shadow */
    background-image:
        linear-gradient(45deg, transparent calc(50% - 1px), red calc(50% - 1px), red calc(50% + 1px), transparent calc(50% + 1px)),
        linear-gradient(-45deg, transparent calc(50% - 1px), red calc(50% - 1px), red calc(50% + 1px), transparent calc(50% + 1px));
    background-size: 100% 100%;
    background-repeat: no-repeat;
    animation-name: scale;
    animation-duration: 1s;
    animation-timing-function: ease-out
}



.missedField {
    position: relative;
    animation-name: scale;
    animation-duration: 0.8s;
    animation-timing-function: ease-out;

}

@keyframes scale {
    0% {
        scale: 2;
        border: none;
    }
    50% {
        scale: 0.7;
    }
    75% {
        border: none;
        scale: 1;
    }
    100% {
        background-size: 100% 100%;
        border: 1px solid black;

    }
}

.missedField::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background-color: rgb(0, 0, 0);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.shipSelectionWrapper {
    position: initial;
    width: min-content;
    margin-top: 100px;
    padding: 10px;
    background: transparent;
    box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.44);
    border: 2px solid rgba(255, 255, 255, 0.692);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    box-shadow: 0 0 var(--fieldSize) rgba(0, 0, 0, 0.507);
    display: flex;
}

#carrier {
    height: 200px;
    background-color: var(--carrier);
    margin: 30px;
}

#battleship {
    height: 160px;
    background-color: var(--battleship);
    margin: 30px;
}

#cruiser {
    height: 120px;
    background-color: var(--cruiser);
    margin: 30px;
}

#submarine {
    height: 120px;
    background-color: var(--submarine);
    margin: 30px;
}

#destroyer {
    height: 80px;
    background-color: var(--destroyer);
    transform: rotate(100);
    margin: 30px;
}

.ship {
    transition: all 0.1s;
    opacity: 1;
    width: var(--fieldSize);
    border: 1px black;
    border-style: solid;
}

.ship:hover {
    cursor: pointer;
    opacity: 0.6;
}

.field:hover {
    filter: brightness(80%);
    background-color: rgba(15, 15, 15, 0.271);
}

.field.right.missedField:hover {
    background-color: inherit;
}

#gameButtonWrapper {
    height: 25px;
    padding: 3px;
}

#turn,
#exitGameButton,
#homeButton,
#winnerDisplay {
    background-color: #141414;
    color: var(--text2);
    width: fit-content;
    padding: 10px;
    border: #000000;
    border-radius: 5px;
}