/* VN Dialogue — Dialogue box, speaker name, typewriter, portrait */

/* === DIALOGUE BOX === */

.vn-dialogue-box {
    position: relative;
    margin: 0 3% 2%;
    padding: 1.1rem 1.3rem 0.8rem;
    background: linear-gradient(
        180deg,
        rgba(8, 8, 18, 0.9) 0%,
        rgba(12, 12, 25, 0.95) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    backdrop-filter: blur(16px);
    pointer-events: auto;
    cursor: pointer;
    min-height: 90px;
    max-height: 180px;
    box-shadow:
        0 -4px 24px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.vn-dialogue-box.hidden {
    display: none;
}

/* === SPEAKER NAME === */

.vn-speaker-name {
    position: absolute;
    top: -14px;
    left: 20px;
    background: linear-gradient(135deg, #4a6fa5 0%, #3d5a8a 100%);
    color: #fff;
    padding: 4px 16px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.vn-speaker-name.narrator {
    background: linear-gradient(135deg, #555 0%, #444 100%);
    font-style: italic;
}

/* === DIALOGUE TEXT === */

.vn-dialogue-text {
    color: rgba(255, 255, 255, 0.92);
    font-size: 1.35rem;
    line-height: 1.7;
    margin-top: 8px;
    min-height: 3em;
    font-family: 'Georgia', 'Times New Roman', serif;
}

/* Typewriter cursor */
.vn-dialogue-text .vn-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: rgba(255, 255, 255, 0.7);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: vn-blink 0.8s step-end infinite;
}

@keyframes vn-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Advance indicator — shows when text is fully revealed */
.vn-advance-indicator {
    position: absolute;
    bottom: 10px;
    right: 16px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
    animation: vn-bounce 1.5s ease-in-out infinite;
}

@keyframes vn-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* === SPEAKER PORTRAIT (small, in dialogue box) === */

.vn-speaker-portrait {
    position: absolute;
    top: -30px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    background: rgba(30, 30, 50, 0.8);
}

.vn-speaker-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vn-speaker-portrait.hidden {
    display: none;
}

/* === CHOICE MENU === */

.vn-choices-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 600px;
    width: 90%;
}

.vn-choice-btn {
    background: linear-gradient(
        135deg,
        rgba(20, 20, 40, 0.9) 0%,
        rgba(30, 30, 55, 0.95) 100%
    );
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(100, 140, 200, 0.25);
    border-radius: 6px;
    padding: 16px 22px;
    font-size: 1.15rem;
    font-family: 'Georgia', 'Times New Roman', serif;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.vn-choice-btn:hover {
    background: linear-gradient(
        135deg,
        rgba(40, 50, 80, 0.95) 0%,
        rgba(50, 60, 100, 0.98) 100%
    );
    border-color: rgba(100, 150, 220, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.vn-choice-btn:active {
    transform: translateY(0);
}

.vn-choice-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.vn-choice-btn .vn-choice-requirement {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 100, 100, 0.7);
    margin-top: 4px;
    font-style: italic;
}

.vn-choice-btn .vn-choice-tag {
    display: inline-block;
    background: rgba(100, 150, 255, 0.2);
    color: rgba(150, 180, 255, 0.9);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-right: 6px;
}

/* === HISTORY OVERLAY === */

.vn-history {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 15, 0.95);
    overflow-y: auto;
    padding: 2rem 3rem;
    display: none;
}

.vn-history.active {
    display: block;
}

.vn-history-entry {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.vn-history-speaker {
    color: rgba(100, 150, 220, 0.9);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.vn-history-text {
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.1rem;
    line-height: 1.6;
}

.vn-history-close {
    position: sticky;
    top: 0;
    text-align: right;
    padding-bottom: 1rem;
}

/* === MOBILE === */

@media (max-width: 768px) {
    .vn-dialogue-box {
        margin: 0 2% 1.5%;
        padding: 0.8rem 1rem 0.6rem;
        min-height: 80px;
        max-height: 150px;
        border-radius: 4px;
    }

    .vn-dialogue-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .vn-speaker-name {
        font-size: 0.75rem;
        padding: 3px 10px;
        top: -12px;
    }

    .vn-speaker-portrait {
        width: 40px;
        height: 40px;
        top: -20px;
    }

    .vn-advance-indicator {
        font-size: 0.6rem;
        bottom: 6px;
        right: 10px;
    }

    .vn-choices-container {
        max-width: 95%;
        padding: 0 2%;
    }

    .vn-choice-btn {
        padding: 12px 14px;
        font-size: 0.85rem;
        min-height: 44px; /* Touch target */
    }

    .vn-history {
        padding: 1rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .vn-dialogue-box {
        margin: 0 1% 1%;
        min-height: 70px;
    }

    .vn-dialogue-text {
        font-size: 0.85rem;
        line-height: 1.4;
    }

    .vn-choice-btn {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}
