/* ============================================
   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;
    /* DA harmonisee avec main-quest.css : meme palette gold-warm + radius 10. */
    background: linear-gradient(170deg, rgba(30, 22, 12, 0.96) 0%, rgba(16, 12, 8, 0.98) 100%);
    border: 2px solid rgba(var(--gold-rgb, 200, 168, 78), 0.55);
    padding: 24px 28px 56px;
    width: 100%;
    max-width: min(720px, 92vw);
    box-shadow:
        0 0 30px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(var(--gold-rgb, 200, 168, 78), 0.22),
        inset 0 -10px 14px -10px rgba(0, 0, 0, 0.55);
    border-radius: 10px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
    cursor: pointer;
}
.tuto-overlay.visible .tuto-dialog {
    opacity: 1;
    transform: translateY(0);
}

.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; }
}

/* Bouton Suivant : DA obsidienne tiede partagee avec mq-dialog-next. */
.tuto-next {
    position: absolute;
    right: 14px;
    bottom: 12px;
    padding: 6px 16px;
    background: linear-gradient(165deg, #241e19 0%, #181310 55%, #0d0a08 100%);
    border: 1px solid rgba(var(--gold-rgb, 200, 168, 78), 0.75);
    border-radius: 8px;
    color: var(--gold-text-light, #ffd98a);
    font-family: 'Oswald', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.tuto-next.ready {
    opacity: 1;
    pointer-events: auto;
}
.tuto-next:hover {
    background: linear-gradient(165deg, #2c241d 0%, #1c1712 55%, #100c0a 100%);
    box-shadow: 0 0 12px rgba(var(--gold-rgb, 200, 168, 78), 0.35);
}

.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);
}

/* Variante inline : Corbak intégré dans la barre d'onglets (.market-tabs)
   après Historique. On annule le positionnement absolu et on réduit la
   taille pour aligner sur la hauteur des tabs. La bulle reste positionnée
   en absolute relative au wrap (top: 100% + 10px). */
.market-corbak-wrap-inline {
    position: relative;
    top: auto;
    right: auto;
    width: auto;
    height: 38px;
    /* Pousse Corbak à droite de la barre d'onglets ; le refresh-btn (qui
       perd son margin-left:auto via override ci-dessous) le suit collé. */
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    z-index: 5;
}
/* Corbak inline présent → refresh-btn ne doit plus pousser à droite tout
   seul, c'est Corbak qui le fait. Refresh reste juste à droite de Corbak. */
.market-corbak-wrap-inline + .market-refresh-btn,
.market-corbak-wrap-inline ~ .market-refresh-btn {
    margin-left: 8px;
}
.market-corbak-wrap-inline .market-corbak-shop {
    width: auto;
    height: 100%;
    display: block;
}
.market-corbak-wrap-inline .market-corbak-bubble {
    /* Bulle s'ouvre vers le bas-gauche pour ne pas déborder à droite (le wrap
       est près du bord droit avec le refresh-btn à sa droite). */
    top: calc(100% + 10px);
    right: 0;
    left: auto;
}

.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-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-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;
    }
}
