@import url('themes.css');

:root {
    /* --box-shadow: 1vmin 1vmin 2vmin rgba(0, 0, 0, 0.3); */
    --color--white: white;
    --color--gray: #C4C4C4;
    --color--red: #761919;
    --color--green: #70ff70;
    --color--blue: #1976d2;
    --color--button--active: #761919;
    --color--button--hover: #70ff70;
    --color--button: #1976d2;
    --color--background: white;
    --color--foreground: black;
    --color--title: black;
    --color--container--foreground: black;
    --color--container--background: white;
    --color--grid: white;
    --color--grid--border: black;
    --color--error: #ff7070;
    --border-radius: 2vmin;
    --color--text: white;
    --color--cell--locked--foreground: black;
    --color--cell--locked--background: #ffffffdd;
    --color--cell--foreground: black;
    --color--cell--pencil: #333333;
    --color--cell--background: white;
    --color--cell--background--hover: #d9e4f2;
    --color--cell--certain--foreground: #1975d2;
    --color--cell--certain--background: white;
    --z-index--overlay: 499;
    --z-index--modal: 500;
    --z-index--top: 1000;
    --box-shadow: 0 0 3vmin var(--color--foreground);
}

:root.dark {
    --color--white: black;
    --color--grid: #666666;
    --color--grid--border: #666666;
    --color--gray: #888888;
    /* --color--red: #761919;
    --color--green: #70ff70;
    --color--blue: #888888; */
    --color--button--active: #761919;
    --color--button--hover: #70ff70;
    --color--button: #1976d2;
    --color--background: black;
    --color--foreground: #CCCCCC;
    --color--title: #888888;
    --color--container--foreground: white;
    --color--container--background: black;
    --color--text: #CCCCCC;
    --color--cell--locked--foreground: black;
    --color--cell--locked--background: #ffffffaa;
    --color--cell--background--hover: #d9e4f2;
    --color--cell--certain--foreground: #1976d2;
    --color--cell--certain--background: #999999;
    --color--cell--foreground: black;
    --color--cell--background: #CCCCCC;
}

/* @keyframes fade-slide {
    from {
        opacity: 0.5;
        transform: rotate3d(0.5, 1, 0, 90deg);
    }

    to {
        opacity: 1;
        transform: rotate3d(0, 0, 0, 0deg);
    }
} */

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes flash-green {
    0% {
        background-color: initial;
    }

    50% {
        background-color: rgba(0, 191, 0, 0.5);
    }

    100% {
        background-color: initial;
    }
}

@keyframes flash-red {
    0% {
        background-color: initial;
    }

    50% {
        background-color: rgba(255, 191, 0, 0.5);
    }

    100% {
        background-color: initial;
    }
}

@keyframes spin-x {
    0% {
        transform: rotateX(0deg);
        color: var(--color--cell--background);
        background-color: var(--color--cell--background);
    }

    50% {
        color: var(--color--cell--certain--foreground);
    }

    100% {
        transform: rotateX(360deg);
        background-color: var(--color--cell--certain--background);
    }
}

@keyframes spin-y {
    0% {
        transform: rotateY(0deg);
        color: var(--color--cell--background);
        background-color: var(--color--cell--background);
    }

    50% {
        color: var(--color--cell--certain--foreground);
    }

    100% {
        transform: rotateY(360deg);
        background-color: var(--color--cell--certain--background);
    }
}

@keyframes hop {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3vmin);
    }
}

@keyframes hop-rl {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-3vmin);
    }
}

@keyframes rock {

    0%,
    25%,
    75% {
        transform: rotateZ(5deg);
    }

    50%,
    100% {
        transform: rotateZ(-5deg);
    }
}

* {
    margin: 0;
    padding: 0;
    gap: 0;
}

body {
    font-family: Arial, sans-serif;
    background: var(--color--background);
    color: var(--color--foreground);
    padding-bottom: 4em;
    transition: background-color 2000ms ease, color 0.2s ease;
}

main {
    max-width: 90ch;
    margin-left: auto;
    margin-right: auto;
    color: var(--color--foreground);
}

main ul {
    list-style: none;
    text-align: center;
}

@media print {
    main h1 {
        font-size: 48pt;
        line-height: 100%;
    }
}

main p {
    text-align: center;
    font-size: 14pt;
    margin-top: 1em;
}

main a {
    color: inherit;
}

#container {
    font-family: "Julee", cursive;
    color: var(--color--container--foreground);
    display: grid;
    padding-bottom: 2vmin;
    align-items: center;
    justify-items: center;
    align-content: center;
    justify-content: center;
    background: var(--color--container--background);
}

.dark #container {
    filter: grayscale(0.5);
}

#sudoku-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    font-size: 8vmin;
    line-height: 100%;
    transition: transform 2000ms ease, background-color 2000ms ease;
    color: var(--color--container--background);
    background-color: var(--color--grid);
    border: 1.25vmin solid var(--color--grid--border);
}

#sudoku-grid.locking {
    animation: rock 500ms ease;
}

#sudoku-grid.unlocking {
    animation: spin-y 1000ms ease;
}

#sudoku-grid.happy {
    background-color: var(--color--green);
    border-color: var(--color--green);
}

#sudoku-grid.happy .cell.certain {
    background-color: var(--color--green);
    border-color: var(--color--green);
    transition: background-color 1000ms ease;
}

#sudoku-grid.error .cell {
    background-color: var(--color--red);
    transition: background-color 1000ms ease;
}

.cell-group {
    border: 0.5vmin solid var(--color--grid--border);
    background: none;
    display: grid;
    grid-template-columns: repeat(3, auto);
    grid-template-rows: repeat(3, auto);
    line-height: 100%;
}

.cell {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    cursor: pointer;
    border: 0.25vmin solid var(--color--grid--border);
    color: var(--color--cell--foreground);
    background-color: var(--color--cell--background);
    font-size: 9.2vmin;
    font-weight: bold;
    line-height: 100%;
    width: 10vmin;
    height: 10vmin;
    transition: none;
}

.cell.selected {
    background-color: #bbdefb;
}

.cell.certain {
    border-color: var(--color--cell--certain--foreground);
    color: var(--color--cell--certain--foreground);
    background-color: var(--color--cell--certain--background);
    animation: spin-y 500ms ease-in;
}

.cell.locked {
    background-color: var(--color--cell--locked--background);
    font-weight: bold;
    cursor: not-allowed;
    transition: background-color 2000ms ease, color 2000ms ease;
    animation: spin-x 500ms ease-in;
}

.cell.error {
    background-color: var(--color--error);
    border-color: var(--color--error);
    transform: rotate3d(1, 0, 1, 360deg) scale(1.25);
    transition: transform 1500ms ease-out, background-color 2000ms ease;
}

.cell.hint {
    background-color: var(--color--green);
    animation: pulse 3000ms ease-in forwards;
}

.loading #sudoku-grid .cell:nth-child(even) {
    animation: flash-red 3000ms ease-out 500ms infinite;
}

.loading #sudoku-grid .cell:nth-child(odd) {
    animation: flash-green 2000ms ease-out infinite;
}

.cell.box-hover,
.cell.row-hover,
.cell.col-hover,
.cell.hover {
    background-color: hsla(210, 53%, 73%, 0.60);
    ;
    transition: none;
    transform: scale(0.95);
}

.cell.row-hover {
    border-top-color: #6da0d2;
    border-bottom-color: #6da0d2;
}

.cell.col-hover {
    border-left-color: #6da0d2;
    border-right-color: #6da0d2;
}

.cell.hover {
    background-color: hsla(210, 53%, 73%, 0.50);
    transition: none;
}

.cell.same-number {
    background-color: var(--color--green);
    transition: none;
}

.loading #sudoku-grid {
    filter: blur(3px);
}

.pencil-marks {
    display: grid;
    grid-template-columns: repeat(3, 2.0vmin);
    grid-template-rows: repeat(3, 2.0vmin);
    width: 100%;
    height: 100%;
    font-size: 2.5vmin;
    color: var(--color--cell--foreground);
    justify-content: space-around;
    align-content: space-evenly;
}

.pencil-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 100%;
}

#message1 h1,
#message2 h2 {
    color: var(--color--title);
    filter: url(#svg-filter-deep-colors-plastic);
}

@media (orientation: landscape) {
    #container {
        grid-template-rows: auto;
        grid-template-columns: repeat(4, auto);
    }

    #sudoku-grid {
        grid-row-start: 1;
        grid-row-end: 2;
        grid-column-start: 2;
        grid-column-end: 3;
        margin: 0;
    }

    #control-pad {
        grid-row-start: 1;
        grid-row-end: 2;
        grid-column-start: 3;
        grid-column-end: 4;
        margin-left: 2vmin;
        margin-right: 2vmin;
    }

    #message1 {
        grid-row-start: 1;
        grid-row-end: 2;
        grid-column-start: 4;
        grid-column-end: 5;
        writing-mode: vertical-lr;
        text-orientation: upright;
        letter-spacing: -0.2em;
        font-size: 8vmin;
    }

    #message1 h1 {
        writing-mode: vertical-lr;
        text-orientation: upright;
        letter-spacing: -0.2em;
        font-size: 8vmin;
    }

    #message2 {
        grid-row-start: 1;
        grid-row-end: 2;
        grid-column-start: 1;
        grid-column-end: 2;
        writing-mode: vertical-lr;
        text-orientation: upright;
        letter-spacing: 0em;
        font-size: 18vmin;
    }

    #message2 h2 {
        writing-mode: vertical-lr;
        text-orientation: upright;
        letter-spacing: 0em;
        font-size: 18vmin;
    }
}

@media (orientation: portrait) {
    #container {
        grid-template-columns: 100vmin;
        grid-template-rows: repeat(4, auto);
    }

    #sudoku-grid {
        grid-row-start: 1;
        grid-row-end: 2;
        margin: 0;
    }

    #control-pad {
        grid-row-start: 2;
        grid-row-end: 3;
        margin-top: 2vmin;
        margin-bottom: 2vmin;
    }

    #message1 {
        grid-row-start: 3;
        grid-row-end: 4;
        font-size: 8vmin;
    }

    #message2 {
        grid-row-start: 4;
        grid-row-end: 5;
        font-size: 8vmin;
    }
}

.pad {
    visibility: hidden;
    position: fixed;
    top: 0;
    left: 0;
    background: #FFFFFF00;
    z-index: var(--z-index--modal);
}

.pad.active {
    visibility: visible;
}

.pad .buttons {
    padding: 2vmin;
    border-radius: var(--border-radius);
    position: absolute;
    background: var(--color--background);
    box-shadow: var(--box-shadow);
}

.full {
    visibility: hidden;
    display: grid;
    align-content: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-index--modal);
}

.full .body {
    margin: 5vmin;
    padding: 5vmin;
}

.full.active {
    visibility: visible;
}

.full .buttons {
    text-align: center;
}

#share-pad .buttons,
#difficulty-pad .buttons {
    display: flex;
    flex-wrap: nowrap;
    flex-direction: row;
    gap: 2vmin;
    padding: 2vmin;
    border-radius: var(--border-radius);
    z-index: var(--z-index--modal);
}

#number-pad.active .buttons {
    display: block;
    box-shadow: var(--box-shadow);
}

#theme-pad {
    visibility: hidden;
    display: grid;
    align-content: center;
    justify-content: center;
    justify-items: center;
    position: fixed;
    align-items: center;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-index--modal);
}

#theme-pad.active {
    visibility: visible;
}

#theme-pad .buttons {
    height: -webkit-fill-available;
    margin: 5vmin;
    padding: 5vmin;
    overflow: scroll;
    display: flex;
    gap: 1vmin;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    background: var(--color--background);
    border-radius: var(--border-radius);
}

#theme-pad button {
    display: flex;
    justify-content: center;
    font-size: 5vmin;
    padding: 1vmin;
    border: 1px solid black;
    border-radius: var(--border-radius);
    width: 100%;
}

.number-grid {
    display: inline-grid;
    justify-items: center;
    align-items: start;
    grid-template-columns: repeat(6, auto);
    margin-bottom: 2vmin;
    width: 100%;
}

button {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    font-family: "Julee", cursive;
    font-weight: bold;
    font-style: normal;
    background: none;
    border: none;
    color: var(--color--button);
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.96);
}

button.hover {
    transform: scale(1.1);
}

button.hidden {
    display: none;
}

button.number-btn {
    width: auto;
    min-width: 7vmin;
    height: 10vmin;
    font-size: 7vmin;
}

button.control-btn,
button.difficulty-btn {
    width: 7.5vmin;
    height: 7.5vmin;
    font-size: 7vmin;
    border: none;
    border-radius: 0;
    background: none;
}

button.pencil-btn {
    width: auto;
    min-width: 5vmin;
    height: 5vmin;
    font-size: 4vmin;
    color: var(--color--cell--pencil);
}

button svg {
    width: auto;
    height: inherit;
    fill: var(--color--button);
    stroke: var(--color--button);
}

button.hover svg {
    fill: var(--color--button--hover);
    stroke: var(--color--button--hover);
}

.dark button svg {
    filter: url(#svg-filter-deep-colors-plastic);
}

.dark button svg .color {
    visibility: hidden;
}

.dark button.hover svg .color {
    display: initial;
}

.action-buttons {
    gap: 2vmin;
    display: flex;
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
}

.action-btn {
    font-size: 7vmin;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}

.action-btn {
    width: auto;
    height: 10vmin;
}

.hopping {
    animation: hop 0.5s ease-in-out infinite;
}

#overlay,
#underlay {
    visibility: hidden;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-index--overlay);
}

#overlay {
    background: rgba(0, 0, 0, 0.5);
}

#underlay {
    background: rgba(0, 0, 0, 0);
}

#overlay.active,
#underlay.active {
    visibility: visible;
}

#info p,
#instructions p {
    font-size: 5vmin;
}

.full button {
    font-size: 10vmin;
    filter: url(#svg-filter-deep-colors-plastic);
}

.full .body {
    color: var(--color--foreground);
    background: var(--color--background);
    box-shadow: var(--box-shadow);
    border-radius: var(--border-radius);
}

#qrcode-print svg {
    width: 1.25in;
    height: auto;
}

#qrcode.active svg {
    width: 90vmin;
    height: auto;
}

#qrcode-icon svg {
    width: 1em;
    height: auto;
}

#confirm-container {
    display: none;
}

#confirm-container.active {
    display: grid;
    align-content: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-index--modal);
}

#confirm {
    background: var(--color--background);
    font-size: 10vmin;
}

#confirm-message {
    font-size: 10vmin;
}

#confirm .buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

#confirm button {
    font-size: 10vmin;
    background: none;
}

#control-pad {
    display: flex;
    align-items: center;

    justify-content: space-evenly;
    gap: 1vmin;
}

#control-pad {
    background: none;
}

#print-message {
    display: none;
    grid-template-columns: auto auto auto;
    justify-content: space-between;
    background: none;
}

#print-message .difficulty-display svg {
    height: 0.5in;
    width: auto;
}

#progress-display {
    font-size: 10vmin;
    text-align: center;
    color: green;
}

@media (orientation: landscape) {
    .hopping {
        animation: hop-rl 0.5s ease-in-out infinite;
    }

    #container {
        padding: 0;
    }

    #control-pad {
        flex-direction: column;
        height: 100%;
    }

    #share-pad .buttons,
    #difficulty-pad .buttons {
        flex-direction: column;
    }

}

@media (orientation: portrait) {
    #control-pad {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto;
        padding: 0;
        width: 100%;
    }
}

@media print {

    * {
        background: none !important;
        filter: none;
    }

    #print-message {
        display: grid;
    }

    .pad,
    button,
    .noprint {
        display: none !important;
    }

    .cell,
    .cell-group,
    #sudoku-grid {
        border-color: black;
    }

}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}