/*
 * Gemeinsame Basis für alle Seiten (Empfänger, Generator, Textseiten).
 *
 * Aufbau:
 *   1. Design-Tokens + Themes   2. Reset   3. Hintergrund (Verlauf + Blobs)
 *   4. Bausteine (.karte, .knopf, .kacheln, .eingabe, .fortschritt …)
 *   5. Textseiten + Fuß        6. Bewegung aus
 *
 * Farben stehen NUR hier. Der Link transportiert höchstens eine Theme-ID.
 */

/* ---------------------------------------------------------------- 1. Tokens */

:root,
[data-theme='rosa'] {
    --bg: #fff1f2;
    --bg-2: #ffdfc9;
    --fg: #3a2230;
    --fg-leise: #6e5260;
    --akzent: #d81b60;
    --akzent-fg: #ffffff;
    --akzent-2: #ff9472;
    --karte: #ffffff;
    --karte-rand: rgba(216, 27, 96, 0.14);
    --schatten: 0 0.75rem 2rem rgba(120, 40, 70, 0.14);

    --radius: 1.5rem;
    --radius-klein: 0.85rem;
    --schrift: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-theme='sonne'] {
    --bg: #fff8e7;
    --bg-2: #ffe0ad;
    --fg: #3d2a12;
    --fg-leise: #6f5630;
    --akzent: #c2410c;
    --akzent-fg: #ffffff;
    --akzent-2: #ffb703;
    --karte: #ffffff;
    --karte-rand: rgba(194, 65, 12, 0.14);
    --schatten: 0 0.75rem 2rem rgba(120, 80, 20, 0.14);
}

[data-theme='mint'] {
    --bg: #eafaf4;
    --bg-2: #c8f0df;
    --fg: #10302a;
    --fg-leise: #3f6b60;
    --akzent: #0a7a60;
    --akzent-fg: #ffffff;
    --akzent-2: #7fd6b5;
    --karte: #ffffff;
    --karte-rand: rgba(10, 122, 96, 0.14);
    --schatten: 0 0.75rem 2rem rgba(16, 70, 60, 0.14);
}

[data-theme='lavendel'] {
    --bg: #f4f0ff;
    --bg-2: #e2d6ff;
    --fg: #291d47;
    --fg-leise: #5a4a85;
    --akzent: #6b3fd4;
    --akzent-fg: #ffffff;
    --akzent-2: #c4a3ff;
    --karte: #ffffff;
    --karte-rand: rgba(107, 63, 212, 0.14);
    --schatten: 0 0.75rem 2rem rgba(70, 45, 130, 0.16);
}

[data-theme='ozean'] {
    --bg: #eaf4ff;
    --bg-2: #cfe6fb;
    --fg: #10283f;
    --fg-leise: #3d5f80;
    --akzent: #1266b8;
    --akzent-fg: #ffffff;
    --akzent-2: #5ec8e8;
    --karte: #ffffff;
    --karte-rand: rgba(18, 102, 184, 0.14);
    --schatten: 0 0.75rem 2rem rgba(20, 60, 100, 0.15);
}

[data-theme='nacht'] {
    --bg: #16121f;
    --bg-2: #2a1e3c;
    --fg: #f4eef8;
    --fg-leise: #bcb1cd;
    --akzent: #ff6b8b;
    --akzent-fg: #2a0e18;
    --akzent-2: #ffb17a;
    --karte: #221a2e;
    --karte-rand: rgba(255, 255, 255, 0.12);
    --schatten: 0 0.9rem 2.4rem rgba(0, 0, 0, 0.5);
}

/* ----------------------------------------------------------------- 2. Reset */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body,
h1,
h2,
h3,
p,
ul,
ol,
figure {
    margin: 0;
}

ul,
ol {
    padding-left: 1.2em;
}

img,
canvas {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--akzent);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

:focus-visible {
    outline: 3px solid var(--akzent);
    outline-offset: 3px;
}

/* Nur für Screenreader. */
.nur-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ----------------------------------------------------- 3. Seite + Hintergrund */

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding:
        calc(1rem + env(safe-area-inset-top))
        calc(1rem + env(safe-area-inset-right))
        calc(1rem + env(safe-area-inset-bottom))
        calc(1rem + env(safe-area-inset-left));
    font-family: var(--schrift);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--fg);
    background-color: var(--bg);
    background-image: linear-gradient(165deg, var(--bg) 0%, var(--bg) 35%, var(--bg-2) 100%);
    background-attachment: fixed;
    overflow-x: hidden;
}

/* Drei sehr weiche Blobs, die langsam schweben. Reine Deko, kein Markup nötig. */
html::before,
body::before,
body::after {
    content: '';
    position: fixed;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(60px);
    opacity: 0.55;
    will-change: transform;
}

html::before {
    top: -14vmin;
    left: -18vmin;
    width: 62vmin;
    height: 62vmin;
    background: var(--akzent-2);
    animation: schweben-a 26s ease-in-out infinite alternate;
}

body::before {
    right: -20vmin;
    top: 22vh;
    width: 54vmin;
    height: 54vmin;
    background: var(--akzent);
    opacity: 0.3;
    animation: schweben-b 32s ease-in-out infinite alternate;
}

body::after {
    left: 10vw;
    bottom: -22vmin;
    width: 58vmin;
    height: 58vmin;
    background: var(--bg-2);
    opacity: 0.75;
    animation: schweben-c 38s ease-in-out infinite alternate;
}

@keyframes schweben-a {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(6vmin, 8vmin, 0) scale(1.12); }
}

@keyframes schweben-b {
    from { transform: translate3d(0, 0, 0) scale(1.05); }
    to   { transform: translate3d(-8vmin, -6vmin, 0) scale(0.92); }
}

@keyframes schweben-c {
    from { transform: translate3d(0, 0, 0) scale(0.95); }
    to   { transform: translate3d(7vmin, -5vmin, 0) scale(1.1); }
}

/* ------------------------------------------------------------- 4. Bausteine */

main {
    width: 100%;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
}

.karte {
    width: 100%;
    max-width: 28rem;
    margin-inline: auto;
    padding: 1.6rem 1.3rem;
    background: var(--karte);
    border: 1px solid var(--karte-rand);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    text-align: center;
}

.karte h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.karte h2 {
    font-size: clamp(1.25rem, 5vw, 1.6rem);
    line-height: 1.25;
}

.karte p {
    color: var(--fg-leise);
}

.karte > * + * {
    margin-top: 0.9rem;
}

.leise {
    color: var(--fg-leise);
    font-size: 0.95rem;
}

.fehler-text {
    color: var(--akzent);
    font-weight: 700;
    font-size: 0.95rem;
}

/* Knöpfe ------------------------------------------------------------------ */

.knopf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    min-height: 3rem;
    min-width: 3rem;
    padding: 0.75em 1.25em;
    border: 2px solid transparent;
    border-radius: 999px;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.knopf:active {
    transform: scale(0.97);
}

.knopf-primaer {
    background: var(--akzent);
    color: var(--akzent-fg);
    box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.16);
}

.knopf-sekundaer {
    background: var(--karte);
    color: var(--fg);
    border-color: var(--karte-rand);
    box-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.08);
}

.knopf-leise {
    display: inline-block;
    min-height: 2.75rem;
    padding: 0.6em 0.8em;
    background: none;
    border: 0;
    color: var(--fg-leise);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
}

.knopf-leise:hover {
    color: var(--akzent);
}

.knopf[disabled],
.knopf[aria-disabled='true'] {
    opacity: 0.45;
    cursor: default;
}

.knopf-reihe {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.7rem;
}

.knopf-spalte {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Kacheln ----------------------------------------------------------------- */

.kacheln {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.kachel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 5.5rem;
    padding: 0.9rem 0.5rem;
    background: var(--karte);
    border: 2px solid var(--karte-rand);
    border-radius: var(--radius-klein);
    color: var(--fg);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    /* Lange Wörter wie „Spaziergang“ dürfen trennen, aber erst im Notfall. */
    overflow-wrap: break-word;
    hyphens: auto;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.kachel-emoji {
    font-size: 1.9rem;
    line-height: 1;
}

.kachel:active {
    transform: scale(0.97);
}

.kachel[aria-pressed='true'] {
    background: var(--akzent);
    border-color: var(--akzent);
    color: var(--akzent-fg);
}

.kachel[disabled] {
    opacity: 0.4;
    cursor: default;
}

.kachel-zusatz {
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.8;
}

/* Eingaben ---------------------------------------------------------------- */

.eingabe {
    width: 100%;
    min-height: 3rem;
    padding: 0.7rem 0.9rem;
    background: var(--karte);
    border: 2px solid var(--karte-rand);
    border-radius: var(--radius-klein);
    color: var(--fg);
    font-family: inherit;
    font-size: 1rem;
}

.eingabe:focus-visible {
    border-color: var(--akzent);
}

.feld {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    text-align: left;
}

.feld-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--fg-leise);
}

.feld-reihe {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.feld-reihe > .feld {
    flex: 1 1 8rem;
}

/* Fortschritt ------------------------------------------------------------- */

.fortschritt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    max-width: 28rem;
}

.fortschritt-punkte {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
}

.fortschritt-punkt {
    width: 1.6rem;
    height: 0.35rem;
    border-radius: 999px;
    background: var(--karte-rand);
    transition: background-color 0.25s ease, width 0.25s ease;
}

.fortschritt-punkt.ist-fertig {
    background: var(--akzent-2);
}

.fortschritt-punkt.ist-aktiv {
    width: 2.6rem;
    background: var(--akzent);
}

.fortschritt-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fg-leise);
}

/* -------------------------------------------------------- 5. Textseiten/Fuß */

.textseite {
    width: 100%;
    max-width: 40rem;
    margin-inline: auto;
    padding: 1.6rem 1.3rem;
    background: var(--karte);
    border: 1px solid var(--karte-rand);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    text-align: left;
    line-height: 1.6;
}

.textseite h1 {
    font-size: 1.7rem;
    margin-bottom: 1rem;
}

.textseite h2 {
    font-size: 1.2rem;
    margin-top: 1.6rem;
    margin-bottom: 0.4rem;
}

.textseite p,
.textseite ul {
    margin-bottom: 0.8rem;
    color: var(--fg-leise);
}

.fuss {
    flex: 0 0 auto;
    width: 100%;
    max-width: 28rem;
    margin-inline: auto;
    padding-top: 0.5rem;
    color: var(--fg-leise);
    font-size: 0.8rem;
    line-height: 1.8;
    text-align: center;
}

.fuss a {
    color: inherit;
    text-decoration: none;
    padding: 0.15rem 0.1rem;
}

.fuss a:hover {
    color: var(--akzent);
    text-decoration: underline;
}

.hinweis {
    max-width: 28rem;
    padding: 0.9rem 1rem;
    background: var(--karte);
    border: 1px solid var(--karte-rand);
    border-radius: var(--radius-klein);
    color: var(--fg-leise);
    text-align: center;
}

/* Für den Kopier-Fallback: unsichtbar, aber markierbar. */
.kopie-feld {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* ---------------------------------------------------------- 6. Bewegung aus */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
