/* RPG-Style Dialogue Widget - Self-Contained */
.dialogue-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9000; /* Below shadowbox (9500) and login modals (10000) */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease-in, opacity 0.3s ease-in;
    opacity: 0;
    pointer-events: none;
}

.dialogue-container.visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7);
    pointer-events: auto;
}

.dialogue-box {
    background: rgba(255, 255, 255, 0.97);
    border: 3px solid var(--border-color, #333);
    padding: 0;
    max-width: 450px;
    width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    position: relative;
    pointer-events: auto; /* Only the dialogue box captures clicks */
}

.dialogue-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background: var(--reverie-core-color, #734ba1);
    border-bottom: 2px solid var(--border-color, #333);
}

.dialogue-avatar {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    object-fit: cover;
}

.dialogue-name {
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: white;
    text-transform: lowercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.dialogue-text {
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 0 30px; /* Horizontal padding only */
    font-family: 'Georgia', serif;
    font-size: 18px;
    line-height: 1.6;
    color: #333;
    min-height: calc(1.6em * 4); /* Space for exactly 4 lines of text */
    max-height: calc(1.6em * 4); /* Space for exactly 4 lines of text */
    text-align: left; /* Default, can be overridden by data-align attribute */
    position: relative;
    overflow-y: auto;
    white-space: pre-wrap; /* Preserve line breaks and whitespace */
    word-wrap: break-word; /* Wrap long words */
}

/* Text formatting support */
.dialogue-text strong {
    font-weight: 700;
    color: #1a1a1a;
}

.dialogue-text em {
    font-style: italic;
    color: #2a2a2a;
}

.dialogue-text[data-align="left"] {
    text-align: left;
}

.dialogue-text[data-align="center"] {
    text-align: center;
}

.dialogue-text[data-align="right"] {
    text-align: right;
}

.dialogue-continue {
    position: absolute;
    bottom: 8px;
    right: 15px;
    font-size: 16px;
    color: var(--reverie-core-color, #734ba1);
    animation: bounce 1s ease-in-out infinite;
}

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

.dialogue-buttons {
    display: flex;
    gap: 12px;
    padding: 0 20px; /* Horizontal padding only */
    border-top: 2px solid var(--border-color, #333);
    /* Light tinted background - 12% mix of reverie-core-color with white */
    background: color-mix(in srgb, var(--reverie-core-color, #734ba1) 12%, white);
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0; /* Don't shrink */
    min-height: 70px; /* Fixed height: 10px top margin + button height + 10px bottom margin */
    max-height: 70px;
}

.dialogue-btn {
    background: var(--reverie-core-color, #734ba1);
    color: white;
    border: 2px solid var(--reverie-core-color, #734ba1);
    padding: 10px 20px;
    margin: 10px 0; /* 10px top and bottom margin */
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 140px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    opacity: 0;
    animation: fadeInButton 0.5s ease-out forwards;
}

@keyframes fadeInButton {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dialogue-btn:hover {
    background: white;
    color: var(--reverie-core-color, #734ba1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.dialogue-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.dialogue-btn.secondary {
    background: white;
    color: var(--reverie-core-color, #734ba1);
    border: 2px solid var(--reverie-core-color, #734ba1);
}

.dialogue-btn.secondary:hover {
    background: var(--reverie-core-color, #734ba1);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(115, 75, 161, 0.3);
}

.dialogue-btn.secondary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.dialogue-btn.rotating {
    position: relative;
}

.dialogue-btn.rotating .btn-text {
    display: inline-block;
}

@keyframes textFadeRotate {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    45% {
        opacity: 0;
        transform: translateY(8px);
    }
    55% {
        opacity: 0;
        transform: translateY(-8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.dialogue-continue-text {
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: var(--reverie-core-color, #734ba1);
    font-style: italic;
    opacity: 0.6;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.7;
    }
}

@media (max-width: 768px) {
    .dialogue-box {
        width: 85vw;
        max-width: none;
    }
    
    .dialogue-text {
        font-size: 16px;
        margin-top: 20px;
        margin-bottom: 20px;
        padding: 0 25px; /* Horizontal padding only */
        min-height: calc(1.6em * 4); /* Space for exactly 4 lines of text */
        max-height: calc(1.6em * 4); /* Space for exactly 4 lines of text */
        overflow-y: auto;
    }
    
    .dialogue-text[data-align="left"] {
        text-align: left;
    }
    
    .dialogue-text[data-align="center"] {
        text-align: center;
    }
    
    .dialogue-text[data-align="right"] {
        text-align: right;
    }
    
    .dialogue-avatar {
        width: 32px;
        height: 32px;
    }
    
    .dialogue-name {
        font-size: 14px;
    }
    
    .dialogue-buttons {
        flex-direction: row;
        gap: 8px;
        padding: 0 16px; /* Horizontal padding only */
        flex-wrap: wrap;
        flex-shrink: 0; /* Don't shrink */
        min-height: 70px; /* Fixed height for mobile too */
        max-height: 70px;
    }
    
    .dialogue-btn {
        flex: 1;
        min-width: 120px;
        padding: 12px 16px;
        margin: 10px 0; /* 10px top and bottom margin */
        font-size: 12px;
    }
    
    .dialogue-continue-text {
        font-size: 11px;
    }
}
