@font-face {
    font-family: 'Montserrat';
    src: url('fonts/Montserrat-Variable.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('fonts/Inter-Variable.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --rot: #bc2822;
    --rot-hell: #e03a33;
    --rot-rgb: 188 40 34;
    --grund: #0f0f0f;
    --flaeche: #1a1a19;
    --text: #ffffff;
    --text-leise: #8a8a88;
    --linie: rgb(255 255 255 / 0.16);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse 70% 55% at 50% 100%, rgb(var(--rot-rgb) / 0.28), transparent 70%),
        radial-gradient(ellipse 60% 50% at 50% 45%, rgb(var(--rot-rgb) / 0.10), transparent 70%),
        var(--grund);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------- Kopf */

.kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(1rem, 3vh, 2.5rem) clamp(1rem, 3vw, 3rem);
}

.logo {
    width: auto;
    height: clamp(28px, 5vh, 56px);
}

.status {
    display: flex;
    align-items: center;
    gap: 0.6em;
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.9rem, 1.6vh, 1.2rem);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-leise);
}

.status::before {
    content: '';
    width: 0.8em;
    height: 0.8em;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.status[data-zustand="verbinde"]::before {
    animation: blinken 0.8s ease-in-out infinite alternate;
}

.status[data-zustand="verbunden"] {
    color: var(--text);
}

.status[data-zustand="verbunden"]::before {
    border-color: var(--rot-hell);
    background: var(--rot-hell);
    box-shadow: 0 0 0.8em var(--rot-hell);
    animation: pulsieren 1.6s ease-in-out infinite;
}

/* ------------------------------------------------------------- Anzeige */

.anzeige {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: clamp(0.5rem, 2vh, 1.5rem);
    min-height: 0;
    padding: 0 1rem;
}

.gewicht {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: min(19vw, 44vh);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    line-height: 1;
    white-space: nowrap;
    transition: opacity 0.3s, text-shadow 0.3s;
}

.einheit {
    margin-left: 0.12em;
    font-size: 0.28em;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--text-leise);
}

.gewicht[data-wert="leer"],
body[data-verbindung="aus"] .gewicht {
    opacity: 0.3;
}

body[data-anzeige="ganz"] .gewicht {
    font-size: min(24vw, 50vh);
}

body[data-stabil="ja"] .gewicht {
    text-shadow: 0 0 0.25em rgb(var(--rot-rgb) / 0.55);
}

.stabil {
    margin: 0;
    padding: 0.45em 1.4em;
    border: 2px solid var(--linie);
    border-radius: 999px;
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(1rem, 3vh, 2.2rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-leise);
    opacity: 0.35;
    transition: opacity 0.2s, background-color 0.2s, border-color 0.2s, color 0.2s;
}

body[data-stabil="ja"] .stabil {
    border-color: var(--rot);
    background: var(--rot);
    color: var(--text);
    opacity: 1;
    box-shadow: 0 0 2em rgb(var(--rot-rgb) / 0.6);
}

.meldung {
    min-height: 1.5em;
    margin: 0;
    max-width: 40em;
    font-size: clamp(0.95rem, 1.8vh, 1.3rem);
    text-align: center;
    color: var(--text-leise);
}

.meldung[data-art="hinweis"] {
    padding: 0.8em 1.2em;
    border: 1px solid var(--rot);
    border-radius: 0.8rem;
    color: var(--text);
}

/* -------------------------------------------------------------- Leiste */

.leiste {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    padding: clamp(1rem, 3vh, 2.5rem) 1rem;
}

.knopf {
    padding: 0.8em 1.8em;
    border: 2px solid var(--linie);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: 600 clamp(0.9rem, 1.7vh, 1.15rem) 'Inter', system-ui, sans-serif;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}


.knopf:focus-visible {
    outline: 3px solid var(--rot-hell);
    outline-offset: 3px;
}

.knopf:disabled {
    opacity: 0.3;
    cursor: default;
}

.knopf--haupt {
    border-color: var(--rot);
    background: var(--rot);
}

@media (hover: hover) {
    .knopf:hover:not(:disabled) {
        border-color: var(--text);
    }

    .knopf--haupt:hover:not(:disabled) {
        border-color: var(--rot-hell);
        background: var(--rot-hell);
    }
}

.knopf--umschalter[aria-pressed="true"] {
    border-color: var(--text);
    background: var(--text);
    color: var(--grund);
}

body[data-verbindung="an"] #verbinden {
    display: none;
}

/* -------------------------------------------------------------- Dialog */

.dialog {
    width: min(30rem, calc(100vw - 2rem));
    padding: 2rem;
    border: 1px solid var(--linie);
    border-radius: 1.2rem;
    background: var(--flaeche);
    color: var(--text);
}

.dialog::backdrop {
    background: rgb(0 0 0 / 0.7);
}

.dialog h2 {
    margin: 0 0 1rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dialog ol {
    margin: 0 0 1.5rem;
    padding-left: 1.2em;
    line-height: 1.6;
    color: var(--text-leise);
}

.dialog label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.dialog input {
    width: 100%;
    padding: 0.7em 0.9em;
    border: 2px solid var(--linie);
    border-radius: 0.7rem;
    background: var(--grund);
    color: var(--text);
    font: 700 1.6rem 'Montserrat', sans-serif;
}

.dialog input:focus {
    border-color: var(--rot-hell);
    outline: none;
}

.dialog__knoepfe {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ---------------------------------------------------------------- Handy */

@media (max-width: 40em) {
    .kopf {
        padding: 1rem;
    }

    .gewicht {
        font-size: min(22vw, 44vh);
    }

    body[data-anzeige="ganz"] .gewicht {
        font-size: min(28vw, 44vh);
    }

    .leiste {
        padding: 1rem 1rem 1.5rem;
    }

    .leiste .knopf {
        flex: 1 1 40%;
        padding: 0.9em 1em;
    }

    .dialog {
        padding: 1.25rem;
    }

    .dialog__knoepfe .knopf {
        flex: 1;
    }
}

@media (max-height: 30em) {
    .kopf,
    .leiste {
        padding-block: 0.6rem;
    }

    .stabil {
        padding-block: 0.25em;
    }
}

/* ---------------------------------------------------------- Bewegungen */

@keyframes pulsieren {
    50% { box-shadow: 0 0 0.2em var(--rot-hell); }
}

@keyframes blinken {
    to { opacity: 0.2; }
}

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