/****************************************************
* Default Components
*****************************************************/

:root {
    --default-font: "Rubik", Montserrat, -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica,
        Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
    --monospace-font: "Fira Code", SourceCodePro, Consolas, Menlo, Monaco, "Courier New", monospace;
    --min-width: 400px;
    --yellow: #ffc40d;
    --green: #00e595;
    --correct: limegreen;
    --mismatch: gold;
    --mixed-gradient: linear-gradient(
        to right,
        var(--mismatch),
        var(--mismatch) 50%,
        var(--correct) 50%,
        var(--correct)
    );
}

body {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    font-size: max(16px, 1rem);
    align-items: center;
    justify-content: center;
    min-width: var(--min-width);
    font-family: var(--default-font);
}
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    text-align: center;
    margin-bottom: 0.5lh;
}
footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    margin-top: 1ch;
    margin-bottom: 25ch;
    text-align: center;
}

hr {
    background-color: var(--yellow);
    border: 1px solid var(--yellow);
    height: 1px;
    border-radius: 3px;
}

header button,
.bttn {
    margin: 0em;
    border: none;
    border-radius: 1ch;
    box-shadow: 1ch;
    background-color: var(--green);
    color: FieldText;
    padding: 0.4em;
    text-align: center;
    text-decoration: none;
    font-size: inherit;
    font-weight: normal;
    font-style: normal;
}
button:hover,
.bttn:hover {
    cursor: pointer;
}

header,
footer {
    max-width: 80ch;
}

/****************************************************
* Header
*****************************************************/

#logo {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}
#logo > * {
    padding: 0 0.25em;
}
#slogan {
    margin: 0;
    padding: 0;
    font-size: 0.5em;
    font-weight: normal;
}

#gameNum {
    font-size: 0.5em;
    font-weight: normal;
    margin: 0;
    padding: 0;
    height: 1lh;
}

/****************************************************
* Controls
*****************************************************/

#settings > #container {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 1ch;
}

#settings > #container span {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 10em;
    margin: 0.5ch 0;
}

#settings input {
    width: 3em;
}

#reset {
    margin-top: 1ch;
}

#controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 1ch;
}

#results {
    min-width: 40ch;
    max-width: 100%;
    width: max-content;
}

#stats {
    width: 100%;
    resize: none;
    border: none;
    text-align: center;
}
#social {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

#howTo ul {
    list-style: none;
}

.small {
    font-size: smaller;
}

#version {
    font-style: italic;
    font-size: smaller;
}

#version:before {
    content: "v";
}

#version:empty {
    display: none;
}

dialog > form > button {
    margin-top: 0.5ch;
    font-size: small;
}

#privacy {
    margin-bottom: 1ch;
}

/****************************************************
* App
*****************************************************/

main {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    width: 100%;
    font-weight: bold;
}

@media (prefers-reduced-motion: no-preference) {
    * {
        transition: ease-in-out;
        transition-duration: 0.3s;
        transition-delay: 0.15;
        transition-property: all;
        transition-behavior: allow-discrete;
    }
    #kbd-container * {
        transition-duration: 0.1s;
        transition-delay: 0s;
    }
}

/****************************************************
* Word Game
*****************************************************/

word-game {
    display: flex;
    flex-direction: column;
    border-radius: 1em;
    min-width: 5em;
    padding: 1ch 1em;
    margin: 0.25ch 0.25em;

    & .remainingGuesses {
        order: 2;
    }
}

word-game[finished] {
    background-color: lightgray;
    
    & word-row {
        padding-inline: 0;
    }
}

word-game[success] {
    background-color: greenyellow;
}

/****************************************************
* Word Rows
*****************************************************/

word-row {
    display: flex;
    flex-flow: row wrap;
    justify-content: space-between;
    align-items: center;
    margin: 0.3ch 0;
    width: 100%;
    border-radius: 0.5em;
    min-height: 2ch;
    padding: 0 0.5em;

    & span {
        display: inline;
        min-height: 1ch;
        min-width: 1em;
        padding: 0.5rch 1rem;
        border-radius: 0.5rem;
        background-color: darkgray;
        vertical-align: middle;
        text-align: center;
        text-transform: uppercase;
        font-family: var(--monospace-font);
    }

    & span[data-correct="true"] {
        background-color: var(--correct);
    }

    & span[data-mismatch="true"] {
        background-color: var(--mismatch);
    }
}

word-row[selected] {
    margin-block: 0.3ch;
    padding: 0.2ch 0.5em;
    background-color: lightskyblue;
    min-width: 1em;

    & span {
        padding: 1rch 1rem;
        min-height: 2rch;
        background-color: #efefef;
        color: black;
    }

    & span:empty {
        border: 1px solid black;
        border-collapse: collapse;
    }
}

word-row:not([selected]) {
    & :empty {
        padding: 0.1ch 0.5em;
        display: none;
    }
}

word-row[selected][invalid],
main [data-invalid="true"] {
    background-color: lightcoral;
    padding: 0.2ch 0.5em;
}

word-row[duplicate],
main [data-duplicate="true"] {
    background-color: goldenrod;
    margin-block: 0.2ch;
    padding: 0.2ch 0.5em;
}

word-row span {
    cursor: default;
    pointer-events: none;
}

/****************************************************
* Keyboard
*****************************************************/

#kbd-container {
    position: fixed;
    bottom: 0;
    background-color: #efefef;
    background-color: light-dark(#efefef, #010100);
    border-radius: 1em 1em 0 0;
    padding: 1ch 1em;
    box-shadow: 0 0 5px lightgray;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 4lh;
    max-width: min(100%, 800px);
    width: 100vw;
    overflow: visible;
}

#kbd-container .kbd-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100%;
    margin-bottom: 0.25ch;
}

@media (max-width: 800px) {
    #kbd-container {
        border-radius: none;
    }
    #kbd-container .kbd-row {
        width: 95%;
    }
}

*:has(#gameLinks) {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
}

#gameLinks {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 0.2em;
    align-items: center;
    justify-items: center;
    align-content: center;
    max-width: 100%;
    overflow-x: auto;
    list-style: none;
    margin: 0 0 2ch 0;
    padding: 0;
    width: 100%;
}

#gameLinks li,
#gameLinks a {
    font-size: larger;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

#gameLinks li:empty {
    display: none;
}

#gameLinks {
    a {
        font-size: max(16px, 2rem);
        color: dimgrey;
    }

    [data-finished="true"] {
        color: grey;
    }
    [data-invalid="true"] {
        color: lightcoral;
    }
    [data-duplicate="true"] {
        color: goldenrod;
    }
    [data-success="true"] {
        color: var(--correct);
        background-color: var(--correct);
        font-size: 100%;
        -webkit-background-clip: text; /* For WebKit browsers */
        background-clip: text;
        -webkit-text-fill-color: transparent; /* For WebKit browsers */
    }
}

kbd {
    padding: 0;
    margin: 0;
    display: contents;
}

kbd button {
    font-size: large;
    font-size: clamp(1em, 1vw, 2em);
    font-family: var(--monospace-font);
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    vertical-align: middle;
    min-height: 2ch;
    min-width: 2em;
    margin: 0.1rch 0.05rem;
    padding: 1.5ch clamp(0.5ch, 1.75vw, 30px);
    border-radius: 1rch 1rch;
    border: 1px solid lightgray;
    color: FieldText;
}

kbd button:hover,
kbd button:focus {
    box-shadow: gray 0 0 0.25ch;
}

kbd button[data-used="true"] {
    background-color: dimgray;
}

kbd button[data-correct="true"] {
    background-color: var(--correct);
}

kbd button[data-mismatch="true"] {
    background-color: var(--mismatch);
}

kbd button[data-correct="true"][data-mismatch="true"] {
    background: var(--mixed-gradient);
}

kbd button[data-pressed] {
    box-shadow: inset 0 0 0.4ch black;
    filter: invert(25%);
}

#kbd-rows {
    display: contents;
    padding: 0;
    margin: 0;
}

#compactNoKeys {
    width: 100%;
    text-align: center;
}

#compactGuess {
    padding-top: 0.25lh;
    font-weight: bold;
    display: none;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

#compactGuess input {
    width: 100%;
    font-size: max(16px, 1rem);
    font-weight: bold;
    font-family: var(--monospace-font);
    text-align: center;
    border-radius: 0.25em;
    border: 1px solid lightgray;
    text-transform: uppercase;
    width: 5em;
}

.compact {
    display: none;
}

/****************************************************
* Dark Mode
*****************************************************/

@media (prefers-color-scheme: dark) {
    :root {
        background-color: #333;
    }
    header,
    footer,
    footer a {
        color: white;
    }

    #kbd-container {
        background-color: #444;
        box-shadow: 0 0 5px #555;
        color: white;
    }
    .remainingGuesses {
        color: white;
    }
}

/****************************************************
* Compact mode
*****************************************************/
body[data-compact-mode="true"] {
    main {
        justify-content: center;
        align-items: center;
    }

    main[data-empty="true"] word-game {
        display: none;
    }

    word-game {
        min-height: 2.25em;
    }
    word-game[finished] {
        border: none;
    }
    #kbd-container {
        width: fit-content;
    }

    .compact {
        display: initial;
    }

    #compactGuess {
        display: flex;
    }

    #gameLinks {
        margin-bottom: 0.25lh;
    }

    #kbd-rows {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        align-items: center;
        width: 100%;
    }

    .kbd-row {
        display: contents;
        width: min-content !important;
    }

    kbd button {
        padding: 0.1ch 0.1ch;
    }

    kbd button:not([data-used="true"]) {
        display: none;
    }

    word-row[states=",,,,"],
    main .remainingGuesses,
    main word-row[selected] {
        display: none;
    }

    .remainingGuesses {
        vertical-align: middle;
        text-align: center;
        font-size: large;
        margin-inline-start: 0.5em;
        min-width: 3em;
    }

    footer {
        margin-bottom: 12ch;
    }
}

input {
    font-size: max(16px, 1rem);
}

/****************************************************
* Dev console
****************************************************/
#devConsole {
max-width: min(100vw, 800px);
max-height: 20lh;
padding: 0;
margin: 0;
background: darkgrey;
color: white;
overflow: auto;
}
