/*
 * WUNDERBLÜTE
*/

@import url("../fonts/fonts.css");

:root {
    --header-h: 5rem;
    --footer-h: 3.75rem;
    --pad: 1.25rem;

    --radius-soft: 1.5rem;
    --radius-sharp: 0.25rem;

    --shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    --border: 1px solid color-mix(in oklch, var(--txt) 18%, transparent);

    --font-title: "Anthony", system-ui, sans-serif;
    --font-mono: "MonaspaceRadonNF", monospace;

    --text-base: 1.1rem;
    --text-sm: 0.9rem;
    --text-lg: 1.5rem;
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--txt);
    font-family: var(--font-mono);
    font-size: var(--text-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

main.app {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: calc(var(--header-h) + var(--pad) + env(safe-area-inset-top))
        var(--pad)
        calc(var(--footer-h) + var(--pad) + env(safe-area-inset-bottom))
        var(--pad);
}

/* Header */
.app-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--header-h);
    padding-top: env(safe-area-inset-top);
    z-index: 20;
    background: color-mix(in oklch, var(--bg) 95%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: var(--border);
    display: grid;
    place-items: center;
}

.title {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    font-family: var(--font-title);
    font-size: 2.8rem;
    letter-spacing: 0.03em;
}

.dl-embedded {
    width: 3.2rem;
    height: 3.2rem;
    transform: translateY(4px);
}

/* Start screen */
.start-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--bg);
    padding: var(--pad);
    display: grid;
    place-items: center;
    overflow-y: none;
}

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: left;
    max-width: 480px;
    width: 100%;
}

.start-logo img {
    width: 48px;
    height: 48px;
    display: block;
    margin: 0 265px 20px 0;
}

.poem {
    color: var(--txt);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: italic;
    line-height: 1.65;
    white-space: pre-wrap;
    margin: 0 0 32px 0;
}

.start-info {
    display: inline-block;
    width: auto;
    color: var(--sec);
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px dashed var(--sec);
    margin-top: 1.5rem;
    text-align: center;
    opacity: 0.9;
    padding: 0.2rem 0.8rem;
    animation: blink-border 2.5s infinite ease-in-out;
}

@keyframes blink-border {
    0%,
    100% {
        border-color: var(--sec);
    }
    50% {
        border-color: transparent;
    }
}

.start-screen.is-leaving {
    pointer-events: none;
    transition:
        opacity 0.4s ease,
        transform 0.4s ease;
    opacity: 0;
    transform: scale(1.02);
}

/* Panels */
.panel {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.equation {
    margin-bottom: 5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.term {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem 1rem;
    font-family: var(--font-title);
    font-size: 2.2rem;
}

/* Cells */
.cell {
    color: var(--txt);
    min-width: 3rem;
    height: 4rem;
    padding: 0 0.5rem;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sharp);
    background: color-mix(in oklch, var(--bg) 96%, var(--txt));
    border: 1px solid transparent;
}

.cell.locked {
    background: var(--sec);
    color: var(--bg);
    border-color: var(--sec);
    box-shadow: 0.25rem 0.25rem 0 color-mix(in oklch, var(--sec) 50%, black);
}

.cell.editable {
    background: var(--bg);
    border-color: var(--acc);
    color: var(--txt);
    /* font-weight: bold; */
    cursor: pointer;
    box-shadow: 0.25rem 0.25rem 0 var(--txt);
}

.cell.editable:hover {
    transform: translate(-0.125rem, -0.125rem);
    box-shadow: 0.375rem 0.375rem 0 var(--txt);
}

.cell.editable:empty::before {
    content: "?";
    font-size: 1rem;
    color: var(--txt);
    opacity: 0.2;
}

/*
 * .cell.editable:active {
 *   transform: translate(0.125rem, 0.125rem);
 *   box-shadow: 0.125rem 0.125rem 0 var(--txt);
 * }
*/

.equals-row {
    font-family: var(--font-mono);
    font-size: 2rem;
    opacity: 0.9;
}

/* Controls */
.controls {
    text-align: center;
}

.btn-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 4rem;
}

.btn {
    appearance: none;
    background: transparent;
    border: 1px solid var(--txt);
    color: var(--txt);
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-soft);
    cursor: pointer;
    transition: all 0.2s ease;
}

:focus-visible {
    outline: 2px dotted var(--ter);
    outline-offset: 3px;
    border-radius: var(--radius-sharp);
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--txt);
    color: var(--bg);
    border-color: var(--txt);
    font-weight: 700;
}

.feedback {
    min-height: 1.6em;
    font-size: 1rem;
    color: var(--sec);
    white-space: pre-line;
}

/* Footer */
.app-footer {
    position: fixed;
    inset: auto 0 0 0;
    height: var(--footer-h);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 20;
    background: color-mix(in oklch, var(--bg) 95%, transparent);
    backdrop-filter: blur(12px);
    border-top: var(--border);
    display: grid;
    place-items: center;
}

.footer-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.linklike {
    background: transparent;
    border: none;
    font-family: var(--font-title);
    font-size: 1.2rem;
    color: var(--txt);
    padding: 0.5rem;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.linklike:hover {
    opacity: 1;
}

#theme-toggle {
    font-size: 1.5rem;
    line-height: 1;
}

/* Modals */
dialog.modal {
    background: transparent;
    border: none;
    padding: 0;
    width: min(600px, 90vw);
    max-height: 85vh;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-right: -0.5rem;
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.modal-card {
    background: var(--bg);
    border-top: 2px solid var(--acc);
    border-left: 2px solid var(--acc);
    border-bottom: 2px solid var(--txt);
    border-right: 2px solid var(--txt);
    border-radius: var(--radius-sharp);
    padding: 1.5rem 1.25rem;
    box-shadow: var(--shadow);
    color: var(--txt);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}

.modal-card h2 {
    font-family: var(--font-title);
    font-size: 1.6rem;
    margin-top: 0;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.modal-card p {
    margin-top: 1.8rem;
}

.modal-card .credits {
    padding-left: 1.25rem;
    margin: 0 0 1.5rem 0;
}

/* Links in modals */
.modal-card a {
    color: var(--ter);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.2s ease;
}

.modal-card a:hover {
    color: var(--sec);
}

.modal-card:focus {
    outline: none;
}

/* List in SIA */
#sia-list {
    list-style-position: inside;
    padding-left: 0.25rem;
    margin: 0;
    max-height: 12.5rem;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#sia-list::-webkit-scrollbar {
    display: none;
}

.scroll-fade-container {
    position: relative;
}

.scroll-fade-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0.5rem;
    background: linear-gradient(to bottom, var(--bg), transparent);
    z-index: 1;
    pointer-events: none;
}

.scroll-fade-container::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1rem;
    background: linear-gradient(to top, var(--bg), transparent);
    z-index: 1;
    pointer-events: none;
}

#sia-list li {
    margin-bottom: 0.75rem;
    font-family: var(--font-mono);
}

#sia-count {
    align-self: center;
    display: inline-block;
    width: auto;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--sec);
    border: 2px dashed var(--sec);
    text-align: center;
    opacity: 0.9;
    padding: 0.2rem 0.8rem;
    animation: blink-border 2.5s infinite ease-in-out;
}

/* Pickers */
/* .picker-backdrop {
 *   position: fixed;
 *   inset: 0;
 *   background: rgba(0, 0, 0, 0.35);
 *   z-index: 80;
 * }
*/

.picker-backdrop {
    position: absolute;
    inset: 0;
    z-index: 70;
    /* background: rgba(0, 0, 0, 0.14); */
    opacity: 0;
    transition: opacity 220ms ease;
    will-change: opacity;
}

.picker-backdrop.is-visible {
    opacity: 1;
}

@supports (
    (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))
) {
    .picker-backdrop {
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .picker-backdrop {
        transition: none;
    }
}

.radial-picker {
    position: fixed;
    z-index: 90;
    transform: translate(-50%, -50%);
    width: calc(var(--r) * 2 + 8rem);
    height: calc(var(--r) * 2 + 8rem);
    pointer-events: none;
}

.radial-item {
    pointer-events: auto;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%)
        translate(
            calc(cos((var(--i) * 60deg) - 90deg) * var(--r)),
            calc(sin((var(--i) * 60deg) - 90deg) * var(--r))
        );

    width: 4rem;
    height: 4rem;
    border: 1px solid color-mix(in oklch, var(--txt) 25%, transparent);
    background: var(--bg);
    color: var(--txt);
    border-radius: 1.25rem;
    font-family: var(--font-mono);
    font-size: 1.125rem;
}

.radial-item:hover {
    transform: scale(1.1);
}

.radial-picker[data-layout="full"] .radial-item {
    transform: translate(-50%, -50%)
        translate(
            calc(cos((var(--i) * 60deg) - 90deg) * var(--r)),
            calc(sin((var(--i) * 60deg) - 90deg) * var(--r))
        );
}

.radial-picker[data-layout="right-half"] .radial-item {
    transform: translate(-50%, -50%)
        translate(
            calc(cos((var(--i) * -36deg) + 90deg) * var(--r)),
            calc(sin((var(--i) * -36deg) + 90deg) * var(--r))
        );
}

.radial-picker[data-layout="left-half"] .radial-item {
    transform: translate(-50%, -50%)
        translate(
            calc(cos((var(--i) * 36deg) + 90deg) * var(--r)),
            calc(sin((var(--i) * 36deg) + 90deg) * var(--r))
        );
}

.wheel-picker {
    position: fixed;
    z-index: 90;
    transform: translate(-50%, 0);
    width: 5rem;
    padding: 0.5rem 0.5rem;
    background: var(--bg);
    border: 1px solid color-mix(in oklch, var(--txt) 25%, transparent);
    border-radius: 1.25rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    display: grid;
    place-items: center;
    gap: 0.25rem;
}

.wheel-arrow {
    background: transparent;
    border: none;
    color: var(--txt);
    font-size: 1.125rem;
    padding: 0.375rem 0.625rem;
    opacity: 0.9;
    cursor: pointer;
}

.wheel-value {
    font-family: var(--font-title);
    font-size: 2rem;
    line-height: 1.1;
}

/* Larger screens */
@media (min-width: 540px) {
    .start-logo img {
        width: 72px;
        height: 72px;
        margin: 0 340px 20px 0;
    }

    .poem {
        font-size: 18px;
        line-height: 1.65;
        margin: 0 0 32px 0;
    }

    .start-info {
        font-size: 18px;
        margin-top: 48px;
    }

    .equation {
        margin-bottom: 8rem;
        gap: 1.6rem;
    }

    .btn-row {
        gap: 1rem;
        margin-bottom: 8rem;
    }

    .btn {
        font-size: 1.2rem;
        padding: 0.8rem 1.4rem;
    }

    .feedback {
        min-height: 1.6em;
        font-size: 1.2rem;
    }

    .modal-card {
        padding: 2rem 2.5rem;
        border-top: 3px solid var(--acc);
        border-left: 3px solid var(--acc);
        border-bottom: 3px solid var(--txt);
        border-right: 3px solid var(--txt);
    }

    #sia-list {
        max-height: 18.75rem;
    }
}

@media (min-width: 860px) {
    .app-footer {
        height: calc(var(--footer-h) + 1rem);
    }

    .footer-nav {
        gap: 2.5rem;
    }

    .linklike {
        font-size: 1.25rem;
    }
}
