/* "UI" base styling */
body {
    margin: 0;
    width: 100vw;
    height: 100vh;
    background-color: #eee;
    user-select: none; 
    font-family: "Cinzel", serif;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
}
.container {
    margin: 0;
    height: 100vh;
    width: 100vw;
    box-sizing: border-box;
    padding: 10px;
    display: grid;
    /* Page layout defined here */
    grid-template:
        "title     title   " 4em
        "subtitle  congrats" 2em
        "cards     quads   " minmax(0, 1fr)
        "cards     buttons " 1em
      /  1fr       auto;

}
/* ----------- Header Styles ------------ */
.title {
    color: #000000;
    margin: auto 20px;
    text-align: center;
}

.subtitle {
    grid-area: subtitle;
    color: #000000;
    margin: auto;
    text-align: center;
}

#congrats {
    grid-area: congrats;
    color: #4fc955;    
    visibility: hidden;
    text-align: center;
}
.finished #congrats {
    visibility: visible;
}

/* ----------- Card Layout Styles -------------- */
#cards {
    --n-cols: 4;
    --n-rows: 2;

    grid-area: cards;

    display: grid;
    grid-template-columns: repeat(var(--n-cols, 4), 1fr);
    grid-template-rows: repeat(var(--n-rows, 2), 1fr);
    padding: 10px;

    justify-items: center;
    align-items: center;

    contain: content;
}
/* Colors of card symbols */
.color-0 { color: #da5f8e; }
.color-1 { color: #9f5cc6; }
.color-2 { color: #56cb5c; }
.color-3 { color: #dfdd3f; }

.card {

    margin-left: 0.1em;
    margin-right: 0.1em;

    padding: 0;

    height: 16.0em;
    width: 15em;

    position: relative;

    font-size: var(--scale, 1em);

    contain: strict;
}

#cards .card {
    --gold-rad: 0.6vh;
    --hover-scale: 1.025;
    --transition-time: 0.15s;
    --border-time: 0.08s;
    --scale: 1em;

    border-radius: 7px;
    box-shadow: 0px 2px 4px 1px rgba(0, 0, 0, 0.25);

    background: radial-gradient(ellipse farthest-corner at right top, #feed9b 0%, #fedc98 8%, #efcc93 30%, #d4c697 40%, transparent 80%),
        radial-gradient(ellipse farthest-corner at left bottom, #ffffd5 0%, #ffffac 8%, #e8d9b1 25%, #deb49f 62.5%, #beb49f 100%);
}

/* Covers up the gold background */
#cards .card::before {
    border-radius: inherit;
    content: "";
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%; 
    height: 100%;  
    opacity: 1; 
    z-index: 1;
    background: #ffffe2;
}

/* Covers the gold background all of the time -- container for icons */
.card-inner {
    z-index: 2;
    border-radius: inherit;
    background: #eee;

    padding: 1em;

    position: absolute;
    top: var(--gold-rad);
    left: var(--gold-rad);
    bottom: var(--gold-rad);
    right: var(--gold-rad);

    display: flex;
    flex-direction: column;
    align-content: center;
    align-items: center;
    justify-content: space-evenly;
    box-sizing: border-box;
}

.card-inner i {
    font-size: 3.5em;
}


/* ----------- Sidebar Styles -------------- */
#found {
    grid-area: quads;
    border-left: 2px solid #ccc;

    padding: 10px 20px 0 20px;
    display: flex;
    flex-direction: column;
    min-width: 15em;

    contain: content;
}

#found-scroll {
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;

    overflow-y: auto;

}
.toptext {
    color: #c100cf;
    margin: 10px;
    overflow: hidden;
    /* The other contains are probably not important.
     * But this one might be, as the timer changes every second,
     * so having a contain here makes sure that when it does, only the layout of this line of text is recomputed. */
    contain: strict;
    width: 15em;
    height: 1.2em;
    line-height: 1.2em;
    text-align: center;
}
.found-quad {
    display: flex;
    justify-content: space-evenly;
    margin: 5px;
}

.found-quad.dummy {
    visibility: hidden;
    height: 0;

    /* Just to be safe... */
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

#found .card {
    --hover-scale: 1.035;
    --gold-rad: 0;
    --transition-time: 0.07s;
    --border-time: 0s;
    --scale: 0.35em;

    border-radius: 4px;
    border: 1px solid #ddd;
}

#buttons {
    grid-area: buttons;
}
.finished #timer {
    color: #000000;
}

/* ----------- Animations -------------- */

/* "Lifting Up" */
#cards .card {
    transition: box-shadow ease-out var(--transition-time),
                transform ease-out var(--transition-time),
                filter ease-out var(--border-time);
}

#cards .card:hover, .card.selected, .card.animating {
    box-shadow: 0px 4px 6px 2px rgba(0, 0, 0, 0.17);
    transform: scale(var(--hover-scale));
}

/* Border fades in when card is selected */
#cards .card::before {
    transition: opacity ease-out var(--border-time);
}
.card.selected::before, .card.animating::before {
    opacity: 0.2 !important;
}

/* On sidebar: when a quad is hovered over it'll be highlighted */

#found .found-quad:hover {
    transform: scale(1.035);
    border-color: #ccc;

}
/* ........... Quad result animations ............ */

/* A card can't be selected during one of these */
.card.animating {
    pointer-events: none;
}

/* Incorrect: shake animation */
.card.incorrect {
    animation-name: shake;
    animation-duration: 0.2s;
    animation-timing-function: ease-in-out;
    animation-direction: alternate;
    animation-iteration-count: 2;

    filter: hue-rotate(-50deg);
}
.card-inner {
    transition: filter var(--border-time);
}
.card.incorrect .card-inner {
    filter: hue-rotate(50deg);
}
.card.incorrect::before {
    opacity: 0;
}

@keyframes shake {
    from {
        transform: scale(var(--hover-scale)) translateX(0);
    }

    30% {
        transform: scale(var(--hover-scale)) translateX(1px);
    }
    66% {
        transform: scale(var(--hover-scale)) translateX(-2px);
    }
    to {
        transform: scale(var(--hover-scale)) translateX(3px);
    }
}


/* Correct: "pop" animation */
.card.correct {
    animation-name: pop;
    animation-duration: 0.55s;
    animation-timing-function: ease-in-out;

    filter: hue-rotate(65deg) saturate(150%);
}
.card.correct .card-inner {
    filter: hue-rotate(-65deg) saturate(70%);
}
.card.correct::before {
    opacity: 0;
}

@keyframes pop {
    from {
        transform: scale(var(--hover-scale));
    }
    to {
        transform: scale(1.05) translateY(-4px);
    }
}


/* Previously found: "gray out" animation */
/* We use an animation instead of transition for this so that the inside part can oversaturate at inverse proportion */
.card.already-found {
    animation-name: gray;
    animation-duration: 0.4s;
    animation-timing-function: cubic-bezier(.17,.67,.59,.93);

}
.card.already-found .card-inner {
    animation-name: gray-inverse;
    animation-duration: 0.4s;
    animation-timing-function: ubic-bezier(.17,.67,.59,.93);
}

@keyframes gray {
    from {
        filter: saturate(100%);
    }

    10% {
        filter: saturate(93%);
    }
    20% {
        filter: saturate(86%);
    }
    30% {
        filter: saturate(79%);
    }
    40% {
        filter: saturate(72%);
    }
    50% {
        filter: saturate(65%);
    }
    60% {
        filter: saturate(58%);
    }
    70% {
        filter: saturate(51%);
    }

    to {
        filter: saturate(44%);
    }
}



@keyframes gray-inverse {
    from {
        filter: saturate(100%);
    }

    20% {
        filter: saturate(116%);
    }
    30% {
        filter: saturate(126%);
    }
    40% {
        filter: saturate(139%);
    }
    50% {
        filter: saturate(153%);
    }
    60% {
        filter: saturate(180%);
    }
    70% {
        filter: saturate(220%);
    }

    to {
        filter: saturate(290%);
    }
}

/* animation for the found quad on the side */
.found-quad.highlight .card {
    border-color: #d7c4b1 !important;
}
.found-quad.highlight {
    animation-name: blink;
    animation-duration: 0.14s;
    animation-timing-function: ease-in-out;
    animation-direction: alternate;
    animation-iteration-count: 4;
}

@keyframes blink {
    from {
        transform: scale(1.0);
    }
    to {
        transform: scale(1.035);
    }
}

/* -------- media queries ---------- */

/* Small desktop displays */
/* I'm going to assume that nobody in 2021 has a landscape display much smaller than this */
/* No parenthesis in @media rules as far as I can tell :( */
@media (min-aspect-ratio: 1/1) and (min-width: 850px) and (max-width: 1150px), (min-aspect-ratio: 1/1) and (max-height: 700px) {
    #cards .card {
        --scale: min(1.4vw, 2.2vh);
    }

    #found .card {
        --scale: min(0.5vw, 0.77vh);
    }
    #found {
        padding: 5px 10px 0 10px;
    }
}
