@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@400;600;700&family=Almendra:wght@400;700&family=Almendra+Display&display=swap');

html {
    font-size: 16px;
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 60px;
    font-family: "Comfortaa", "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #eef4f8 0%, #f3efe2 52%, #e8f0eb 100%);
    color: #3d2f4f;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.15rem #ffffff, 0 0 0 0.3rem #6f97b9;
}

.jill-shell {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.2rem 0.25rem 2rem;
}

.story-card {
    border-radius: 28px;
    padding: 1rem;
    background: #f6f6f4;
    border: 3px solid #ffe8b0;
    box-shadow: 0 12px 28px #4e67831f;
    display: flex;
    flex-direction: column;
}

.story-stage {
    border-radius: 22px;
    overflow: visible; /* sonst wird der Rahmenschatten abgeschnitten */
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
}



/* Märchenbuch-Rahmen – feste Grösse, damit beim Wechsel nichts springt.
   --ratio-w / --ratio-h auf das Seitenverhältnis deiner Bilder setzen (z.B. 3/2, 16/9, 4/3). */
.story-image-frame {
    --ratio-w: 2;
    --ratio-h: 3;
    --frame-pad: 10px;
    position: relative;
    width: min(100%, calc(62vh * var(--ratio-w) / var(--ratio-h)));
    aspect-ratio: var(--ratio-w) / var(--ratio-h);
    margin: 0 auto;
    padding: var(--frame-pad);
    border-radius: 18px;
    background: linear-gradient(135deg, #e8c877, #b8893a 40%, #f2d58a 60%, #a8792e);
    box-shadow: 0 6px 18px #5a3d1a40, inset 0 0 0 2px #fff4d0;
}

/* Beide Bilder liegen deckungsgleich übereinander und füllen die Innenfläche ganz */
.story-image {
    position: absolute;
    inset: var(--frame-pad);
    width: calc(100% - 2 * var(--frame-pad));
    height: calc(100% - 2 * var(--frame-pad));
    object-fit: cover;
    display: block;
    border-radius: 10px;
    opacity: 0;
    z-index: 0;
    /* altes Bild bleibt sichtbar, bis das neue fertig eingeblendet ist, erst dann weg */
    transition: opacity 0s linear 0.95s;
}

/* neues Bild liegt oben und blendet weich ein */
.story-image-active {
    opacity: 1;
    z-index: 1;
    transition: opacity 0.95s ease-in-out;
}

/* leicht abgedunkelte Bildränder */
.story-image-frame::before {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 10px;
    pointer-events: none;
    z-index: 2;
    box-shadow: inset 0 0 40px 8px #3a24104d;
}

/* Perlen in den Ecken */
.story-image-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    background: radial-gradient(circle at 10px 10px, #fff4d0 3px, transparent 4px), radial-gradient(circle at calc(100% - 10px) 10px, #fff4d0 3px, transparent 4px), radial-gradient(circle at 10px calc(100% - 10px), #fff4d0 3px, transparent 4px), radial-gradient(circle at calc(100% - 10px) calc(100% - 10px), #fff4d0 3px, transparent 4px);
}

/* Sternenstaub */
.story-sparkles {
    position: absolute;
    inset: 10px;
    border-radius: 10px;
    overflow: hidden;
    pointer-events: none;
    z-index: 3;
}

    .story-sparkles span {
        position: absolute;
        color: #fff8d6;
        font-size: clamp(12px, 2vw, 18px);
        text-shadow: 0 0 6px #ffe89a, 0 0 12px #ffd24d;
        opacity: 0;
        animation: story-sparkle 4s ease-in-out infinite;
    }

        .story-sparkles span:nth-child(1) {
            left: 12%;
            top: 70%;
            animation-delay: 0s;
        }

        .story-sparkles span:nth-child(2) {
            left: 30%;
            top: 40%;
            animation-delay: 1.1s;
        }

        .story-sparkles span:nth-child(3) {
            left: 52%;
            top: 75%;
            animation-delay: 2.3s;
        }

        .story-sparkles span:nth-child(4) {
            left: 70%;
            top: 30%;
            animation-delay: 0.6s;
        }

        .story-sparkles span:nth-child(5) {
            left: 86%;
            top: 60%;
            animation-delay: 1.8s;
        }

        .story-sparkles span:nth-child(6) {
            left: 44%;
            top: 20%;
            animation-delay: 3.1s;
        }

@keyframes story-sparkle {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5) rotate(0deg);
    }

    30% {
        opacity: 1;
        transform: translateY(-8px) scale(1) rotate(45deg);
    }

    70% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
        transform: translateY(-26px) scale(0.6) rotate(90deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .story-sparkles span {
        animation: none;
    }
}

.story-info {
    text-align: center;
    margin-bottom: 0.8rem;
}

.story-footer {
    margin-top: auto;
}

.story-info h2 {
    margin-bottom: 0.2rem;
    font-family: "Almendra", Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.8vw, 2.4rem);
    line-height: 1.2;
    color: #4a3b2a;
}

    .story-info h2::first-letter {
        font-family: "Almendra Display", serif;
        font-size: 1.35em;
        color: #fffaf0;
        background: #b5462f;
        padding: 0.02em 0.18em 0.06em;
        margin-right: 0.06em;
        border-radius: 10px;
        border: 2px solid #e8c877;
        box-shadow: 0 2px 0 #00000022;
    }

    .story-info h2[data-variant="1"]::first-letter {
        background: #2f6b8a;
    }

    .story-info h2[data-variant="2"]::first-letter {
        background: #4f7d45;
    }

    .story-info h2[data-variant="3"]::first-letter {
        background: #7a4f96;
    }

.story-info::after {
    content: "✦ ✦ ✦";
    display: block;
    color: #c9a45c;
    font-size: 1.1rem;
    letter-spacing: 0.4em;
}

.story-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    margin: 0.8rem 0;
}

    .story-controls [data-story-prev] {
        margin-right: auto;
    }

    .story-controls [data-story-next] {
        margin-left: auto;
    }

.story-readaloud {
    display: flex;
    justify-content: center;
    margin: 0.2rem 0 0.8rem;
}

.story-download {
    display: flex;
    justify-content: center;
    margin: 0.2rem 0 0.8rem;
}

.btn-story-arrow {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 0;
    font-size: 1.8rem;
    line-height: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.story-readaloud-hidden {
    display: none;
}

.story-download-hidden {
    display: none;
}

.btn-story {
    background: linear-gradient(90deg, #5f7ea5 0%, #719f7b 100%);
    border: 0;
    color: white;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.6rem 1.25rem;
}

    .btn-story:disabled {
        background: #a7b9c8;
        cursor: not-allowed;
    }

#story-audio {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.audio-progress {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: #d9e2e8;
    margin-top: 0.8rem;
    overflow: hidden;
}

.audio-progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #7e98b6 0%, #7ea989 100%);
    transition: width 0.12s linear;
}

.story-time {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
    color: #5f6f7d;
}

@media (max-width: 768px) {
    .jill-shell {
        padding: 0.55rem 0.08rem 1rem;
    }

    .story-card {
        min-height: calc(100dvh - 2rem);
        padding: 0.65rem;
    }
}

.admin-panel {
    border-radius: 20px;
    padding: 1rem;
    background: #f6f6f4;
    border: 2px solid #d8e1c8;
    margin-bottom: 1rem;
}
