/* ============================================
   Tuto Corbak — overlay premiere session
   ============================================ */

.tuto-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: auto;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    /* padding-left > sidebar (220px) pour ne pas masquer les icones sidebar
       qui doivent briller pendant les beats a click force */
    padding: 0 40px 40px 240px;
    opacity: 0;
    transition: opacity 0.4s ease;
}
@media (max-width: 900px) {
    .tuto-overlay {
        padding: 0 20px 40px 20px;
    }
}
.tuto-overlay.visible { opacity: 1; }

.tuto-scrim {
    position: absolute;
    inset: 0;
    background: rgba(5, 3, 10, 0.55);
    backdrop-filter: blur(2px);
    z-index: 0;
    transition: background 0.35s ease, backdrop-filter 0.35s ease;
}
.tuto-overlay--clear .tuto-scrim {
    background: transparent;
    backdrop-filter: none;
}

.tuto-corbak-wrap {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    width: 100%;
    max-width: min(960px, 92vw);
    pointer-events: none;
}

.tuto-corbak-sprite {
    width: clamp(180px, 22vw, 320px);
    height: auto;
    margin-left: 12px;
    margin-bottom: -18px;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.8));
    transform: translateY(0);
    transition: opacity 0.6s ease, transform 0.6s ease;
    opacity: 0;
}
.tuto-overlay.visible .tuto-corbak-sprite {
    opacity: 1;
}
.tuto-corbak-sprite.leaving {
    opacity: 0;
    transform: translateY(40px);
}

.tuto-dialog {
    position: relative;
    pointer-events: auto;
    background:
        linear-gradient(170deg, rgba(30, 22, 12, 0.96) 0%, rgba(16, 12, 8, 0.98) 100%);
    border: 2px solid var(--border-modal-gold, #6a5a2e);
    padding: 24px 34px 20px;
    width: 100%;
    max-width: min(960px, 92vw);
    box-shadow:
        0 0 30px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(var(--gold-rgb, 200, 168, 78), 0.18),
        inset 0 -1px 0 rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}
.tuto-overlay.visible .tuto-dialog {
    opacity: 1;
    transform: translateY(0);
}
.tuto-dialog::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(var(--gold-rgb, 200, 168, 78), 0.1);
    pointer-events: none;
    border-radius: 3px;
}
.tuto-dialog::after {
    content: '';
    position: absolute;
    top: -14px;
    left: 90px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 14px solid var(--border-modal-gold, #6a5a2e);
    filter: drop-shadow(0 -2px 0 rgba(30, 22, 12, 0.96));
}

.tuto-speaker {
    font-family: 'MedievalSharp', serif;
    color: var(--gold, #c8a84e);
    font-size: 1.2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(var(--gold-rgb, 200, 168, 78), 0.35);
}

.tuto-text {
    font-family: 'Roboto Condensed', sans-serif;
    color: var(--text-warm, #e6dcc4);
    font-size: 1.05rem;
    line-height: 1.55;
    min-height: 3em;
    white-space: pre-wrap;
    margin-bottom: 16px;
}
.tuto-text .tuto-caret {
    display: inline-block;
    width: 8px;
    height: 1em;
    background: var(--gold, #c8a84e);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: tuto-caret 0.9s steps(2) infinite;
}
@keyframes tuto-caret {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.tuto-next {
    display: inline-block;
    background: linear-gradient(180deg, rgba(var(--gold-rgb, 200, 168, 78), 0.2), rgba(var(--gold-rgb, 200, 168, 78), 0.08));
    border: 1px solid var(--gold, #c8a84e);
    color: var(--gold, #c8a84e);
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 8px 20px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
    pointer-events: none;
}
.tuto-next.ready {
    opacity: 1;
    pointer-events: auto;
}
.tuto-next:hover {
    background: linear-gradient(180deg, rgba(var(--gold-rgb, 200, 168, 78), 0.35), rgba(var(--gold-rgb, 200, 168, 78), 0.15));
    box-shadow: 0 0 16px rgba(var(--gold-rgb, 200, 168, 78), 0.4);
}

.tuto-hint {
    font-family: 'Oswald', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary, #9a8e6f);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 4px;
    animation: tuto-hint-pulse 1.8s ease-in-out infinite;
}
@keyframes tuto-hint-pulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ============================================
   Highlights — cadres inline (passifs)
   ============================================ */

.tuto-highlight {
    /* Pas de position/z-index : l ecran est deflouree pendant les highlights,
       donc pas besoin de surelever. On garde le positionnement original de l element
       (absolute, fixed, static...) pour ne pas le deplacer. */
    box-shadow:
        0 0 0 3px rgba(var(--gold-rgb, 200, 168, 78), 0.9),
        0 0 24px 6px rgba(var(--gold-rgb, 200, 168, 78), 0.5);
    border-radius: 8px;
    animation: tuto-highlight-pulse 1.6s ease-in-out infinite;
}
@keyframes tuto-highlight-pulse {
    0%, 100% {
        box-shadow:
            0 0 0 3px rgba(var(--gold-rgb, 200, 168, 78), 0.9),
            0 0 24px 6px rgba(var(--gold-rgb, 200, 168, 78), 0.4);
    }
    50% {
        box-shadow:
            0 0 0 3px rgba(var(--gold-rgb, 200, 168, 78), 1),
            0 0 36px 10px rgba(var(--gold-rgb, 200, 168, 78), 0.7);
    }
}

/* ============================================
   Click force — glow continu + elevation z-index
   ============================================ */

.tuto-pulse {
    position: relative;
    z-index: 9100 !important;
    animation: tuto-pulse-glow 1.4s ease-in-out infinite;
}
@keyframes tuto-pulse-glow {
    0%, 100% {
        box-shadow:
            0 0 0 2px rgba(var(--gold-rgb, 200, 168, 78), 0.9),
            0 0 20px 4px rgba(var(--gold-rgb, 200, 168, 78), 0.5);
        background: rgba(var(--gold-rgb, 200, 168, 78), 0.15);
    }
    50% {
        box-shadow:
            0 0 0 3px rgba(var(--gold-rgb, 200, 168, 78), 1),
            0 0 32px 8px rgba(var(--gold-rgb, 200, 168, 78), 0.8);
        background: rgba(var(--gold-rgb, 200, 168, 78), 0.28);
    }
}

/* Pendant le tuto, le scrim avec pointer-events:auto bloque tout,
   sauf l'element cible qui a .tuto-clickable (passe au-dessus). */
.tuto-clickable {
    position: relative;
    z-index: 9200 !important;
    pointer-events: auto !important;
}

/* Masque la croix fermeture sidebar pendant le tuto pour eviter de perdre le focus */
.tuto-overlay.visible ~ * .sidebar-toggle { display: none; }

/* ============================================
   Corbak shopkeeper — perche en haut a droite du Marche Noir
   Apparait a la fin du tuto (classe .visible ajoutee par JS),
   ou immediatement si tutorial_done === 1.
   ============================================ */

.panel-market { position: relative; }

.market-corbak-wrap {
    position: absolute;
    top: 12px;
    right: 90px;
    width: clamp(110px, 11vw, 170px);
    z-index: 5;
    opacity: 0;
    transform: translateY(-18px) scale(0.92);
    transition:
        opacity 0.9s ease,
        transform 0.9s cubic-bezier(0.2, 0.8, 0.3, 1.2);
}
.market-corbak-wrap.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.market-corbak-shop {
    display: block;
    width: 100%;
    height: auto;
    cursor: pointer;
    user-select: none;
    filter:
        drop-shadow(0 6px 18px rgba(0, 0, 0, 0.7))
        drop-shadow(0 0 14px rgba(var(--gold-rgb, 200, 168, 78), 0.35));
    transition: filter 0.25s ease, transform 0.25s ease;
}
.market-corbak-shop:hover {
    filter:
        drop-shadow(0 6px 18px rgba(0, 0, 0, 0.7))
        drop-shadow(0 0 22px rgba(var(--gold-rgb, 200, 168, 78), 0.65));
    transform: translateY(-2px);
}
.market-corbak-shop:active {
    transform: translateY(1px);
}

.market-corbak-bubble {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 180px;
    max-width: 280px;
    padding: 10px 14px;
    background:
        linear-gradient(170deg, rgba(30, 22, 12, 0.97) 0%, rgba(16, 12, 8, 0.98) 100%);
    border: 2px solid var(--border-modal-gold, #6a5a2e);
    border-radius: 4px;
    color: var(--text-warm, #e6dcc4);
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: left;
    box-shadow:
        0 0 20px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(var(--gold-rgb, 200, 168, 78), 0.18);
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.market-corbak-bubble.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.market-corbak-bubble::before {
    content: '';
    position: absolute;
    top: -10px;
    right: 36px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 10px solid var(--border-modal-gold, #6a5a2e);
}
.market-corbak-bubble::after {
    content: '';
    position: absolute;
    top: -7px;
    right: 38px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid rgba(30, 22, 12, 0.97);
}

@media (max-width: 900px) {
    .market-corbak-wrap {
        top: 8px;
        right: 72px;
        width: clamp(80px, 18vw, 120px);
    }
    .market-corbak-bubble {
        min-width: 150px;
        max-width: 220px;
        font-size: 0.85rem;
    }
}
