/*
 * Copyright 2026 Thomas Rosenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

:root {
    --form-theme-color: #467;
}

body {
    background: white;
}

header, main {
    width: calc(50vw - 2rem);
}

label:has(small) {
    align-items: stretch !important;
    flex-direction: column;
}

label[data-invalid-message] {
    &:not(:last-child) {
        margin-bottom: -.75em !important;
    }

    &::after {
        content: attr(data-invalid-message);
        font-size: max(80%, 13px) !important;
        pointer-events: none;
        opacity: 0;
        color: var(--form-field-invalid-color);
        transition: opacity .4s ease;
    }

    &:has(:invalid)::after {
        opacity: 1;
        transition-delay: 5s;
    }
}

#enmities-explanation {
    --line-count: 1;
    overflow: hidden;
    height: calc(var(--line-count) * 1.25em);
    margin-top: -1em;
    margin-bottom: -.75em;
    padding-bottom: .75em;
    white-space: pre-wrap;
    transition: height .5s ease-in-out;
}

.canvas-container {
    position: fixed;
    top: 10px;
    right: 10px;
    bottom: 10px;
    overflow: hidden;
    max-width: calc(50vw - 2 * 10px);
    height: calc(100vh - 2 * 10px);
    max-height: calc(50vw - 2 * 10px);
    margin: auto 0;
    background: var(--form-background-color);
    box-shadow: 0 0 5px #ccc;
    aspect-ratio: 1 / 1;

    &.loading::before {
        content: "⏳";
        font-size: 1rem;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        pointer-events: none;
    }

    &:hover::before,
    &:hover::after {
        display: block;
        content: "";
        z-index: 1;
        position: absolute;
        transform: none;
        background: black;
        box-shadow: 0 0 0 1px hsl(none 0% 100% / 0.75);
    }

    &:hover::before {
        top: 0;
        left: calc(50% - 1px / 2);
        width: 1px;
        height: 100%;
    }

    &:hover::after {
        top: calc(50% - 1px / 2);
        left: 0;
        width: 100%;
        height: 1px;
    }
}

canvas#output {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: crisp-edges;
}

fieldset {
    display: initial;
}

form {
    margin-bottom: 1rem;
}

button {
    width: auto;
    min-width: auto;
    margin: .2rem;
    vertical-align: top;
}

@media (aspect-ratio < 3 / 4) {
    header, main {
        width: 100%;
    }

    header {
        padding-top: 100vw;
    }

    h1 {
        margin-top: 0;
    }

    .canvas-container {
        position: fixed;
        top: 0;
        right: unset;
        bottom: unset;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: unset;
        margin: 0;
    }
}
