/* ============================================================================
   TUTORIAL-BUCH STYLES
   ============================================================================ */

/* Tutorial-Buch Overlay */
.tutorial-book-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    /* Über Mega-Menü (11000), Intro (10050) und z. B. Ele-Logo-Wrap (2147483640) — sonst wirkt openTutorial() „leer“ */
    z-index: 2147483646;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tutorial-book-overlay.tutorial-open {
    opacity: 1;
}

/* Hellmodus: Theme kommt aus data-tutorial-theme (localStorage), nicht nur html/body */
#tutorialBookOverlay[data-tutorial-theme="light"] {
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#tutorialBookOverlay[data-tutorial-theme="light"] .tutorial-book-container {
    background: #ffffff;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(0, 0, 0, 0.06);
}

#tutorialBookOverlay[data-tutorial-theme="light"] .tutorial-book-navigation {
    border-top-color: rgba(0, 0, 0, 0.08);
}

/* Dark Mode: neutraler Vorhang (data-tutorial-theme = settingDarkMode) */
#tutorialBookOverlay[data-tutorial-theme="dark"] {
    background: rgba(6, 6, 8, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Tutorial-Buch Container */
.tutorial-book-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    /* Desktop: ohne min-height kann column-flex + flex:1 den Textbereich auf ~0 kollabieren lassen */
    min-height: min(70vh, 560px);
    background: linear-gradient(135deg, #f5e6d3 0%, #e8d5b7 100%);
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 3px rgba(139, 69, 19, 0.3),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    padding: 15px;
    display: flex;
    flex-direction: column;
    animation: tutorialBookOpen 0.4s ease-out;
    overflow: hidden;
}

@keyframes tutorialBookOpen {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Dark Mode: Tutorial-Buch – kühles Grau, kein Sepia/Braun */
#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-book-container {
    background: linear-gradient(145deg, #1c1c20 0%, #121214 55%, #0e0e10 100%);
    box-shadow:
        0 20px 56px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* SchlieÃŸen-Button */
.tutorial-book-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #333;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    line-height: 1;
    padding: 0;
}

.tutorial-book-close:hover {
    background: rgba(255, 107, 157, 0.8);
    color: white;
    transform: rotate(90deg) scale(1.1);
}

#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-book-close {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Tutorial-Buch Content */
.tutorial-book-content {
    flex: 1 1 auto;
    min-height: 180px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    /* Verstecke Scrollbalken */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE und Edge */
}

.tutorial-book-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Tutorial-Seite */
.tutorial-page {
    width: 100%;
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 5px 10px;
}

/* Emoji auf Tutorial-Seite */
.tutorial-page-emoji {
    font-size: 50px;
    line-height: 1;
    margin-bottom: 0;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* Animationen fÃ¼r Emojis */
.tutorial-animation-wave {
    animation: tutorialWave 2s ease-in-out infinite;
}

.tutorial-animation-paint {
    animation: tutorialPaint 2s ease-in-out infinite;
}

.tutorial-animation-book {
    animation: tutorialBook 2s ease-in-out infinite;
}

.tutorial-animation-gallery {
    animation: tutorialGallery 2s ease-in-out infinite;
}

.tutorial-animation-lock {
    animation: tutorialLock 2s ease-in-out infinite;
}

.tutorial-animation-friends {
    animation: tutorialFriends 2s ease-in-out infinite;
}

.tutorial-animation-video {
    animation: tutorialVideo 2s ease-in-out infinite;
}

.tutorial-animation-confetti {
    animation: tutorialConfetti 2s ease-in-out infinite;
}

.tutorial-animation-clock {
    animation: tutorialClock 2s ease-in-out infinite;
}

.tutorial-animation-character {
    animation: tutorialCharacter 2s ease-in-out infinite;
}

.tutorial-animation-publish {
    animation: tutorialPublish 2s ease-in-out infinite;
}

.tutorial-animation-collaborate {
    animation: tutorialCollaborate 2s ease-in-out infinite;
}

@keyframes tutorialWave {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-10deg) scale(1.05); }
    75% { transform: rotate(10deg) scale(1.05); }
}

@keyframes tutorialPaint {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

@keyframes tutorialBook {
    0%, 100% { transform: scale(1) rotateY(0deg); }
    50% { transform: scale(1.05) rotateY(5deg); }
}

@keyframes tutorialGallery {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

@keyframes tutorialLock {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes tutorialFriends {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes tutorialVideo {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes tutorialCollaborate {
    0%, 100% { transform: translateX(0) scale(1); }
    25% { transform: translateX(-8px) scale(1.05); }
    75% { transform: translateX(8px) scale(1.05); }
}

@keyframes tutorialConfetti {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-15deg) scale(1.1); }
    75% { transform: rotate(15deg) scale(1.1); }
}

/* Titel auf Tutorial-Seite */
.tutorial-page-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    margin-top: 5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-page-title {
    color: #fff;
}

/* Medien auf Tutorial-Seite */
.tutorial-page-media {
    max-width: 100%;
    max-height: 350px;
    width: auto;
    height: auto;
    border-radius: 10px;
    margin-bottom: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    object-fit: contain;
}

.tutorial-page-media video {
    width: 100%;
    height: auto;
}

/* Text auf Tutorial-Seite */
.tutorial-page-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    line-height: 1.4;
    color: #555;
    max-width: 600px;
    margin: 0;
    margin-top: 5px;
}

#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-page-text {
    color: #e0e0e0;
}

/* Action-Button */
.tutorial-action-btn {
    margin-top: 20px;
    padding: 12px 30px;
    background: linear-gradient(135deg, #FF6B9D 0%, #667eea 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.tutorial-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #ff8bb3 0%, #7d8ff5 100%);
}

/* Tutorial-Navigation */
.tutorial-book-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid rgba(139, 69, 19, 0.2);
    flex-shrink: 0;
}

#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-book-navigation {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* Navigation-Buttons */
.tutorial-nav-btn {
    width: 50px;
    height: 50px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    line-height: 1;
    padding: 0;
}

.tutorial-nav-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #7d8ff5 0%, #8b5fbf 100%);
}

.tutorial-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Seitenzahl */
.tutorial-page-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 600;
    color: #555;
    min-width: 80px;
    text-align: center;
}

#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-page-number {
    color: #e0e0e0;
}

/* Skip-Button */
.tutorial-book-skip {
    text-align: center;
    margin-top: 10px;
    flex-shrink: 0;
}

.tutorial-skip-btn {
    background: transparent;
    border: none;
    color: #999;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s ease;
    padding: 5px 10px;
}

.tutorial-skip-btn:hover {
    color: #667eea;
}

#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-skip-btn {
    color: #aaa;
}

#tutorialBookOverlay[data-tutorial-theme="dark"] .tutorial-skip-btn:hover {
    color: #7d8ff5;
}

/* Alter Service-Worker/JS ohne data-tutorial-theme: an Seiten-Dark-Mode koppeln */
html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]),
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) {
    background: rgba(6, 6, 8, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-book-container,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-book-container {
    background: linear-gradient(145deg, #1c1c20 0%, #121214 55%, #0e0e10 100%);
    box-shadow:
        0 20px 56px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-book-close,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-book-close {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-page-title,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-page-title {
    color: #fff;
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-page-text,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-page-text {
    color: #e0e0e0;
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-book-navigation,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-book-navigation {
    border-top-color: rgba(255, 255, 255, 0.1);
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-page-number,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-page-number {
    color: #e0e0e0;
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-skip-btn,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-skip-btn {
    color: #aaa;
}

html.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-skip-btn:hover,
body.dark-mode #tutorialBookOverlay:not([data-tutorial-theme]) .tutorial-skip-btn:hover {
    color: #7d8ff5;
}

/* ============================================================================
   Scope #tutorialBookOverlay (hängt unter <html>): volle Abdeckung, keine Lücken
   oben; Buttons gegen globale Seiten-Styles / UA (grau, flach, überlagert).
   ============================================================================ */
#tutorialBookOverlay.tutorial-book-overlay {
    isolation: isolate;
    pointer-events: auto;
}

#tutorialBookOverlay .tutorial-book-container {
    position: relative;
    z-index: 1;
}

#tutorialBookOverlay .tutorial-page {
    position: relative;
    z-index: 0;
}

#tutorialBookOverlay .tutorial-page-title {
    position: relative;
    z-index: 1;
}

#tutorialBookOverlay button.tutorial-nav-btn {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
    border: none !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #fff !important;
    font-size: 32px !important;
    font-weight: bold !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 0 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    cursor: pointer !important;
}

#tutorialBookOverlay button.tutorial-action-btn {
    -webkit-appearance: none !important;
    appearance: none !important;
    margin-top: 20px !important;
    padding: 12px 30px !important;
    background: linear-gradient(135deg, #FF6B9D 0%, #667eea 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 25px !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

#tutorialBookOverlay button.tutorial-book-close {
    -webkit-appearance: none !important;
    appearance: none !important;
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    width: 40px !important;
    height: 40px !important;
    border: none !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    color: #333 !important;
    font-size: 28px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 20 !important;
    line-height: 1 !important;
    padding: 0 !important;
}

#tutorialBookOverlay[data-tutorial-theme="dark"] button.tutorial-book-close {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}

#tutorialBookOverlay button.tutorial-skip-btn {
    -webkit-appearance: none !important;
    appearance: none !important;
    background: transparent !important;
    border: none !important;
    color: #999 !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 14px !important;
    cursor: pointer !important;
    text-decoration: underline !important;
    padding: 5px 10px !important;
}

#tutorialBookOverlay[data-tutorial-theme="dark"] button.tutorial-skip-btn {
    color: #aaa !important;
}

@media (max-width: 768px) {
    #tutorialBookOverlay button.tutorial-nav-btn {
        width: 45px !important;
        height: 45px !important;
        min-width: 45px !important;
        min-height: 45px !important;
        font-size: 28px !important;
    }
}

@media (max-width: 480px) {
    #tutorialBookOverlay button.tutorial-nav-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        font-size: 24px !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .tutorial-book-container {
        width: 95%;
        padding: 30px 20px;
        min-height: 400px;
    }
    
    .tutorial-page-emoji {
        font-size: 80px;
    }
    
    .tutorial-page-title {
        font-size: 24px;
    }
    
    .tutorial-page-text {
        font-size: 16px;
    }
    
    .tutorial-book-content {
        min-height: 300px;
        padding: 10px;
    }
    
    .tutorial-nav-btn {
        width: 45px;
        height: 45px;
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .tutorial-book-container {
        padding: 10px 10px;
        padding-bottom: 60px;
    }
    
    .tutorial-page-emoji {
        font-size: 40px;
    }
    
    .tutorial-page-title {
        font-size: 18px;
    }
    
    .tutorial-page-text {
        font-size: 13px;
    }
    
    .tutorial-page-media {
        max-height: 250px;
    }
    
    .tutorial-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .tutorial-book-navigation {
        gap: 20px;
    }
}
