/* Additional styles for The Pale Harbor */

/* Loading screen and game initialization */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: #fff;
    font-family: 'Courier New', monospace;
}

.loading-text {
    font-size: 24px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.loading-bar {
    width: 300px;
    height: 4px;
    background-color: #333;
    border: 1px solid #666;
    overflow: hidden;
}

.loading-fill {
    height: 100%;
    background-color: #4a90e2;
    width: 0%;
    transition: width 0.3s ease;
}

/* Game title styling */
.game-title {
    font-size: 18px;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 1);
    color: #e0e0e0;
    margin-bottom: 10px;
}

/* Enhanced UI elements */
#ui {
    font-family: 'Courier New', monospace;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    user-select: none;
}

#location {
    font-size: 14px;
    color: #cccccc;
    margin-top: 5px;
    margin-bottom: 15px;
}

/* Sanity bar animations */
.sanity-bar {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    transition: border-color 0.3s ease;
}

.sanity-fill {
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.2);
}

/* Low sanity warning effect */
.sanity-critical {
    animation: sanity-pulse 1s infinite alternate;
    border-color: #ff4444 !important;
}

@keyframes sanity-pulse {
    0% { box-shadow: 0 0 5px rgba(255, 68, 68, 0.3); }
    100% { box-shadow: 0 0 20px rgba(255, 68, 68, 0.8); }
}

/* Inventory styling */
#inventory {
    background-color: rgba(0, 0, 0, 0.85);
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    user-select: none;
}

#inventory > div:first-child {
    color: #ffdd00;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

#inventoryItems > div {
    padding: 2px 0;
    color: #cccccc;
    transition: color 0.2s ease;
}

#inventoryItems > div:hover {
    color: #ffffff;
}

/* Dialogue enhancements */
#dialogue {
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    user-select: none;
    transition: all 0.3s ease;
}

#dialogue.sanity-low {
    animation: dialogue-shake 0.1s infinite alternate;
    border-color: #ff4444;
    background-color: rgba(50, 0, 0, 0.95) !important;
}

@keyframes dialogue-shake {
    0% { transform: translateX(-50%) translateY(1px); }
    100% { transform: translateX(-50%) translateY(-1px); }
}

#dialogueText {
    min-height: 60px;
    display: flex;
    align-items: center;
}

/* Dialogue text formatting with proper spacing */
#dialogueText b {
    margin: 0 1px; /* Add small margins around bold text */
    padding: 0 1px; /* Add small padding for extra spacing */
}

#dialogueText span {
    margin: 0 1px; /* Add small margins around span elements */
    padding: 0 1px; /* Add small padding for extra spacing */
}

/* Ensure no spacing issues with inline elements */
#dialogueText b::before,
#dialogueText b::after,
#dialogueText span::before,
#dialogueText span::after {
    content: " "; /* Add explicit space characters */
    font-size: 0; /* Make the spaces invisible but present for layout */
    line-height: 0;
}

/* CSS-only word emphasis - simple approach with text effects */
#dialogue #dialogueText.has-lighthouse {
    text-shadow: 0 0 20px rgba(255, 255, 255, 1.0), 0 0 10px rgba(255, 255, 255, 0.8), 2px 2px 4px rgba(0,0,0,0.8) !important;
    font-weight: bold !important;
    color: #ffffff !important;
    filter: brightness(1.5) !important;
}

#dialogue #dialogueText.has-key {
    text-shadow: 0 0 20px rgba(255, 221, 0, 1.0), 0 0 10px rgba(255, 221, 0, 0.8), 2px 2px 4px rgba(0,0,0,0.8) !important;
    color: #ffdd00 !important;
    font-weight: bold !important;
    filter: brightness(1.5) !important;
}

#dialogue #dialogueText.has-journal {
    text-shadow: 0 0 20px rgba(136, 204, 255, 1.0), 0 0 10px rgba(136, 204, 255, 0.8), 2px 2px 4px rgba(0,0,0,0.8) !important;
    color: #88ccff !important;
    font-weight: bold !important;
    filter: brightness(1.5) !important;
}

/* Horror-specific visual effects */
.screen-glitch {
    animation: glitch 0.3s infinite;
}

@keyframes glitch {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

/* Responsive design for different screen sizes */
@media (max-width: 1200px) {
    #gameCanvas {
        width: 90vw;
        height: 67.5vw; /* Maintain 4:3 aspect ratio */
        max-width: 1024px;
        max-height: 768px;
    }
}

@media (max-width: 768px) {
    #ui {
        font-size: 12px;
    }
    
    #inventory {
        font-size: 10px;
        min-width: 120px;
    }
    
    #dialogue {
        width: 90%;
        font-size: 14px;
        padding: 15px;
    }
    
    .sanity-bar {
        width: 150px;
        height: 15px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .sanity-fill,
    #dialogue,
    .loading-fill {
        transition: none;
    }
    
    .sanity-critical,
    .screen-glitch,
    #dialogue.sanity-low {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #ui {
        background-color: rgba(0, 0, 0, 0.9);
        padding: 10px;
        border-radius: 5px;
    }
    
    #dialogue {
        border-width: 3px;
        background-color: rgba(0, 0, 0, 0.95) !important;
    }
    
    .sanity-bar {
        border-width: 3px;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #000000;
    }
}

/* Print styles (hide game elements) */
@media print {
    #gameCanvas,
    #ui,
    #inventory,
    #dialogue {
        display: none;
    }
}
