/**
 * Quest for Glory Style RPG Dialogue System CSS
 * Classic adventure game aesthetic with modern polish
 */

/* ========== MAGIC LAMP (Genie Discovery) ========== */
.magic-lamp {
    pointer-events: auto;
}

.magic-lamp.hidden {
    pointer-events: none;
}

.lamp-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.lamp-icon {
    font-size: 2.5rem;
    animation: lampFloat 3s ease-in-out infinite;
}

.lamp-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

@keyframes lampGlow {
    0%, 100% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

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

.lamp-hint {
    background: rgba(0, 0, 0, 0.9);
    color: #ffd700;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    border: 1px solid rgba(255, 215, 0, 0.3);
    animation: hintPulse 2s infinite;
    display: none;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ========== MAGIC PERIOD (Aziza Discovery) ========== */
.magic-period {
    display: inline-block;
    transition: all 0.3s ease;
}

@keyframes periodShimmer {
    0%, 100% {
        opacity: 0.6;
        text-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
    }
    50% {
        opacity: 1;
        text-shadow: 0 0 15px rgba(102, 126, 234, 0.6);
    }
}

/* ========== RPG DIALOGUE CONTAINER ========== */
.rpg-dialogue-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-family: 'Courier New', monospace;
}

.rpg-dialogue-container.show {
    opacity: 1;
}

.dialogue-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

/* ========== DIALOGUE BOX (Classic RPG Style) ========== */
.dialogue-box {
    position: fixed;
    bottom: 120px;
    right: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 70vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 4px solid #ffd700;
    border-radius: 12px;
    box-shadow:
        0 0 30px rgba(255, 215, 0, 0.3),
        inset 0 0 20px rgba(255, 215, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
}

.rpg-dialogue-container.show .dialogue-box {
    transform: scale(1);
}

/* ========== HEADER ========== */
.dialogue-header {
    background: linear-gradient(135deg, #2d3561 0%, #1f2749 100%);
    border-bottom: 2px solid #ffd700;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.npc-name {
    color: #ffd700;
    font-size: 1.25rem;
    margin: 0;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    letter-spacing: 2px;
}

.dialogue-close {
    background: none;
    border: 2px solid #ffd700;
    color: #ffd700;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.dialogue-close:hover {
    background: #ffd700;
    color: #1a1a2e;
    transform: scale(1.1);
}

/* ========== CONTENT AREA ========== */
.dialogue-content {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex: 1;
    align-items: flex-start;
}

/* ========== NPC PORTRAIT ========== */
.npc-portrait-container {
    position: relative;
    flex-shrink: 0;
}

.npc-portrait {
    width: 120px;
    height: 120px;
    border: 3px solid #ffd700;
    border-radius: 8px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    transition: all 0.3s ease;
}

.portrait-glow {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.2) 0%, transparent 70%);
    border-radius: 8px;
    z-index: -1;
    animation: portraitGlow 3s infinite;
}

@keyframes portraitGlow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ========== TEXT BOX (Classic RPG) ========== */
.dialogue-text-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-radius: 8px;
    padding: 20px;
    min-height: 150px;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.text-content {
    color: #e0e0e0;
    font-size: 1rem;
    line-height: 1.6;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.typing-indicator {
    display: inline;
    color: #ffd700;
    animation: blink 0.8s infinite;
    margin-left: 2px;
}

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

/* ========== DIALOGUE CHOICES ========== */
.dialogue-choices {
    padding: 15px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    transition: opacity 0.3s ease;
}

.dialogue-choice {
    background: linear-gradient(135deg, #2d3561 0%, #1f2749 100%);
    border: 2px solid rgba(255, 215, 0, 0.3);
    color: #e0e0e0;
    padding: 12px 16px;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    position: relative;
    overflow: visible;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.4;
}

.dialogue-choice::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
    transition: left 0.5s ease;
}

.dialogue-choice:hover {
    border-color: #ffd700;
    background: linear-gradient(135deg, #3d4571 0%, #2f3759 100%);
    transform: translateX(5px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.dialogue-choice:hover::before {
    left: 100%;
}

.choice-arrow {
    color: #ffd700;
    margin-right: 8px;
    display: inline-block;
    transition: transform 0.2s ease;
}

.dialogue-choice:hover .choice-arrow {
    transform: translateX(3px);
}

/* ========== CUSTOM INPUT ========== */
.dialogue-input-container {
    padding: 15px 20px;
    border-top: 2px solid rgba(255, 215, 0, 0.3);
    display: flex;
    gap: 10px;
    align-items: center;
    transition: all 0.3s ease;
}

.dialogue-input-container.hidden {
    display: none;
}

#userQuestion {
    flex: 1;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 215, 0, 0.5);
    color: #e0e0e0;
    padding: 10px 15px;
    font-size: 0.95rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    transition: all 0.2s ease;
}

#userQuestion:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

#submitQuestion,
#cancelQuestion {
    background: linear-gradient(135deg, #2d3561 0%, #1f2749 100%);
    border: 2px solid rgba(255, 215, 0, 0.5);
    color: #ffd700;
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

#submitQuestion:hover,
#cancelQuestion:hover {
    background: linear-gradient(135deg, #3d4571 0%, #2f3759 100%);
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    transform: translateY(-2px);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .dialogue-box {
        bottom: 20px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        max-height: 85vh;
    }

    .dialogue-content {
        flex-direction: column;
        align-items: center;
    }

    .npc-portrait {
        width: 100px;
        height: 100px;
    }

    .dialogue-text-box {
        min-height: 120px;
    }

    .npc-name {
        font-size: 1rem;
    }

    .text-content {
        font-size: 0.9rem;
    }

    .dialogue-choice {
        font-size: 0.85rem;
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .dialogue-header {
        padding: 10px 15px;
    }

    .dialogue-content {
        padding: 15px;
    }

    .npc-portrait {
        width: 80px;
        height: 80px;
    }

    .dialogue-text-box {
        padding: 15px;
        min-height: 100px;
    }

    .text-content {
        font-size: 0.85rem;
    }

    .lamp-icon {
        font-size: 2rem;
    }

    #magic-lamp {
        bottom: 70px;
        right: 20px;
    }
}

/* ========== SCROLLBAR STYLING ========== */
.dialogue-choices::-webkit-scrollbar {
    width: 8px;
}

.dialogue-choices::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.dialogue-choices::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 4px;
}

.dialogue-choices::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.7);
}

/* ========== ACCESSIBILITY ========== */
@media (prefers-reduced-motion: reduce) {
    .lamp-icon,
    .portrait-glow,
    .typing-indicator,
    .lamp-glow,
    .dialogue-choice::before {
        animation: none;
    }

    .dialogue-choice:hover {
        transform: none;
    }
}
