/* TUTORIAL SYSTEM CSS */

#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    z-index: 10003; /* Above everything except nav reveal */
    transition: background 0.5s ease;
    pointer-events: none;
}

#tutorial-overlay.active {
    pointer-events: auto; /* Block clicks on background */
    background: rgba(0, 0, 0, 0.85); /* Solid dark, no blur */
}

#tutorial-overlay.has-spotlight {
    background: transparent; /* Spotlight box-shadow handles the darkness */
}

/* For steps where we want the background fully visible (like the map) */
#tutorial-overlay.transparent {
    pointer-events: none !important;
    background: transparent !important;
}

#tutorial-spotlight {
    position: fixed;
    z-index: 10002; /* Just under the overlay */
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.85), inset 0 0 15px rgba(201, 168, 76, 0.5);
    border: 2px solid #c9a84c;
    border-radius: 8px;
    transition: opacity 0.3s ease;
    opacity: 0;
    display: none;
}

#tutorial-spotlight.active {
    display: block;
    opacity: 1;
}

#tutorial-spotlight.no-darken {
    box-shadow: inset 0 0 15px rgba(201, 168, 76, 0.5); /* Removes the 9999px black shadow */
}

#tutorial-widget {
    position: fixed;
    bottom: -500px; /* Hidden initially */
    left: 20px;
    z-index: 10006; /* Above the highlight (10005) */
    display: flex;
    align-items: flex-end;
    gap: 20px;
    transition: bottom 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

#tutorial-widget.active {
    bottom: 30px;
    pointer-events: auto;
}

#tutorial-chibi {
    width: 250px;
    height: auto;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
    animation: chibi-float 4s ease-in-out infinite;
    transform-origin: bottom center;
    pointer-events: none; /* Prevents dragging and right-clicking */
    user-select: none;
    -webkit-user-drag: none;
}

@keyframes chibi-float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.02); }
}

#tutorial-dialogue-box {
    background: linear-gradient(135deg, rgba(20, 20, 25, 0.95), rgba(10, 10, 15, 0.98));
    border: 2px solid rgba(201, 168, 76, 0.6);
    border-radius: 16px;
    border-bottom-left-radius: 4px; /* Speech bubble tail effect */
    padding: 24px;
    width: 350px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(201, 168, 76, 0.1);
    position: relative;
    color: #e8e8e8;
    font-family: 'Quicksand', sans-serif;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#tutorial-widget.active #tutorial-dialogue-box {
    transform: scale(1);
    opacity: 1;
    transition-delay: 0.3s;
}

/* Speech Bubble Tail */
#tutorial-dialogue-box::before {
    content: '';
    position: absolute;
    bottom: 20px;
    left: -12px;
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-right: 12px solid rgba(201, 168, 76, 0.6);
    border-bottom: 10px solid transparent;
}
#tutorial-dialogue-box::after {
    content: '';
    position: absolute;
    bottom: 22px;
    left: -9px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-right: 10px solid rgba(20, 20, 25, 0.95);
    border-bottom: 8px solid transparent;
}

#tutorial-text {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 20px;
    min-height: 80px;
}

.tutorial-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-controls button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ccc;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    transition: all 0.2s;
}

.tutorial-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

#tutorial-btn-next {
    background: rgba(201, 168, 76, 0.2);
    border-color: rgba(201, 168, 76, 0.5);
    color: #ffd700;
}

#tutorial-btn-next:hover {
    background: rgba(201, 168, 76, 0.4);
    box-shadow: 0 0 15px rgba(201, 168, 76, 0.3);
}

#tutorial-btn-next:disabled {
    opacity: 0.3;
    pointer-events: none;
}

@keyframes highlight-pulse {
    from { box-shadow: 0 0 0 4px rgba(201, 168, 76, 0.8), 0 0 30px rgba(201, 168, 76, 0.5); }
    to { box-shadow: 0 0 0 8px rgba(201, 168, 76, 0.4), 0 0 50px rgba(201, 168, 76, 0.8); }
}

/* Up Arrow for Nav Reveal */
#tutorial-arrow-up {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 80px;
    color: #c9a84c;
    text-shadow: 0 0 30px rgba(201, 168, 76, 0.8), 0 5px 15px rgba(0,0,0,0.8);
    z-index: 10005;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    animation: tutorial-bounce-up 1s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
    display: none;
}

#tutorial-arrow-up.active {
    display: block;
    opacity: 1;
}

@keyframes tutorial-bounce-up {
    from { top: 90px; }
    to { top: 20px; }
}

/* Replay Button (Corner Widget) */
#tutorial-replay-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9990;
    cursor: pointer;
    transition: all 0.3s;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transform-origin: bottom left;
}

#tutorial-replay-btn.visible {
    opacity: 0.8;
    pointer-events: auto;
    transform: scale(1);
}

#tutorial-replay-btn:hover {
    opacity: 1;
    transform: scale(1.1) translateY(-5px);
}

#tutorial-replay-btn img {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.5));
    pointer-events: none; /* Prevents dragging and right-clicking */
    user-select: none;
    -webkit-user-drag: none;
}


#tutorial-replay-btn .chibi-bubble {
    position: absolute;
    bottom: 100%;
    left: 100%;
    transform: translate(-30%, -10px);
    background: #0a0a0a;
    border: 2px solid #c9a84c;
    color: #e0e0e0;
    padding: 10px 15px;
    border-radius: 12px;
    border-bottom-left-radius: 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 13px;
    width: max-content;
    max-width: 250px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

#tutorial-replay-btn:hover .chibi-bubble {
    opacity: 1;
    transform: translate(-30%, -20px);
}

#tutorial-replay-btn.highlight-pulse img {
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% { filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 1)); transform: scale(1.05); }
    100% { filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5)); transform: scale(1); }
}

#tutorial-replay-btn .chibi-bubble.force-show {
    opacity: 1 !important;
    transform: translate(-30%, -20px) !important;
}

.glow-r {
    color: #FFD700;
    text-shadow: 0 0 8px #FFD700, 0 0 15px #FFD700;
    font-weight: 900;
    animation: text-pulse-glow 1.5s infinite alternate;
}

@keyframes text-pulse-glow {
    0% { text-shadow: 0 0 8px rgba(255, 215, 0, 0.5), 0 0 15px rgba(255, 215, 0, 0.5); }
    100% { text-shadow: 0 0 15px rgba(255, 215, 0, 1), 0 0 25px rgba(255, 140, 0, 1); }
}
