/* padding is included in size calculations *
 * all elements have no maring and padding  */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-white: hsl(0 100% 100%);
    --color-black: hsl(0 0% 0%);
    --color-red: hsl(0 75% 45%);
    --color-link: #DC007D;
    --color-text: hsl(0 0% 0%);
    --color-caret: hsl(280 100% 88%);
    --color-bg: hsl(89 100% 90%);
    --color-bg-hl: hsl(89 100% 93%);
}


html {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    color: var(--color-text);
    background-color: var(--color-bg);
}

body {
    height: 100dvh;
    width: 100dvw;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

main {
    display: flex;
    flex-direction: column;
    margin-inline: auto;
    padding-inline: 1rem;
    padding-block: 1rem;
    gap: 1rem;
    height: 100%;
    width: 100%;
    max-width: 402px;
    min-width: 270px;

    b {
        font-weight: 500;
    }

    ul {
        padding-left: 1.4rem;
    }

    ul li {
        padding: 0.2rem 0;
    }

    h1 {
        font-size: 2.35rem;
        font-weight: 200;
        text-wrap: balance;
    }

    h2 {
        font-size: 1.5rem;
        font-weight: 200;
        text-wrap: balance;
        text-align: center;
    }

    @media (max-height: 580px) {
        h1 {
            font-size: 1.5rem;
        }

        h2 {
            font-size: 1.2rem;
        }
    }

    label {
        font-weight: 600;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    >:last-child {
        margin-top: auto;
    }

    .mascot {
        flex: 1;
        width: auto;
        object-fit: contain;
        min-height: 10rem;
        margin-block: -1rem;
        max-width: 100%;
    }

}

article.coupon {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background-color: rgb(226, 214, 162);
    padding-inline: 0.5rem;
    padding-block: 1rem;
    mask: repeating-conic-gradient(from 135deg at 50% 6px, #0000 0, #000 1deg 89deg, #0000 90deg 180deg) 50% -6px/12px
}

header {
    display: flex;
    flex-direction: column;
    gap: 1rem;

    .logo-container {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
    }

    a {
        display: flex;
        height: 1.62rem;
    }

    .logo {
        max-height: 1.62rem;
        max-width: 12rem;
        align-self: self-start;
    }

    .powered-by {
        height: 16px;
        cursor: pointer;
        margin-block: auto;
    }
}

@media (max-height: 610px) {
    h1 {
        transition: margin 0.5s ease, opacity 0.5s ease;
    }

    h1.hide {
        margin-bottom: -6rem;
        opacity: 0;
    }
}

p {
    font-weight: 300;
    text-wrap: balance;
}

button {
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-family: inherit;
    color: inherit;
    font-size: 1rem;
    font-weight: 500;
    padding: 1.618rem 0;
    width: 100%;
    border-radius: 8px;

    &.primary {
        display: inline-block;
        background: black;
        color: var(--color-white);
    }

    &.secondary {
        display: inline-block;
        border: 1px solid black;
        color: var(--color-black);
    }
}



dialog {
    border: none;
    border-radius: 8px;
    max-width: 380px;
    padding: 1rem;
    font-size: 1.4rem;
    text-align: left;
    font-weight: 300;
    background-color: var(--color-bg);
    margin: auto auto;

    h1 {
        font-size: 0.8rem;
        justify-content: start;
        text-align: left;
    }

    p {
        margin: 1rem 0;
    }

    button {
        font-weight: 400;
        font-size: 1.5rem;
        margin: 0.3rem 0;
    }

    .confirm {
        background: var(--color-black, black);
        color: white;
    }

    .cancel {
        background: var(--color-red, red);
        color: white;
    }

    ::backdrop {
        background: rgba(0, 0, 0, 0.5);
    }
}

textarea {
    padding: 0.8rem;
    width: 100%;
    height: 100%;
    font-size: 1rem;
    font-weight: 400;
    background: var(--color-bg);
    font-family: inherit;
    color: var(--color-text, black);
    caret-color: var(--color-caret, #c9a3f0);
    border: 1px solid var(--color-text, black);
    border-radius: 8px;
    margin-block: 1px;
    outline: none;
    resize: none;
    overflow: scroll;
    box-sizing: border-box;

    &:hover,
    &:focus {
        background-color: var(--color-bg-hl);
    }

    &::placeholder {
        font-style: italic;
        color: black;
        font-weight: 200;
    }
}

::selection {
    background-color: var(--color-caret, #c9a3f0);
}

#message-prompt {
    position: relative;
    display: flex;
    flex-direction: column;
    padding-inline: 2rem;
    flex: 1;
    padding-bottom: 4rem;

    mascot-cup-icon {
        position: absolute;
        right: 50%;
        bottom: 0;
        width: 8rem;
        transition: right 500ms ease, bottom 500ms ease;
        transform: translate(50%, 50%);
    }

    .icon-wrapper {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    post-letter-icon {
        width: 10rem;
        animation: bounce 3s ease-in-out infinite;
    }

    textarea:read-only {
        width: auto;
        height: auto;
        border-radius: unset;
        font-family: "Gochi Hand";
        font-weight: 300;
        font-size: 1.3rem;
        margin-block: auto;
        margin-inline: 0rem;
        padding: 0.8rem;
        color: var(--color-text, black);
        background: var(--color-white, white);
        border: 1px solid var(--color-text, black);
        box-shadow: -5px 5px black;
        overflow: hidden;
        transition: opacity ease 1000ms;
    }

    @media (max-height: 650px) {
        textarea:read-only {
            font-size: 1rem;
        }
    }

}

.overlay {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(2px);
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10;
}

.highlight {
    color: var(--color-text, black);
    z-index: 11;
    transition: color 100ms ease;
    pointer-events: none;
}

body:has(.overlay) {
    .highlight {
        color: var(--color-white, white);
    }

    h2 {
        position: absolute;
        text-wrap: nowrap;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }

    textarea:read-only {
        opacity: 0;
    }
}

body:not(:has(.overlay)) {
    .highlight {
        color: var(--color-black, black);
    }

    h2 {
        opacity: 0;
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }

    #message-prompt {
        post-letter-icon {
            animation: scaleOut 500ms ease-in-out forwards;
        }

        textarea:read-only {
            opacity: 1;
        }

        mascot-cup-icon {
            right: 3rem;
            bottom: 4rem;
            transform: translate(50%, 50%);
        }
    }
}

@keyframes scaleOut {
    from {
        transform: rotate(-18deg) scale(1);
        opacity: 1;
    }

    to {
        transform: rotate(0) scale(0);
        opacity: 0;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(5px) rotate(-18deg);
    }

    50% {
        transform: translateY(-5px) rotate(-18deg);
    }
}
