/* Variables */

:root {
    --green: green;
    --yellow: #eec039;
    --orange: #f5793a;
    --blue: #85c0f9;
    --black: #000;
    --white: #fff;
    --gray-1: rgb(22, 22, 22);
    --gray-2: #333;
    --gray-3: #737373;
    --gray-4: grey;
    --gray-5: #aaa;
    --gray-6: rgb(202, 202, 202);
    --gray-7: lightgrey;

    --standard-color: var(--gray-5);
    --standard-block-color: var(--black);
    --correct-color: var(--green);
    --within-color: var(--yellow);
    --incorrect-color: var(--gray-2);
    --pressed-color: var(--gray-4);
    --held-color: var(--gray-6);

    --box-border-color: var(--gray-3);
    --box-border-color-highlighted: var(--gray-5);

    --settings-item-border-color: 1px solid var(--gray-4);

    --background-color: var(--black);
    --fallback-background-color: var(--background-color);
    --item-background-color: rgba(0, 0, 0, 0);
    --dialog-background-color: var(--gray-1);

    --text-color: var(--white);
    --letter-text-color: var(--white);
    --letter-selected-text-color: var(--white);
    --letter-selected-inverted-text-color: var(--white);

    --notification-background-color: var(--gray-7);
    --notification-text-color: var(--black);

    --active-card-border-color: var(--white);
    --focused-card-border-color: var(--within-color);
}

.light {
    --standard-color: var(--gray-5);
    --standard-block-color: var(--white);
    --correct-color: var(--green);
    --within-color: var(--yellow);
    --incorrect-color: var(--gray-3);

    --box-border-color: var(--gray-7);
    --box-border-color-highlighted: var(--gray-5);

    --background-color: var(--white);
    --fallback-background-color: var(--background-color);
    --dialog-background-color: var(--gray-6);

    --text-color: var(--black);
    --letter-text-color: var(--black);
    --letter-selected-text-color: var(--white);

    --notification-background-color: var(--black);
    --notification-text-color: var(--white);

    --active-card-border-color: var(--black);
}

.snow {
    --background-color: linear-gradient(180deg, rgba(2, 0, 36, 1) 40%, rgba(9, 9, 121, 1) 100%);
    --fallback-background-color: rgb(2, 0, 36);

    --standard-block-color: rgba(0, 0, 0, 0);

    --dialog-background-color: #070069;
}

.high-contrast {
    --correct-color: var(--orange);
    --within-color: var(--blue);
    --letter-selected-inverted-text-color: var(--black);

    --focused-card-border-color: var(--within-color);
}

/* Main Content */

html {
    font-size: 125%;
    font-family: sans-serif;
}

body {
    background: var(--fallback-background-color);
    margin: 0;
    overflow: hidden;
}

body > div.game-background {
    background: var(--fallback-background-color);
    background: var(--background-color);
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -100;
}

svg {
    color: var(--text-color);
}

.top-menu {
    position: relative;
    background-color: var(--item-background-color);
    border-bottom: 1px solid var(--standard-color);
    padding: 1rem;
    font-size: 1rem;
    font-family: sans-serif;
    text-transform: uppercase;
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    height: 64px;
    box-sizing: border-box;
}

.top-menu > .icon-bar {
    position: absolute;
    right: 20px;
}

.top-menu > .icon-bar > a.link-icon {
    text-decoration: none;
    margin-right: 4px;
}

.top-menu > .icon-bar > a.link-icon:last-child {
    margin-right: 0;
}

.wordle-rows {
    width: 100%;
    height: 60%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.keyboard-view {
    display: flex;
    align-items: center;
    width: 100%;
    display: flex;
    justify-content: center;
    height: max-content;
}

.game-wrapper {
    position: relative;
    left: 50%;
    width: 50vw;
    height: 100%;
    transform: translateX(-50%);
}

.input-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 75%;
    height: 16.67%;
    max-height: 3rem;
}

.pane > .space {
    flex: 1;
}

.pane .pane-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

@media (max-width: 1028px) {
    .game-wrapper {
        width: 100%;
    }
}

.pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto;
    height: calc(100% - 64px);
    width: 100%;
    transform-origin: top;
}

.pane h1,
h2,
h3,
h4,
h5 {
    color: var(--text-color);
}

.pane > .footer {
    color: var(--text-color);
    text-align: center;
}

button {
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button.close {
    z-index: 1;
    width: 2.5rem;
    height: 2.5rem;
    background-color: rgba(0, 0, 0, 0);
    color: var(--text-color);
}

button.button {
    padding: 0.5em 0.5em 0.5em 0.5em;
    margin: 0.5em 0em 0.5em 0em;
    border-radius: 8em;
    background-color: var(--correct-color);
}

button.button > * {
    color: var(--letter-selected-inverted-text-color);
    font-weight: bold;
}

/* Settings */

.settings {
    position: relative;
}

.settings > button.close {
    position: absolute;
    top: 0;
    right: 0;
}

.settings > .settings-item-group {
    width: 100%;
}

.settings .settings-item {
    color: var(--text-color);
    display: flex;
    width: 100%;
    justify-content: space-around;
    align-items: center;
    border-top: var(--settings-item-border-color);
    border-bottom: none;
    height: 2em;
}

.settings .settings-item:last-child {
    border-bottom: var(--settings-item-border-color);
}

.settings .settings-item > * {
    pointer-events: none;
}

.settings .settings-item a {
    text-decoration: none;
}

.settings .settings-item .settings-item-column {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.5em;
}

.settings .settings-item .settings-item-column:last-child {
    width: 60%;
}

.settings .settings-item .settings-item-column > .toggle {
    text-transform: capitalize;
}

/* Overlay Backdrop */

.overlay-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 100;
}

/* Dialog Window */

.dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    right: 0;
    bottom: 0;
    z-index: 101;
    transform: translate(-50%, -50%);

    background-color: var(--dialog-background-color);
    color: var(--text-color);
    border: 1px solid black;
    width: 340px;
    max-height: 90vh;
    height: auto;
    margin: 0;
    padding: 0;

    display: flex;
    flex-direction: column;

    opacity: 1;

    transition:
        top 0.5s,
        opacity 0.5s;
}

@media (max-width: 320px) {
    .dialog {
        width: 290px;
    }
}

.dialog > div.dialog-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: 100%;
    padding: 2rem 2rem 0;
    box-sizing: border-box;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.dialog > div.dialog-content > div.dialog-text {
    height: 100%;
    position: relative;
}

.dialog > div.dialog-content > div.dialog-text > ul > li {
    margin-bottom: 8px;
}

.dialog > div.dialog-content > div.dialog-text > ul > li:last-child {
    margin-bottom: 0;
}

.dialog > div.dialog-content > div.dialog-text > *:last-child {
    padding: 0 0 16px 0;
}

.dialog > div.dialog-content > span {
    margin: 8px 0;
}

.dialog > div.dialog-content > .next-wordle {
    margin: 8px 0;
}

.dialog button > span {
    margin-left: 8px;
}

.dialog button.close {
    position: absolute;
    top: 0;
    right: 0;
}

/* Specific Dialogs */

.dialog > .dialog-content > .how-to-play {
    height: 100%;
    position: relative;
}

.dialog > .dialog-content > .how-to-play > .how-to-play-content {
    padding: 0 0 8px 0;
}

.dialog > .dialog-content > .how-to-play > .how-to-play-content > h2 {
    text-transform: uppercase;
    margin: 12px 0;
}

.dialog > .dialog-content > .how-to-play > .how-to-play-content div.sample {
    display: flex;
}

.dialog > .dialog-content > .how-to-play > .how-to-play-content > div.meaning {
    margin: 12px 0;
}

.dialog > .dialog-content > .how-to-play > .how-to-play-content > div.meaning > div.sample {
    margin: 4px 0;
}

.dialog > .dialog-content > .how-to-play > .how-to-play-content > div.meaning > span.text {
    line-height: 1.25;
    font-size: 0.75em;
}

/* Notification */

.notification-area {
    position: fixed;
    top: 10%;
    left: 50%;
    z-index: 102;
    transform: translate(-50%, 0);

    display: flex;
    flex-direction: column-reverse;
    justify-content: center;
    width: 60%;
}

.notification-area > .notification {
    background-color: var(--notification-background-color);
    border: 1px solid var(--notification-background-color);
    border-radius: 0.25rem;
    margin: 0.2rem;

    /* Need to inherit z-index from parent, otherwise they won't appear on top of dialogs in iOS Safari */
    z-index: inherit;

    text-align: center;

    opacity: 1;
    transition: opacity 0.25s;
}

.notification-area > .notification > .notification-content {
    padding: 1rem 1.5rem;
    font-weight: bold;
    color: var(--notification-text-color);
}

/* Landscape Overlay */

#landscape-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    text-align: center;
    font-size: 24px;
    color: var(--text-color);
    z-index: 9999;
}

#landscape-overlay > .overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

#landscape-overlay > .overlay-content > img {
    height: 100px;
}

/* Text Content */

a {
    color: var(--text-color);
}

/* Boxes */

.box {
    padding: 1em;
    margin: 0.1em;
    border: 1px solid black;
    line-height: 1.9em;
    text-align: center;
    position: relative;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    max-height: 2.75em;
    aspect-ratio: 1/1;
    width: 100%;
    max-width: 2.75em;
}

.box .box-letter {
    display: block;
    position: absolute;
    line-height: normal;
    font-size: 2rem;
    font-weight: bold;
    font-family: sans-serif;
    text-transform: uppercase;
    color: var(--letter-text-color);
}

/* Keyboard */

.keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
}

.keyboard > .keyboard-row {
    display: flex;
    justify-content: center;
    width: 100%;
}

.keyboard > .keyboard-row > .keyboard-item {
    position: relative;
    padding: 1em 0.5em;
    margin: 0.1em;
    border: 1px solid rgba(0, 0, 0, 0);
    border-radius: 0.25em;
    width: 5%;
    height: 1em;
    line-height: 1em;
    color: var(--letter-text-color);
    text-align: center;
}

.keyboard > .keyboard-row > .keyboard-item.big {
    width: 10%;
}

@media (max-width: 600px) {
    .keyboard > .keyboard-row > .keyboard-item {
        width: 0.4em;
    }

    .keyboard > .keyboard-row > .keyboard-item.big {
        width: 2.1em;
    }
}

@media (max-width: 320px) {
    .keyboard > .keyboard-row > .keyboard-item {
        width: 0.2em;
        height: 0.5em;
        line-height: 0.5em;
    }

    .keyboard > .keyboard-row > .keyboard-item.big {
        width: 1.6em;
    }
}

.keyboard > .keyboard-row > .keyboard-item > div {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    display: inline-block;
    vertical-align: middle;
    font-size: 0.75em;
    font-weight: bold;
    font-family: sans-serif;
    pointer-events: none;
}

.keyboard > .keyboard-row > .keyboard-item.big > div {
    font-size: 0.65em;
}

/* Colours */

.standard {
    background-color: var(--standard-color);
}

.box {
    background-color: var(--standard-block-color);
    border: 1px solid var(--box-border-color);
}

.box.filled {
    border: 2px solid var(--box-border-color-highlighted);
}

.box.incorrect,
.box.correct,
.box.within {
    border: 1px solid rgba(0, 0, 0, 0);
}

.correct {
    background-color: var(--correct-color);
}

.within {
    background-color: var(--within-color);
}

.incorrect {
    background-color: var(--incorrect-color);
}

.pressed {
    background-color: var(--pressed-color);
}

.held {
    background-color: var(--held-color);
}

.correct > .box-letter,
.within > .box-letter,
.incorrect > .box-letter,
.keyboard > .keyboard-row > .correct.keyboard-item,
.keyboard > .keyboard-row > .within.keyboard-item,
.keyboard > .keyboard-row > .incorrect.keyboard-item {
    color: var(--letter-selected-text-color);
    user-select: none;
    -webkit-user-select: none;
}

.correct > .box-letter,
.within > .box-letter,
.keyboard > .keyboard-row > .correct.keyboard-item,
.keyboard > .keyboard-row > .within.keyboard-item {
    color: var(--letter-selected-inverted-text-color);
}

/* Special */

.embedim-snow {
    pointer-events: none;
}

body .footer > .snow-theme-credits {
    opacity: 0;
    pointer-events: none;
}

body.snow .footer > .snow-theme-credits {
    opacity: 1;
    pointer-events: initial;
}

body .footer a.author-link {
    text-decoration: none;
}

body a > .version-number,
body a > .commit-hash {
    pointer-events: initial;
}

body a > .commit-hash {
    font-size: 16px;
}

/* Settings Toggle */

.knob {
    position: relative;

    width: 50px;
    height: 22px;
    border-radius: 8em;
    background-color: var(--gray-2);

    transition: background-color 0.25s;
}

.knob.enabled {
    background-color: var(--correct-color);
}

.knob > .knob-inside {
    position: absolute;
    top: 1px;
    left: 1px;

    width: 20px;
    height: 20px;
    background-color: var(--gray-7);
    border-radius: 8em;

    transition: left 0.25s;
}

.knob.enabled > .knob-inside {
    left: 29px;
}

/* Dark theme scoping class (used on theme cards to enforce dark theme variables) */

.dark {
    --standard-color: var(--gray-5);
    --standard-block-color: var(--black);
    --correct-color: var(--green);
    --within-color: var(--yellow);
    --incorrect-color: var(--gray-2);
    --box-border-color: var(--gray-3);
    --box-border-color-highlighted: var(--gray-5);
    --background-color: var(--black);
    --fallback-background-color: var(--black);
    --text-color: var(--white);
    --letter-text-color: var(--white);
    --letter-selected-text-color: var(--white);
    --letter-selected-inverted-text-color: var(--white);
    --active-card-border-color: var(--white);
}

/* Themes Pane */

.themes {
    position: relative;
}

.themes > button.back {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 2.5rem;
    height: 2.5rem;
    background-color: transparent;
    color: var(--text-color);
}

.themes > button.close {
    position: absolute;
    top: 0;
    right: 0;
}

.themes > .space {
    flex: 0 0 0.5rem;
}

.theme-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, 150px);
    grid-auto-rows: 210px;
    justify-content: center;
    align-items: start;
    gap: 1rem;
    padding: 0 1rem;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    outline: none;
}

.theme-card {
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    gap: 0.4rem;
    background: var(--background-color, var(--fallback-background-color));
    background-clip: padding-box;
    user-select: none;
    outline: none;
    font: inherit;
}

.theme-card.snow {
    overflow: hidden;
    --incorrect-color: var(--gray-2);
    --box-border-color: var(--gray-3);
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.85) 1.5px, transparent 1.5px) 6px 14px / 24px 22px,
        radial-gradient(circle, rgba(255, 255, 255, 0.6) 1px, transparent 1px) 21px 3px / 38px 28px,
        radial-gradient(circle, rgba(255, 255, 255, 0.7) 1.2px, transparent 1.2px) 12px 24px / 22px 40px,
        linear-gradient(180deg, rgba(2, 0, 36, 1) 40%, rgba(9, 9, 121, 1) 100%);
    background-clip: padding-box;
}

.theme-card:focus-visible {
    outline: 2px solid var(--focused-card-border-color);
    outline-offset: 2px;
}

.theme-card.active {
    border-color: var(--active-card-border-color);
}

body.high-contrast .theme-card {
    --correct-color: var(--orange);
    --within-color: var(--blue);
    --letter-selected-inverted-text-color: var(--black);
}

.theme-card-name {
    color: var(--text-color);
    font-weight: bold;
    font-size: 0.85rem;
    text-transform: capitalize;
}

.theme-card.snow .theme-card-name {
    color: var(--white);
}

.theme-card-board {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.theme-card-row {
    display: flex;
    gap: 2px;
}

.theme-card-box {
    width: 16px;
    height: 16px;
    border: 1px solid var(--box-border-color);
    background-color: var(--standard-block-color);
}

.theme-card-box.correct {
    background-color: var(--correct-color);
    border-color: transparent;
}

.theme-card-box.within {
    background-color: var(--within-color);
    border-color: transparent;
}

.theme-card-box.incorrect {
    background-color: var(--incorrect-color);
    border-color: transparent;
}

.theme-card-keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
}

.theme-card-keyboard-row {
    display: flex;
    gap: 2px;
    justify-content: center;
}

.theme-card-key {
    height: 10px;
    width: 8px;
    border-radius: 1px;
    background-color: var(--standard-color);
}

.theme-card-key.correct {
    background-color: var(--correct-color);
}

.theme-card-key.within {
    background-color: var(--within-color);
}

.theme-card-key.incorrect {
    background-color: var(--incorrect-color);
}
