
/* * * * * * * * * * * *\
 *     Paint App       *
 *                     *
 *  By: Dean Wagner    *
 * info@deanwagner.net *
 *                     *
 *   Assignment for:   *
 *  The Odin Project   *
 * theodinproject.com  *
\* * * * * * * * * * * */

:root {
    --paint-color:     #000000;
    --canvas-color:    #ffffff;
    --grid-color:      #000000;
    --grid-size:       1px;

    --color-dark:      #666;
    --color-base:      #ccc;
    --color-light:     #eee;
    --color-accent:    #f4f4f4;
    --color-highlight: #fff;
}

* {
    box-sizing: border-box;
    color-scheme: dark;
    cursor: default;
}

/* * * * * * * * *\
 * Element Base  *
\* * * * * * * * */

html {
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-dark);
    background-image: linear-gradient(to bottom right, rgba(0,0,0,0),rgba(0,0,0,0.7));
    color: var(--color-base);
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    font-size: 12pt;
    margin: 0;
    min-height: 100vh;
    padding: 0;
    text-shadow: 0.1em 0.1em 0.1em #000;
}

a, a * {
    cursor: pointer;
}

a:link, a:visited {
    color: var(--color-highlight);
    text-decoration: underline;
}

a:hover, a:focus, a:active {
    color: var(--color-highlight);
    text-decoration: none;
    text-shadow: 0 0 0.2em var(--color-highlight);
}

button, .button, .button:link, .button:visited {
    background-color: var(--color-light);
    border: 1px solid #000;
    border-radius: 0.5em;
    box-shadow: 0.3em 0.3em 0.3em rgba(0,0,0,0.6);
    color: var(--color-dark);
    cursor: pointer;
    display: block;
    font-weight: bold;
    margin: 0 auto;
    padding: 0.5em;
    text-align: center;
    text-decoration: none;
    text-shadow: 0.1em 0.1em 0.2em rgba(0,0,0,0.5);
    width: 100%;
}

button:hover, button:focus, button:active,
.button:hover, .button:focus, .button:active {
    background-color: var(--color-highlight);
    box-shadow: 0 0 0.4em var(--color-highlight);
    color: #000;
    text-decoration: none;
    text-shadow: 0 0 0.2em #000;
}

p {
    margin: 0 auto 1em;
    max-width: 40ch;
    line-height: 1.5em;
}

main {
    align-content: stretch;
    align-items: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin: 0 auto;
    max-width: 80vw;
    min-height: 100vh;
}

/* * * * * * * * *\
 *  Page Header  *
\* * * * * * * * */

header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    grid-column: 1 / span 4;
    grid-row: 1;
    margin: 2em auto 1em;
    max-width: 57em;
    padding: 0;
    width: 100%;
}

header h1 {
    color: #f4f4f4;
    font-size: 2em;
    letter-spacing: 0.5em;
    margin: 0;
    text-shadow: 0.1em 0.1em 0.1em #000;
    text-transform: uppercase;
}

header h1:before {
    background: url('../img/paint.png') no-repeat center center;
    background-size: contain;
    content: '';
    display: inline-block;
    filter: drop-shadow(0.2rem 0.2rem 0.2rem rgba(0,0,0,0.8));
    height: 1em;
    margin-right: 0.5em;
    width: 1em;
}

/* * * * * * * * *\
 *  GitHub Icon  *
\* * * * * * * * */

.github-link {
    transition: all 0.3s ease-out;
}

.github-link:hover,
.github-link:focus {
    transform: rotate(360deg) scale(1.5);
}

.github-icon {
    filter: drop-shadow(0.15em 0.15em 0.15em #000);
    height: 2em;
    transition: all 0.3s ease-out;
    width: 2em;
}

.github-link:hover .github-icon,
.github-link:focus .github-icon {
    filter: drop-shadow(0 0 0.3em #fff);
}

.github-path {
    fill: var(--color-accent);
}

/* * * * * * * * *\
 *    Section    *
\* * * * * * * * */

section {
    align-items: flex-start;
    display: flex;
    flex: 1;
    flex-direction: row;
    gap: 2em;
    justify-content: center;
}

/* * * * * * * * *\
 *    Toolbar    *
\* * * * * * * * */

#toolbar {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

#toolbar fieldset {
    background-color: rgba(0,0,0,0.1);
    border: 1px solid #000;
    border-radius: 0.5em;
    box-shadow: 0.2em 0.2em 0.5em rgba(0,0,0,0.7);
    flex: 1 1 auto;
    margin: 0;
    width: 100%;
}

#toolbar legend {
    margin: 0 auto -1em;
    padding: 0 0.3em 0.2em;
    position: relative;
    width: auto;
}

#toolbar label {
    display: block;
    margin: 1em auto;
    white-space: nowrap;
}

#toolbar #paint-color {
    border-radius: 0.5em;
    box-shadow: 0.3em 0.3em 0.3em rgba(0,0,0,0.6);
    cursor: pointer;
    display: block;
    height: 4em;
    width: 100%;
}

#toolbar input[type='color'] {
    background-color: var(--color-light);
    border: 1px solid #000;
    border-radius: 0.3em;
    box-shadow: 0.2em 0.2em 0.2em rgba(0,0,0,0.6);
    cursor: pointer;
    padding: 0;
}

#toolbar #paint-color:hover,
#toolbar input[type='color']:hover {
    background-color: var(--color-highlight);
    box-shadow: 0 0 0.4em var(--color-highlight);
}

#toolbar label {
    accent-color: var(--color-light);
    cursor: pointer;
}

#toolbar input[type='radio'] {
    accent-color: var(--color-light);
    cursor: pointer;
}

#toolbar input[type='checkbox'] {
    accent-color: var(--color-light);
    cursor: pointer;
    height: 1.5em;
    width: 1.5em;
}

#toolbar label[for='canvas-size'] {
    margin-bottom: 0;
}

#toolbar input[type='range'] {
    accent-color: var(--color-dark);
    cursor: grab;
    margin-bottom: 0;
    width: 100%;
}

#toolbar input[type='range']:active {
    cursor: grabbing;
}

#toolbar #range {
    text-align: center;
}

/* * * * * * * * *\
 *    Canvas     *
\* * * * * * * * */

#canvas {
    background-color: var(--grid-color);
    box-shadow: 0.5em 0.5em 1em rgba(0,0,0,0.8);
    cursor: crosshair;
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(16, 1fr);
    grid-column-gap: var(--grid-size);
    grid-row-gap: var(--grid-size);
    margin: 0;
    padding: var(--grid-size);
    height: 70vmin;
    width: 70vmin;
}

#canvas div {
    background-color: var(--canvas-color);
    cursor: crosshair;
    transition: background-color 0.3s ease-out;
}

#canvas div:hover,
#canvas.custom div:hover {
    background-color: var(--paint-color) !important;
    background-image: none;
}

#canvas.erase div:hover {
    background-color: var(--canvas-color) !important;
    background-image: none;
}

#canvas.random div:hover {
    background-color: var(--color-highlight);
    background-image:
        linear-gradient(217deg, rgba(255,0,0,1), rgba(255,0,0,0) 70.71%),
        linear-gradient(127deg, rgba(0,255,0,1), rgba(0,255,0,0) 70.71%),
        linear-gradient(336deg, rgba(0,0,255,1), rgba(0,0,255,0) 70.71%);
}

/* * * * * * * * *\
 *    Actions    *
\* * * * * * * * */

#actions {
    align-items: stretch;
    display: flex;
    gap: 1em;
    justify-content: stretch;
    margin: 1em 0 0;
}

#actions button {
    flex: 1;
}

/* * * * * * * * *\
 *  Page Footer  *
\* * * * * * * * */

footer {
    font-size: 0.7em;
    grid-column: 1 / span 4;
    grid-row: 8;
    padding: 2em 0;
    text-align: center;
}

/* * * * * * * * *\
 *    Modals     *
\* * * * * * * * */

#modal {
    align-items: center;
    background-color: rgba(0,0,0,0.6);
    bottom: 0;
    display: none;
    height: 100vh;
    justify-content: center;
    left: 0;
    opacity: 1;
    position: fixed;
    right: 0;
    top: 0;
    transition: all 0.2s ease-out;
    width: 100vw;
}

#modal > div {
    background-color: var(--color-dark);
    border: 1px solid #000;
    border-radius: 1em;
    box-shadow: 0 0.5em 1em #000;
    color: var(--color-accent);
    display: none;
    padding: 2em;
    position: relative;
}

#modal div h3 {
    color: var(--color-highlight);
    font-weight: normal;
    margin: 0 0 1em;
    text-align: center;
}

#modal .close_modal {
    height: 2em;
    position: absolute;
    right: 0.5em;
    top: 0.5em;
    transition: all 0.3s ease-out;
    width: 2em;
}

#modal .close_modal svg {
    filter: drop-shadow(0.1em 0.1em 0.2em #000);
    transition: all 0.3s ease-out;
}

#modal .close_modal svg path {
    fill: var(--color-accent);
}

#modal .close_modal:hover svg path {
    fill: var(--color-highlight);
}

#modal .close_modal:hover {
    transform: rotate(360deg) scale(1.3);
}

#modal .close_modal:hover svg {
    filter: drop-shadow(0 0 0.5em var(--color-highlight));
}

/* * * * * * * * *\
 *  Save Image   *
\* * * * * * * * */

#save_modal button {
    margin: 3em auto 0;
    padding: 1em;
    width: 8em;
}

/* * * * * * * * *\
 * Export Image  *
\* * * * * * * * */

#export_modal {
    text-align: center;
}

#export_modal #actual_canvas {
    margin: 0 auto 1em;
}

#export_modal #download_image {
    font-weight: normal;
    padding-left: 2em;
    padding-right: 2em;
}

/* * * * * * * * *\
 * Media Queries *
\* * * * * * * * */

@media screen and (orientation: portrait) {
    body { font-size: 10pt; }
    main { max-width: 100vw; }
    header { max-width: 95vw; }
    section { align-items: center; flex-direction: column; justify-content: flex-start; }
    #toolbar { flex-direction: row; max-width: 90vw; width: 100%; }
    #canvas { height: 90vmin; width: 90vmin; }
}

@media print {
    @page { margin: 0; }
    * { color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
    body { background-color: #ffffff; background-image: none; height: auto; margin: 0.5in; max-height: none; max-width: none; min-height: auto; min-width: auto; }
    header, #toolbar, #actions, footer { display: none; }
    #canvas { box-shadow: none; grid-gap: 0; padding: 0; }
    #canvas div { background-color: #ffffff; }
}