@import url("../games.css?v=2026.03.20a");

:root {
    --tile-gap: 1rem;
    --tile-size: 8rem;

    --primary-color: #ff972f;
    --secondary-color: #ff5917;
    --color-gradient: linear-gradient(var(--primary-color), var(--secondary-color));
    --color-gradient-flip: linear-gradient(var(--secondary-color), var(--primary-color));
    --glow-color: rgba(255, 151, 47, 0.65);

    --fade-in: 0.5s;
    --fade-away: 0.5s;

    --bad: #ff325f;
    --bad-darker: #d7002f;
}

html, body {
    width: 100vw;
    height: 100dvh;
    position: fixed;
    margin: 0;
    box-sizing: border-box;
    touch-action: none;
    overscroll-behavior: none;
}

body {
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    animation: come-in var(--fade-in) forwards;
}

.title {
    margin-bottom: 1.5rem;
}

.gradient {
	background: var(--color-gradient);
	background-clip: text;
	color: transparent;
}

.statement {
    color: var(--secondary-color);
}

strong.gradient, strong.statement {
    font-weight: 900;
}

.navbar.regular {
	position: relative;
	inset: 0;

	justify-content: center;
}

#game {
    display: flex;
    flex-direction: column;
    margin-top: 6rem;
    animation: come-in var(--fade-in) backwards;

    &.fade { animation: go-away var(--fade-away) forwards; }
    &.end {
        cursor: default;
    }

    &:not(.end) .tile.active {
        cursor: grabbing;
        scale: 0.9;
        z-index: 4;
        opacity: 0.85;
        box-shadow: 0 0.25rem 1rem #d442078f;
    }
}

.row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tile-gap);
    height: var(--tile-size);
}

#empty {
    display: flex;
    flex-direction: column;
    margin-bottom: 6rem;
}

@keyframes come-in { from { opacity: 0; } }
@keyframes go-away { to { opacity: 0; } }
@keyframes up-away { to {
    transform: translateY(-1.5rem);
    opacity: 0;
} }

.tile {
    height: 100%;
    width: auto;
    aspect-ratio: 1;
    box-sizing: border-box;
    
    background: var(--color-gradient);
    border-radius: 0.75rem;
    box-shadow: 0 0 0.75rem var(--glow-color);

    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;

    font: calc(var(--tile-size) / 2) 'Martian Mono';
    font-weight: 600;
    text-shadow: 0 0.3rem 0.65rem #0000001f;
    touch-action: none;
    user-select: none;

    &::after {
        content: attr(data-number);
        color: white;
    }

    &.empty {
        background: none;
        box-shadow: none;
        border: 0.25rem dashed var(--secondary-color);
        box-shadow: inset 0 0.25rem 1.5rem rgba(255, 151, 47, 0.307);

        &::after {
            color: var(--secondary-color);
            text-shadow: none;
            font-weight: 200;
            opacity: 0.5;
        }
    }
}

@property --pseudo-p {
    syntax: "<color>";
    inherits: false;
    initial-value: black;
}

@property --pseudo-s {
    syntax: "<color>";
    inherits: false;
    initial-value: black;
}

#given > .tile {
    --pseudo-p: var(--primary-color);
    --pseudo-s: var(--secondary-color);

    background: linear-gradient(var(--pseudo-p), var(--pseudo-s));
    position: relative;
    cursor: grab;
    transition:
        opacity 0.25s,
        scale 0.7s var(--spring-easing),
        rotate 50ms,
        box-shadow 0.7s var(--spring-easing);

    &.new {
        animation: pulse 0.7s var(--smooth-easing) backwards;
        animation-delay: calc(40ms * sibling-index());
    }

    &.snapping {
        transition:
            opacity 0.25s,
            scale 0.7s var(--spring-easing),
            rotate 50ms,
            box-shadow 0.7s var(--spring-easing),
            translate 0.35s var(--smooth-easing);
    }

    &.wrong { animation: flash-wrong 0.65s; }
}

@keyframes pulse {
    from {
        translate: 0 -2rem;
        rotate: -8deg;
        opacity: 0;
    }
}

@keyframes flash-wrong {
    50% {
        --pseudo-p: var(--bad);
        --pseudo-s: var(--bad);
    }
}

.requirements {
    display: flex;
    gap: var(--tile-gap);
    margin: 0.5rem 0;

    & > p {
        width: var(--tile-size);
        position: relative;

        display: flex;
        text-align: center;
        justify-content: center;
        flex-direction: column;
        color: var(--secondary-color);
        font: 1.25rem 'Martian Mono';
        font-weight: 800;
        border-color: var(--secondary-color);

        &[data-span] {
            &::after {
                content: "";
                position: absolute;
                box-sizing: border-box;
                width: 100%;
                height: 1.5rem;
                left: 0;
                border: 0.25rem solid;
            }

            &.wrong { animation: req-flash-wrong 0.65s; }
        }
    }

    &:nth-of-type(1) > p {
        padding-bottom: 2rem;
        justify-content: end;

        &::after {
            bottom: 0;
            border-bottom: none;
        }
    }

    &:nth-of-type(3) > p {
        padding-top: 2rem;
        justify-content: start;

        &::after {
            top: 0;
            border-top: none;
        }
    }
}

@keyframes req-flash-wrong {
    50% {
        color: var(--bad-darker);
        border-color: var(--bad-darker);
    }
}

#tip {
    display: flex;
    justify-content: center;

    margin-top: 2rem;
    font: 1.5rem "Cabinet Grotesk";
    white-space: preserve nowrap;
    align-self: center;
    max-width: var(--tile-size);
    user-select: auto;

    &:not(.new, .proceed) { opacity: 0; }
    &.new {
        animation: come-in 2s backwards;
        animation-delay: 3s;
    }
    
    span { font-weight: bold }

    & > strong {
        margin-right: 0.5rem;
        user-select: none;
    }

    &.proceed {
        animation: flash 0.5s;

        & > strong { margin: 0 }
        & > span { display: none }
    }
}

@keyframes flash { from {opacity: 0;} }

#stats {
    display: flex;
    flex-direction: row;
    margin: 2rem;
    gap: 2rem;

    h2 {
        font-size: 2rem;
        font-family: "Cabinet Grotesk";
    }

    span {
        font-family: "Martian Mono";
        font-weight: 900;
        user-select: none;
        display: inline-block;

        &.update {
            animation:
                twitch calc(0.75s + (0.05s * min(var(--combo), 6))) var(--spring-easing);
        }
    }

    #mistake-count {
        color: var(--bad); 
    }

}

@property --combo {
    syntax: "<number>";
    inherits: false;
    initial-value: 1;
}

@keyframes twitch {
    from {
        rotate: min(5deg + 5deg * var(--combo), 30deg);
    }
}

.timer {
    font: 4rem "Martian Mono";
    font-weight: 900;
    letter-spacing: -0.15rem;
    text-align: center;
    user-select: none;

    margin-top: -1rem;

    &:not(.fake) {
        span {
            display: inline-block;
            animation: timer-roll 0.75s var(--smooth-easing) backwards;
            animation-delay: calc(
                (sibling-count() - sibling-index()) * 50ms
            );
        }

        &.add span { animation-name: timer-roll-reverse; }
        &.end {
            animation: up-away calc(var(--fade-away) * 1.25) var(--smooth-in);
        }
        &.disabled {
            display: none;
        }
    }
}

@keyframes timer-roll {
    from {
        transform: translateY(-1rem);
        opacity: 0;
    }
}

@keyframes timer-roll-reverse {
    from {
        transform: translateY(1.5rem);
        opacity: 0;
    }
}

/* DIALOGS ---------------------------------------------------------------------------------------------------- */

dialog {
    .requirements {
        gap: 0.5rem;

        & > p {
            font-size: 1rem;

            &[data-span]::after {
                height: 1.25rem;
                border-width: 0.2rem;
            }
        }

        &:nth-of-type(1) > p {
            padding-bottom: 1.75rem;
        }

        &:nth-of-type(3) > p {
            padding-top: 1.75rem;
        }
    }

    .tile.floating {
        position: absolute;
    }
}

#how-to-play {
    width: min-content;

    ol, ul {
        margin: 0;
    }

    .examples {
        display: flex;
        flex-direction: row;
        gap: 4rem;
        margin: 2rem 0;

        & > div {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: fit-content;
            flex: 0 1;
        }

        .label {
            text-align: center;
            align-self: center;
        }
    }

    .example {
        display: flex;
        flex-direction: column;
        width: min-content;
        margin-inline: 2rem;
    }

    .row {
        align-self: start;
        position: relative;
        height: 4rem;
    }
}

#settings
{
    align-items: stretch;
    width: 36rem;
    max-height: 60rem;

    #settings-save,
    #settings-save + button {
        display: inline;
    }

    #settings-save {
        align-self: flex-end;
        width: auto;
        font-size: 1.1rem;
        padding: .5rem 1rem;

        place-items: center;
        place-content: center;
    }

    .category {
        border: 1.5px solid #dde;
        border-radius: 1rem;

        display: flex;
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 2rem;

        transition:
            color 0.3s,
            opacity 0.3s;

        &:has(+ .options) { margin-bottom: 0 }
        &.disabled {
            color: #bbc;
            opacity: 0.6;
            
            * { cursor: default; }
            input { color: #bbc }
        }
    }

    #progression-mode {
        display: flex;
        justify-content: space-between;
        gap: 0.5rem;

        padding: 0.25rem;
        border: 1.5px solid #dde;
        border-radius: 100vw;
        margin-bottom: 0.5rem;

        button {
            appearance: none;
            background: none;
            border: none;
            outline: none;
            padding: 0.5rem 0;
            flex-grow: 1;

            font: 1.5rem "Cabinet Grotesk";
            font-weight: bold;
            border-radius: 999rem;
            --color: #fff;

            cursor: pointer;
            user-select: none;

            transition:
                background 0.3s,
                flex-grow 0.5s var(--smooth-easing);

            --color: attr(data-color type(<color>), red);

            &:hover {
                background: hsl(from var(--color) H S L / 0.25);
            }

            &[selected] {
                flex-grow: 1.5;
                background: var(--color);
                color: white;

                cursor: default;
            }
        }

        & + p.label {
            text-align: center;
            align-self: stretch;

            span {
                font-weight: 800;
                color: hsl(from var(--secondary-color) H S calc(L + 10));
            }
        }
    }
}

#settings .setting {
    display: grid;
    grid-template-columns: 1fr max-content;
    grid-template-rows: auto auto;
    padding: 1rem 0.5rem;
    box-sizing: border-box;

    h2 { grid-column: 1; font-weight: bold; }
    h2 + p { grid-column: 1; }

    &:is(.category .setting) {
        padding-inline: 1.5rem;
        &:not(:last-child) { border-bottom: 1.5px solid #dde; }
    }

    &:not(:has(h2 + p)) {
        grid-template-rows: auto;

        h2 {
            align-self: center;
            text-box: trim-both cap alphabetic;
        }
    }

    input, .control {
        appearance: none;
        background: none;
        
        grid-column: 2;
        grid-row: 1 / -1;
        place-items: center;
        place-content: center;

        border: 1.5px solid #ccd;
        border-radius: .7rem;
        box-sizing: border-box;
        height: 2rem;

        align-self: center;
        margin-left: 1rem;

        &::-webkit-outer-spin-button,
        &::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        transition: 
            border-color 0.3s,
            color 0.3s;

        &[type="number"] {
            appearance: textfield;

            height: auto;
            font: 1.25rem "Martian Mono";
            font-weight: bold;
            width: 5rem;
            padding-block: 0.35rem;

            &:focus {
                outline: none;
                border-color: var(--secondary-color);
            }
        }

        &[type="checkbox"] {
            position: relative;
            aspect-ratio: 1;

            cursor: pointer;
            animation: unchecked 1s var(--spring-easing);

            &:hover {
                border-color: var(--secondary-color);
            }

            &:checked {
                border-width: 0;
                background: var(--color-gradient);

                animation: checked 1s var(--smooth-easing);

                &::after {
                    position: absolute;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);

                    content: '\2713';
                    color: white;
                    font-size: 1.2rem;
                    font-weight: 900;
                    text-align: center;
                }
            }
        }
    }
}

@keyframes checked {
    from {
        scale: 1.2;
        opacity: 0;
    }
}

@keyframes unchecked {
    from {
        rotate: -30deg;
    }
}


#game-over 
{
    & > h1, & > h2 {
        text-align: center;
        align-self: stretch;
    }

    & > h1 { font-size: 4rem; }
    & > h2 { margin-bottom: 1.5rem; }

    div:has(.fake.timer) {
        display: flex;
        align-self: stretch;
        justify-content: center;
        gap: 3rem;
    }

    .fake.timer {
        font-size: 3rem;

        margin-block: 0rem 1rem;

        &::before {
            content: attr(data-label);

            font: 1.25rem "Cabinet Grotesk";
            font-weight: bold;
            font-kerning: auto;
            letter-spacing: normal;

            margin-bottom: -0.25rem;
            display: block;
        }
    }

    .stats {
        margin-block: 1rem 2rem;

        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-self: stretch;

        p {
            display: flex;
            justify-content: space-between;
            font: 2rem "Cabinet Grotesk";
            font-weight: bold;

            & > span.gradient {
                font-family: "Martian Mono";
                font-weight: 900;
            }

            &.mistakes > span.gradient {
                background-clip: auto;
                background: none;
                color: var(--bad);
            }
        }
    }

    .big-stats {
        display: grid;
        align-self: stretch;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;

        & > div {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: end;
            justify-content: end;
            background-color: #ccd;

            padding: 1rem;
            padding-top: 2.25rem;
            border-radius: .75rem;
            user-select: none;
        }

        h1 {
            font-size: 2.5rem;
            font-family: 'Martian Mono';
        }

        p { font-weight: bold; }

        .color * {
            color: white;
            text-shadow: 0 .25rem .75rem #0000001f;
        }
    }

    .highscore { background: linear-gradient(-45deg, var(--primary-color), var(--secondary-color)); }

    #show-full-stats {
        background: none;
        border: none;
        outline: none;

        align-self: center;
        font: 1rem 'Cabinet Grotesk';
        font-weight: bold;
        color: var(--secondary-color);
        border-bottom: 1px solid var(--secondary-color);

        cursor: pointer;

        svg {
            display: inline-block;
            height: 1ch;
            transform: scaleX(-1);
            fill: none;
            stroke: var(--secondary-color);
            stroke-width: 1rem;
        }
    }
}


/* MOBILE!!!!!!!!!!!!!!!! -------------------------------------------- */


@media (max-width: 768px) {
    :root {
        --tile-gap: 0.5rem;
    }

    html {
        font-size: 14px;
    }
    
    body {
        justify-content: start;
    }

    #game {
        margin: 0 calc(var(--tile-gap) * 4);
        flex: 1 1;
        align-self: stretch;
        justify-content: center;
    }

    .row {
        height: auto;
    }

    .tile {
        flex: 1;
        aspect-ratio: 1;
    }

    .requirements > p {
        font-size: 1rem;
    }

    #tip {
        display: inline-block;
        font-size: 1.25rem;

        max-width: inherit;
        align-self: stretch;
        text-align: center;
        white-space: inherit;

        & > strong { margin-right: 0.35rem }
    }

    #stats {
        margin: 1rem 2rem;
        order: 2;
        align-self: stretch;
        justify-content: space-between;

        h2 {
            font-size: 1.25rem;
            font-weight: 600;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        span { font-size: 2rem }
    }

    #timer {
        width: stretch;
        margin: 0 2rem;
        order: 1;
    }
}

@media (max-width: 32rem) {
    #how-to-play {
        width: 100vw;
        /*max-height: 75dvh;*/

        .examples {
            flex-direction: column;
            align-items: center;
            gap: 2rem;
        }

        .what { display: none }
    }

    #game-over {
        justify-content: center;
    }
}